forked from mfulz_github/qmk_firmware
Add software FIFOs to the UC3B pipe control interfaces, to match the endpoint control interfaces. Fix incorrect endianness for the Endpoint/Pipe read and write routines.
This commit is contained in:
parent
b763c3f33e
commit
1e3d892b6a
|
@ -349,8 +349,8 @@
|
|||
*
|
||||
* \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset.
|
||||
*/
|
||||
static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)
|
||||
static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber)
|
||||
{
|
||||
UERST = (1 << EndpointNumber);
|
||||
UERST = 0;
|
||||
|
|
|
@ -50,9 +50,9 @@ void USB_Device_ProcessControlRequest(void)
|
|||
{
|
||||
USB_ControlRequest.bmRequestType = Endpoint_Read_Byte();
|
||||
USB_ControlRequest.bRequest = Endpoint_Read_Byte();
|
||||
USB_ControlRequest.wValue = le16_to_cpu(Endpoint_Read_Word_LE());
|
||||
USB_ControlRequest.wIndex = le16_to_cpu(Endpoint_Read_Word_LE());
|
||||
USB_ControlRequest.wLength = le16_to_cpu(Endpoint_Read_Word_LE());
|
||||
USB_ControlRequest.wValue = Endpoint_Read_Word_LE();
|
||||
USB_ControlRequest.wIndex = Endpoint_Read_Word_LE();
|
||||
USB_ControlRequest.wLength = Endpoint_Read_Word_LE();
|
||||
|
||||
EVENT_USB_Device_ControlRequest();
|
||||
|
||||
|
@ -339,7 +339,7 @@ static void USB_Device_ClearSetFeature(void)
|
|||
else
|
||||
{
|
||||
Endpoint_ClearStall();
|
||||
Endpoint_ResetFIFO(EndpointIndex);
|
||||
Endpoint_ResetEndpoint(EndpointIndex);
|
||||
Endpoint_ResetDataToggle();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
|
|||
|
||||
(&AVR32_USBB.uecfg0)[Number] = 0;
|
||||
(&AVR32_USBB.uecfg0)[Number] = UECFG0Data;
|
||||
USB_EndpointFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
|
||||
USB_EndpointFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
|
||||
|
||||
return Endpoint_IsConfigured();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ void Endpoint_ClearEndpoints(void)
|
|||
Endpoint_SelectEndpoint(EPNum);
|
||||
(&AVR32_USBB.uecfg0)[EPNum] = 0;
|
||||
(&AVR32_USBB.uecon0clr)[EPNum] = 0xFFFFFFFF;
|
||||
USB_EndpointFIFOPos[EPNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000];
|
||||
USB_EndpointFIFOPos[EPNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000];
|
||||
Endpoint_DisableEndpoint();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,8 +332,8 @@
|
|||
*
|
||||
* \param[in] EndpointNumber Endpoint number whose FIFO buffers are to be reset.
|
||||
*/
|
||||
static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)
|
||||
static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
|
||||
static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber)
|
||||
{
|
||||
AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << EndpointNumber);
|
||||
AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << EndpointNumber);
|
||||
|
@ -397,8 +397,6 @@
|
|||
(&AVR32_USBB.UECON0SET)[USB_SelectedEndpoint].killbks = true;
|
||||
while ((&AVR32_USBB.UECON0)[USB_SelectedEndpoint].killbk);
|
||||
}
|
||||
|
||||
USB_EndpointFIFOPos[USB_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_SelectedEndpoint * 0x10000];
|
||||
}
|
||||
|
||||
/** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint
|
||||
|
@ -647,7 +645,7 @@
|
|||
uint16_t Byte1 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
uint16_t Byte0 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
|
||||
return ((Byte1 << 8) | Byte0);
|
||||
return ((Byte0 << 8) | Byte1);
|
||||
}
|
||||
|
||||
/** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT
|
||||
|
@ -663,7 +661,7 @@
|
|||
uint16_t Byte0 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
uint16_t Byte1 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
|
||||
return ((Byte1 << 8) | Byte0);
|
||||
return ((Byte0 << 8) | Byte1);
|
||||
}
|
||||
|
||||
/** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN
|
||||
|
@ -676,8 +674,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)
|
||||
{
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (Word & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (Word >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (Word & 0xFF);
|
||||
}
|
||||
|
||||
/** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN
|
||||
|
@ -690,8 +688,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)
|
||||
{
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (Word >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (Word & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (Word >> 8);
|
||||
}
|
||||
|
||||
/** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.
|
||||
|
@ -722,7 +720,7 @@
|
|||
uint32_t Byte1 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
uint32_t Byte0 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
|
||||
return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);
|
||||
return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
|
||||
}
|
||||
|
||||
/** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT
|
||||
|
@ -740,7 +738,7 @@
|
|||
uint32_t Byte2 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
uint32_t Byte3 = *(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++);
|
||||
|
||||
return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);
|
||||
return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
|
||||
}
|
||||
|
||||
/** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN
|
||||
|
@ -753,10 +751,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)
|
||||
{
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 16);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 24);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 16);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord & 0xFF);
|
||||
}
|
||||
|
||||
/** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN
|
||||
|
@ -769,10 +767,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)
|
||||
{
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 24);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 16);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 16);
|
||||
*(((volatile uint8_t** volatile)USB_EndpointFIFOPos)[USB_SelectedEndpoint]++) = (DWord >> 24);
|
||||
}
|
||||
|
||||
/** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.
|
||||
|
|
|
@ -36,7 +36,9 @@
|
|||
#include "../Pipe.h"
|
||||
|
||||
uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
|
||||
|
||||
volatile uint8_t USB_SelectedPipe = PIPE_CONTROLPIPE;
|
||||
volatile void* USB_PipeFIFOPos[PIPE_TOTAL_PIPES];
|
||||
|
||||
bool Pipe_ConfigurePipe(const uint8_t Number,
|
||||
const uint8_t Type,
|
||||
|
@ -50,10 +52,11 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
|
|||
|
||||
(&AVR32_USBB.upcfg0)[Number] = 0;
|
||||
(&AVR32_USBB.upcfg0)[Number] = (AVR32_USBB_ALLOC_MASK |
|
||||
((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
|
||||
((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
|
||||
((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
|
||||
((EndpointNumber & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));
|
||||
((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
|
||||
((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
|
||||
((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
|
||||
((EndpointNumber & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));
|
||||
USB_PipeFIFOPos[PNum] = &AVR32_USBB_SLAVE[PNum * 0x10000];
|
||||
|
||||
Pipe_SetInfiniteINRequests();
|
||||
|
||||
|
@ -67,6 +70,7 @@ void Pipe_ClearPipes(void)
|
|||
Pipe_SelectPipe(PNum);
|
||||
(&AVR32_USBB.upcfg0)[PNum] = 0;
|
||||
(&AVR32_USBB.upcon0clr)[PNum] = 0xFFFFFFFF;
|
||||
USB_PipeFIFOPos[PNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000];
|
||||
Pipe_DisablePipe();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,6 +246,7 @@
|
|||
{
|
||||
AVR32_USBB.uprst |= (AVR32_USBB_PRST0_MASK << PipeNumber);
|
||||
AVR32_USBB.uprst &= ~(AVR32_USBB_PRST0_MASK << PipeNumber);
|
||||
USB_PipeFIFOPos[Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[Pipe_SelectedPipe * 0x10000];
|
||||
}
|
||||
|
||||
/** Enables the currently selected pipe so that data can be sent and received through it to and from
|
||||
|
@ -518,6 +519,7 @@
|
|||
static inline void Pipe_ClearSETUP(void)
|
||||
{
|
||||
(&AVR32_USBB.UPSTA0CLR)[USB_SelectedPipe].txstpic = true;
|
||||
USB_PipeFIFOPos[Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[Pipe_SelectedPipe * 0x10000];
|
||||
}
|
||||
|
||||
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected
|
||||
|
@ -530,6 +532,7 @@
|
|||
{
|
||||
(&AVR32_USBB.UPSTA0CLR)[USB_SelectedPipe].rxinic = true;
|
||||
(&AVR32_USBB.UPCON0CLR)[USB_SelectedPipe].fifoconc = true;
|
||||
USB_PipeFIFOPos[Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[Pipe_SelectedPipe * 0x10000];
|
||||
}
|
||||
|
||||
/** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
|
||||
|
@ -542,6 +545,7 @@
|
|||
{
|
||||
(&AVR32_USBB.UPSTA0CLR)[USB_SelectedPipe].txoutic = true;
|
||||
(&AVR32_USBB.UPCON0CLR)[USB_SelectedPipe].fifoconc = true;
|
||||
USB_PipeFIFOPos[Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[Pipe_SelectedPipe * 0x10000];
|
||||
}
|
||||
|
||||
/** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on
|
||||
|
@ -593,6 +597,7 @@
|
|||
static inline void Pipe_ClearStall(void)
|
||||
{
|
||||
(&AVR32_USBB.UPSTA0CLR)[USB_SelectedPipe].rxstalldic = true;
|
||||
USB_PipeFIFOPos[Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[Pipe_SelectedPipe * 0x10000];
|
||||
}
|
||||
|
||||
/** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
@ -604,7 +609,7 @@
|
|||
static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint8_t Pipe_Read_Byte(void)
|
||||
{
|
||||
return *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
return *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
}
|
||||
|
||||
/** Writes one byte from the currently selected pipe's bank, for IN direction pipes.
|
||||
|
@ -616,7 +621,7 @@
|
|||
static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
|
||||
static inline void Pipe_Write_Byte(const uint8_t Byte)
|
||||
{
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = Byte;
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = Byte;
|
||||
}
|
||||
|
||||
/** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
@ -628,7 +633,7 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
}
|
||||
|
||||
/** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT
|
||||
|
@ -641,16 +646,10 @@
|
|||
static inline uint16_t Pipe_Read_Word_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint16_t Pipe_Read_Word_LE(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint16_t Word;
|
||||
uint8_t Bytes[2];
|
||||
} Data;
|
||||
uint16_t Byte1 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint16_t Byte0 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
|
||||
Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
|
||||
return Data.Word;
|
||||
return ((Byte0 << 8) | Byte1);
|
||||
}
|
||||
|
||||
/** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT
|
||||
|
@ -663,16 +662,10 @@
|
|||
static inline uint16_t Pipe_Read_Word_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint16_t Pipe_Read_Word_BE(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint16_t Word;
|
||||
uint8_t Bytes[2];
|
||||
} Data;
|
||||
uint16_t Byte0 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint16_t Byte1 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
|
||||
Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
|
||||
return Data.Word;
|
||||
return ((Byte0 << 8) | Byte1);
|
||||
}
|
||||
|
||||
/** Writes two bytes to the currently selected pipe's bank in little endian format, for IN
|
||||
|
@ -685,8 +678,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)
|
||||
{
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (Word >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (Word & 0xFF);
|
||||
}
|
||||
|
||||
/** Writes two bytes to the currently selected pipe's bank in big endian format, for IN
|
||||
|
@ -699,8 +692,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)
|
||||
{
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (Word & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (Word >> 8);
|
||||
}
|
||||
|
||||
/** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
@ -712,8 +705,8 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
}
|
||||
|
||||
/** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT
|
||||
|
@ -726,18 +719,12 @@
|
|||
static inline uint32_t Pipe_Read_DWord_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint32_t Pipe_Read_DWord_LE(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t DWord;
|
||||
uint8_t Bytes[4];
|
||||
} Data;
|
||||
uint32_t Byte3 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint32_t Byte2 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint32_t Byte1 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint32_t Byte0 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
|
||||
Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
|
||||
return Data.DWord;
|
||||
return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
|
||||
}
|
||||
|
||||
/** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT
|
||||
|
@ -750,18 +737,12 @@
|
|||
static inline uint32_t Pipe_Read_DWord_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
|
||||
static inline uint32_t Pipe_Read_DWord_BE(void)
|
||||
{
|
||||
union
|
||||
{
|
||||
uint32_t DWord;
|
||||
uint8_t Bytes[4];
|
||||
} Data;
|
||||
uint32_t Byte0 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint32_t Byte1 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint32_t Byte2 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
uint32_t Byte3 = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
|
||||
Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
|
||||
return Data.DWord;
|
||||
return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
|
||||
}
|
||||
|
||||
/** Writes four bytes to the currently selected pipe's bank in little endian format, for IN
|
||||
|
@ -774,10 +755,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)
|
||||
{
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord >> 24);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord >> 16);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord & 0xFF);
|
||||
}
|
||||
|
||||
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
|
||||
|
@ -790,10 +771,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)
|
||||
{
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);
|
||||
*((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord & 0xFF);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord >> 8);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord >> 16);
|
||||
*(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++) = (DWord >> 24);
|
||||
}
|
||||
|
||||
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
|
||||
|
@ -805,10 +786,10 @@
|
|||
{
|
||||
uint8_t Dummy;
|
||||
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
Dummy = *(((volatile uint8_t** volatile)USB_PipeFIFOPos)[USB_SelectedPipe]++);
|
||||
}
|
||||
|
||||
/* External Variables: */
|
||||
|
|
Loading…
Reference in New Issue