aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-04-14 08:48:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2013-04-14 08:48:55 +0000
commitb6a38164bdaf67bdd482e93b32bad9c3c5720264 (patch)
treeb77d816e6a1a07e621c5f8ced5e6b5f70d922b75 /LUFA/Drivers
parent70c59a7e42e5091a96af2607730cef7a83d5bbbd (diff)
downloadlufa-b6a38164bdaf67bdd482e93b32bad9c3c5720264.tar.gz
lufa-b6a38164bdaf67bdd482e93b32bad9c3c5720264.tar.bz2
lufa-b6a38164bdaf67bdd482e93b32bad9c3c5720264.zip
Reduce the amount of inlining of core Endpoint functions for XMEGA, to reduce the compiled code size (size/speed tradeoff).
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r--LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c104
-rw-r--r--LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h107
2 files changed, 112 insertions, 99 deletions
diff --git a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c
index 5dc75fc86..b8a80a479 100644
--- a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c
+++ b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.c
@@ -48,6 +48,106 @@ volatile uint8_t USB_Endpoint_SelectedEndpoint;
volatile USB_EP_t* USB_Endpoint_SelectedHandle;
volatile Endpoint_FIFO_t* USB_Endpoint_SelectedFIFO;
+bool Endpoint_IsINReady(void)
+{
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
+
+ return ((USB_Endpoint_SelectedHandle->STATUS & USB_EP_BUSNACK0_bm) ? true : false);
+}
+
+bool Endpoint_IsOUTReceived(void)
+{
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
+
+ if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_TRNCOMPL0_bm)
+ {
+ USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;
+ return true;
+ }
+
+ return false;
+}
+
+bool Endpoint_IsSETUPReceived(void)
+{
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
+
+ if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm)
+ {
+ USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;
+ return true;
+ }
+
+ return false;
+}
+
+void Endpoint_ClearSETUP(void)
+{
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
+ USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
+ USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;
+ USB_Endpoint_SelectedFIFO->Position = 0;
+
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
+ USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;
+ USB_Endpoint_SelectedFIFO->Position = 0;
+}
+
+void Endpoint_ClearIN(void)
+{
+ USB_Endpoint_SelectedHandle->CNT = USB_Endpoint_SelectedFIFO->Position;
+ USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
+ USB_Endpoint_SelectedFIFO->Position = 0;
+}
+
+void Endpoint_ClearOUT(void)
+{
+ USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
+ USB_Endpoint_SelectedFIFO->Position = 0;
+}
+
+void Endpoint_StallTransaction(void)
+{
+ USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
+
+ if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc)
+ {
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint ^ ENDPOINT_DIR_IN);
+ USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
+ }
+}
+
+uint8_t Endpoint_Read_8(void)
+{
+ return USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++];
+}
+
+void Endpoint_Write_8(const uint8_t Data)
+{
+ USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++] = Data;
+}
+
+void Endpoint_SelectEndpoint(const uint8_t Address)
+{
+ uint8_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK);
+
+ USB_Endpoint_SelectedEndpoint = Address;
+
+ Endpoint_FIFOPair_t* EndpointFIFOPair = &USB_Endpoint_FIFOs[EndpointNumber];
+ USB_EndpointTable_t* EndpointTable = (USB_EndpointTable_t*)USB.EPPTR;
+
+ if (Address & ENDPOINT_DIR_IN)
+ {
+ USB_Endpoint_SelectedFIFO = &EndpointFIFOPair->IN;
+ USB_Endpoint_SelectedHandle = &EndpointTable->Endpoints[EndpointNumber].IN;
+ }
+ else
+ {
+ USB_Endpoint_SelectedFIFO = &EndpointFIFOPair->OUT;
+ USB_Endpoint_SelectedHandle = &EndpointTable->Endpoints[EndpointNumber].OUT;
+ }
+}
+
bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,
const uint8_t Entries)
{
@@ -55,13 +155,13 @@ bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,
{
if (!(Table[i].Address))
continue;
-
+
if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks)))
{
return false;
}
}
-
+
return true;
}
diff --git a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
index 184823c68..9d6a628d5 100644
--- a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
+++ b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h
@@ -192,24 +192,7 @@
*
* \param[in] Address Endpoint address to select.
*/
- static inline void Endpoint_SelectEndpoint(const uint8_t Address);
- static inline void Endpoint_SelectEndpoint(const uint8_t Address)
- {
- uint8_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK);
-
- USB_Endpoint_SelectedEndpoint = Address;
-
- if (Address & ENDPOINT_DIR_IN)
- {
- USB_Endpoint_SelectedFIFO = &USB_Endpoint_FIFOs[EndpointNumber].IN;
- USB_Endpoint_SelectedHandle = &((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EndpointNumber].IN;
- }
- else
- {
- USB_Endpoint_SelectedFIFO = &USB_Endpoint_FIFOs[EndpointNumber].OUT;
- USB_Endpoint_SelectedHandle = &((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EndpointNumber].OUT;
- }
- }
+ void Endpoint_SelectEndpoint(const uint8_t Address);
/** Configures the specified endpoint address with the given endpoint type, direction, bank size
* and banking mode. Once configured, the endpoint may be read from or written to, depending
@@ -369,13 +352,7 @@
*
* \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.
*/
- static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsINReady(void)
- {
- Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
-
- return ((USB_Endpoint_SelectedHandle->STATUS & USB_EP_BUSNACK0_bm) ? true : false);
- }
+ bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT;
/** Determines if the selected OUT endpoint has received new packet from the host.
*
@@ -383,19 +360,7 @@
*
* \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.
*/
- static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsOUTReceived(void)
- {
- Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
-
- if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_TRNCOMPL0_bm)
- {
- USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;
- return true;
- }
-
- return false;
- }
+ bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT;
/** Determines if the current CONTROL type endpoint has received a SETUP packet.
*
@@ -403,19 +368,7 @@
*
* \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.
*/
- static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool Endpoint_IsSETUPReceived(void)
- {
- Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
-
- if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm)
- {
- USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;
- return true;
- }
-
- return false;
- }
+ bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT;
/** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the
* endpoint for the next packet.
@@ -424,43 +377,21 @@
*
* \note This is not applicable for non CONTROL type endpoints.
*/
- static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearSETUP(void)
- {
- Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
- USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
- USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;
- USB_Endpoint_SelectedFIFO->Position = 0;
-
- Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
- USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;
- USB_Endpoint_SelectedFIFO->Position = 0;
- }
+ void Endpoint_ClearSETUP(void);
/** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the
* next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement_XMEGA
*/
- static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearIN(void)
- {
- USB_Endpoint_SelectedHandle->CNT = USB_Endpoint_SelectedFIFO->Position;
- USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
- USB_Endpoint_SelectedFIFO->Position = 0;
- }
+ void Endpoint_ClearIN(void);
/** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint
* for the next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement_XMEGA
*/
- static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_ClearOUT(void)
- {
- USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
- USB_Endpoint_SelectedFIFO->Position = 0;
- }
+ void Endpoint_ClearOUT(void);
/** Stalls the current endpoint, indicating to the host that a logical problem occurred with the
* indicated endpoint and that the current transfer sequence should be aborted. This provides a
@@ -473,17 +404,7 @@
*
* \ingroup Group_EndpointPacketManagement_XMEGA
*/
- static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_StallTransaction(void)
- {
- USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
-
- if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc)
- {
- Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint ^ ENDPOINT_DIR_IN);
- USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
- }
- }
+ void Endpoint_StallTransaction(void);
/** Clears the STALL condition on the currently selected endpoint.
*
@@ -530,11 +451,7 @@
*
* \return Next byte in the currently selected endpoint's FIFO buffer.
*/
- static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_Read_8(void)
- {
- return USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++];
- }
+ uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT;
/** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints.
*
@@ -542,11 +459,7 @@
*
* \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer.
*/
- static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;
- static inline void Endpoint_Write_8(const uint8_t Data)
- {
- USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++] = Data;
- }
+ void Endpoint_Write_8(const uint8_t Data);
/** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.
*