More AVR32 achitecture ports.
[pub/lufa.git] / LUFA / Drivers / USB / LowLevel / Endpoint.c
index 8244382..89fd39f 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
 \r
   Permission to use, copy, modify, distribute, and sell this \r
   software and its documentation for any purpose is hereby granted\r
   this software.\r
 */\r
 \r
   this software.\r
 */\r
 \r
+#define  __INCLUDE_FROM_USB_DRIVER\r
 #include "../HighLevel/USBMode.h"\r
 \r
 #if defined(USB_CAN_BE_DEVICE)\r
 \r
 #include "../HighLevel/USBMode.h"\r
 \r
 #if defined(USB_CAN_BE_DEVICE)\r
 \r
-#define  INCLUDE_FROM_ENDPOINT_C\r
+#define  __INCLUDE_FROM_ENDPOINT_C\r
 #include "Endpoint.h"\r
 \r
 #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
 uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
 #endif\r
 \r
 #include "Endpoint.h"\r
 \r
 #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
 uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
 #endif\r
 \r
-uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)\r
+uintN_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)\r
 {\r
        return Endpoint_BytesToEPSizeMask(Size);\r
 }\r
 \r
 {\r
        return Endpoint_BytesToEPSizeMask(Size);\r
 }\r
 \r
-bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData)\r
+bool Endpoint_ConfigureEndpoint_Prv(const uintN_t Number, const uintN_t UECFG0XData, const uintN_t UECFG1XData)\r
 {\r
        Endpoint_SelectEndpoint(Number);\r
        Endpoint_EnableEndpoint();\r
 {\r
        Endpoint_SelectEndpoint(Number);\r
        Endpoint_EnableEndpoint();\r
@@ -224,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++))\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Write_EStream_LE\r
-#define  TEMPLATE_BUFFER_TYPE                      const void*\r
-#define  TEMPLATE_CLEAR_ENDPOINT()                 Endpoint_ClearIN()\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            0\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))\r
-#include "Template/Template_Endpoint_RW.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Write_EStream_LE\r
+       #define  TEMPLATE_BUFFER_TYPE                  const void*\r
+       #define  TEMPLATE_CLEAR_ENDPOINT()             Endpoint_ClearIN()\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        0\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))\r
+       #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Stream_BE\r
 #define  TEMPLATE_BUFFER_TYPE                      const void*\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Stream_BE\r
 #define  TEMPLATE_BUFFER_TYPE                      const void*\r
@@ -238,12 +241,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(*((uint8_t*)BufferPtr--))\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(*((uint8_t*)BufferPtr--))\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Write_EStream_BE\r
-#define  TEMPLATE_BUFFER_TYPE                      const void*\r
-#define  TEMPLATE_CLEAR_ENDPOINT()                 Endpoint_ClearIN()\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))\r
-#include "Template/Template_Endpoint_RW.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Write_EStream_BE\r
+       #define  TEMPLATE_BUFFER_TYPE                  const void*\r
+       #define  TEMPLATE_CLEAR_ENDPOINT()             Endpoint_ClearIN()\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        (Length - 1)\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))\r
+       #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_PStream_BE\r
 #define  TEMPLATE_BUFFER_TYPE                      const void*\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_PStream_BE\r
 #define  TEMPLATE_BUFFER_TYPE                      const void*\r
@@ -259,12 +264,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Read_EStream_LE\r
-#define  TEMPLATE_BUFFER_TYPE                      void*\r
-#define  TEMPLATE_CLEAR_ENDPOINT()                 Endpoint_ClearOUT()\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            0\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())\r
-#include "Template/Template_Endpoint_RW.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Read_EStream_LE\r
+       #define  TEMPLATE_BUFFER_TYPE                  void*\r
+       #define  TEMPLATE_CLEAR_ENDPOINT()             Endpoint_ClearOUT()\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        0\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())\r
+       #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Stream_BE\r
 #define  TEMPLATE_BUFFER_TYPE                      void*\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Stream_BE\r
 #define  TEMPLATE_BUFFER_TYPE                      void*\r
@@ -273,12 +280,14 @@ uint8_t Endpoint_Discard_Stream(uint16_t Length
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_RW.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Read_EStream_BE\r
-#define  TEMPLATE_BUFFER_TYPE                      void*\r
-#define  TEMPLATE_CLEAR_ENDPOINT()                 Endpoint_ClearOUT()\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())\r
-#include "Template/Template_Endpoint_RW.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Read_EStream_BE\r
+       #define  TEMPLATE_BUFFER_TYPE                  void*\r
+       #define  TEMPLATE_CLEAR_ENDPOINT()             Endpoint_ClearOUT()\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        (Length - 1)\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())\r
+       #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
 \r
 #endif\r
 \r
 \r
 #endif\r
 \r
@@ -292,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++))\r
 #include "Template/Template_Endpoint_Control_W.c"\r
 \r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr++))\r
 #include "Template/Template_Endpoint_Control_W.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Control_EStream_LE\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            0\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))\r
-#include "Template/Template_Endpoint_Control_W.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Write_Control_EStream_LE\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        0\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr++))\r
+       #include "Template/Template_Endpoint_Control_W.c"\r
+#endif\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Control_Stream_BE\r
 #define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Control_Stream_BE\r
 #define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
@@ -307,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--))\r
 #include "Template/Template_Endpoint_Control_W.c"\r
 \r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(pgm_read_byte((uint8_t*)BufferPtr--))\r
 #include "Template/Template_Endpoint_Control_W.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Write_Control_EStream_BE\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))\r
-#include "Template/Template_Endpoint_Control_W.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Write_Control_EStream_BE\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        (Length - 1)\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)BufferPtr--))\r
+       #include "Template/Template_Endpoint_Control_W.c"\r
+#endif\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Control_Stream_LE\r
 #define  TEMPLATE_BUFFER_OFFSET(Length)            0\r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_Control_R.c"\r
 \r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Control_Stream_LE\r
 #define  TEMPLATE_BUFFER_OFFSET(Length)            0\r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr++) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_Control_R.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Control_EStream_LE\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            0\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())\r
-#include "Template/Template_Endpoint_Control_R.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Read_Control_EStream_LE\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        0\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     eeprom_write_byte((uint8_t*)BufferPtr++, Endpoint_Read_Byte())\r
+       #include "Template/Template_Endpoint_Control_R.c"\r
+#endif\r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Control_Stream_BE\r
 #define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_Control_R.c"\r
 \r
 \r
 #define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Control_Stream_BE\r
 #define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
 #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         *((uint8_t*)BufferPtr--) = Endpoint_Read_Byte()\r
 #include "Template/Template_Endpoint_Control_R.c"\r
 \r
-#define  TEMPLATE_FUNC_NAME                        Endpoint_Read_Control_EStream_BE\r
-#define  TEMPLATE_BUFFER_OFFSET(Length)            (Length - 1)\r
-#define  TEMPLATE_TRANSFER_BYTE(BufferPtr)         eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())\r
-#include "Template/Template_Endpoint_Control_R.c"\r
+#if defined(__AVR__)\r
+       #define  TEMPLATE_FUNC_NAME                    Endpoint_Read_Control_EStream_BE\r
+       #define  TEMPLATE_BUFFER_OFFSET(Length)        (Length - 1)\r
+       #define  TEMPLATE_TRANSFER_BYTE(BufferPtr)     eeprom_write_byte((uint8_t*)BufferPtr--, Endpoint_Read_Byte())\r
+       #include "Template/Template_Endpoint_Control_R.c"\r
+#endif\r
 \r
 #endif\r
 \r
 #endif\r