Revert changes made for the partial port to the AVR32 architecture.
This commit is contained in:
parent
a7aaa45ec4
commit
071fd8ce53
79 changed files with 739 additions and 1727 deletions
|
|
@ -139,7 +139,7 @@ static void USB_Device_SetAddress(void)
|
|||
if (DeviceAddress)
|
||||
USB_DeviceState = DEVICE_STATE_Addressed;
|
||||
|
||||
USB_Device_SetDeviceAddress(DeviceAddress);
|
||||
UDADDR = ((1 << ADDEN) | DeviceAddress);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,15 +32,10 @@
|
|||
#define __DEVCHAPTER9_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/boot.h>
|
||||
#endif
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/boot.h>
|
||||
|
||||
#include "../HighLevel/StdDescriptors.h"
|
||||
#include "../HighLevel/Events.h"
|
||||
|
|
@ -55,7 +50,7 @@
|
|||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
|
|
@ -75,11 +70,7 @@
|
|||
enum USB_DescriptorMemorySpaces_t
|
||||
{
|
||||
MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory */
|
||||
|
||||
#if defined(__AVR__) || defined(__DOXYGEN__)
|
||||
MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory */
|
||||
#endif
|
||||
|
||||
MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory */
|
||||
};
|
||||
#endif
|
||||
|
|
@ -134,10 +125,6 @@
|
|||
#elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)
|
||||
#error Only one of the USE_*_DESCRIPTORS modes should be selected.
|
||||
#endif
|
||||
|
||||
#if defined(USE_EEPROM_DESCRIPTORS) && defined(USB_SERIES_UC3B_AVR)
|
||||
#error USE_EEPROM_DESCRIPTORS is not available on the UC3B series AVRs.
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
void USB_Device_ProcessControlRequest(void);
|
||||
|
|
|
|||
|
|
@ -41,11 +41,9 @@
|
|||
#define __USBDEVICE_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR__)
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#endif
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
#include "../HighLevel/StdDescriptors.h"
|
||||
#include "Endpoint.h"
|
||||
|
|
@ -56,13 +54,12 @@
|
|||
#endif
|
||||
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
#if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || \
|
||||
defined(USB_SERIES_UC3B_AVR) || defined(__DOXYGEN__))
|
||||
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
|
||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in low speed (1.5Mb/s) mode.
|
||||
*
|
||||
|
|
@ -71,13 +68,13 @@
|
|||
* \note Restrictions apply on the number, size and type of endpoints which can be used
|
||||
* when running in low speed mode -- refer to the USB 2.0 standard.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||
#endif
|
||||
|
||||
/** Mask for the Options parameter of the USB_Init() function. This indicates that the
|
||||
* USB interface should be initialized in full speed (12Mb/s) mode.
|
||||
*/
|
||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||
|
||||
/* Pseudo-Function Macros: */
|
||||
#if defined(__DOXYGEN__)
|
||||
|
|
@ -132,25 +129,16 @@
|
|||
*/
|
||||
static inline bool USB_Device_DisableSOFEvents(void);
|
||||
#else
|
||||
#if defined(__AVR32__)
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
#define USB_Device_SendRemoteWakeup() MACROS{ AVR32_USBB.UDCON.rmwkup = true; }MACROE
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE
|
||||
|
||||
#define USB_Device_IsRemoteWakeupSent() AVR32_USBB.UDCON.rmwkup
|
||||
#endif
|
||||
|
||||
#define USB_Device_IsUSBSuspended() AVR32_USBB.UDINT.susp
|
||||
#elif defined(__AVR__)
|
||||
#if !defined(NO_DEVICE_REMOTE_WAKEUP)
|
||||
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE
|
||||
|
||||
#define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)
|
||||
#endif
|
||||
|
||||
#define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false)
|
||||
#define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)
|
||||
#endif
|
||||
|
||||
|
||||
#define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false)
|
||||
|
||||
#define USB_Device_EnableSOFEvents() MACROS{ USB_INT_Enable(USB_INT_SOFI); }MACROE
|
||||
|
||||
#define USB_Device_DisableSOFEvents() MACROS{ USB_INT_Disable(USB_INT_SOFI); }MACROE
|
||||
#endif
|
||||
|
||||
|
|
@ -219,17 +207,8 @@
|
|||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#if defined(__AVR32__)
|
||||
#define USB_Device_SetLowSpeed() MACROS{ AVR32_USBB.UDCON.ls = true; }MACROE
|
||||
#define USB_Device_SetFullSpeed() MACROS{ AVR32_USBB.UDCON.ls = false; }MACROE
|
||||
|
||||
#define USB_Device_SetDeviceAddress(addr) MACROS{ AVR32_USBB.UDCON.uadd = DeviceAddress; AVR32_USBB.UDCON.adden = true; }MACROE
|
||||
#elif defined(__AVR__)
|
||||
#define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE
|
||||
#define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE
|
||||
|
||||
#define USB_Device_SetDeviceAddress(addr) MACROS{ UDADDR = ((1 << ADDEN) | DeviceAddress); }MACROE
|
||||
#endif
|
||||
#define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE
|
||||
#define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@
|
|||
uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;
|
||||
#endif
|
||||
|
||||
uintN_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)
|
||||
uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)
|
||||
{
|
||||
return Endpoint_BytesToEPSizeMask(Size);
|
||||
}
|
||||
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uintN_t Number, const uintN_t UECFG0XData, const uintN_t UECFG1XData)
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData)
|
||||
{
|
||||
Endpoint_SelectEndpoint(Number);
|
||||
Endpoint_EnableEndpoint();
|
||||
|
|
@ -225,14 +225,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
|
|
@ -241,14 +239,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
|
|
@ -264,14 +260,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
|
|
@ -280,14 +274,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_RW.c"
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -301,12 +293,10 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Endpoint_Control_W.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Endpoint_Control_W.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Endpoint_Control_W.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
|
|
@ -318,35 +308,29 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Endpoint_Control_W.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Endpoint_Control_W.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Endpoint_Control_W.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()
|
||||
#include "Template/Template_Endpoint_Control_R.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_Control_R.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_Control_R.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()
|
||||
#include "Template/Template_Endpoint_Control_R.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_Control_R.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
|
||||
#include "Template/Template_Endpoint_Control_R.c"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -66,19 +66,12 @@
|
|||
#define __ENDPOINT_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
#include "LowLevel.h"
|
||||
#include "../HighLevel/USBTask.h"
|
||||
|
||||
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
|
||||
|
|
@ -92,45 +85,34 @@
|
|||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if defined(__AVR32__) && !defined(__AVR32_EPREG_X)
|
||||
#define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber]
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
#if defined(__AVR32__) || defined(__DOXYGEN__)
|
||||
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
|
||||
* should be initialized in the OUT direction - i.e. data flows from host to device.
|
||||
*/
|
||||
#define ENDPOINT_DIR_OUT 0
|
||||
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
|
||||
* should be initialized in the OUT direction - i.e. data flows from host to device.
|
||||
*/
|
||||
#define ENDPOINT_DIR_OUT (0 << EPDIR)
|
||||
|
||||
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
|
||||
* should be initialized in the IN direction - i.e. data flows from device to host.
|
||||
*/
|
||||
#define ENDPOINT_DIR_IN AVR32_USBB_EPDIR_IN
|
||||
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
|
||||
* should be initialized in the IN direction - i.e. data flows from device to host.
|
||||
*/
|
||||
#define ENDPOINT_DIR_IN (1 << EPDIR)
|
||||
|
||||
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
|
||||
* that the endpoint should have one single bank, which requires less USB FIFO memory but results
|
||||
* in slower transfers as only one USB device (the AVR or the host) can access the endpoint's
|
||||
* bank at the one time.
|
||||
*/
|
||||
#define ENDPOINT_BANK_SINGLE AVR32_USBB_EPBK_SINGLE
|
||||
|
||||
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
|
||||
* that the endpoint should have two banks, which requires more USB FIFO memory but results
|
||||
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other
|
||||
* accesses the second bank.
|
||||
*/
|
||||
#define ENDPOINT_BANK_DOUBLE AVR32_USBB_EPBK_DOUBLE
|
||||
#elif defined(__AVR__)
|
||||
#define ENDPOINT_DIR_OUT (0 << EPDIR)
|
||||
#define ENDPOINT_DIR_IN (1 << EPDIR)
|
||||
#define ENDPOINT_BANK_SINGLE (0 << EPBK0)
|
||||
#define ENDPOINT_BANK_DOUBLE (1 << EPBK0)
|
||||
#endif
|
||||
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
|
||||
* that the endpoint should have one single bank, which requires less USB FIFO memory but results
|
||||
* in slower transfers as only one USB device (the AVR or the host) can access the endpoint's
|
||||
* bank at the one time.
|
||||
*/
|
||||
#define ENDPOINT_BANK_SINGLE (0 << EPBK0)
|
||||
|
||||
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
|
||||
* that the endpoint should have two banks, which requires more USB FIFO memory but results
|
||||
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other
|
||||
* accesses the second bank.
|
||||
*/
|
||||
#define ENDPOINT_BANK_DOUBLE (1 << EPBK0)
|
||||
|
||||
/** Endpoint address for the default control endpoint, which always resides in address 0. This is
|
||||
* defined for convenience to give more readable code when used with the endpoint macros.
|
||||
|
|
@ -172,18 +154,17 @@
|
|||
#define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n)
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || \
|
||||
defined(USB_SERIES_UC3B_AVR) || defined(__DOXYGEN__))
|
||||
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
|
||||
/** Total number of endpoints (including the default control endpoint at address 0) which may
|
||||
* be used in the device. Different USB AVR models support different amounts of endpoints,
|
||||
* this value reflects the maximum number of endpoints for the currently selected AVR model.
|
||||
*/
|
||||
#define ENDPOINT_TOTAL_ENDPOINTS 7
|
||||
#define ENDPOINT_TOTAL_ENDPOINTS 7
|
||||
#else
|
||||
#define ENDPOINT_TOTAL_ENDPOINTS 5
|
||||
#define ENDPOINT_TOTAL_ENDPOINTS 5
|
||||
#endif
|
||||
#else
|
||||
#define ENDPOINT_TOTAL_ENDPOINTS 1
|
||||
#define ENDPOINT_TOTAL_ENDPOINTS 1
|
||||
#endif
|
||||
|
||||
/* Pseudo-Function Macros: */
|
||||
|
|
@ -373,84 +354,71 @@
|
|||
#define Endpoint_BytesInEndpoint() (((uint16_t)UEBCHX << 8) | UEBCLX)
|
||||
#elif defined(USB_SERIES_2_AVR)
|
||||
#define Endpoint_BytesInEndpoint() UEBCLX
|
||||
#elif defined(USB_SERIES_UC3B_AVR)
|
||||
#define Endpoint_BytesInEndpoint() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_BYCT_MASK) >> AVR32_USBB_BYCT)
|
||||
#endif
|
||||
|
||||
#if defined(__AVR32__)
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_GetCurrentEndpoint() USB_SelectedEPNumber
|
||||
#define Endpoint_SelectEndpoint(epnum) MACROS{ USB_SelectedEPNumber = (epnum); }MACROE
|
||||
#define Endpoint_IsReadWriteAllowed() (__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RWALL_MASK)
|
||||
#else
|
||||
#define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP
|
||||
#define Endpoint_SelectEndpoint(epnum) (void)(epnum)
|
||||
#endif
|
||||
|
||||
#define Endpoint_ResetFIFO(epnum) MACROS{ AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << (epnum)); \
|
||||
AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << (epnum)); }MACROE
|
||||
#define Endpoint_EnableEndpoint() MACROS{ AVR32_USBB.uerst |= (AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber); }MACROE
|
||||
#define Endpoint_DisableEndpoint() MACROS{ AVR32_USBB.uerst &= ~(AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber); }MACROE
|
||||
#define Endpoint_IsEnabled() ((AVR32_USBB.uerst & (AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber)) ? true : false)
|
||||
|
||||
#define Endpoint_IsConfigured() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_UESTA0_CFGOK_MASK) ? true : false)
|
||||
#define Endpoint_GetEndpointInterrupts() (AVR32_USBB.UDINT >> AVR32_USBB_EP0INT)
|
||||
#define Endpoint_HasEndpointInterrupted(n) ((AVR32_USBB.UDINT & (AVR32_USBB_EP0INT << (n))) ? true : false)
|
||||
#define Endpoint_IsINReady() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_TXINI) ? true : false)
|
||||
#define Endpoint_IsOUTReceived() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RXOUTI) ? true : false)
|
||||
#define Endpoint_IsSETUPReceived() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RXSTPI) ? true : false)
|
||||
#define Endpoint_ClearSETUP() MACROS{ __AVR32_EPREG_X(UESTA0CLR) = AVR32_USBB_RXSTPIC; }MACROE
|
||||
#define Endpoint_ClearIN() MACROS{ __AVR32_EPREG_X(UESTA0CLR) = AVR32_USBB_TXINIC; \
|
||||
__AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_FIFOCONC; }MACROE
|
||||
#define Endpoint_ClearOUT() MACROS{ __AVR32_EPREG_X(UESTA0CLR) = AVR32_USBB_RXOUTI; \
|
||||
__AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_FIFOCONC; }MACROE
|
||||
#define Endpoint_StallTransaction() MACROS{ __AVR32_EPREG_X(UECON0SET) = AVR32_USBB_STALLRQS; }MACROE
|
||||
#define Endpoint_ClearStall() MACROS{ __AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_STALLRQC; }MACROE
|
||||
#define Endpoint_IsStalled() ((__AVR32_EPREG_X(UECON0) & AVR32_USBB_STALLRQ) ? true : false)
|
||||
#define Endpoint_ResetDataToggle() MACROS{ __AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_RSTDTS; }MACROE
|
||||
#define Endpoint_GetEndpointDirection() ((__AVR32_EPREG_X(UECFG0) & ENDPOINT_DIR_IN) ? true : false)
|
||||
#define Endpoint_SetEndpointDirection(dir) MACROS{ __AVR32_EPREG_X(UECFG0) = \
|
||||
((__AVR32_EPREG_X(UECFG0) & ENDPOINT_DIR_IN) | (dir)); }MACROE
|
||||
#elif defined(__AVR__)
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)
|
||||
#define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = (epnum); }MACROE
|
||||
#define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)
|
||||
#else
|
||||
#define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP
|
||||
#define Endpoint_SelectEndpoint(epnum) (void)(epnum)
|
||||
#endif
|
||||
|
||||
#define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE
|
||||
#define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE
|
||||
#define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE
|
||||
#define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)
|
||||
|
||||
#define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)
|
||||
#define Endpoint_GetEndpointInterrupts() UEINT
|
||||
#define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << (n))) ? true : false)
|
||||
#define Endpoint_IsINReady() ((UEINTX & (1 << TXINI)) ? true : false)
|
||||
#define Endpoint_IsOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false)
|
||||
#define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)
|
||||
#define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
|
||||
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
|
||||
#define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \
|
||||
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
|
||||
#else
|
||||
#define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
|
||||
#define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
|
||||
#endif
|
||||
|
||||
#define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE
|
||||
#define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE
|
||||
#define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false)
|
||||
#define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE
|
||||
#define Endpoint_GetEndpointDirection() (UECFG0X & ENDPOINT_DIR_IN)
|
||||
#define Endpoint_SetEndpointDirection(dir) MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | (dir)); }MACROE
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)
|
||||
#else
|
||||
#define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP
|
||||
#endif
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = (epnum); }MACROE
|
||||
#else
|
||||
#define Endpoint_SelectEndpoint(epnum) (void)(epnum)
|
||||
#endif
|
||||
|
||||
#define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE
|
||||
|
||||
#define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE
|
||||
|
||||
#define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE
|
||||
|
||||
#define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)
|
||||
#endif
|
||||
|
||||
#define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)
|
||||
|
||||
#define Endpoint_GetEndpointInterrupts() UEINT
|
||||
|
||||
#define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << (n))) ? true : false)
|
||||
|
||||
#define Endpoint_IsINReady() ((UEINTX & (1 << TXINI)) ? true : false)
|
||||
|
||||
#define Endpoint_IsOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false)
|
||||
|
||||
#define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)
|
||||
|
||||
#define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
|
||||
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
|
||||
#else
|
||||
#define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
|
||||
#endif
|
||||
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
#define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \
|
||||
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
|
||||
#else
|
||||
#define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
|
||||
#endif
|
||||
|
||||
#define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE
|
||||
|
||||
#define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE
|
||||
|
||||
#define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false)
|
||||
|
||||
#define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE
|
||||
|
||||
#define Endpoint_GetEndpointDirection() (UECFG0X & ENDPOINT_DIR_IN)
|
||||
|
||||
#define Endpoint_SetEndpointDirection(dir) MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | (dir)); }MACROE
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
|
|
@ -518,11 +486,7 @@
|
|||
static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t Endpoint_Read_Byte(void)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
return __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
return UEDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.
|
||||
|
|
@ -534,11 +498,7 @@
|
|||
static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_Write_Byte(const uint8_t Byte)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = Byte;
|
||||
#elif defined(__AVR__)
|
||||
UEDATX = Byte;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
|
||||
|
|
@ -550,11 +510,7 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Dummy = UEDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT
|
||||
|
|
@ -573,13 +529,8 @@
|
|||
uint8_t Bytes[2];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[0] = UEDATX;
|
||||
Data.Bytes[1] = UEDATX;
|
||||
#endif
|
||||
|
||||
return Data.Word;
|
||||
}
|
||||
|
|
@ -600,13 +551,8 @@
|
|||
uint8_t Bytes[2];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[1] = UEDATX;
|
||||
Data.Bytes[0] = UEDATX;
|
||||
#endif
|
||||
|
||||
return Data.Word;
|
||||
}
|
||||
|
|
@ -621,13 +567,8 @@
|
|||
static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_Write_Word_LE(const uint16_t Word)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word & 0xFF);
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word >> 8);
|
||||
#elif defined(__AVR__)
|
||||
UEDATX = (Word & 0xFF);
|
||||
UEDATX = (Word >> 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN
|
||||
|
|
@ -640,13 +581,8 @@
|
|||
static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_Write_Word_BE(const uint16_t Word)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word >> 8);
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word & 0xFF);
|
||||
#elif defined(__AVR__)
|
||||
UEDATX = (Word >> 8);
|
||||
UEDATX = (Word & 0xFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.
|
||||
|
|
@ -658,13 +594,8 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Dummy = UEDATX;
|
||||
Dummy = UEDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT
|
||||
|
|
@ -683,17 +614,10 @@
|
|||
uint8_t Bytes[4];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[2] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[3] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[0] = UEDATX;
|
||||
Data.Bytes[1] = UEDATX;
|
||||
Data.Bytes[2] = UEDATX;
|
||||
Data.Bytes[3] = UEDATX;
|
||||
#endif
|
||||
|
||||
return Data.DWord;
|
||||
}
|
||||
|
|
@ -714,17 +638,10 @@
|
|||
uint8_t Bytes[4];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[3] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[2] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[3] = UEDATX;
|
||||
Data.Bytes[2] = UEDATX;
|
||||
Data.Bytes[1] = UEDATX;
|
||||
Data.Bytes[0] = UEDATX;
|
||||
#endif
|
||||
|
||||
return Data.DWord;
|
||||
}
|
||||
|
|
@ -739,17 +656,10 @@
|
|||
static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord & 0xFF);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 8);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 16);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 24);
|
||||
#elif defined(__AVR__)
|
||||
UEDATX = (DWord & 0xFF);
|
||||
UEDATX = (DWord >> 8);
|
||||
UEDATX = (DWord >> 16);
|
||||
UEDATX = (DWord >> 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN
|
||||
|
|
@ -762,17 +672,10 @@
|
|||
static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 24);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 16);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 8);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord & 0xFF);
|
||||
#elif defined(__AVR__)
|
||||
UEDATX = (DWord >> 24);
|
||||
UEDATX = (DWord >> 16);
|
||||
UEDATX = (DWord >> 8);
|
||||
UEDATX = (DWord & 0xFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.
|
||||
|
|
@ -784,17 +687,10 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Dummy = UEDATX;
|
||||
Dummy = UEDATX;
|
||||
Dummy = UEDATX;
|
||||
Dummy = UEDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* External Variables: */
|
||||
|
|
@ -838,7 +734,7 @@
|
|||
* endpoint numbers can handle different maximum packet sizes - refer to the chosen USB AVR's
|
||||
* datasheet to determine the maximum bank size for each endpoint.
|
||||
*
|
||||
* The banking mode must be a ENDPOINT_BANK_* mask.
|
||||
* The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE.
|
||||
*
|
||||
* \note The default control endpoint does not have to be manually configured, as it is automatically
|
||||
* configured by the library internally.
|
||||
|
|
@ -848,8 +744,8 @@
|
|||
*
|
||||
* \return Boolean true if the configuration succeeded, false otherwise
|
||||
*/
|
||||
bool Endpoint_ConfigureEndpoint(const uintN_t Number, const uintN_t Type, const uintN_t Direction,
|
||||
const uint16_t Size, const uintN_t Banks);
|
||||
bool Endpoint_ConfigureEndpoint(const uint8_t Number, const uint8_t Type, const uint8_t Direction,
|
||||
const uint16_t Size, const uint8_t Banks);
|
||||
|
||||
/** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data
|
||||
* to be read or written to it.
|
||||
|
|
@ -921,8 +817,6 @@
|
|||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Write_EStream_LE(const void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -972,8 +866,6 @@
|
|||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Write_EStream_BE(const void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1023,8 +915,6 @@
|
|||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Read_EStream_LE(void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1060,8 +950,6 @@
|
|||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Read_EStream_BE(void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1103,8 +991,6 @@
|
|||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Write_Control_EStream_LE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1167,8 +1053,6 @@
|
|||
* \param[in] Buffer Pointer to the source data buffer to read from.
|
||||
* \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Write_Control_EStream_BE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1231,8 +1115,6 @@
|
|||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Read_Control_EStream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1274,8 +1156,6 @@
|
|||
* \param[out] Buffer Pointer to the destination data buffer to write to.
|
||||
* \param[in] Length Number of bytes to send via the currently selected endpoint.
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Endpoint_Read_Control_EStream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1283,29 +1163,8 @@
|
|||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#if defined(__AVR32__)
|
||||
#define Endpoint_AllocateMemory() MACROS{ __AVR32_EPREG_X(UECFG10) |= AVR32_USBB_UECFG0_ALLOC_MASK; }MACROE
|
||||
#define Endpoint_DeallocateMemory() MACROS{ __AVR32_EPREG_X(UECFG10) &= ~AVR32_USBB_UECFG0_ALLOC_MASK; }MACROE
|
||||
|
||||
#define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \
|
||||
Endpoint_ConfigureEndpoint_Prv((Number), \
|
||||
(((Type) << AVR32_USBB_UECFG0_EPTYPE) | (Direction)), \
|
||||
(AVR32_USBB_UECFG0_ALLOC_MASK | (Banks) | \
|
||||
(__builtin_constant_p(Size) ? \
|
||||
Endpoint_BytesToEPSizeMask(Size) : \
|
||||
Endpoint_BytesToEPSizeMaskDynamic(Size))))
|
||||
#elif defined(__AVR__)
|
||||
#define Endpoint_AllocateMemory() MACROS{ UECFG1X |= (1 << ALLOC); }MACROE
|
||||
#define Endpoint_DeallocateMemory() MACROS{ UECFG1X &= ~(1 << ALLOC); }MACROE
|
||||
|
||||
#define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \
|
||||
Endpoint_ConfigureEndpoint_Prv((Number), \
|
||||
(((Type) << EPTYPE0) | (Direction)), \
|
||||
((1 << ALLOC) | (Banks) | \
|
||||
(__builtin_constant_p(Size) ? \
|
||||
Endpoint_BytesToEPSizeMask(Size) : \
|
||||
Endpoint_BytesToEPSizeMaskDynamic(Size))))
|
||||
#endif
|
||||
#define Endpoint_AllocateMemory() MACROS{ UECFG1X |= (1 << ALLOC); }MACROE
|
||||
#define Endpoint_DeallocateMemory() MACROS{ UECFG1X &= ~(1 << ALLOC); }MACROE
|
||||
|
||||
#define _ENDPOINT_GET_MAXSIZE(n) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## n)
|
||||
#define _ENDPOINT_GET_MAXSIZE2(details) _ENDPOINT_GET_MAXSIZE3(details)
|
||||
|
|
@ -1323,15 +1182,7 @@
|
|||
#define ENDPOINT_DETAILS_EP4 64, true
|
||||
#define ENDPOINT_DETAILS_EP5 64, true
|
||||
#define ENDPOINT_DETAILS_EP6 64, true
|
||||
#elif defined(USB_SERIES_UC3B_AVR)
|
||||
#define ENDPOINT_DETAILS_EP0 64, false
|
||||
#define ENDPOINT_DETAILS_EP1 64, true
|
||||
#define ENDPOINT_DETAILS_EP2 64, true
|
||||
#define ENDPOINT_DETAILS_EP3 64, true
|
||||
#define ENDPOINT_DETAILS_EP4 64, true
|
||||
#define ENDPOINT_DETAILS_EP5 256, true
|
||||
#define ENDPOINT_DETAILS_EP6 256, true
|
||||
#elif defined(USB_SERIES_2_AVR)
|
||||
#else
|
||||
#define ENDPOINT_DETAILS_EP0 64, true
|
||||
#define ENDPOINT_DETAILS_EP1 64, false
|
||||
#define ENDPOINT_DETAILS_EP2 64, false
|
||||
|
|
@ -1339,27 +1190,23 @@
|
|||
#define ENDPOINT_DETAILS_EP4 64, true
|
||||
#endif
|
||||
|
||||
#define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \
|
||||
Endpoint_ConfigureEndpoint_Prv((Number), \
|
||||
(((Type) << EPTYPE0) | (Direction)), \
|
||||
((1 << ALLOC) | (Banks) | \
|
||||
(__builtin_constant_p(Size) ? \
|
||||
Endpoint_BytesToEPSizeMask(Size) : \
|
||||
Endpoint_BytesToEPSizeMaskDynamic(Size))))
|
||||
|
||||
/* Function Prototypes: */
|
||||
void Endpoint_ClearEndpoints(void);
|
||||
uintN_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size);
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uintN_t Number, const uintN_t UECFG0XData, const uintN_t UECFG1XData);
|
||||
uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size);
|
||||
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData);
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline uintN_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uintN_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
|
||||
static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
uint8_t MaskVal = 0;
|
||||
uint16_t CheckBytes = 8;
|
||||
|
||||
while (CheckBytes < Bytes)
|
||||
{
|
||||
MaskVal++;
|
||||
CheckBytes <<= 1;
|
||||
}
|
||||
|
||||
return (MaskVal << AVR32_USBB_EPSIZE);
|
||||
#else
|
||||
uint8_t MaskVal = 0;
|
||||
uint16_t CheckBytes = 8;
|
||||
|
||||
|
|
@ -1370,7 +1217,6 @@
|
|||
}
|
||||
|
||||
return (MaskVal << EPSIZE0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -41,16 +41,10 @@
|
|||
#define __USBHOST_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#include <util/delay.h>
|
||||
#endif
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
#include "../HighLevel/USBInterrupt.h"
|
||||
#include "../HighLevel/StdDescriptors.h"
|
||||
|
|
@ -63,7 +57,7 @@
|
|||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
|
|
@ -165,29 +159,25 @@
|
|||
*/
|
||||
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void);
|
||||
#else
|
||||
#if defined(__AVR32__)
|
||||
#define USB_Host_ResetBus() MACROS{ AVR32_USBB.UHCON.reset = true; }MACROE
|
||||
#define USB_Host_IsBusResetComplete() AVR32_USBB.UHCON.reset
|
||||
#define USB_Host_ResumeBus() MACROS{ AVR32_USBB.UHCON.sofen = true; }MACROE
|
||||
#define USB_Host_SuspendBus() MACROS{ AVR32_USBB.UHCON.sofen = false; }MACROE
|
||||
#define USB_Host_IsBusSuspended() AVR32_USBB.UHCON.sofen
|
||||
#define USB_Host_IsDeviceFullSpeed() (AVR32_USBB.USBSTA.speed == 0)
|
||||
#define USB_Host_IsRemoteWakeupSent() AVR32_USBB.UHINT.rxrsmi
|
||||
#define USB_Host_ClearRemoteWakeupSent() MACROS{ AVR32_USBB.UHINTCLR.rxrsmic = true; }MACROE
|
||||
#define USB_Host_ResumeFromWakeupRequest() MACROS{ AVR32_USBB.UHCON.resume = true; }MACROE
|
||||
#define USB_Host_IsResumeFromWakeupRequestSent() AVR32_USBB.UHCON.resume
|
||||
#elif defined(__AVR__)
|
||||
#define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE
|
||||
#define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true)
|
||||
#define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE
|
||||
#define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE
|
||||
#define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)
|
||||
#define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)
|
||||
#define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)
|
||||
#define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE
|
||||
#define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE
|
||||
#define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)
|
||||
#endif
|
||||
#define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE
|
||||
|
||||
#define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true)
|
||||
|
||||
#define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE
|
||||
|
||||
#define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE
|
||||
|
||||
#define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)
|
||||
|
||||
#define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)
|
||||
|
||||
#define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)
|
||||
|
||||
#define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE
|
||||
|
||||
#define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE
|
||||
|
||||
#define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
|
|
@ -385,36 +375,20 @@
|
|||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#if defined(__AVR32__)
|
||||
#define USB_Host_HostMode_On() MACROS{ AVR32_USBB.USBCON.uimod = false; }MACROE
|
||||
#define USB_Host_HostMode_Off() MACROS{ AVR32_USBB.USBCON.uimod = true; }MACROE
|
||||
#define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE
|
||||
#define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE
|
||||
|
||||
#define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE
|
||||
#define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE
|
||||
#define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE
|
||||
#define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE
|
||||
|
||||
#define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE
|
||||
#define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE
|
||||
#define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE
|
||||
#define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE
|
||||
|
||||
#define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE
|
||||
#define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE
|
||||
#define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE
|
||||
#define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE
|
||||
|
||||
#define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE
|
||||
#elif defined(__AVR__)
|
||||
#define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE
|
||||
#define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE
|
||||
#define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE
|
||||
|
||||
#define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE
|
||||
#define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE
|
||||
|
||||
#define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE
|
||||
#define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE
|
||||
|
||||
#define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE
|
||||
#define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE
|
||||
|
||||
#define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE
|
||||
#endif
|
||||
|
||||
/* Enums: */
|
||||
enum USB_Host_WaitMSErrorCodes_t
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,14 +32,8 @@
|
|||
#define __HOSTCHAPTER9_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "LowLevel.h"
|
||||
#include "../HighLevel/USBMode.h"
|
||||
|
|
@ -52,7 +46,7 @@
|
|||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
|
|
|
|||
|
|
@ -39,10 +39,6 @@ volatile uint8_t USB_CurrentMode = USB_MODE_NONE;
|
|||
volatile uint8_t USB_Options;
|
||||
#endif
|
||||
|
||||
#if defined(__AVR32__) && !defined(CONTROL_ONLY_DEVICE)
|
||||
uint8_t USB_SelectedEPNumber;
|
||||
#endif
|
||||
|
||||
void USB_Init(
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
const uint8_t Mode
|
||||
|
|
@ -59,10 +55,6 @@ void USB_Init(
|
|||
#endif
|
||||
)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
USB_SelectedEPNumber = 0;
|
||||
#endif
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
USB_CurrentMode = Mode;
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -39,26 +39,11 @@
|
|||
#ifndef __USBLOWLEVEL_H__
|
||||
#define __USBLOWLEVEL_H__
|
||||
|
||||
/* External Variables: */
|
||||
#if defined(__AVR32__)
|
||||
#if !defined(CONTROL_ONLY_DEVICE)
|
||||
extern uint8_t USB_SelectedEPNumber;
|
||||
#else
|
||||
#define USB_SelectedEPNumber 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../HighLevel/USBMode.h"
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
|
@ -86,45 +71,41 @@
|
|||
|
||||
/* Preprocessor Checks and Defines: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if !defined(F_CLOCK)
|
||||
#error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled input clock in your project makefile.
|
||||
#endif
|
||||
|
||||
#if (F_CLOCK == 8000000)
|
||||
#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
|
||||
defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
|
||||
defined(__AVR_ATmega32U2__))
|
||||
#define USB_PLL_PSC 0
|
||||
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
#define USB_PLL_PSC 0
|
||||
#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))
|
||||
#define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
|
||||
#elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
|
||||
#define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
|
||||
#endif
|
||||
#elif (F_CLOCK == 16000000)
|
||||
#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
|
||||
defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
|
||||
defined(__AVR_ATmega32U2__))
|
||||
#define USB_PLL_PSC (1 << PLLP0)
|
||||
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
#define USB_PLL_PSC (1 << PINDIV)
|
||||
#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
|
||||
#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
|
||||
#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
|
||||
#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__AVR32__)
|
||||
#define USB_PLL_PSC 0
|
||||
#elif defined(__AVR__)
|
||||
#if !defined(F_CLOCK)
|
||||
#error F_CLOCK is not defined. You must define F_CLOCK to the frequency of the unprescaled input clock in your project makefile.
|
||||
#endif
|
||||
|
||||
#if (F_CLOCK == 8000000)
|
||||
#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
|
||||
defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
|
||||
defined(__AVR_ATmega32U2__))
|
||||
#define USB_PLL_PSC 0
|
||||
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
#define USB_PLL_PSC 0
|
||||
#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))
|
||||
#define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
|
||||
#elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
|
||||
#define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))
|
||||
#endif
|
||||
#elif (F_CLOCK == 16000000)
|
||||
#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \
|
||||
defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \
|
||||
defined(__AVR_ATmega32U2__))
|
||||
#define USB_PLL_PSC (1 << PLLP0)
|
||||
#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
|
||||
#define USB_PLL_PSC (1 << PINDIV)
|
||||
#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
|
||||
#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))
|
||||
#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
|
||||
#define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(USB_PLL_PSC)
|
||||
#error No PLL prescale value available for chosen F_CLOCK value and AVR model.
|
||||
#endif
|
||||
#if !defined(USB_PLL_PSC)
|
||||
#error No PLL prescale value available for chosen F_CPU value and AVR model.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
|
|
@ -151,7 +132,7 @@
|
|||
*
|
||||
* \note This token is not available on AVR models which do not support both host and device modes.
|
||||
*/
|
||||
#define USB_MODE_UID 3
|
||||
#define USB_MODE_UID 3
|
||||
#endif
|
||||
|
||||
/** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad
|
||||
|
|
@ -210,7 +191,7 @@
|
|||
*
|
||||
* \note This token is not available on some AVR models which do not support hardware VBUS monitoring.
|
||||
*/
|
||||
#define USB_VBUS_GetStatus() ((USBSTA & (1 << VBUS)) ? true : false)
|
||||
#define USB_VBUS_GetStatus() ((USBSTA & (1 << VBUS)) ? true : false)
|
||||
#endif
|
||||
|
||||
/** Detaches the device from the USB bus. This has the effect of removing the device from any
|
||||
|
|
@ -367,22 +348,16 @@
|
|||
#define USB_Controller_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE
|
||||
#define USB_Controller_Reset() MACROS{ const uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \
|
||||
USBCON = (Temp | (1 << USBE)); }MACROE
|
||||
|
||||
/* Inline Functions: */
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t USB_GetUSBModeFromUID(void)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
if (AVR32_USBB.USBSTA.id)
|
||||
return USB_MODE_DEVICE;
|
||||
else
|
||||
return USB_MODE_HOST;
|
||||
#elif defined(__AVR__)
|
||||
if (USBSTA & (1 << ID))
|
||||
return USB_MODE_DEVICE;
|
||||
else
|
||||
return USB_MODE_HOST;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -42,20 +42,14 @@
|
|||
#define __USBOTG_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
|
|
|
|||
|
|
@ -226,15 +226,13 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
|
|
@ -252,15 +250,13 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE const void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_OUT
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
|
|
@ -270,15 +266,13 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Pipe_Read_Byte()
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Pipe_Read_Byte())
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) 0
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Pipe_Read_Byte())
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
|
|
@ -288,14 +282,12 @@ uint8_t Pipe_Discard_Stream(uint16_t Length
|
|||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Pipe_Read_Byte()
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#if defined(__AVR__)
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Pipe_Read_Byte())
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
#endif
|
||||
#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE
|
||||
#define TEMPLATE_BUFFER_TYPE void*
|
||||
#define TEMPLATE_TOKEN PIPE_TOKEN_IN
|
||||
#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()
|
||||
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
|
||||
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Pipe_Read_Byte())
|
||||
#include "Template/Template_Pipe_RW.c"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -74,19 +74,12 @@
|
|||
#define __PIPE_H__
|
||||
|
||||
/* Includes: */
|
||||
#if defined(__AVR32__)
|
||||
#include <avr32/io.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#elif defined(__AVR__)
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
#include "LowLevel.h"
|
||||
#include "../HighLevel/USBTask.h"
|
||||
|
||||
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)
|
||||
|
|
@ -100,13 +93,9 @@
|
|||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__INCLUDE_FROM_USB_DRIVER)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
|
||||
#error Do not include this file directly. Include LUFA/Drivers/USB.h instead.
|
||||
#endif
|
||||
|
||||
#if defined(__AVR32__) && !defined(__AVR32_EPREG_X)
|
||||
#define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber]
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */
|
||||
|
|
@ -558,11 +547,7 @@
|
|||
static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t Pipe_Read_Byte(void)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
return __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
return UPDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Writes one byte from the currently selected pipe's bank, for IN direction pipes.
|
||||
|
|
@ -574,11 +559,7 @@
|
|||
static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
|
||||
static inline void Pipe_Write_Byte(const uint8_t Byte)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = Byte;
|
||||
#elif defined(__AVR__)
|
||||
UPDATX = Byte;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
|
@ -590,11 +571,7 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Dummy = UPDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT
|
||||
|
|
@ -613,13 +590,8 @@
|
|||
uint8_t Bytes[2];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[0] = UPDATX;
|
||||
Data.Bytes[1] = UPDATX;
|
||||
#endif
|
||||
|
||||
return Data.Word;
|
||||
}
|
||||
|
|
@ -640,13 +612,8 @@
|
|||
uint8_t Bytes[2];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[1] = UPDATX;
|
||||
Data.Bytes[0] = UPDATX;
|
||||
#endif
|
||||
|
||||
return Data.Word;
|
||||
}
|
||||
|
|
@ -661,13 +628,8 @@
|
|||
static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
|
||||
static inline void Pipe_Write_Word_LE(const uint16_t Word)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word & 0xFF);
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word >> 8);
|
||||
#elif defined(__AVR__)
|
||||
UPDATX = (Word & 0xFF);
|
||||
UPDATX = (Word >> 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Writes two bytes to the currently selected pipe's bank in big endian format, for IN
|
||||
|
|
@ -680,13 +642,8 @@
|
|||
static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
|
||||
static inline void Pipe_Write_Word_BE(const uint16_t Word)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word >> 8);
|
||||
__AVR32_EPREG_X(UEDAT0) = (Word & 0xFF);
|
||||
#elif defined(__AVR__)
|
||||
UPDATX = (Word >> 8);
|
||||
UPDATX = (Word & 0xFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
|
@ -698,13 +655,8 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Dummy = UPDATX;
|
||||
Dummy = UPDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT
|
||||
|
|
@ -723,17 +675,10 @@
|
|||
uint8_t Bytes[4];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[2] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[3] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[0] = UPDATX;
|
||||
Data.Bytes[1] = UPDATX;
|
||||
Data.Bytes[2] = UPDATX;
|
||||
Data.Bytes[3] = UPDATX;
|
||||
#endif
|
||||
|
||||
return Data.DWord;
|
||||
}
|
||||
|
|
@ -754,17 +699,10 @@
|
|||
uint8_t Bytes[4];
|
||||
} Data;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Data.Bytes[3] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[2] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);
|
||||
Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Data.Bytes[3] = UPDATX;
|
||||
Data.Bytes[2] = UPDATX;
|
||||
Data.Bytes[1] = UPDATX;
|
||||
Data.Bytes[0] = UPDATX;
|
||||
#endif
|
||||
|
||||
return Data.DWord;
|
||||
}
|
||||
|
|
@ -779,17 +717,10 @@
|
|||
static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
|
||||
static inline void Pipe_Write_DWord_LE(const uint32_t DWord)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord & 0xFF);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 8);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 16);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 24);
|
||||
#elif defined(__AVR__)
|
||||
UPDATX = (DWord & 0xFF);
|
||||
UPDATX = (DWord >> 8);
|
||||
UPDATX = (DWord >> 16);
|
||||
UPDATX = (DWord >> 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
|
||||
|
|
@ -802,17 +733,10 @@
|
|||
static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
|
||||
static inline void Pipe_Write_DWord_BE(const uint32_t DWord)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 24);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 16);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord >> 8);
|
||||
__AVR32_EPREG_X(UEDAT0) = (DWord & 0xFF);
|
||||
#elif defined(__AVR__)
|
||||
UPDATX = (DWord >> 24);
|
||||
UPDATX = (DWord >> 16);
|
||||
UPDATX = (DWord >> 8);
|
||||
UPDATX = (DWord & 0xFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
|
@ -824,17 +748,10 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
#if defined(__AVR32__)
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
Dummy = __AVR32_EPREG_X(UEDAT0);
|
||||
#elif defined(__AVR__)
|
||||
Dummy = UPDATX;
|
||||
Dummy = UPDATX;
|
||||
Dummy = UPDATX;
|
||||
Dummy = UPDATX;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* External Variables: */
|
||||
|
|
@ -958,8 +875,6 @@
|
|||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Pipe_Write_EStream_LE(const void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1009,8 +924,6 @@
|
|||
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Pipe_Write_EStream_BE(const void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1060,8 +973,6 @@
|
|||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Pipe_Read_EStream_LE(void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1097,8 +1008,6 @@
|
|||
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.
|
||||
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback
|
||||
*
|
||||
* \note Not available on AVR32 UC3B targets.
|
||||
*
|
||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||
*/
|
||||
uint8_t Pipe_Read_EStream_BE(void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
|
@ -1119,13 +1028,9 @@
|
|||
void Pipe_ClearPipes(void);
|
||||
|
||||
/* Inline Functions: */
|
||||
static inline uintN_t Pipe_BytesToEPSizeMask(uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uintN_t Pipe_BytesToEPSizeMask(uint16_t Bytes)
|
||||
static inline uint8_t Pipe_BytesToEPSizeMask(uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t Pipe_BytesToEPSizeMask(uint16_t Bytes)
|
||||
{
|
||||
#if defined(__AVR32__)
|
||||
// TODO
|
||||
return 0;
|
||||
#elif defined(__AVR__)
|
||||
if (Bytes <= 8)
|
||||
return (0 << EPSIZE0);
|
||||
else if (Bytes <= 16)
|
||||
|
|
@ -1138,7 +1043,6 @@
|
|||
return (4 << EPSIZE0);
|
||||
else
|
||||
return (5 << EPSIZE0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue