![]() |
Data Structures | |
struct | TransferHeader |
struct | Transfer |
struct | MblTransfer |
struct | Endpoint |
struct | UdphsDmaDescriptor |
Modules | |
USB Device LEDs | |
Defines | |
#define | DMA |
#define | SHIFT_INTERUPT 12 |
#define | UDPHS_ENDPOINT_DISABLED 0 |
#define | UDPHS_ENDPOINT_HALTED 1 |
#define | UDPHS_ENDPOINT_IDLE 2 |
#define | UDPHS_ENDPOINT_SENDING 3 |
#define | UDPHS_ENDPOINT_RECEIVING 4 |
#define | UDPHS_ENDPOINT_SENDINGM 5 |
#define | UDPHS_ENDPOINT_RECEIVINGM 6 |
#define | MBL_NbBuffer(i, o, size) (((i)>(o))?((i)-(o)):((i)+(size)-(o))) |
#define | MBL_FULL 1 |
#define | MBL_NULL 2 |
#define | CHIP_USB_UDP |
#define | CHIP_USB_PULLUP_INTERNAL |
#define | CHIP_USB_NUMENDPOINTS 8 |
#define | CHIP_USB_ENDPOINTS_MAXPACKETSIZE(i) |
#define | CHIP_USB_ENDPOINTS_BANKS(i) |
#define | UDP_CSR_RXDATA_BK (UDP_CSR_RX_DATA_BK0 | UDP_CSR_RX_DATA_BK1) |
#define | UDP_ENDPOINT_DISABLED 0 |
#define | UDP_ENDPOINT_HALTED 1 |
#define | UDP_ENDPOINT_IDLE 2 |
#define | UDP_ENDPOINT_SENDING 3 |
#define | UDP_ENDPOINT_RECEIVING 4 |
#define | UDP_ENDPOINT_SENDINGM 5 |
#define | UDP_ENDPOINT_RECEIVINGM 6 |
#define | REG_NO_EFFECT_1_ALL |
#define | SET_CSR(endpoint, flags) |
#define | CLEAR_CSR(endpoint, flags) |
#define | MBL_NbBuffer(i, o, size) (((i)>(o))?((i)-(o)):((i)+(size)-(o))) |
#define | MBL_FULL 1 |
#define | MBL_NULL 2 |
#define | DMA |
#define | NUM_IT_MAX (UDPHS->UDPHS_IPFEATURES & UDPHS_IPFEATURES_EPT_NBR_MAX_Msk) |
#define | NUM_IT_MAX_DMA |
#define | SHIFT_DMA 24 |
#define | SHIFT_INTERUPT 8 |
#define | DMA_MAX_FIFO_SIZE (65536/1) |
#define | EPT_VIRTUAL_SIZE 16384 |
#define | UDPHS_ENDPOINT_DISABLED 0 |
#define | UDPHS_ENDPOINT_HALTED 1 |
#define | UDPHS_ENDPOINT_IDLE 2 |
#define | UDPHS_ENDPOINT_SENDING 3 |
#define | UDPHS_ENDPOINT_RECEIVING 4 |
#define | UDPHS_ENDPOINT_SENDINGM 5 |
#define | UDPHS_ENDPOINT_RECEIVINGM 6 |
#define | MBL_NbBuffer(i, o, size) (((i)>(o))?((i)-(o)):((i)+(size)-(o))) |
#define | MBL_FULL 1 |
#define | MBL_NULL 2 |
#define | bmEP(bEP) (1 << (bEP)) |
#define | EndpointInt |
#define | DMAEndpointInt |
Functions | |
COMPILER_ALIGNED (16) | |
void | USBHS_Handler (void) |
void | USBD_HAL_ResetEPs (uint32_t bmEPs, uint8_t bStatus, uint8_t bKeepCfg) |
Reset endpoints and disable them.
| |
void | USBD_HAL_CancelIo (uint32_t bmEPs) |
uint8_t | USBD_HAL_ConfigureEP (const USBEndpointDescriptor *pDescriptor) |
uint8_t | USBD_HAL_SetTransferCallback (uint8_t bEP, TransferCallback fCallback, void *pCbData) |
uint8_t | USBD_HAL_SetupMblTransfer (uint8_t bEndpoint, USBDTransferBuffer *pMbList, uint16_t mblSize, uint16_t startOffset) |
uint8_t | USBD_HAL_Write (uint8_t bEndpoint, const void *pData, uint32_t dLength) |
uint8_t | USBD_HAL_WrWithHdr (uint8_t bEndpoint, const void *pHdr, uint8_t bHdrLen, const void *pData, uint32_t dLength) |
uint8_t | USBD_HAL_Read (uint8_t bEndpoint, void *pData, uint32_t dLength) |
void | USBD_HAL_Connect (void) |
Enable Pull-up, connect. | |
void | USBD_HAL_Disconnect (void) |
Disable Pull-up, disconnect. | |
void | USBD_HAL_RemoteWakeUp (void) |
void | USBD_HAL_SetAddress (uint8_t address) |
void | USBD_HAL_SetConfiguration (uint8_t cfgnum) |
void | USBD_HAL_Init (void) |
uint8_t | USBD_HAL_Stall (uint8_t bEP) |
uint8_t | USBD_HAL_Halt (uint8_t bEndpoint, uint8_t ctl) |
void | USBD_HAL_WaitReadData (uint8_t bEndpoint) |
uint8_t | USBD_HAL_IsHighSpeed (void) |
void | USBD_HAL_Suspend (void) |
void | USBD_HAL_Activate (void) |
void | USBD_HAL_Disable (void) |
void | USBD_HAL_Test (uint8_t bIndex) |
void | USBD_IrqHandler (void) |
void | USBD_HAL_DetachUsb (void) |
void | USBD_HAL_AttachUsb (void) |
void | USBD_HAL_Enable (void) |
#define bmEP | ( | bEP | ) | (1 << (bEP)) |
Get bitmap for an endpoint
Definition at line 60 of file USBD_HAL.h.
#define CHIP_USB_ENDPOINTS_BANKS | ( | i | ) |
#define CHIP_USB_ENDPOINTS_MAXPACKETSIZE | ( | i | ) |
#define CHIP_USB_PULLUP_INTERNAL |
#define CLEAR_CSR | ( | endpoint, | ||
flags | ||||
) |
{ \ volatile uint32_t reg; \ int32_t nop_count; \ reg = UDP->UDP_CSR[endpoint]; \ reg |= REG_NO_EFFECT_1_ALL; \ reg &= ~((uint32_t)(flags)); \ UDP->UDP_CSR[endpoint] = reg; \ for( nop_count=0; nop_count<15; nop_count++ ) {\ nop();\ }\ }
Clears the specified bit(s) in the UDP_CSR register.
endpoint | The endpoint number of the CSR to process. | |
flags | The bitmap to clear to 0. |
#define DMA_MAX_FIFO_SIZE (65536/1) |
Max size of the FMA FIFO
Definition at line 76 of file hal_udphs.c.
#define DMAEndpointInt |
(USBHS_DEVISR_DMA_1 | USBHS_DEVISR_DMA_2 | USBHS_DEVISR_DMA_3 |\ USBHS_DEVISR_DMA_4 | USBHS_DEVISR_DMA_5 | USBHS_DEVISR_DMA_6 | USBHS_DEVISR_DMA_7 )
Definition at line 66 of file USBD_HAL.h.
#define EndpointInt |
(USBHS_DEVISR_PEP_0 | USBHS_DEVISR_PEP_1 | USBHS_DEVISR_PEP_2 | USBHS_DEVISR_PEP_3 |\ USBHS_DEVISR_PEP_4 | USBHS_DEVISR_PEP_5 | USBHS_DEVISR_PEP_6 | USBHS_DEVISR_PEP_7 |\ USBHS_DEVISR_PEP_8 | USBHS_DEVISR_PEP_9 | USBHS_DEVISR_PEP_10 | USBHS_DEVISR_PEP_11 )
Definition at line 62 of file USBD_HAL.h.
#define EPT_VIRTUAL_SIZE 16384 |
fifo space size in DW
Definition at line 78 of file hal_udphs.c.
#define MBL_FULL 1 |
Buffer list is full
Definition at line 103 of file USBD_HAL.c.
#define MBL_FULL 1 |
Buffer list is full
Definition at line 118 of file hal_udphs.c.
#define MBL_NbBuffer | ( | i, | ||
o, | ||||
size | ||||
) | (((i)>(o))?((i)-(o)):((i)+(size)-(o))) |
Get Number of buffer in Multi-Buffer-List
i | input index | |
o | output index | |
size | list size |
Definition at line 100 of file USBD_HAL.c.
#define MBL_NbBuffer | ( | i, | ||
o, | ||||
size | ||||
) | (((i)>(o))?((i)-(o)):((i)+(size)-(o))) |
Get Number of buffer in Multi-Buffer-List
i | input index | |
o | output index | |
size | list size |
Definition at line 115 of file hal_udphs.c.
#define MBL_NbBuffer | ( | i, | ||
o, | ||||
size | ||||
) | (((i)>(o))?((i)-(o)):((i)+(size)-(o))) |
#define MBL_NULL 2 |
Buffer list is null
Definition at line 120 of file hal_udphs.c.
#define MBL_NULL 2 |
Buffer list is null
Definition at line 105 of file USBD_HAL.c.
#define NUM_IT_MAX (UDPHS->UDPHS_IPFEATURES & UDPHS_IPFEATURES_EPT_NBR_MAX_Msk) |
Maximum number of endpoints interrupts.
Definition at line 63 of file hal_udphs.c.
#define NUM_IT_MAX_DMA |
((UDPHS->UDPHS_IPFEATURES \ & UDPHS_IPFEATURES_DMA_CHANNEL_NBR_Msk) \ >>UDPHS_IPFEATURES_DMA_CHANNEL_NBR_Pos)
Maximum number of endpoint DMA interrupts
Definition at line 66 of file hal_udphs.c.
#define REG_NO_EFFECT_1_ALL |
UDP_CSR_RX_DATA_BK0 | UDP_CSR_RX_DATA_BK1 \ |UDP_CSR_STALLSENTISOERROR | UDP_CSR_RXSETUP \ |UDP_CSR_TXCOMP
This page lists the macros to access UDP CSR register.
In a preemptive environment, set or clear the flag and wait for a time of 1 UDPCK clock cycle and 1 peripheral clock cycle. However, RX_DATA_BK0, TXPKTRDY, RX_DATA_BK1 require wait times of 3 UDPCK clock cycles and 5 peripheral clock cycles before accessing DPR. See datasheet
!Macros
#define SET_CSR | ( | endpoint, | ||
flags | ||||
) |
{ \ volatile uint32_t reg; \ int32_t nop_count; \ reg = UDP->UDP_CSR[endpoint]; \ reg |= REG_NO_EFFECT_1_ALL; \ reg |= (flags); \ UDP->UDP_CSR[endpoint] = reg; \ for( nop_count=0; nop_count<15; nop_count++ ) {\ nop();\ }\ }
Sets the specified bit(s) in the UDP_CSR register.
endpoint | The endpoint number of the CSR to process. | |
flags | The bitmap to set to 1. |
#define SHIFT_DMA 24 |
Bits that should be shifted to access DMA control bits.
Definition at line 71 of file hal_udphs.c.
#define SHIFT_INTERUPT 8 |
Bits that should be shifted to access interrupt bits.
Definition at line 73 of file hal_udphs.c.
#define SHIFT_INTERUPT 12 |
Bits that should be shifted to access interrupt bits.
Definition at line 62 of file USBD_HAL.c.
#define UDP_CSR_RXDATA_BK (UDP_CSR_RX_DATA_BK0 | UDP_CSR_RX_DATA_BK1) |
#define UDP_ENDPOINT_DISABLED 0 |
#define UDP_ENDPOINT_HALTED 1 |
#define UDP_ENDPOINT_IDLE 2 |
#define UDP_ENDPOINT_RECEIVING 4 |
#define UDP_ENDPOINT_RECEIVINGM 6 |
#define UDP_ENDPOINT_SENDING 3 |
#define UDP_ENDPOINT_SENDINGM 5 |
#define UDPHS_ENDPOINT_DISABLED 0 |
This page lists the endpoint states.
Definition at line 96 of file hal_udphs.c.
#define UDPHS_ENDPOINT_DISABLED 0 |
This page lists the endpoint states.
Definition at line 80 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_HALTED 1 |
Endpoint states: Endpoint is halted (i.e. STALLs every request)
Definition at line 82 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_HALTED 1 |
Endpoint states: Endpoint is halted (i.e. STALLs every request)
Definition at line 98 of file hal_udphs.c.
#define UDPHS_ENDPOINT_IDLE 2 |
Endpoint states: Endpoint is idle (i.e. ready for transmission)
Definition at line 84 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_IDLE 2 |
Endpoint states: Endpoint is idle (i.e. ready for transmission)
Definition at line 100 of file hal_udphs.c.
#define UDPHS_ENDPOINT_RECEIVING 4 |
Endpoint states: Endpoint is receiving data
Definition at line 104 of file hal_udphs.c.
#define UDPHS_ENDPOINT_RECEIVING 4 |
Endpoint states: Endpoint is receiving data
Definition at line 88 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_RECEIVINGM 6 |
Endpoint states: Endpoint is receiving MBL
Definition at line 108 of file hal_udphs.c.
#define UDPHS_ENDPOINT_RECEIVINGM 6 |
Endpoint states: Endpoint is receiving MBL
Definition at line 92 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_SENDING 3 |
Endpoint states: Endpoint is sending data
Definition at line 102 of file hal_udphs.c.
#define UDPHS_ENDPOINT_SENDING 3 |
Endpoint states: Endpoint is sending data
Definition at line 86 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_SENDINGM 5 |
Endpoint states: Endpoint is sending MBL
Definition at line 90 of file USBD_HAL.c.
#define UDPHS_ENDPOINT_SENDINGM 5 |
Endpoint states: Endpoint is sending MBL
Definition at line 106 of file hal_udphs.c.
COMPILER_ALIGNED | ( | 16 | ) |
DMA link list
Definition at line 219 of file USBD_HAL.c.
void USBD_HAL_Activate | ( | void | ) |
void USBD_HAL_CancelIo | ( | uint32_t | bmEPs | ) |
uint8_t USBD_HAL_ConfigureEP | ( | const USBEndpointDescriptor * | pDescriptor | ) |
Configures an endpoint according to its endpoint Descriptor.
pDescriptor | Pointer to an endpoint descriptor. |
Configures an endpoint according to its endpoint Descriptor.
pDescriptor | Pointer to an endpoint descriptor. |
Definition at line 1260 of file hal_udp.c.
void USBD_HAL_Connect | ( | void | ) |
void USBD_HAL_Disconnect | ( | void | ) |
uint8_t USBD_HAL_Halt | ( | uint8_t | bEndpoint, | |
uint8_t | ctl | |||
) |
Sets/Clear/Get the HALT state on the endpoint. In HALT state, the endpoint should keep stalling any packet.
bEndpoint | Endpoint number. | |
ctl | Control code CLR/HALT/READ. 0: Clear HALT state; 1: Set HALT state; .: Return HALT status. |
void USBD_HAL_Init | ( | void | ) |
uint8_t USBD_HAL_IsHighSpeed | ( | void | ) |
uint8_t USBD_HAL_Read | ( | uint8_t | bEndpoint, | |
void * | pData, | |||
uint32_t | dLength | |||
) |
Reads incoming data on an USB endpoint This methods sets the transfer descriptor and activate the endpoint interrupt. The actual transfer is then carried out by the endpoint interrupt handler. The Read operation finishes either when the buffer is full, or a short packet (inferior to endpoint maximum size) is received.
*The buffer must be kept allocated until the transfer is finished*.
bEndpoint | Endpoint number. | |
pData | Pointer to a data buffer. | |
dLength | Size of the data buffer in bytes. |
void USBD_HAL_RemoteWakeUp | ( | void | ) |
void USBD_HAL_ResetEPs | ( | uint32_t | bmEPs, | |
uint8_t | bStatus, | |||
uint8_t | bKeepCfg | |||
) |
Reset endpoints and disable them.
bmEPs | Bitmap for endpoints to reset. | |
bStatus | Status passed to terminate transfer on endpoint. | |
bKeepCfg | 1 to keep old endpoint configuration. |
void USBD_HAL_SetAddress | ( | uint8_t | address | ) |
void USBD_HAL_SetConfiguration | ( | uint8_t | cfgnum | ) |
uint8_t USBD_HAL_SetTransferCallback | ( | uint8_t | bEP, | |
TransferCallback | fCallback, | |||
void * | pCbData | |||
) |
Set callback for a USB endpoint for transfer (read/write).
bEP | Endpoint number. | |
fCallback | Optional callback function to invoke when the transfer is complete. | |
pCbData | Optional pointer to data to the callback function. |
uint8_t USBD_HAL_SetupMblTransfer | ( | uint8_t | bEndpoint, | |
USBDTransferBuffer * | pMbList, | |||
uint16_t | mblSize, | |||
uint16_t | startOffset | |||
) |
Configure an endpoint to use multi-buffer-list transfer mode. The buffers can be added by _Read/_Write function.
pMbList | Pointer to a multi-buffer list used, NULL to disable MBL. | |
mblSize | Multi-buffer list size (number of buffers can be queued) | |
startOffset | When number of buffer achieve this offset transfer start |
uint8_t USBD_HAL_Stall | ( | uint8_t | bEP | ) |
void USBD_HAL_Suspend | ( | void | ) |
void USBD_HAL_Test | ( | uint8_t | bIndex | ) |
void USBD_HAL_WaitReadData | ( | uint8_t | bEndpoint | ) |
Wait for data to read and then return
bEndpoint | Endpoint number |
uint8_t USBD_HAL_Write | ( | uint8_t | bEndpoint, | |
const void * | pData, | |||
uint32_t | dLength | |||
) |
Sends data through a USB endpoint. Sets up the transfer descriptor, writes one or two data payloads (depending on the number of FIFO bank for the endpoint) and then starts the actual transfer. The operation is complete when all the data has been sent.
*If the size of the buffer is greater than the size of the endpoint (or twice the size if the endpoint has two FIFO banks), then the buffer must be kept allocated until the transfer is finished*. This means that it is not possible to declare it on the stack (i.e. as a local variable of a function which returns after starting a transfer).
bEndpoint | Endpoint number. | |
pData | Pointer to a buffer with the data to send. | |
dLength | Size of the data buffer. |
uint8_t USBD_HAL_WrWithHdr | ( | uint8_t | bEndpoint, | |
const void * | pHdr, | |||
uint8_t | bHdrLen, | |||
const void * | pData, | |||
uint32_t | dLength | |||
) |
Special write function. Sends data through a USB endpoint. Sets up the transfer descriptor, writes header and one or two data payloads (depending on the number of FIFO bank for the endpoint) and then starts the actual transfer. The operation is complete when all the data has been sent.
*If the size of the buffer is greater than the size of the endpoint (or twice the size if the endpoint has two FIFO banks), then the buffer must be kept allocated until the transfer is finished*. This means that it is not possible to declare it on the stack (i.e. as a local variable of a function which returns after starting a transfer).
bEndpoint | Endpoint number. | |
pData | Pointer to a buffer with the data to send. | |
dLength | Size of the data buffer. |
Definition at line 1625 of file hal_udphs.c.
void USBD_IrqHandler | ( | void | ) |
USBD (UDP) interrupt handler Manages device resume, suspend, end of bus reset. Forwards endpoint events to the appropriate handler.
/ Start Of Frame (SOF)
Definition at line 1120 of file hal_udphs.c.
void USBHS_Handler | ( | void | ) |
USBD (UDP) interrupt handler Manages device resume, suspend, end of bus reset. Forwards endpoint events to the appropriate handler.
Definition at line 1006 of file USBD_HAL.c.