Commit 0e6d5cf5 authored by Dean Camera's avatar Dean Camera
Browse files

Start porting the USB core to the AVR32 UC3B.

parent e11fddfe
...@@ -47,7 +47,11 @@ ...@@ -47,7 +47,11 @@
#define __CONFIGDESCRIPTOR_H__ #define __CONFIGDESCRIPTOR_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #if defined(__AVR32__)
#include <avr32/io.h>
#elif defined(__AVR__)
#include <avr/io.h>
#endif
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#include "../HighLevel/USBMode.h" #include "../HighLevel/USBMode.h"
......
...@@ -50,7 +50,11 @@ ...@@ -50,7 +50,11 @@
#define __USBEVENTS_H__ #define __USBEVENTS_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #if defined(__AVR32__)
#include <avr32/io.h>
#elif defined(__AVR__)
#include <avr/io.h>
#endif
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#include "USBMode.h" #include "USBMode.h"
......
...@@ -41,9 +41,16 @@ ...@@ -41,9 +41,16 @@
#define __USBDESCRIPTORS_H__ #define __USBDESCRIPTORS_H__
/* Includes: */ /* Includes: */
#include <avr/pgmspace.h> #if defined(__AVR32__)
#include <stdbool.h> #include <avr32/io.h>
#include <stddef.h> #include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#elif defined(__AVR__)
#include <avr/pgmspace.h>
#include <stdbool.h>
#include <stddef.h>
#endif
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#include "USBMode.h" #include "USBMode.h"
......
...@@ -32,8 +32,14 @@ ...@@ -32,8 +32,14 @@
#define __USBINTERRUPT_H__ #define __USBINTERRUPT_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #if defined(__AVR32__)
#include <stdbool.h> #include <avr32/io.h>
#include <stdbool.h>
#include <stdint.h>
#elif defined(__AVR__)
#include <avr/io.h>
#include <stdbool.h>
#endif
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#include "../LowLevel/LowLevel.h" #include "../LowLevel/LowLevel.h"
......
...@@ -69,6 +69,11 @@ ...@@ -69,6 +69,11 @@
* (i.e. AT90USBXXX7) when defined. * (i.e. AT90USBXXX7) when defined.
*/ */
#define USB_SERIES_7_AVR #define USB_SERIES_7_AVR
/** Indicates that the target AVR microcontroller belongs to the Series UC3B USB controller
* (i.e. AT32UC3BXXXX) when defined.
*/
#define USB_SERIES_UC3B_AVR
/** Indicates that the target AVR microcontroller and compilation settings allow for the /** Indicates that the target AVR microcontroller and compilation settings allow for the
* target to be configured in USB Device mode when defined. * target to be configured in USB Device mode when defined.
...@@ -95,9 +100,11 @@ ...@@ -95,9 +100,11 @@
#define USB_SERIES_6_AVR #define USB_SERIES_6_AVR
#elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__)) #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))
#define USB_SERIES_7_AVR #define USB_SERIES_7_AVR
#elif (defined(__AVR32_UC3B0256__))
#define USB_SERIES_UC3B_AVR
#endif #endif
#if !defined(USB_SERIES_7_AVR) #if !defined(USB_SERIES_7_AVR) && !defined(USB_SERIES_UC3B_AVR)
#if defined(USB_HOST_ONLY) #if defined(USB_HOST_ONLY)
#error USB_HOST_ONLY is not available for the currently selected USB AVR model. #error USB_HOST_ONLY is not available for the currently selected USB AVR model.
#endif #endif
......
...@@ -32,9 +32,15 @@ ...@@ -32,9 +32,15 @@
#define __USBTASK_H__ #define __USBTASK_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #if defined(__AVR32__)
#include <avr/interrupt.h> #include <avr32/io.h>
#include <stdbool.h> #include <stdint.h>
#include <stdbool.h>
#elif defined(__AVR__)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#endif
#include "../LowLevel/LowLevel.h" #include "../LowLevel/LowLevel.h"
#include "Events.h" #include "Events.h"
......
...@@ -139,7 +139,7 @@ static void USB_Device_SetAddress(void) ...@@ -139,7 +139,7 @@ static void USB_Device_SetAddress(void)
if (DeviceAddress) if (DeviceAddress)
USB_DeviceState = DEVICE_STATE_Addressed; USB_DeviceState = DEVICE_STATE_Addressed;
UDADDR = ((1 << ADDEN) | DeviceAddress); USB_Device_SetDeviceAddress(DeviceAddress);
return; return;
} }
......
...@@ -32,10 +32,15 @@ ...@@ -32,10 +32,15 @@
#define __DEVCHAPTER9_H__ #define __DEVCHAPTER9_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #if defined(__AVR32__)
#include <avr/pgmspace.h> #include <avr32/io.h>
#include <avr/eeprom.h> #include <stdint.h>
#include <avr/boot.h> #elif defined(__AVR__)
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/boot.h>
#endif
#include "../HighLevel/StdDescriptors.h" #include "../HighLevel/StdDescriptors.h"
#include "../HighLevel/Events.h" #include "../HighLevel/Events.h"
...@@ -70,7 +75,11 @@ ...@@ -70,7 +75,11 @@
enum USB_DescriptorMemorySpaces_t enum USB_DescriptorMemorySpaces_t
{ {
MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory */ 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 */ 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 */ MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory */
}; };
#endif #endif
...@@ -125,6 +134,10 @@ ...@@ -125,6 +134,10 @@
#elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS) #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)
#error Only one of the USE_*_DESCRIPTORS modes should be selected. #error Only one of the USE_*_DESCRIPTORS modes should be selected.
#endif #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: */ /* Function Prototypes: */
void USB_Device_ProcessControlRequest(void); void USB_Device_ProcessControlRequest(void);
......
...@@ -41,9 +41,11 @@ ...@@ -41,9 +41,11 @@
#define __USBDEVICE_H__ #define __USBDEVICE_H__
/* Includes: */ /* Includes: */
#include <avr/pgmspace.h> #if defined(__AVR__)
#include <avr/eeprom.h> #include <avr/pgmspace.h>
#include <avr/eeprom.h>
#endif
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#include "../HighLevel/StdDescriptors.h" #include "../HighLevel/StdDescriptors.h"
#include "Endpoint.h" #include "Endpoint.h"
...@@ -59,7 +61,8 @@ ...@@ -59,7 +61,8 @@
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */ /* Macros: */
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__) #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || \
defined(USB_SERIES_UC3B_AVR) || defined(__DOXYGEN__))
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the /** 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. * USB interface should be initialized in low speed (1.5Mb/s) mode.
* *
...@@ -68,13 +71,13 @@ ...@@ -68,13 +71,13 @@
* \note Restrictions apply on the number, size and type of endpoints which can be used * \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. * 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 #endif
/** Mask for the Options parameter of the USB_Init() function. This indicates that the /** 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. * 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: */ /* Pseudo-Function Macros: */
#if defined(__DOXYGEN__) #if defined(__DOXYGEN__)
...@@ -129,16 +132,25 @@ ...@@ -129,16 +132,25 @@
*/ */
static inline bool USB_Device_DisableSOFEvents(void); static inline bool USB_Device_DisableSOFEvents(void);
#else #else
#if !defined(NO_DEVICE_REMOTE_WAKEUP) #if defined(__AVR32__)
#define USB_Device_SendRemoteWakeup() MACROS{ UDCON |= (1 << RMWKUP); }MACROE #if !defined(NO_DEVICE_REMOTE_WAKEUP)
#define USB_Device_SendRemoteWakeup() MACROS{ AVR32_USBB.UDCON.rmwkup = true; }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) #define USB_Device_IsRemoteWakeupSent() ((UDCON & (1 << RMWKUP)) ? false : true)
#endif
#define USB_Device_IsUSBSuspended() ((UDINT & (1 << SUSPI)) ? true : false)
#endif #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_EnableSOFEvents() MACROS{ USB_INT_Enable(USB_INT_SOFI); }MACROE
#define USB_Device_DisableSOFEvents() MACROS{ USB_INT_Disable(USB_INT_SOFI); }MACROE #define USB_Device_DisableSOFEvents() MACROS{ USB_INT_Disable(USB_INT_SOFI); }MACROE
#endif #endif
...@@ -207,8 +219,17 @@ ...@@ -207,8 +219,17 @@
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */
#define USB_Device_SetLowSpeed() MACROS{ UDCON |= (1 << LSM); }MACROE #if defined(__AVR32__)
#define USB_Device_SetFullSpeed() MACROS{ UDCON &= ~(1 << LSM); }MACROE #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.UDADDR = (AVR32_USBB_UDCON_ADDEN_MASK | DeviceAddress); }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
#endif #endif
#endif #endif
......
...@@ -225,12 +225,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length ...@@ -225,12 +225,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))
#include "Template/Template_Endpoint_RW.c" #include "Template/Template_Endpoint_RW.c"
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE #if defined(__AVR__)
#define TEMPLATE_BUFFER_TYPE const void* #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() #define TEMPLATE_BUFFER_TYPE const void*
#define TEMPLATE_BUFFER_OFFSET(Length) 0 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) #define TEMPLATE_BUFFER_OFFSET(Length) 0
#include "Template/Template_Endpoint_RW.c" #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_Stream_BE #define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
#define TEMPLATE_BUFFER_TYPE const void* #define TEMPLATE_BUFFER_TYPE const void*
...@@ -239,12 +241,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length ...@@ -239,12 +241,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)BufferPtr--)) #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(*((uint8_t*)BufferPtr--))
#include "Template/Template_Endpoint_RW.c" #include "Template/Template_Endpoint_RW.c"
#define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE #if defined(__AVR__)
#define TEMPLATE_BUFFER_TYPE const void* #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN() #define TEMPLATE_BUFFER_TYPE const void*
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
#include "Template/Template_Endpoint_RW.c" #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_PStream_BE #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
#define TEMPLATE_BUFFER_TYPE const void* #define TEMPLATE_BUFFER_TYPE const void*
...@@ -260,12 +264,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length ...@@ -260,12 +264,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte() #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()
#include "Template/Template_Endpoint_RW.c" #include "Template/Template_Endpoint_RW.c"
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE #if defined(__AVR__)
#define TEMPLATE_BUFFER_TYPE void* #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() #define TEMPLATE_BUFFER_TYPE void*
#define TEMPLATE_BUFFER_OFFSET(Length) 0 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) #define TEMPLATE_BUFFER_OFFSET(Length) 0
#include "Template/Template_Endpoint_RW.c" #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_Stream_BE #define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
#define TEMPLATE_BUFFER_TYPE void* #define TEMPLATE_BUFFER_TYPE void*
...@@ -274,12 +280,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length ...@@ -274,12 +280,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte() #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()
#include "Template/Template_Endpoint_RW.c" #include "Template/Template_Endpoint_RW.c"
#define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE #if defined(__AVR__)
#define TEMPLATE_BUFFER_TYPE void* #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT() #define TEMPLATE_BUFFER_TYPE void*
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
#include "Template/Template_Endpoint_RW.c" #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
#include "Template/Template_Endpoint_RW.c"
#endif
#endif #endif
...@@ -293,10 +301,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length ...@@ -293,10 +301,12 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++)) #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))
#include "Template/Template_Endpoint_Control_W.c" #include "Template/Template_Endpoint_Control_W.c"
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE #if defined(__AVR__)
#define TEMPLATE_BUFFER_OFFSET(Length) 0 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++)) #define TEMPLATE_BUFFER_OFFSET(Length) 0
#include "Template/Template_Endpoint_Control_W.c" #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_Stream_BE #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
...@@ -308,29 +318,35 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length ...@@ -308,29 +318,35 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--)) #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--))
#include "Template/Template_Endpoint_Control_W.c" #include "Template/Template_Endpoint_Control_W.c"
#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE #if defined(__AVR__)
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--)) #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
#include "Template/Template_Endpoint_Control_W.c" #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_Read_Control_Stream_LE #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
#define TEMPLATE_BUFFER_OFFSET(Length) 0 #define TEMPLATE_BUFFER_OFFSET(Length) 0
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte() #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()
#include "Template/Template_Endpoint_Control_R.c" #include "Template/Template_Endpoint_Control_R.c"
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE #if defined(__AVR__)
#define TEMPLATE_BUFFER_OFFSET(Length) 0 #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte()) #define TEMPLATE_BUFFER_OFFSET(Length) 0
#include "Template/Template_Endpoint_Control_R.c" #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_Stream_BE #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte() #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()
#include "Template/Template_Endpoint_Control_R.c" #include "Template/Template_Endpoint_Control_R.c"
#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE #if defined(__AVR__)
#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1) #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte()) #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
#include "Template/Template_Endpoint_Control_R.c" #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())
#include "Template/Template_Endpoint_Control_R.c"
#endif
#endif #endif
...@@ -66,11 +66,17 @@ ...@@ -66,11 +66,17 @@
#define __ENDPOINT_H__ #define __ENDPOINT_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #if defined(__AVR32__)
#include <avr/pgmspace.h> #include <avr32/io.h>
#include <avr/eeprom.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#elif defined(__AVR__)
#include <avr/io.h>
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <stdbool.h>
#endif
#include "../../../Common/Common.h" #include "../../../Common/Common.h"
#include "../HighLevel/USBTask.h" #include "../HighLevel/USBTask.h"
...@@ -486,7 +492,11 @@ ...@@ -486,7 +492,11 @@
static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Endpoint_Read_Byte(void) static inline uint8_t Endpoint_Read_Byte(void)
{ {
#if defined(__AVR32__)
return 0; // TODO
#elif defined(__AVR__)
return UEDATX; return UEDATX;
#endif
} }
/** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints. /** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.
...@@ -498,7 +508,11 @@ ...@@ -498,7 +508,11 @@
static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE; static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Endpoint_Write_Byte(const uint8_t Byte) static inline void Endpoint_Write_Byte(const uint8_t Byte)
{ {
#if defined(__AVR32__)
// TODO
#elif defined(__AVR__)
UEDATX = Byte; UEDATX = Byte;
#endif
} }
/** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints. /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
...@@ -510,7 +524,11 @@ ...@@ -510,7 +524,11 @@
{ {
uint8_t Dummy; uint8_t Dummy;
#if defined(__AVR32__)
// TODO
#elif defined(__AVR__)
Dummy = UEDATX; Dummy = UEDATX;
#endif
} }
/** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT
...@@ -529,8 +547,12 @@ ...@@ -529,8 +547,12 @@
uint8_t Bytes[2]; uint8_t Bytes[2];
} Data; } Data;
#if defined(__AVR32__)
// TODO
#elif defined(__AVR__)
Data.Bytes[0] = UEDATX; Data.Bytes[0] = UEDATX;
Data.Bytes[1] = UEDATX; Data.Bytes[1] = UEDATX;
#endif
return Data.Word; return Data.Word;
} }
...@@ -551,8 +573,12 @@ ...@@ -551,8 +573,12 @@
uint8_t Bytes[2]; uint8_t Bytes[2];
} Data; } Data;
#if defined(__AVR32__)
// TODO
#elif defined(__AVR__)
Data.Bytes[1] = UEDATX; Data.Bytes[1] = UEDATX;
Data.Bytes[0] = UEDATX; Data.Bytes[0] = UEDATX;
#endif
return Data.Word;