4.16 USB - Universal Serial Bus
4.16.1 Introduction
The Universal Serial Bus (USB) peripheral is a USB 2.0 full-speed (12 Mbps) device-compliant interface that supports 16 endpoint addresses and full endpoint flexibility for up to 32 endpoints. Each endpoint address is supported by the four transfer types: control, interrupt, bulk, or isochronous.
4.16.2 Supported Device Families
AVR-DU |
4.16.3 Required header files:
#include "mcc_generated_files/usb/usb[X].h"
4.16.4 Specific MISRA C:2012 Deviations
- Global USB_EndpointInBufferSet (uint8_t endpointAddress, uint8_t *bufAddress)
-
Advisory: misra-c2012- 11.4
Justification: A conversion should not be performed between a pointer to object and an integer type. The EP.IN.DATAPTR register is a 16-bit register, expecting an AVR DU specific 16-bit RAM address. - Global USB_EndpointOutBufferSet (uint8_t endpointAddress, uint8_t *bufAddress)
-
Advisory: misra-c2012- 11.4
Justification: A conversion should not be performed between a pointer to object and an integer type. The EP.OUT.DATAPTR register is a 16-bit register, expecting an AVR DU specific 16-bit RAM address.
4.16.5 Module Documentation
4.16.5.1 USB0
This file contains the API prototypes for the USB0 driver.
4.16.5.1.1 Module description
This file contains the API prototypes for the USB0 driver.
Typedefs
typedef void(* USB_cb_t) (void)
Data type for the interrupt handlers called by USB. The default value is set to NULL which means that no callback function will be used.
Functions
void USB0_Initialize (void)
Initializes USB0.
void USB0_TrnComplCallbackRegister (USB_cb_t cb)
Registers a callback function handling the Interrupt Service Routine (ISR) if a Transaction Complete interrupt flag is set.
void USB0_BusEventCallbackRegister (USB_cb_t cb)
Registers a callback function handling the ISR if a Bus Event interrupt flag is set.
4.16.5.1.2 Typedef Documentation
USB_cb_t
void * USB_cb_t
Data type for the interrupt handlers called by USB. The default value is set to NULL which means that no callback function will be used.
4.16.5.1.3 Function Documentation
USB0_BusEventCallbackRegister()
void USB0_BusEventCallbackRegister (USB_cb_t cb)
Registers a callback function handling the ISR if a Bus Event interrupt flag is set.
USB_cb_t |
cb - Callback function for a bus event |
None. |
USB0_Initialize()
void USB0_Initialize (void )
Initializes USB0.
Section: USB0 APIs
None. |
None. |
USB0_TrnComplCallbackRegister()
void USB0_TrnComplCallbackRegister (USB_cb_t cb)
Registers a callback function handling the Interrupt Service Routine (ISR) if a Transaction Complete interrupt flag is set.
USB_cb_t |
cb - Callback function for a transaction complete event |
None. |
4.16.5.2 USB Peripheral Hardware Abstraction Layer (HAL)
Interface for a USB peripheral module that needs to be implemented by a device-specific USB module driver.
4.16.5.2.1 Module description
Interface for a USB peripheral module that needs to be implemented by a device-specific USB module driver.
Modules
-
This file encompasses all the register settings of the AVR DU device in the form of inline functions. It also abstracts the Read-Modify-Write loop for STATUS registers, which is required, as the hardware and software can both write into the STATUS register.
-
API module for usb_peripheral_endpoint covering endpoint-related functions.
-
API module for usb_peripheral covering low-level USB transaction functions.
Data structures
struct USB_CONTROL_TRANSFER_t
The data structure for internally handling control transfers, either IN or OUT.
Functions
bool USB_SetupIsReceived (void)
Detects if the Setup event was received.
bool USB_EventSOFIsReceived (void)
Detects if the Start-of-Frame (SOF) event was received.
void USB_EventSOFClear (void)
Clears the SOF event.
bool USB_EventResetIsReceived (void)
Detects if the Reset event was received.
void USB_EventResetClear (void)
Clears the Reset event.
uint8_t USB_EventOverUnderflowIsReceived (void)
Detects if an Overflow and/or Underflow event was received.
uint8_t USB_ControlOverUnderflowIsReceived (void)
Detects if an Overflow and/or Underflow event was received on the control endpoints.
void USB_EventOverUnderflowClear (void)
Clears the Over/Underflow event.
bool USB_EventSuspendIsReceived (void)
Detects if a Suspend event was received.
void USB_EventSuspendClear (void)
Clears the Suspend event.
bool USB_EventResumeIsReceived (void)
Detects if a Resume event was received.
void USB_EventResumeClear (void)
Clears the Resume event.
bool USB_EventStalledIsReceived (void)
Detects if a Stalled event was received.
void USB_EventStalledClear (void)
Clears the Stalled event.
void USB_BusAttach (void)
Attaches the device to the USB bus.
void USB_BusDetach (void)
Detaches the device from the USB bus.
bool USB_IsBusAttached (void)
Checks if the device is attached to the USB bus not.
void USB_DeviceAddressConfigure (uint8_t deviceAddress)
Sets the device address.
uint16_t USB_FrameNumberGet (void)
Gets the current frame number.
RETURN_CODE_t USB_ControlEndpointsInit (void)
Ensures correct control endpoint initialization.
RETURN_CODE_t USB_ControlSetupReceived (void)
Verifies the received control setup.
RETURN_CODE_t USB_ControlTransactionComplete (USB_PIPE_t pipe)
Handles completed transactions on the control endpoints. Checks and verifies data OUT, data IN, ZLP OUT and ZLP IN.
RETURN_CODE_t USB_ControlTransferZLP (uint8_t direction)
Sends ZLP OUT and ZLP IN transactions on the control endpoints.
RETURN_CODE_t USB_ControlTransferReset (void)
Ensures correct control transfer reset.
RETURN_CODE_t USB_ControlTransferDataSet (uint8_t *dataPtr, uint16_t dataSize)
Updates the transfer data pointer and size in ControlTransfer.
RETURN_CODE_t USB_ControlTransferDataWriteBuffer (uint8_t *dataPtr, uint8_t dataSize)
Copies data to the transfer buffer and sets the transfer data pointer and size in ControlTransfer.
void USB_ControlEndOfRequestCallbackRegister (USB_SETUP_ENDOFREQUEST_CALLBACK_t callback)
Sets the callback for end of a control request.
void USB_ControlProcessSetupCallbackRegister (USB_SETUP_PROCESS_CALLBACK_t callback)
Sets the callback for the setup processing.
void USB_ControlOverUnderRunCallbackRegister (USB_SETUP_OVERUNDERRUN_CALLBACK_t callback)
Sets the callback for a control overrun or underrun.
RETURN_CODE_t USB_ControlProcessOverUnderflow (uint8_t overunderflow)
Handles the control Over/Underflow events.
RETURN_CODE_t USB_HandleEventStalled (USB_PIPE_t pipe)
Handles the Stall events.
void USB_PeripheralInitialize (void)
Enables the peripheral and the frame number, enables and resets FIFO, sets the endpoint table address and max endpoints.
void USB_PeripheralDisable (void)
Disables the USB peripheral and aborts any ongoing transaction.
static ALWAYS_INLINE uint16_t USB_FrameNumGet (void)
Gets the current frame number.
4.16.5.2.2 Function Documentation
USB_BusAttach()
void USB_BusAttach (void )
Attaches the device to the USB bus.
None. |
None. |
USB_BusDetach()
void USB_BusDetach (void )
Detaches the device from the USB bus.
None. |
None. |
USB_ControlEndOfRequestCallbackRegister()
void USB_ControlEndOfRequestCallbackRegister (USB_SETUP_ENDOFREQUEST_CALLBACK_t callback)
Sets the callback for end of a control request.
callback |
- The function to call for the end of a control request |
None. |
USB_ControlEndpointsInit()
RETURN_CODE_t USB_ControlEndpointsInit (void )
Ensures correct control endpoint initialization.
None. |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlOverUnderflowIsReceived()
uint8_t USB_ControlOverUnderflowIsReceived (void )
Detects if an Overflow and/or Underflow event was received on the control endpoints.
None. |
A value representing the events received |
USB_ControlOverUnderRunCallbackRegister()
void USB_ControlOverUnderRunCallbackRegister (USB_SETUP_OVERUNDERRUN_CALLBACK_t callback)
Sets the callback for a control overrun or underrun.
callback |
- The function to call on a control overrun or underrun |
None. |
USB_ControlProcessOverUnderflow()
RETURN_CODE_t USB_ControlProcessOverUnderflow (uint8_t overunderflow)
Handles the control Over/Underflow events.
overunderflow |
- A value representing overflow or underflow |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlProcessSetupCallbackRegister()
void USB_ControlProcessSetupCallbackRegister (USB_SETUP_PROCESS_CALLBACK_t callback)
Sets the callback for the setup processing.
callback |
- The function to call for the setup processing |
None. |
USB_ControlSetupReceived()
RETURN_CODE_t USB_ControlSetupReceived (void )
Verifies the received control setup.
None. |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlTransactionComplete()
RETURN_CODE_t USB_ControlTransactionComplete (USB_PIPE_t pipe)
Handles completed transactions on the control endpoints. Checks and verifies data OUT, data IN, ZLP OUT and ZLP IN.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlTransferDataSet()
RETURN_CODE_t USB_ControlTransferDataSet (uint8_t * dataPtr, uint16_t dataSize)
Updates the transfer data pointer and size in ControlTransfer.
*dataPtr |
- Pointer to new data |
dataSize |
- Number of elements in the array |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlTransferDataWriteBuffer()
RETURN_CODE_t USB_ControlTransferDataWriteBuffer (uint8_t * dataPtr, uint8_t dataSize)
Copies data to the transfer buffer and sets the transfer data pointer and size in ControlTransfer.
*dataPtr |
- Pointer to data to copy |
dataSize |
- Number of elements in the array |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlTransferReset()
RETURN_CODE_t USB_ControlTransferReset (void )
Ensures correct control transfer reset.
None. |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_ControlTransferZLP()
RETURN_CODE_t USB_ControlTransferZLP (uint8_t direction)
Sends ZLP OUT and ZLP IN transactions on the control endpoints.
direction |
- The endpoint direction to send the ZLP |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_DeviceAddressConfigure()
void USB_DeviceAddressConfigure (uint8_t deviceAddress)
Sets the device address.
deviceAddress |
- Device address to set |
None. |
USB_EventOverUnderflowClear()
void USB_EventOverUnderflowClear (void )
Clears the Over/Underflow event.
None. |
None. |
USB_EventOverUnderflowIsReceived()
uint8_t USB_EventOverUnderflowIsReceived (void )
Detects if an Overflow and/or Underflow event was received.
None. |
A value representing the events received |
USB_EventResetClear()
void USB_EventResetClear (void )
Clears the Reset event.
None. |
None. |
USB_EventResetIsReceived()
bool USB_EventResetIsReceived (void )
Detects if the Reset event was received.
None. |
1 |
- Reset event was received |
0 |
- Reset event was not received |
USB_EventResumeClear()
void USB_EventResumeClear (void )
Clears the Resume event.
None. |
None. |
USB_EventResumeIsReceived()
bool USB_EventResumeIsReceived (void )
Detects if a Resume event was received.
None. |
0 |
- Resume event was not received |
1 |
- Resume event was received |
USB_EventSOFClear()
void USB_EventSOFClear (void )
Clears the SOF event.
None. |
None. |
USB_EventSOFIsReceived()
bool USB_EventSOFIsReceived (void )
Detects if the Start-of-Frame (SOF) event was received.
None. |
0 |
- SOF event was not received |
1 |
- SOF event was received |
USB_EventStalledClear()
void USB_EventStalledClear (void )
Clears the Stalled event.
None. |
None. |
USB_EventStalledIsReceived()
bool USB_EventStalledIsReceived (void )
Detects if a Stalled event was received.
None. |
0 |
- Stalled event was not received |
1 |
- Stalled event was received |
USB_EventSuspendClear()
void USB_EventSuspendClear (void )
Clears the Suspend event.
None. |
None. |
USB_EventSuspendIsReceived()
bool USB_EventSuspendIsReceived (void )
Detects if a Suspend event was received.
None. |
A boolean value representing the Suspend event received condition |
0 |
- Suspend event was not received |
1 |
- Suspend event was received |
USB_FrameNumberGet()
uint16_t USB_FrameNumberGet (void )
Gets the current frame number.
None. |
15-bit frame number |
USB_FrameNumGet()
static ALWAYS_INLINE uint16_t USB_FrameNumGet (void )[static]
Gets the current frame number.
None. |
15-bit frame number |
USB_HandleEventStalled()
RETURN_CODE_t USB_HandleEventStalled (USB_PIPE_t pipe)
Handles the Stall events.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_IsBusAttached()
bool USB_IsBusAttached (void )
Checks if the device is attached to the USB bus not.
None. |
0 |
- USB bus is not attached |
1 |
- USB bus is attached |
USB_PeripheralDisable()
void USB_PeripheralDisable (void )
Disables the USB peripheral and aborts any ongoing transaction.
None. |
None. |
USB_PeripheralInitialize()
void USB_PeripheralInitialize (void )
Enables the peripheral and the frame number, enables and resets FIFO, sets the endpoint table address and max endpoints.
None. |
None. |
USB_SetupIsReceived()
bool USB_SetupIsReceived (void )
Detects if the Setup event was received.
None. |
0 |
- Setup event was not received |
1 |
- Setup event was received |
4.16.5.3 USB Peripheral AVR DU
This file encompasses all the register settings of the AVR DU device in the form of inline functions. It also abstracts the Read-Modify-Write loop for STATUS registers, which is required, as the hardware and software can both write into the STATUS register.
4.16.5.3.1 Module description
This file encompasses all the register settings of the AVR DU device in the form of inline functions. It also abstracts the Read-Modify-Write loop for STATUS registers, which is required, as the hardware and software can both write into the STATUS register.
Data structures
struct USB_ENDPOINT_TABLE_struct
Represents the endpoint configuration table based on the number of endpoints in use. The table data structure is defined by USB_EP_TABLE_struct in the device header file, modified to support configuration of size from USB_EP_NUM.
struct USB_PIPE_TRANSFER_struct
Represents a transfer created for a pipe, either IN or OUT.
Definitions
#define ALWAYS_INLINE __attribute__((always_inline)) inline
Alias that makes always inline function definitions more readable.
Functions
static ALWAYS_INLINE void WaitUntilRMWDone (void)
Waits until a Read-Modify-Write operation is done. This blocking wait operation is expected to complete within 14 clock cycles.
static ALWAYS_INLINE void USB_EndPointOutDisable (uint8_t endpointAddress)
Disables the OUT endpoint with the given address.
static ALWAYS_INLINE void USB_EndPointInDisable (uint8_t endpointAddress)
Disables the IN endpoint with the given address.
static ALWAYS_INLINE bool USB_EndPointOutIsEnabled (uint8_t endpointAddress)
Checks if the OUT endpoint at the given address is enabled.
static ALWAYS_INLINE bool USB_EndPointInIsEnabled (uint8_t endpointAddress)
Checks if the IN endpoint at the given address is enabled.
static ALWAYS_INLINE uint8_t USB_EndPointOutTypeConfigGet (uint8_t endpointAddress)
Gets the OUT endpoint configuration at the given address.
static ALWAYS_INLINE uint8_t USB_EndPointInTypeConfigGet (uint8_t endpointAddress)
Gets the IN endpoint configuration at the given address.
static ALWAYS_INLINE void USB_EndpointOutControlSet (uint8_t endpointAddress, uint8_t value)
Sets endpoint control OUT.
static ALWAYS_INLINE void USB_EndpointInControlSet (uint8_t endpointAddress, uint8_t value)
Sets endpoint control IN.
static ALWAYS_INLINE void USB_EndpointOutStatusClear (uint8_t endpointAddress)
Clears OUT endpoint status.
static ALWAYS_INLINE void USB_EndpointInStatusClear (uint8_t endpointAddress)
Clears IN endpoint status.
static ALWAYS_INLINE void USB_EndpointOutDefaultSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for a default type OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInDefaultSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for a default type IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutIsoSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for an isochronous OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInIsoSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for an isochronous IN endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointOutDefaultSizeGet (uint8_t endpointAddress)
Gets the size of a default type OUT endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointInDefaultSizeGet (uint8_t endpointAddress)
Gets the size of a default type IN endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointOutIsoSizeGet (uint8_t endpointAddress)
Gets the size of an isochronous OUT endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointInIsoSizeGet (uint8_t endpointAddress)
Gets the size of an isochronous IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteInterruptEnable (uint8_t endpointAddress)
Enables transaction complete interrupt for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteInterruptEnable (uint8_t endpointAddress)
Enables transaction complete interrupt for the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteInterruptDisable (uint8_t endpointAddress)
Disables transaction complete interrupt for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteDisable (uint8_t endpointAddress)
Disables transaction complete interrupt for the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutMultipktEnable (uint8_t endpointAddress)
Enables multipacket for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInMultipktEnable (uint8_t endpointAddress)
Enables multipacket for the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutMultipktDisable (uint8_t endpointAddress)
Disables multipacket for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInMultipktDisable (uint8_t endpointAddress)
Disables multipacket for the specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutMultipktIsEnabled (uint8_t endpointAddress)
Checks if multipacket is enabled on the specified OUT endpoint.
static ALWAYS_INLINE bool USB_EndpointInMultipktIsEnabled (uint8_t endpointAddress)
Checks if multipacket is enabled on the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutAzlpEnable (uint8_t endpointAddress)
Enables Auto Zero Length Packet (AZLP) on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInAlzpEnable (uint8_t endpointAddress)
Enables AZLP on the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutAzlpDisable (uint8_t endpointAddress)
Disables AZLP on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInAzlpDisable (uint8_t endpointAddress)
Disables AZLP on the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutStall (uint8_t endpointAddress)
Stalls the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInStall (uint8_t endpointAddress)
Stalls the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutStallClear (uint8_t endpointAddress)
Stops stalling the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInStallClear (uint8_t endpointAddress)
Stops stalling the specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutIsStalled (uint8_t endpointAddress)
Checks if the specified OUT endpoint is stalled.
static ALWAYS_INLINE bool USB_EndpointInIsStalled (uint8_t endpointAddress)
Checks if the specified IN endpoint is stalled.
static ALWAYS_INLINE void USB_EndpointOutStallAck (uint8_t endpointAddress)
Acknowledges that an OUT endpoint is stalled and Clears the USB STATUS register.
static ALWAYS_INLINE void USB_EndpointInStallAck (uint8_t endpointAddress)
Acknowledges that an IN endpoint is stalled and Clears the USB STATUS register.
static ALWAYS_INLINE void USB_EndpointOutNAKSet (uint8_t endpointAddress)
Sets OUT endpoint status to NAK.
static ALWAYS_INLINE void USB_EndpointInNAKSet (uint8_t endpointAddress)
Sets IN endpoint status to NAK.
static ALWAYS_INLINE void USB_EndpointOutNAKClear (uint8_t endpointAddress)
Clears the USB NAK status from the OUT endpoint STATUS register.
static ALWAYS_INLINE void USB_EndpointInNAKClear (uint8_t endpointAddress)
Clears the USB NAK status from the IN endpoint STATUS register.
static ALWAYS_INLINE bool USB_EndpointOutNAKIsSet (uint8_t endpointAddress)
Checks the OUT endpoint STATUS register for the NAK status.
static ALWAYS_INLINE bool USB_EndpointInNAKIsSet (uint8_t endpointAddress)
Checks the OUT endpoint STATUS register for the NAK status.
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteAck (uint8_t endpointAddress)
Acknowledges the transaction complete status on a specified OUT endpoint and Clears the USB STATUS register.
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteAck (uint8_t endpointAddress)
Acknowledges the transaction complete status on a specified IN endpoint and Clears the USB STATUS register.
static ALWAYS_INLINE bool USB_EndpointOutTransactionIsComplete (uint8_t endpointAddress)
Checks if the USB OUT endpoint has the Transaction Complete status.
static ALWAYS_INLINE bool USB_EndpointInTransactionIsComplete (uint8_t endpointAddress)
Checks if the USB IN endpoint has the Transaction Complete status.
static ALWAYS_INLINE void USB_EndpointOutSetupReceivedAck (uint8_t endpointAddress)
Acknowledges the Setup Received status on a specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInSetupCompleteAck (uint8_t endpointAddress)
Acknowledges the Setup Received status on a specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutSetupIsReceived (uint8_t endpointAddress)
Checks if the USB OUT endpoint has the Setup Received status.
static ALWAYS_INLINE bool USB_EndpointInSetupIsReceived (uint8_t endpointAddress)
Checks if the USB IN endpoint has the Setup Received status.
static ALWAYS_INLINE void USB_EndpointOutDataToggleSet (uint8_t endpointAddress)
Sets OUT endpoint data toggle.
static ALWAYS_INLINE void USB_EndpointInDataToggleSet (uint8_t endpointAddress)
Sets IN endpoint data toggle.
static ALWAYS_INLINE void USB_EndpointOutDataToggleClear (uint8_t endpointAddress)
Clears OUT endpoint data toggle.
static ALWAYS_INLINE void USB_EndpointInDataToggleClear (uint8_t endpointAddress)
Clears IN endpoint data toggle.
static ALWAYS_INLINE bool USB_EndpointOutDataToggleIsSet (uint8_t endpointAddress)
Checks if data toggle is set on the specified OUT endpoint.
static ALWAYS_INLINE bool USB_EndpointInDataToggleIsSet (uint8_t endpointAddress)
Checks if data toggle is set on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointOutBufferSet (uint8_t endpointAddress, uint8_t *bufAddress)
Sets endpoint buffer OUT.
static ALWAYS_INLINE void USB_EndpointInBufferSet (uint8_t endpointAddress, uint8_t *bufAddress)
Sets endpoint buffer IN.
static ALWAYS_INLINE void USB_NumberBytesToSendSet (uint8_t endpointAddress, uint16_t numberBytes)
Sets how many bytes of data are intended to be sent from the specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesToSendGet (uint8_t endpointAddress)
Reads out the CNT register to know how many bytes of data are intended to be sent from the specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesToSendReset (uint8_t endpointAddress)
Clears the CNT register to tell the peripheral no data is intended to be sent from the specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesSentGet (uint8_t endpointAddress)
Reads out how many bytes have been sent from the specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesSentReset (uint8_t endpointAddress)
Clears the MCNT register that keeps track of how many bytes of data have been sent.
static ALWAYS_INLINE void USB_NumberBytesToReceiveSet (uint8_t endpointAddress, uint16_t numberBytes)
Sets how many bytes of data are expected to be received on a specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesToReceiveGet (uint8_t endpointAddress)
Gets how many bytes of data are expected to be received on a specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesToReceiveReset (uint8_t endpointAddress)
Clears the MCNT register to tell the peripheral no data is intended to be received on the specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesReceivedGet (uint8_t endpointAddress)
Gets how many bytes of data have been received on a specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesReceivedReset (uint8_t endpointAddress)
Resets the counter that counts amount of bytes of data received on a specific endpoint.
static ALWAYS_INLINE bool USB_EndpointOutOverUnderflowIsSet (uint8_t endpointAddress)
Checks if OUT endpoint has overflowed.
static ALWAYS_INLINE bool USB_EndpointInOverUnderflowIsSet (uint8_t endpointAddress)
Checks if IN endpoint has underflowed.
static ALWAYS_INLINE void USB_EndpointOutOverUnderflowAck (uint8_t endpointAddress)
Acknowledges overflow on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInOverUnderflowAck (uint8_t endpointAddress)
Acknowledges underflow on the specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutCRCHasFailed (uint8_t endpointAddress)
Checks if the specified OUT endpoint has a Cyclic Redundancy Check (CRC) failure.
static ALWAYS_INLINE bool USB_EndpointInCRCHasFailed (uint8_t endpointAddress)
Checks if the specified IN endpoint has a CRC failure.
static ALWAYS_INLINE void USB_EndpointOutCRCAck (uint8_t endpointAddress)
Acknowledges a CRC failure on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInCRCAck (uint8_t endpointAddress)
Acknowledges a CRC failure on the specified IN endpoint.
static ALWAYS_INLINE void USB_GlobalNAKEnable (void)
Enables global NAK.
static ALWAYS_INLINE void USB_GlobalNAKDisable (void)
Disables global NAK.
static ALWAYS_INLINE bool USB_GlobalNAKIsEnable (void)
Checks the global NAK setting.
static ALWAYS_INLINE void USB_ConnectionAttach (void)
Tells the USB peripheral to attach.
static ALWAYS_INLINE void USB_ConnectionDetach (void)
Tells the USB peripheral to detach.
static ALWAYS_INLINE bool USB_ConnectionIsAttach (void)
Checks if the USB connection is attached.
static ALWAYS_INLINE void USB_Enable (void)
Enables the USB peripheral.
static ALWAYS_INLINE void USB_Disable (void)
Disables the USB peripheral.
static ALWAYS_INLINE bool USB_IsEnable (void)
Checks if the USB peripheral is enabled.
static ALWAYS_INLINE void USB_FifoEnable (void)
Enables USB FIFO.
static ALWAYS_INLINE void USB_FifoDisable (void)
Disables USB FIFO.
static ALWAYS_INLINE bool USB_FifoIsEnable (void)
Checks if USB FIFO has been enabled.
static ALWAYS_INLINE void USB_AutomaticGlobalNAKEnable (void)
Enables automatic global NAK for the USB peripheral.
static ALWAYS_INLINE void USB_AutomaticGlobalNAKDisable (void)
Disables automatic global NAK for the USB peripheral.
static ALWAYS_INLINE bool USB_AutomaticGlobalNAKIsEnable (void)
Checks if automatic global NAK has been enabled.
static ALWAYS_INLINE void USB_FrameNumEnable (void)
Enables storing the last SOF token frame number in FRAMENUM. This is a device-specific function.
static ALWAYS_INLINE void USB_FrameNumDisable (void)
Disables storing the last SOF token frame number in FRAMENUM. This is a device-specific function.
static ALWAYS_INLINE bool USB_FrameNumIsEnable (void)
Checks if storing of the last SOF token frame number is enabled. This is a device-specific function.
static ALWAYS_INLINE void USB_MaxEndpointsSet (uint8_t maxEndpoint)
Sets maximum number of endpoint addresses used by the USB peripheral.
static ALWAYS_INLINE void USB_MaxEndpointsReset (void)
Clears the USB endpoint maximum, setting the maximum endpoint to EP0.
static ALWAYS_INLINE uint8_t USB_MaxEndpointsGet (void)
Checks what the maximum number of endpoint addresses is.
static ALWAYS_INLINE void USB_EndpointTableAddressSet (USB_EP_PAIR_t *endpointTableAddress)
Sets the address of the endpoint table. This is a device-specific function.
static ALWAYS_INLINE void USB_EndpointTableAddressReset (void)
Sets the address of the endpoint table to 0. This is a device-specific function.
static ALWAYS_INLINE uint16_t USB_EndpointTableAddressGet (void)
Gets the address of the endpoint table. This is a device-specific function.
static ALWAYS_INLINE void USB_FifoReadPointerReset (void)
Resets the read FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE int8_t USB_FifoReadPointerGet (void)
Gets the read FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE void USB_FifoWritePointerReset (void)
Resets the write FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE int8_t USB_FifoWritePointerGet (void)
Gets the write FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE void USB_DeviceAddressSet (uint8_t usbAddress)
Sets the device address.
static ALWAYS_INLINE void USB_DeviceAddressReset (void)
Resets the device address.
static ALWAYS_INLINE uint8_t USB_DeviceAddressGet (void)
Gets the device address.
static ALWAYS_INLINE void USB_UpstreamResumeEnable (void)
Enables an upstream resume to be initated.
static ALWAYS_INLINE bool USB_UpstreamResumeIsEnable (void)
Checks if upstream resume is enabled, but not yet initiated.
static ALWAYS_INLINE uint8_t USB_BusStateGet (void)
Gets the USB bus state.
static ALWAYS_INLINE bool USB_BusStateIs (uint8_t bus_state_bm)
Checks if the USB bus has any specific status flags set.
static ALWAYS_INLINE void USB_SOFInterruptEnable (void)
Enables the USB Start-Of-Frame interrupt.
static ALWAYS_INLINE void USB_SOFInterruptDisable (void)
Disables the USB Start-Of-Frame interrupt.
static ALWAYS_INLINE void USB_SOFInterruptClear (void)
Clears the USB Start-Of-Frame Interrupt flag.
static ALWAYS_INLINE bool USB_SOFInterruptIs (void)
Checks if the USB Start-Of-Frame interrupt has been triggered.
static ALWAYS_INLINE void USB_SuspendInterruptEnable (void)
Enables the USB Suspend interrupt.
static ALWAYS_INLINE void USB_SuspendInterruptDisable (void)
Disables the USB Suspend interrupt.
static ALWAYS_INLINE void USB_SuspendInterruptClear (void)
Clears the USB Suspend Interrupt flag.
static ALWAYS_INLINE bool USB_SuspendInterruptIs (void)
Checks if the USB Suspend interrupt has been triggered.
static ALWAYS_INLINE void USB_ResumeInterruptEnable (void)
Enables the USB Resume interrupt.
static ALWAYS_INLINE void USB_ResumeInterruptDisable (void)
Disables the USB Resume interrupt.
static ALWAYS_INLINE void USB_ResumeInterruptClear (void)
Clears the USB Resume Interrupt flag.
static ALWAYS_INLINE bool USB_ResumeInterruptIs (void)
Checks if the USB Resume interrupt has been triggered.
static ALWAYS_INLINE void USB_ResetInterruptEnable (void)
Enables the USB Reset interrupt.
static ALWAYS_INLINE void USB_ResetInterruptDisable (void)
Disables the USB Reset interrupt.
static ALWAYS_INLINE void USB_ResetInterruptClear (void)
Clears the USB Reset Interrupt flag.
static ALWAYS_INLINE bool USB_ResetInterruptIs (void)
Checks if the USB Reset interrupt has been triggered.
static ALWAYS_INLINE void USB_StalledInterruptEnable (void)
Enables the USB Stalled interrupt.
static ALWAYS_INLINE void USB_StalledInterruptDisable (void)
Disables the USB Stalled interrupt.
static ALWAYS_INLINE void USB_StalledInterruptClear (void)
Clears the USB Stalled Interrupt flag.
static ALWAYS_INLINE bool USB_StalledInterruptIs (void)
Checks if the USB Stalled interrupt has been triggered.
static ALWAYS_INLINE void USB_UnderflowInterruptEnable (void)
Enables the USB Underflow interrupt.
static ALWAYS_INLINE void USB_UnderflowInterruptDisable (void)
Disables the USB Underflow interrupt.
static ALWAYS_INLINE void USB_UnderflowInterruptClear (void)
Clears the USB Underflow Interrupt flag.
static ALWAYS_INLINE bool USB_UnderflowInterruptIs (void)
Checks if an Underflow interrupt has been triggered.
static ALWAYS_INLINE void USB_OverflowInterruptEnable (void)
Enables the USB Overflow interrupt.
static ALWAYS_INLINE void USB_OverflowInterruptDisable (void)
Disables the USB Overflow interrupt.
static ALWAYS_INLINE void USB_OverflowInterruptClear (void)
Clears the USB Overflow Interrupt flag.
static ALWAYS_INLINE bool USB_OverflowInterruptIs (void)
Checks if an Overflow interrupt has been triggered.
static ALWAYS_INLINE void USB_TransactionCompleteInterruptEnable (void)
Enables the USB Transaction Complete interrupt.
static ALWAYS_INLINE void USB_TransactionCompleteInterruptDisable (void)
Disables the USB Transaction Complete interrupt.
static ALWAYS_INLINE void USB_TransactionCompleteInterruptAck (void)
Clears the USB Transaction Complete Interrupt flag.
static ALWAYS_INLINE bool USB_TransactionCompleteInterruptIs (void)
Checks if a Transaction Complete interrupt has been triggered.
static ALWAYS_INLINE bool USB_ReadModifyWriteInterruptIs (void)
Checks if the USB Read-Modify-Write Interrupt is enabled.
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptEnable (void)
Enables the USB Global NAK Done interrupt.
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptDisable (void)
Disables the USB Global NAK Done interrupt.
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptAck (void)
Clears the USB Global NAK Done Interrupt flag.
static ALWAYS_INLINE bool USB_GlobalNAKDoneInterruptIs (void)
Checks if the USB Global NAK Done interrupt has been triggered.
static ALWAYS_INLINE void USB_SetupInterruptEnable (void)
Enables the USB Setup interrupt.
static ALWAYS_INLINE void USB_SetupInterruptDisable (void)
Disables the USB Setup interrupt.
static ALWAYS_INLINE void USB_SetupInterruptClear (void)
Clears the USB Setup Interrupt flag.
static ALWAYS_INLINE bool USB_SetupInterruptIs (void)
Checks if a USB Setup interrupt has been triggered.
static ALWAYS_INLINE void USB_InterruptFlagsClear (void)
Clears all the USB Interrupt flags.
4.16.5.3.2 Definition Documentation
ALWAYS_INLINE
#define ALWAYS_INLINE __attribute__((always_inline)) inline
Alias that makes always inline function definitions more readable.
4.16.5.3.3 Function Documentation
USB_AutomaticGlobalNAKDisable()
static ALWAYS_INLINE void USB_AutomaticGlobalNAKDisable (void )[static]
Disables automatic global NAK for the USB peripheral.
None. |
None. |
USB_AutomaticGlobalNAKEnable()
static ALWAYS_INLINE void USB_AutomaticGlobalNAKEnable (void )[static]
Enables automatic global NAK for the USB peripheral.
None. |
None. |
USB_AutomaticGlobalNAKIsEnable()
static ALWAYS_INLINE bool USB_AutomaticGlobalNAKIsEnable (void )[static]
Checks if automatic global NAK has been enabled.
None. |
0 |
- Automatic global NAK is not enabled |
1 |
- Automatic global NAK is enabled |
USB_BusStateGet()
static ALWAYS_INLINE uint8_t USB_BusStateGet (void )[static]
Gets the USB bus state.
None. |
The state of the USB bus |
USB_BusStateIs()
static ALWAYS_INLINE bool USB_BusStateIs (uint8_t bus_state_bm)[static]
Checks if the USB bus has any specific status flags set.
bus_state_bm |
- The bitmap of the specific status flags to check |
0 |
- No status flags set |
1 |
- The bus has one or more specified status flags set |
USB_ConnectionAttach()
static ALWAYS_INLINE void USB_ConnectionAttach (void )[static]
Tells the USB peripheral to attach.
None. |
None. |
USB_ConnectionDetach()
static ALWAYS_INLINE void USB_ConnectionDetach (void )[static]
Tells the USB peripheral to detach.
None. |
None. |
USB_ConnectionIsAttach()
static ALWAYS_INLINE bool USB_ConnectionIsAttach (void )[static]
Checks if the USB connection is attached.
None. |
0 |
- USB connection is not attached |
1 |
- USB connection is attached |
USB_DeviceAddressGet()
static ALWAYS_INLINE uint8_t USB_DeviceAddressGet (void )[static]
Gets the device address.
None. |
The device address |
USB_DeviceAddressReset()
static ALWAYS_INLINE void USB_DeviceAddressReset (void )[static]
Resets the device address.
None. |
None. |
USB_DeviceAddressSet()
static ALWAYS_INLINE void USB_DeviceAddressSet (uint8_t usbAddress)[static]
Sets the device address.
usbAddress |
- The device address to set |
None. |
USB_Disable()
static ALWAYS_INLINE void USB_Disable (void )[static]
Disables the USB peripheral.
None. |
None. |
USB_Enable()
static ALWAYS_INLINE void USB_Enable (void )[static]
Enables the USB peripheral.
None. |
None. |
USB_EndpointInAlzpEnable()
static ALWAYS_INLINE void USB_EndpointInAlzpEnable (uint8_t endpointAddress)[static]
Enables AZLP on the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInAzlpDisable()
static ALWAYS_INLINE void USB_EndpointInAzlpDisable (uint8_t endpointAddress)[static]
Disables AZLP on the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInBufferSet()
static ALWAYS_INLINE void USB_EndpointInBufferSet (uint8_t endpointAddress, uint8_t * bufAddress)[static]
Sets endpoint buffer IN.
endpointAddress |
- Address of the endpoint |
bufAddress |
- Address pointer to buffer |
None. |
MISRA C:2012 Deviation Advisory: misra-c2012- 11.4
Justification: A conversion should not be performed between a pointer to object and an integer type. The EP.IN.DATAPTR register is a 16-bit register, expecting an AVR DU specific 16-bit RAM address.USB_EndpointInControlSet()
static ALWAYS_INLINE void USB_EndpointInControlSet (uint8_t endpointAddress, uint8_t value)[static]
Sets endpoint control IN.
endpointAddress |
- Address of the endpoint |
value |
- Register bitmask |
None. |
USB_EndpointInCRCAck()
static ALWAYS_INLINE void USB_EndpointInCRCAck (uint8_t endpointAddress)[static]
Acknowledges a CRC failure on the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInCRCHasFailed()
static ALWAYS_INLINE bool USB_EndpointInCRCHasFailed (uint8_t endpointAddress)[static]
Checks if the specified IN endpoint has a CRC failure.
endpointAddress |
- Address of the endpoint |
0 |
- No CRC failure on endpoint |
1 |
- CRC failure on endpoint |
USB_EndpointInDataToggleClear()
static ALWAYS_INLINE void USB_EndpointInDataToggleClear (uint8_t endpointAddress)[static]
Clears IN endpoint data toggle.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInDataToggleIsSet()
static ALWAYS_INLINE bool USB_EndpointInDataToggleIsSet (uint8_t endpointAddress)[static]
Checks if data toggle is set on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
0 |
- Data toggle is not set |
1 |
- Data toggle is set |
USB_EndpointInDataToggleSet()
static ALWAYS_INLINE void USB_EndpointInDataToggleSet (uint8_t endpointAddress)[static]
Sets IN endpoint data toggle.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInDefaultSizeGet()
static ALWAYS_INLINE uint8_t USB_EndpointInDefaultSizeGet (uint8_t endpointAddress)[static]
Gets the size of a default type IN endpoint.
endpointAddress |
- Address of the endpoint |
IN endpoint size |
USB_EndpointInDefaultSizeSet()
static ALWAYS_INLINE void USB_EndpointInDefaultSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)[static]
Sets the endpoint size for a default type IN endpoint.
endpointAddress |
- Address of the endpoint |
endpointSizeConfig |
- Size of endpoint to set |
None. |
USB_EndPointInDisable()
static ALWAYS_INLINE void USB_EndPointInDisable (uint8_t endpointAddress)[static]
Disables the IN endpoint with the given address.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndPointInIsEnabled()
static ALWAYS_INLINE bool USB_EndPointInIsEnabled (uint8_t endpointAddress)[static]
Checks if the IN endpoint at the given address is enabled.
None. |
0 |
Endpoint not enabled |
1 |
Endpoint enabled |
USB_EndpointInIsoSizeGet()
static ALWAYS_INLINE uint8_t USB_EndpointInIsoSizeGet (uint8_t endpointAddress)[static]
Gets the size of an isochronous IN endpoint.
endpointAddress |
- Address of the endpoint |
IN endpoint size |
USB_EndpointInIsoSizeSet()
static ALWAYS_INLINE void USB_EndpointInIsoSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)[static]
Sets the endpoint size for an isochronous IN endpoint.
endpointAddress |
- Address of the endpoint |
endpointSizeConfig |
- Size of endpoint to set |
None. |
USB_EndpointInIsStalled()
static ALWAYS_INLINE bool USB_EndpointInIsStalled (uint8_t endpointAddress)[static]
Checks if the specified IN endpoint is stalled.
endpointAddress |
- Address of the endpoint |
0 |
- Endpoint is not stalled |
1 |
- Endpoint is stalled |
USB_EndpointInMultipktDisable()
static ALWAYS_INLINE void USB_EndpointInMultipktDisable (uint8_t endpointAddress)[static]
Disables multipacket for the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInMultipktEnable()
static ALWAYS_INLINE void USB_EndpointInMultipktEnable (uint8_t endpointAddress)[static]
Enables multipacket for the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInMultipktIsEnabled()
static ALWAYS_INLINE bool USB_EndpointInMultipktIsEnabled (uint8_t endpointAddress)[static]
Checks if multipacket is enabled on the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
0 |
- Multipacket disabled |
1 |
- Multipacket enabled |
USB_EndpointInNAKClear()
static ALWAYS_INLINE void USB_EndpointInNAKClear (uint8_t endpointAddress)[static]
Clears the USB NAK status from the IN endpoint STATUS register.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInNAKIsSet()
static ALWAYS_INLINE bool USB_EndpointInNAKIsSet (uint8_t endpointAddress)[static]
Checks the OUT endpoint STATUS register for the NAK status.
endpointAddress |
- Address of the endpoint |
0 |
- Endpoint is not NAKed |
1 |
- Endpoint is NAKed |
USB_EndpointInNAKSet()
static ALWAYS_INLINE void USB_EndpointInNAKSet (uint8_t endpointAddress)[static]
Sets IN endpoint status to NAK.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInOverUnderflowAck()
static ALWAYS_INLINE void USB_EndpointInOverUnderflowAck (uint8_t endpointAddress)[static]
Acknowledges underflow on the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInOverUnderflowIsSet()
static ALWAYS_INLINE bool USB_EndpointInOverUnderflowIsSet (uint8_t endpointAddress)[static]
Checks if IN endpoint has underflowed.
endpointAddress |
- Address of the endpoint |
0 |
- No underflow on endpoint |
1 |
- Undeflow on endpoint |
USB_EndpointInSetupCompleteAck()
static ALWAYS_INLINE void USB_EndpointInSetupCompleteAck (uint8_t endpointAddress)[static]
Acknowledges the Setup Received status on a specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInSetupIsReceived()
static ALWAYS_INLINE bool USB_EndpointInSetupIsReceived (uint8_t endpointAddress)[static]
Checks if the USB IN endpoint has the Setup Received status.
endpointAddress |
- Address of the endpoint |
0 |
- No setup received |
1 |
- Setup received |
USB_EndpointInStall()
static ALWAYS_INLINE void USB_EndpointInStall (uint8_t endpointAddress)[static]
Stalls the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInStallAck()
static ALWAYS_INLINE void USB_EndpointInStallAck (uint8_t endpointAddress)[static]
Acknowledges that an IN endpoint is stalled and Clears the USB STATUS register.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInStallClear()
static ALWAYS_INLINE void USB_EndpointInStallClear (uint8_t endpointAddress)[static]
Stops stalling the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInStatusClear()
static ALWAYS_INLINE void USB_EndpointInStatusClear (uint8_t endpointAddress)[static]
Clears IN endpoint status.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInTransactionCompleteAck()
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteAck (uint8_t endpointAddress)[static]
Acknowledges the transaction complete status on a specified IN endpoint and Clears the USB STATUS register.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInTransactionCompleteDisable()
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteDisable (uint8_t endpointAddress)[static]
Disables transaction complete interrupt for the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInTransactionCompleteInterruptEnable()
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteInterruptEnable (uint8_t endpointAddress)[static]
Enables transaction complete interrupt for the specified IN endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointInTransactionIsComplete()
static ALWAYS_INLINE bool USB_EndpointInTransactionIsComplete (uint8_t endpointAddress)[static]
Checks if the USB IN endpoint has the Transaction Complete status.
endpointAddress |
- Address of the endpoint |
0 |
- Transaction incomplete |
1 |
- Transaction complete |
USB_EndPointInTypeConfigGet()
static ALWAYS_INLINE uint8_t USB_EndPointInTypeConfigGet (uint8_t endpointAddress)[static]
Gets the IN endpoint configuration at the given address.
endpointAddress |
- Address of the endpoint |
Endpoint configuration type |
USB_EndpointOutAzlpDisable()
static ALWAYS_INLINE void USB_EndpointOutAzlpDisable (uint8_t endpointAddress)[static]
Disables AZLP on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutAzlpEnable()
static ALWAYS_INLINE void USB_EndpointOutAzlpEnable (uint8_t endpointAddress)[static]
Enables Auto Zero Length Packet (AZLP) on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutBufferSet()
static ALWAYS_INLINE void USB_EndpointOutBufferSet (uint8_t endpointAddress, uint8_t * bufAddress)[static]
Sets endpoint buffer OUT.
endpointAddress |
- Address of the endpoint |
bufAddress |
- Address pointer to buffer |
None. |
MISRA C:2012 Deviation Advisory: misra-c2012- 11.4
Justification: A conversion should not be performed between a pointer to object and an integer type. The EP.OUT.DATAPTR register is a 16-bit register, expecting an AVR DU specific 16-bit RAM address.USB_EndpointOutControlSet()
static ALWAYS_INLINE void USB_EndpointOutControlSet (uint8_t endpointAddress, uint8_t value)[static]
Sets endpoint control OUT.
endpointAddress |
- Address of the endpoint |
value |
- Register bitmask |
None. |
USB_EndpointOutCRCAck()
static ALWAYS_INLINE void USB_EndpointOutCRCAck (uint8_t endpointAddress)[static]
Acknowledges a CRC failure on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutCRCHasFailed()
static ALWAYS_INLINE bool USB_EndpointOutCRCHasFailed (uint8_t endpointAddress)[static]
Checks if the specified OUT endpoint has a Cyclic Redundancy Check (CRC) failure.
endpointAddress |
- Address of the endpoint |
0 |
- No CRC failure on endpoint |
1 |
- CRC failure on endpoint |
USB_EndpointOutDataToggleClear()
static ALWAYS_INLINE void USB_EndpointOutDataToggleClear (uint8_t endpointAddress)[static]
Clears OUT endpoint data toggle.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutDataToggleIsSet()
static ALWAYS_INLINE bool USB_EndpointOutDataToggleIsSet (uint8_t endpointAddress)[static]
Checks if data toggle is set on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
0 |
- Data toggle is not set |
1 |
- Data toggle is set |
USB_EndpointOutDataToggleSet()
static ALWAYS_INLINE void USB_EndpointOutDataToggleSet (uint8_t endpointAddress)[static]
Sets OUT endpoint data toggle.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutDefaultSizeGet()
static ALWAYS_INLINE uint8_t USB_EndpointOutDefaultSizeGet (uint8_t endpointAddress)[static]
Gets the size of a default type OUT endpoint.
endpointAddress |
- Address of the endpoint |
OUT endpoint size |
USB_EndpointOutDefaultSizeSet()
static ALWAYS_INLINE void USB_EndpointOutDefaultSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)[static]
Sets the endpoint size for a default type OUT endpoint.
endpointAddress |
- Address of the endpoint |
endpointSizeConfig |
- Size of endpoint to set |
None. |
USB_EndPointOutDisable()
static ALWAYS_INLINE void USB_EndPointOutDisable (uint8_t endpointAddress)[static]
Disables the OUT endpoint with the given address.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndPointOutIsEnabled()
static ALWAYS_INLINE bool USB_EndPointOutIsEnabled (uint8_t endpointAddress)[static]
Checks if the OUT endpoint at the given address is enabled.
endpointAddress |
- Address of the endpoint |
0 |
Endpoint not enabled |
1 |
Endpoint enabled |
USB_EndpointOutIsoSizeGet()
static ALWAYS_INLINE uint8_t USB_EndpointOutIsoSizeGet (uint8_t endpointAddress)[static]
Gets the size of an isochronous OUT endpoint.
endpointAddress |
- Address of the endpoint |
OUT endpoint size |
USB_EndpointOutIsoSizeSet()
static ALWAYS_INLINE void USB_EndpointOutIsoSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)[static]
Sets the endpoint size for an isochronous OUT endpoint.
endpointAddress |
- Address of the endpoint |
endpointSizeConfig |
- Size of endpoint to set |
None. |
USB_EndpointOutIsStalled()
static ALWAYS_INLINE bool USB_EndpointOutIsStalled (uint8_t endpointAddress)[static]
Checks if the specified OUT endpoint is stalled.
endpointAddress |
- Address of the endpoint |
0 |
- Endpoint is not stalled |
1 |
- Endpoint is stalled |
USB_EndpointOutMultipktDisable()
static ALWAYS_INLINE void USB_EndpointOutMultipktDisable (uint8_t endpointAddress)[static]
Disables multipacket for the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutMultipktEnable()
static ALWAYS_INLINE void USB_EndpointOutMultipktEnable (uint8_t endpointAddress)[static]
Enables multipacket for the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutMultipktIsEnabled()
static ALWAYS_INLINE bool USB_EndpointOutMultipktIsEnabled (uint8_t endpointAddress)[static]
Checks if multipacket is enabled on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
0 |
- Multipacket disabled |
1 |
- Multipacket enabled |
USB_EndpointOutNAKClear()
static ALWAYS_INLINE void USB_EndpointOutNAKClear (uint8_t endpointAddress)[static]
Clears the USB NAK status from the OUT endpoint STATUS register.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutNAKIsSet()
static ALWAYS_INLINE bool USB_EndpointOutNAKIsSet (uint8_t endpointAddress)[static]
Checks the OUT endpoint STATUS register for the NAK status.
endpointAddress |
- Address of the endpoint |
0 |
- Endpoint is not NAKed |
1 |
- Endpoint is NAKed |
USB_EndpointOutNAKSet()
static ALWAYS_INLINE void USB_EndpointOutNAKSet (uint8_t endpointAddress)[static]
Sets OUT endpoint status to NAK.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutOverUnderflowAck()
static ALWAYS_INLINE void USB_EndpointOutOverUnderflowAck (uint8_t endpointAddress)[static]
Acknowledges overflow on the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutOverUnderflowIsSet()
static ALWAYS_INLINE bool USB_EndpointOutOverUnderflowIsSet (uint8_t endpointAddress)[static]
Checks if OUT endpoint has overflowed.
endpointAddress |
- Address of the endpoint |
0 |
- No overflow on endpoint |
1 |
- Overflow on endpoint |
USB_EndpointOutSetupIsReceived()
static ALWAYS_INLINE bool USB_EndpointOutSetupIsReceived (uint8_t endpointAddress)[static]
Checks if the USB OUT endpoint has the Setup Received status.
endpointAddress |
- Address of the endpoint |
0 |
- No setup received |
1 |
- Setup received |
USB_EndpointOutSetupReceivedAck()
static ALWAYS_INLINE void USB_EndpointOutSetupReceivedAck (uint8_t endpointAddress)[static]
Acknowledges the Setup Received status on a specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutStall()
static ALWAYS_INLINE void USB_EndpointOutStall (uint8_t endpointAddress)[static]
Stalls the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutStallAck()
static ALWAYS_INLINE void USB_EndpointOutStallAck (uint8_t endpointAddress)[static]
Acknowledges that an OUT endpoint is stalled and Clears the USB STATUS register.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutStallClear()
static ALWAYS_INLINE void USB_EndpointOutStallClear (uint8_t endpointAddress)[static]
Stops stalling the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutStatusClear()
static ALWAYS_INLINE void USB_EndpointOutStatusClear (uint8_t endpointAddress)[static]
Clears OUT endpoint status.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutTransactionCompleteAck()
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteAck (uint8_t endpointAddress)[static]
Acknowledges the transaction complete status on a specified OUT endpoint and Clears the USB STATUS register.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutTransactionCompleteInterruptDisable()
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteInterruptDisable (uint8_t endpointAddress)[static]
Disables transaction complete interrupt for the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutTransactionCompleteInterruptEnable()
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteInterruptEnable (uint8_t endpointAddress)[static]
Enables transaction complete interrupt for the specified OUT endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_EndpointOutTransactionIsComplete()
static ALWAYS_INLINE bool USB_EndpointOutTransactionIsComplete (uint8_t endpointAddress)[static]
Checks if the USB OUT endpoint has the Transaction Complete status.
endpointAddress |
- Address of the endpoint |
0 |
- Transaction incomplete |
1 |
- Transaction complete |
USB_EndPointOutTypeConfigGet()
static ALWAYS_INLINE uint8_t USB_EndPointOutTypeConfigGet (uint8_t endpointAddress)[static]
Gets the OUT endpoint configuration at the given address.
endpointAddress |
- Address of the endpoint |
Endpoint configuration type |
USB_EndpointTableAddressGet()
static ALWAYS_INLINE uint16_t USB_EndpointTableAddressGet (void )[static]
Gets the address of the endpoint table. This is a device-specific function.
None. |
The address of the endpoint table |
USB_EndpointTableAddressReset()
static ALWAYS_INLINE void USB_EndpointTableAddressReset (void )[static]
Sets the address of the endpoint table to 0. This is a device-specific function.
None. |
None. |
USB_EndpointTableAddressSet()
static ALWAYS_INLINE void USB_EndpointTableAddressSet (USB_EP_PAIR_t * endpointTableAddress)[static]
Sets the address of the endpoint table. This is a device-specific function.
endpointTableAddress |
- Address of the endpoint table |
None. |
USB_FifoDisable()
static ALWAYS_INLINE void USB_FifoDisable (void )[static]
Disables USB FIFO.
This is a device-specific function.
None. |
None. |
USB_FifoEnable()
static ALWAYS_INLINE void USB_FifoEnable (void )[static]
Enables USB FIFO.
This is a device-specific function.
None. |
None. |
USB_FifoIsEnable()
static ALWAYS_INLINE bool USB_FifoIsEnable (void )[static]
Checks if USB FIFO has been enabled.
This is a device-specific function.
None. |
0 |
- USB FIFO is not enabled |
1 |
- USB FIFO is enabled |
USB_FifoReadPointerGet()
static ALWAYS_INLINE int8_t USB_FifoReadPointerGet (void )[static]
Gets the read FIFO pointer. This is a device-specific function.
None. |
The FIFO read pointer |
USB_FifoReadPointerReset()
static ALWAYS_INLINE void USB_FifoReadPointerReset (void )[static]
Resets the read FIFO pointer. This is a device-specific function.
None. |
None. |
USB_FifoWritePointerGet()
static ALWAYS_INLINE int8_t USB_FifoWritePointerGet (void )[static]
Gets the write FIFO pointer. This is a device-specific function.
None. |
The FIFO write pointer |
USB_FifoWritePointerReset()
static ALWAYS_INLINE void USB_FifoWritePointerReset (void )[static]
Resets the write FIFO pointer. This is a device-specific function.
None. |
None. |
USB_FrameNumDisable()
static ALWAYS_INLINE void USB_FrameNumDisable (void )[static]
Disables storing the last SOF token frame number in FRAMENUM. This is a device-specific function.
None. |
None. |
USB_FrameNumEnable()
static ALWAYS_INLINE void USB_FrameNumEnable (void )[static]
Enables storing the last SOF token frame number in FRAMENUM. This is a device-specific function.
None. |
None. |
USB_FrameNumIsEnable()
static ALWAYS_INLINE bool USB_FrameNumIsEnable (void )[static]
Checks if storing of the last SOF token frame number is enabled. This is a device-specific function.
None. |
0 |
- Storing the last SOF token frame number in FRAMENUM is disabled |
1 |
- Storing the last SOF token frame number in FRAMENUM is enabled |
USB_GlobalNAKDisable()
static ALWAYS_INLINE void USB_GlobalNAKDisable (void )[static]
Disables global NAK.
None. |
None. |
USB_GlobalNAKDoneInterruptAck()
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptAck (void )[static]
Clears the USB Global NAK Done Interrupt flag.
None. |
None. |
USB_GlobalNAKDoneInterruptDisable()
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptDisable (void )[static]
Disables the USB Global NAK Done interrupt.
None. |
None. |
USB_GlobalNAKDoneInterruptEnable()
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptEnable (void )[static]
Enables the USB Global NAK Done interrupt.
None. |
None. |
USB_GlobalNAKDoneInterruptIs()
static ALWAYS_INLINE bool USB_GlobalNAKDoneInterruptIs (void )[static]
Checks if the USB Global NAK Done interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_GlobalNAKEnable()
static ALWAYS_INLINE void USB_GlobalNAKEnable (void )[static]
Enables global NAK.
None. |
None. |
USB_GlobalNAKIsEnable()
static ALWAYS_INLINE bool USB_GlobalNAKIsEnable (void )[static]
Checks the global NAK setting.
None. |
0 |
- Global NAK is disabled |
1 |
- Global NAK is enabled |
USB_InterruptFlagsClear()
static ALWAYS_INLINE void USB_InterruptFlagsClear (void )[static]
Clears all the USB Interrupt flags.
None. |
None. |
USB_IsEnable()
static ALWAYS_INLINE bool USB_IsEnable (void )[static]
Checks if the USB peripheral is enabled.
None. |
0 |
- USB peripheral not enabled |
1 |
- USB peripheral enabled |
USB_MaxEndpointsGet()
static ALWAYS_INLINE uint8_t USB_MaxEndpointsGet (void )[static]
Checks what the maximum number of endpoint addresses is.
None. |
Last accessible endpoint |
USB_MaxEndpointsReset()
static ALWAYS_INLINE void USB_MaxEndpointsReset (void )[static]
Clears the USB endpoint maximum, setting the maximum endpoint to EP0.
None. |
None. |
USB_MaxEndpointsSet()
static ALWAYS_INLINE void USB_MaxEndpointsSet (uint8_t maxEndpoint)[static]
Sets maximum number of endpoint addresses used by the USB peripheral.
maxEndpoint |
- Last accessible endpoint |
None. |
USB_NumberBytesReceivedGet()
static ALWAYS_INLINE uint16_t USB_NumberBytesReceivedGet (uint8_t endpointAddress)[static]
Gets how many bytes of data have been received on a specified endpoint.
endpointAddress |
- Address of the endpoint |
Amount of bytes expected |
USB_NumberBytesReceivedReset()
static ALWAYS_INLINE void USB_NumberBytesReceivedReset (uint8_t endpointAddress)[static]
Resets the counter that counts amount of bytes of data received on a specific endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_NumberBytesSentGet()
static ALWAYS_INLINE uint16_t USB_NumberBytesSentGet (uint8_t endpointAddress)[static]
Reads out how many bytes have been sent from the specified endpoint.
endpointAddress |
- Address of the endpoint |
Amount of bytes that have been sent |
USB_NumberBytesSentReset()
static ALWAYS_INLINE void USB_NumberBytesSentReset (uint8_t endpointAddress)[static]
Clears the MCNT register that keeps track of how many bytes of data have been sent.
endpointAddress |
- Address of the endpoint |
None. |
USB_NumberBytesToReceiveGet()
static ALWAYS_INLINE uint16_t USB_NumberBytesToReceiveGet (uint8_t endpointAddress)[static]
Gets how many bytes of data are expected to be received on a specified endpoint.
endpointAddress |
- Address of the endpoint |
Amount of bytes expected |
USB_NumberBytesToReceiveReset()
static ALWAYS_INLINE void USB_NumberBytesToReceiveReset (uint8_t endpointAddress)[static]
Clears the MCNT register to tell the peripheral no data is intended to be received on the specified endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_NumberBytesToReceiveSet()
static ALWAYS_INLINE void USB_NumberBytesToReceiveSet (uint8_t endpointAddress, uint16_t numberBytes)[static]
Sets how many bytes of data are expected to be received on a specified endpoint.
endpointAddress |
- Address of the endpoint |
numberBytes |
- The amount of bytes to receive |
None. |
USB_NumberBytesToSendGet()
static ALWAYS_INLINE uint16_t USB_NumberBytesToSendGet (uint8_t endpointAddress)[static]
Reads out the CNT register to know how many bytes of data are intended to be sent from the specified endpoint.
endpointAddress |
- Address of the endpoint |
Amount of bytes to send |
USB_NumberBytesToSendReset()
static ALWAYS_INLINE void USB_NumberBytesToSendReset (uint8_t endpointAddress)[static]
Clears the CNT register to tell the peripheral no data is intended to be sent from the specified endpoint.
endpointAddress |
- Address of the endpoint |
None. |
USB_NumberBytesToSendSet()
static ALWAYS_INLINE void USB_NumberBytesToSendSet (uint8_t endpointAddress, uint16_t numberBytes)[static]
Sets how many bytes of data are intended to be sent from the specified endpoint.
endpointAddress |
- Address of the endpoint |
numberBytes |
- Amount of bytes to send |
None. |
USB_OverflowInterruptClear()
static ALWAYS_INLINE void USB_OverflowInterruptClear (void )[static]
Clears the USB Overflow Interrupt flag.
None. |
None. |
USB_OverflowInterruptDisable()
static ALWAYS_INLINE void USB_OverflowInterruptDisable (void )[static]
Disables the USB Overflow interrupt.
None. |
None. |
USB_OverflowInterruptEnable()
static ALWAYS_INLINE void USB_OverflowInterruptEnable (void )[static]
Enables the USB Overflow interrupt.
None. |
None. |
USB_OverflowInterruptIs()
static ALWAYS_INLINE bool USB_OverflowInterruptIs (void )[static]
Checks if an Overflow interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_ReadModifyWriteInterruptIs()
static ALWAYS_INLINE bool USB_ReadModifyWriteInterruptIs (void )[static]
Checks if the USB Read-Modify-Write Interrupt is enabled.
None. |
0 |
- Interrupt not enabled |
1 |
- Interrupt enabled |
USB_ResetInterruptClear()
static ALWAYS_INLINE void USB_ResetInterruptClear (void )[static]
Clears the USB Reset Interrupt flag.
None. |
None. |
USB_ResetInterruptDisable()
static ALWAYS_INLINE void USB_ResetInterruptDisable (void )[static]
Disables the USB Reset interrupt.
None. |
None. |
USB_ResetInterruptEnable()
static ALWAYS_INLINE void USB_ResetInterruptEnable (void )[static]
Enables the USB Reset interrupt.
None. |
None. |
USB_ResetInterruptIs()
static ALWAYS_INLINE bool USB_ResetInterruptIs (void )[static]
Checks if the USB Reset interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_ResumeInterruptClear()
static ALWAYS_INLINE void USB_ResumeInterruptClear (void )[static]
Clears the USB Resume Interrupt flag.
None. |
None. |
USB_ResumeInterruptDisable()
static ALWAYS_INLINE void USB_ResumeInterruptDisable (void )[static]
Disables the USB Resume interrupt.
None. |
None. |
USB_ResumeInterruptEnable()
static ALWAYS_INLINE void USB_ResumeInterruptEnable (void )[static]
Enables the USB Resume interrupt.
None. |
None. |
USB_ResumeInterruptIs()
static ALWAYS_INLINE bool USB_ResumeInterruptIs (void )[static]
Checks if the USB Resume interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_SetupInterruptClear()
static ALWAYS_INLINE void USB_SetupInterruptClear (void )[static]
Clears the USB Setup Interrupt flag.
None. |
None. |
USB_SetupInterruptDisable()
static ALWAYS_INLINE void USB_SetupInterruptDisable (void )[static]
Disables the USB Setup interrupt.
None. |
None. |
USB_SetupInterruptEnable()
static ALWAYS_INLINE void USB_SetupInterruptEnable (void )[static]
Enables the USB Setup interrupt.
None. |
None. |
USB_SetupInterruptIs()
static ALWAYS_INLINE bool USB_SetupInterruptIs (void )[static]
Checks if a USB Setup interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_SOFInterruptClear()
static ALWAYS_INLINE void USB_SOFInterruptClear (void )[static]
Clears the USB Start-Of-Frame Interrupt flag.
None. |
None. |
USB_SOFInterruptDisable()
static ALWAYS_INLINE void USB_SOFInterruptDisable (void )[static]
Disables the USB Start-Of-Frame interrupt.
None. |
None. |
USB_SOFInterruptEnable()
static ALWAYS_INLINE void USB_SOFInterruptEnable (void )[static]
Enables the USB Start-Of-Frame interrupt.
None. |
None. |
USB_SOFInterruptIs()
static ALWAYS_INLINE bool USB_SOFInterruptIs (void )[static]
Checks if the USB Start-Of-Frame interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_StalledInterruptClear()
static ALWAYS_INLINE void USB_StalledInterruptClear (void )[static]
Clears the USB Stalled Interrupt flag.
None. |
None. |
USB_StalledInterruptDisable()
static ALWAYS_INLINE void USB_StalledInterruptDisable (void )[static]
Disables the USB Stalled interrupt.
None. |
None. |
USB_StalledInterruptEnable()
static ALWAYS_INLINE void USB_StalledInterruptEnable (void )[static]
Enables the USB Stalled interrupt.
None. |
None. |
USB_StalledInterruptIs()
static ALWAYS_INLINE bool USB_StalledInterruptIs (void )[static]
Checks if the USB Stalled interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_SuspendInterruptClear()
static ALWAYS_INLINE void USB_SuspendInterruptClear (void )[static]
Clears the USB Suspend Interrupt flag.
None. |
None. |
USB_SuspendInterruptDisable()
static ALWAYS_INLINE void USB_SuspendInterruptDisable (void )[static]
Disables the USB Suspend interrupt.
None. |
None. |
USB_SuspendInterruptEnable()
static ALWAYS_INLINE void USB_SuspendInterruptEnable (void )[static]
Enables the USB Suspend interrupt.
None. |
None. |
USB_SuspendInterruptIs()
static ALWAYS_INLINE bool USB_SuspendInterruptIs (void )[static]
Checks if the USB Suspend interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_TransactionCompleteInterruptAck()
static ALWAYS_INLINE void USB_TransactionCompleteInterruptAck (void )[static]
Clears the USB Transaction Complete Interrupt flag.
None. |
None. |
USB_TransactionCompleteInterruptDisable()
static ALWAYS_INLINE void USB_TransactionCompleteInterruptDisable (void )[static]
Disables the USB Transaction Complete interrupt.
None. |
None. |
USB_TransactionCompleteInterruptEnable()
static ALWAYS_INLINE void USB_TransactionCompleteInterruptEnable (void )[static]
Enables the USB Transaction Complete interrupt.
None. |
None. |
USB_TransactionCompleteInterruptIs()
static ALWAYS_INLINE bool USB_TransactionCompleteInterruptIs (void )[static]
Checks if a Transaction Complete interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_UnderflowInterruptClear()
static ALWAYS_INLINE void USB_UnderflowInterruptClear (void )[static]
Clears the USB Underflow Interrupt flag.
None. |
None. |
USB_UnderflowInterruptDisable()
static ALWAYS_INLINE void USB_UnderflowInterruptDisable (void )[static]
Disables the USB Underflow interrupt.
None. |
None. |
USB_UnderflowInterruptEnable()
static ALWAYS_INLINE void USB_UnderflowInterruptEnable (void )[static]
Enables the USB Underflow interrupt.
None. |
None. |
USB_UnderflowInterruptIs()
static ALWAYS_INLINE bool USB_UnderflowInterruptIs (void )[static]
Checks if an Underflow interrupt has been triggered.
None. |
0 |
- Interrupt not triggered |
1 |
- Interrupt triggered |
USB_UpstreamResumeEnable()
static ALWAYS_INLINE void USB_UpstreamResumeEnable (void )[static]
Enables an upstream resume to be initated.
None. |
None. |
USB_UpstreamResumeIsEnable()
static ALWAYS_INLINE bool USB_UpstreamResumeIsEnable (void )[static]
Checks if upstream resume is enabled, but not yet initiated.
None. |
0 |
- Upstream resume initiated or not enabled |
1 |
- Upstream resume enabled |
WaitUntilRMWDone()
static ALWAYS_INLINE void WaitUntilRMWDone (void )[static]
Waits until a Read-Modify-Write operation is done. This blocking wait operation is expected to complete within 14 clock cycles.
None. |
None. |
4.16.5.4 USB Peripheral Endpoint
API module for usb_peripheral_endpoint covering endpoint-related functions.
4.16.5.4.1 Module description
API module for usb_peripheral_endpoint covering endpoint-related functions.
Definitions
#define IsPowerOfTwo(number) ((0u != (number)) && (((number) & ((number)-1u)) == 0u))
Algorithm to detect if a given number is a power of two. A number is a power of two if it has exactly one '1' in its binary representation. This is true if subtracting '1' from the number and doing an AND operation on the result with the number itself returns 0.
Functions
RETURN_CODE_t USB_EndpointConfigure (USB_PIPE_t pipe, uint16_t endpointSize, USB_ENDPOINT_t endpointType)
Configures the endpoint with the desired settings using the Control and Status Register. Used to set up an endpoint before using it in an application. Sets up all the control register settings by looking up the usb_config.h file and clears the count registers.
RETURN_CODE_t USB_EndpointDisable (USB_PIPE_t pipe)
Disables the endpoint by setting the endpoint type to 0x00.
uint16_t USB_EndpointSizeGet (USB_PIPE_t pipe)
Helper function to return the endpoint size.
USB_ENDPOINT_t USB_EndpointTypeGet (USB_PIPE_t pipe)
Helper function to return the endpoint type.
RETURN_CODE_t USB_EndpointStall (USB_PIPE_t pipe)
Helps stall an endpoint when a command received from the host is invalid or unrecognizable. Used if the host sends data that is not supported by the device.
RETURN_CODE_t USB_EndpointStallClear (USB_PIPE_t pipe)
Helps clear the Stall condition after the device has recovered from an unsupported command from the host. Used to reset stall before the next USB transfer. Used when the host issues a clear HALT/Feature request to reset stall.
bool USB_EndpointIsStalled (USB_PIPE_t pipe)
Helper function to return the endpoint Stall condition.
RETURN_CODE_t USB_EndpointStalledConditionAck (USB_PIPE_t pipe)
Acknowledges the stall status condition by clearing the Stall Status bit. Used to clear the Stall Status bit after a stall has been detected.
RETURN_CODE_t USB_DataToggleSet (USB_PIPE_t pipe)
Sets the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t USB_DataToggleClear (USB_PIPE_t pipe)
Clears the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t USB_DataToggle (USB_PIPE_t pipe)
Toggles the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t ConvertEndpointSizeToMask (uint16_t endpointSize, USB_ENDPOINT_t endpointType, uint8_t *endpointMaskPtr)
Converts an endpoint size in number of bytes into a register setting. Converts the endpoint size bit mask based on the EP_BUFSIZE setting of the endpoint control register.
RETURN_CODE_t EndpointBufferSet (USB_PIPE_t pipe, uint8_t *bufAddress)
Configures the endpoint data buffer to a location in RAM for the next transaction.
Variables
USB_ENDPOINT_TABLE_t endpointTable
SRAM tables for the FIFO and endpoint registers, as well as the FRAMENUM register. Represents the endpoint configuration table based on the number of endpoints in use. This line instantiates an object using the data structure type.
4.16.5.4.2 Definition Documentation
IsPowerOfTwo
#define IsPowerOfTwo( number) ((0u != (number)) && (((number) & ((number)-1u)) == 0u))
Algorithm to detect if a given number is a power of two. A number is a power of two if it has exactly one '1' in its binary representation. This is true if subtracting '1' from the number and doing an AND operation on the result with the number itself returns 0.
number |
8-bit unsigned integer |
True |
- The given number is a power of two |
False |
- The given number is not a power of two |
4.16.5.4.3 Function Documentation
ConvertEndpointSizeToMask()
RETURN_CODE_t ConvertEndpointSizeToMask (uint16_t endpointSize, USB_ENDPOINT_t endpointType, uint8_t * endpointMaskPtr)
Converts an endpoint size in number of bytes into a register setting. Converts the endpoint size bit mask based on the EP_BUFSIZE setting of the endpoint control register.
endpointSize |
- The size to convert |
endpointType |
- The endpoint type |
endpointMaskPtr |
- Pointer to the mask variable to write to |
SUCCESS or an Error code according to RETURN_CODE_t |
EndpointBufferSet()
RETURN_CODE_t EndpointBufferSet (USB_PIPE_t pipe, uint8_t * bufAddress)
Configures the endpoint data buffer to a location in RAM for the next transaction.
pipe |
- A combination of endpoint address and direction |
bufAddress |
- The pointer to the data buffer the endpoint will use |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_DataToggle()
RETURN_CODE_t USB_DataToggle (USB_PIPE_t pipe)
Toggles the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_DataToggleClear()
RETURN_CODE_t USB_DataToggleClear (USB_PIPE_t pipe)
Clears the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_DataToggleSet()
RETURN_CODE_t USB_DataToggleSet (USB_PIPE_t pipe)
Sets the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_EndpointConfigure()
RETURN_CODE_t USB_EndpointConfigure (USB_PIPE_t pipe, uint16_t endpointSize, USB_ENDPOINT_t endpointType)
Configures the endpoint with the desired settings using the Control and Status Register. Used to set up an endpoint before using it in an application. Sets up all the control register settings by looking up the usb_config.h file and clears the count registers.
pipe |
- A combination of endpoint address and direction |
endpointSize |
- Number of bytes of data supported by the endpoint in one USB transaction |
endpointType |
- Type of USB endpoint as defined by usb_endpoint_type |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_EndpointDisable()
RETURN_CODE_t USB_EndpointDisable (USB_PIPE_t pipe)
Disables the endpoint by setting the endpoint type to 0x00.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_EndpointIsStalled()
bool USB_EndpointIsStalled (USB_PIPE_t pipe)
Helper function to return the endpoint Stall condition.
pipe |
- A combination of endpoint address and direction |
A boolean value representing the Stall condition. If the pipe address is out of bounds, the function will always return false |
USB_EndpointSizeGet()
uint16_t USB_EndpointSizeGet (USB_PIPE_t pipe)
Helper function to return the endpoint size.
pipe |
- A combination of endpoint address and direction |
The size of the endpoint |
USB_EndpointStall()
RETURN_CODE_t USB_EndpointStall (USB_PIPE_t pipe)
Helps stall an endpoint when a command received from the host is invalid or unrecognizable. Used if the host sends data that is not supported by the device.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_EndpointStallClear()
RETURN_CODE_t USB_EndpointStallClear (USB_PIPE_t pipe)
Helps clear the Stall condition after the device has recovered from an unsupported command from the host. Used to reset stall before the next USB transfer. Used when the host issues a clear HALT/Feature request to reset stall.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_EndpointStalledConditionAck()
RETURN_CODE_t USB_EndpointStalledConditionAck (USB_PIPE_t pipe)
Acknowledges the stall status condition by clearing the Stall Status bit. Used to clear the Stall Status bit after a stall has been detected.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_EndpointTypeGet()
USB_ENDPOINT_t USB_EndpointTypeGet (USB_PIPE_t pipe)
Helper function to return the endpoint type.
pipe |
- A combination of endpoint address and direction |
The endpoint type |
4.16.5.4.4 Variable Documentation
endpointTable
USB_ENDPOINT_TABLE_t endpointTable
SRAM tables for the FIFO and endpoint registers, as well as the FRAMENUM register. Represents the endpoint configuration table based on the number of endpoints in use. This line instantiates an object using the data structure type.
4.16.5.5 USB Peripheral Read/Write
API module for usb_peripheral covering low-level USB transaction functions.
4.16.5.5.1 Module description
API module for usb_peripheral covering low-level USB transaction functions.
Functions
RETURN_CODE_t USB_TransactionStart (USB_PIPE_t pipe)
Starts sending or receiving data on an endpoint by clearing BUSNACK. Used as a final step while setting up a transaction on the bus.
RETURN_CODE_t USB_TransactionAbort (USB_PIPE_t pipe)
Aborts the next transaction on an endpoint by setting BUSNACK. Used to stop exchanging data on an endpoint. The device will start NAKing requests from the host after calling this API.
RETURN_CODE_t USB_TransactionCompleteAck (USB_PIPE_t pipe)
Acknowledges the Transaction Complete status condition by clearing the Transaction Complete status bit. Used to clear the Transaction Complete status bit after a transaction has successfully completed.
bool USB_TransactionIsCompleted (void)
Helper function to return the endpoint transaction complete condition.
RETURN_CODE_t USB_TransactionCompletedPipeGet (USB_PIPE_t *pipe)
Returns the pipe address and direction for the latest completed transaction.
RETURN_CODE_t USB_PipeReset (USB_PIPE_t pipe)
Resets the pipe.
USB_TRANSFER_STATUS_t USB_PipeStatusGet (USB_PIPE_t pipe)
Gets the current status of pipe.
bool USB_PipeStatusIsBusy (USB_PIPE_t pipe)
Checks if the pipe status is busy.
void USB_PipeDataPtrSet (USB_PIPE_t pipe, uint8_t *dataPtr)
Configures the pointer for the data transfer in a given pipe.
uint8_t * USB_PipeDataPtrGet (USB_PIPE_t pipe)
Gets the current data pointer for a given pipe.
void USB_PipeDataToTransferSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of pipe data to transfer.
uint16_t USB_PipeDataToTransferSizeGet (USB_PIPE_t pipe)
Gets the size of pipe data to transfer.
uint16_t USB_PipeDataTransferredSizeGet (USB_PIPE_t pipe)
Gets the size of the transferred pipe data.
void USB_PipeDataTransferredSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of the transferred pipe data.
void USB_PipeDataTransferredSizeReset (USB_PIPE_t pipe)
Resets the size of transferred pipe data.
void USB_PipeTransferZLP_Enable (USB_PIPE_t pipe)
Enables a ZLP on a transfer. It is enabled by default if the AZLP static config is enabled for the pipe.
void USB_PipeTransferEndCallbackRegister (USB_PIPE_t pipe, USB_TRANSFER_END_CALLBACK_t callback)
Sets the callback for transfer end.
void USB_PipeTransferEndCallback (USB_PIPE_t pipe)
Calls the callback for transfer end.
RETURN_CODE_t USB_InTransactionRun (USB_PIPE_t pipe)
Checks the correctness of IN transactions and runs them.
RETURN_CODE_t USB_OutTransactionRun (USB_PIPE_t pipe)
Checks the correctness OUT transactions and runs them.
RETURN_CODE_t USB_PipeTransactionComplete (USB_PIPE_t pipe)
Handles completed IN and OUT transactions. Processes the completed transaction and either completes the transfer or runs the next transaction. Will call the pipe transferEndCallback at the end of transfer, if configured.
4.16.5.5.2 Function Documentation
USB_InTransactionRun()
RETURN_CODE_t USB_InTransactionRun (USB_PIPE_t pipe)
Checks the correctness of IN transactions and runs them.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_OutTransactionRun()
RETURN_CODE_t USB_OutTransactionRun (USB_PIPE_t pipe)
Checks the correctness OUT transactions and runs them.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_PipeDataPtrGet()
uint8_t* USB_PipeDataPtrGet (USB_PIPE_t pipe)
Gets the current data pointer for a given pipe.
pipe |
- A combination of endpoint address and direction |
The pointer to the data location |
USB_PipeDataPtrSet()
void USB_PipeDataPtrSet (USB_PIPE_t pipe, uint8_t * dataPtr)
Configures the pointer for the data transfer in a given pipe.
pipe |
- A combination of endpoint address and direction |
*dataPtr |
- The pointer to the data location |
None. |
USB_PipeDataToTransferSizeGet()
uint16_t USB_PipeDataToTransferSizeGet (USB_PIPE_t pipe)
Gets the size of pipe data to transfer.
pipe |
- A combination of endpoint address and direction |
The size of pipe data to transfer |
USB_PipeDataToTransferSizeSet()
void USB_PipeDataToTransferSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of pipe data to transfer.
pipe |
- A combination of endpoint address and direction |
dataSize |
- The size of pipe data to transfer |
None. |
USB_PipeDataTransferredSizeGet()
uint16_t USB_PipeDataTransferredSizeGet (USB_PIPE_t pipe)
Gets the size of the transferred pipe data.
pipe |
- A combination of endpoint address and direction |
The size of transferred pipe data |
USB_PipeDataTransferredSizeReset()
void USB_PipeDataTransferredSizeReset (USB_PIPE_t pipe)
Resets the size of transferred pipe data.
pipe |
- A combination of endpoint address and direction |
None. |
USB_PipeDataTransferredSizeSet()
void USB_PipeDataTransferredSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of the transferred pipe data.
pipe |
- A combination of endpoint address and direction |
dataSize |
- The size of pipe data transferred |
None. |
USB_PipeReset()
RETURN_CODE_t USB_PipeReset (USB_PIPE_t pipe)
Resets the pipe.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_PipeStatusGet()
USB_TRANSFER_STATUS_t USB_PipeStatusGet (USB_PIPE_t pipe)
Gets the current status of pipe.
pipe |
- A combination of endpoint address and direction |
USB_PIPE_TRANSFER_OK or an Error code according to USB_TRANSFER_STATUS_t |
USB_PipeStatusIsBusy()
bool USB_PipeStatusIsBusy (USB_PIPE_t pipe)
Checks if the pipe status is busy.
pipe |
- A combination of endpoint address and direction |
0 |
- Pipe status not busy |
1 |
- Pipe status is busy |
USB_PipeTransactionComplete()
RETURN_CODE_t USB_PipeTransactionComplete (USB_PIPE_t pipe)
Handles completed IN and OUT transactions. Processes the completed transaction and either completes the transfer or runs the next transaction. Will call the pipe transferEndCallback at the end of transfer, if configured.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_PipeTransferEndCallback()
void USB_PipeTransferEndCallback (USB_PIPE_t pipe)
Calls the callback for transfer end.
pipe |
- A combination of endpoint address and direction |
None. |
USB_PipeTransferEndCallbackRegister()
void USB_PipeTransferEndCallbackRegister (USB_PIPE_t pipe, USB_TRANSFER_END_CALLBACK_t callback)
Sets the callback for transfer end.
pipe |
- A combination of endpoint address and direction |
callback |
- A combination of pipe, status and transferred bytes |
None. |
USB_PipeTransferZLP_Enable()
void USB_PipeTransferZLP_Enable (USB_PIPE_t pipe)
Enables a ZLP on a transfer. It is enabled by default if the AZLP static config is enabled for the pipe.
pipe |
- A combination of endpoint address and direction |
None. |
USB_TransactionAbort()
RETURN_CODE_t USB_TransactionAbort (USB_PIPE_t pipe)
Aborts the next transaction on an endpoint by setting BUSNACK. Used to stop exchanging data on an endpoint. The device will start NAKing requests from the host after calling this API.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_TransactionCompleteAck()
RETURN_CODE_t USB_TransactionCompleteAck (USB_PIPE_t pipe)
Acknowledges the Transaction Complete status condition by clearing the Transaction Complete status bit. Used to clear the Transaction Complete status bit after a transaction has successfully completed.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_TransactionCompletedPipeGet()
RETURN_CODE_t USB_TransactionCompletedPipeGet (USB_PIPE_t * pipe)
Returns the pipe address and direction for the latest completed transaction.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
USB_TransactionIsCompleted()
bool USB_TransactionIsCompleted (void )
Helper function to return the endpoint transaction complete condition.
None. |
0 |
- Transaction not complete or pipe address is out of bounds |
1 |
- Transaction is complete |
USB_TransactionStart()
RETURN_CODE_t USB_TransactionStart (USB_PIPE_t pipe)
Starts sending or receiving data on an endpoint by clearing BUSNACK. Used as a final step while setting up a transaction on the bus.
pipe |
- A combination of endpoint address and direction |
SUCCESS or an Error code according to RETURN_CODE_t |
4.16.6 Data Structure Documentation
4.16.6.1 USB_CONTROL_TRANSFER_struct Struct Reference
#include <usb_peripheral.h>
4.16.6.1.1 Data Fields
uint8_t buffer [64]
volatile USB_CONTROL_STATUS_t status
uint8_t * transferDataPtr
uint16_t transferDataSize
uint16_t totalBytesTransferred
USB_SETUP_PROCESS_CALLBACK_t processSetupCallback
USB_SETUP_OVERUNDERRUN_CALLBACK_t overUnderRunCallback
USB_SETUP_ENDOFREQUEST_CALLBACK_t endOfRequestCallback
USB_SETUP_REQUEST_t setupRequest
4.16.6.1.2 Field Documentation
buffer
uint8_t buffer[64]
Default buffer for control data transfers
endOfRequestCallback
USB_SETUP_ENDOFREQUEST_CALLBACK_t endOfRequestCallback
Callback to call when a setup request is complete
overUnderRunCallback
USB_SETUP_OVERUNDERRUN_CALLBACK_t overUnderRunCallback
Callback to call on a control overrun or underrun
processSetupCallback
USB_SETUP_PROCESS_CALLBACK_t processSetupCallback
Callback to call during setup process
setupRequest
USB_SETUP_REQUEST_t setupRequest
Setup request packet
status
volatile USB_CONTROL_STATUS_t status
The status of a transfer on this pipe
totalBytesTransferred
uint16_t totalBytesTransferred
Number of data transfered last transaction
transferDataPtr
uint8_t* transferDataPtr
Location in RAM to send or fill during transfer
transferDataSize
uint16_t transferDataSize
Number of bytes to transfer to or from RAM location
4.16.6.2 USB_CONTROL_TRANSFER_t Struct Reference
The data structure for internally handling control transfers, either IN or OUT.
4.16.6.2.1 Detailed Description
The data structure for internally handling control transfers, either IN or OUT.
#include <usb_peripheral.h>
The documentation for this struct was generated from the following file:
source/
4.16.6.3 USB_ENDPOINT_TABLE_struct Struct Reference
Represents the endpoint configuration table based on the number of endpoints in use. The table data structure is defined by USB_EP_TABLE_struct in the device header file, modified to support configuration of size from USB_EP_NUM.
4.16.6.3.1 Detailed Description
Represents the endpoint configuration table based on the number of endpoints in use. The table data structure is defined by USB_EP_TABLE_struct in the device header file, modified to support configuration of size from USB_EP_NUM.
#include <usb_peripheral_avr_du.h>
Data Fields
4.16.6.3.2 Field Documentation
The documentation for this struct was generated from the following file:
source/
EP
USB_EP_PAIR_t EP[USB_EP_NUM]
USB Endpoint Register Pairs
FIFO
register8_t FIFO[USB_EP_NUM *2u]
FIFO Entry
FRAMENUM
register16_t FRAMENUM
Frame Number
4.16.6.4 USB_PIPE_TRANSFER_struct Struct Reference
Represents a transfer created for a pipe, either IN or OUT.
4.16.6.4.1 Detailed Description
Represents a transfer created for a pipe, either IN or OUT.
#include <usb_peripheral_avr_du.h>
Data Fields
USB_TRANSFER_STATUS_t status
uint8_t ZLPEnable: 1
uint8_t reserved: 7
uint8_t * transferDataPtr
uint16_t transferDataSize
uint16_t bytesTransferred
USB_TRANSFER_END_CALLBACK_t transferEndCallback
4.16.6.4.2 Field Documentation
The documentation for this struct was generated from the following file:
source/
bytesTransferred
uint16_t bytesTransferred
Total number of data transfered
reserved
uint8_t reserved
These bits are unused
status
USB_TRANSFER_STATUS_t status
The status of a transfer on this pipe
transferDataPtr
uint8_t* transferDataPtr
Location in RAM to send or fill during transfer
transferDataSize
uint16_t transferDataSize
Number of bytes to transfer to or from the RAM location
transferEndCallback
USB_TRANSFER_END_CALLBACK_t transferEndCallback
Callback to call at the end of transfer when transfer_data_size == bytes_transfered, NULL if not used
ZLPEnable
uint8_t ZLPEnable
A Zero Length Packet (ZLP) is enabled for the end of this transfer if the transfer size is a multiple of endpoint size
4.16.7 File Documentation
4.16.7.1 source/usb0.c File Reference
This file contains the API implementations for the USB0 driver.
#include <stddef.h> #include "../usb0.h" #include "../../system/syscfg.h" #include "../../system/utils/compiler.h"
4.16.7.1.1 Functions
static void USB0_DefaultTrnComplCallback (void)
static void USB0_DefaultBusEventCallback (void)
void USB0_Initialize (void)
Initializes USB0.
void USB0_TrnComplCallbackRegister (USB_cb_t cb)
Registers a callback function handling the Interrupt Service Routine (ISR) if a Transaction Complete interrupt flag is set.
void USB0_BusEventCallbackRegister (USB_cb_t cb)
Registers a callback function handling the ISR if a Bus Event interrupt flag is set.
ISR (USB0_TRNCOMPL_vect)
ISR (USB0_BUSEVENT_vect)
4.16.7.1.2 Variables
static void(* USB0_TrnCompl_isr_cb )(void) = &USB0_DefaultTrnComplCallback
static void(* USB0_BusEvent_isr_cb )(void) = &USB0_DefaultBusEventCallback
4.16.7.1.3 Detailed Description
This file contains the API implementations for the USB0 driver.
USB0 Generated Driver File
4.16.7.1.4 Function Documentation
ISR()[1/2]
ISR (USB0_BUSEVENT_vect )
ISR()[2/2]
ISR (USB0_TRNCOMPL_vect )
USB0_DefaultBusEventCallback()
static void USB0_DefaultBusEventCallback (void )[static]
USB0_DefaultTrnComplCallback()
static void USB0_DefaultTrnComplCallback (void )[static]
4.16.7.1.5 Variable Documentation
USB0_BusEvent_isr_cb
void(* USB0_BusEvent_isr_cb) (void) = &USB0_DefaultBusEventCallback[static]
USB0_TrnCompl_isr_cb
void(* USB0_TrnCompl_isr_cb) (void) = &USB0_DefaultTrnComplCallback[static]
4.16.7.2 source/usb0.h File Reference
4.16.7.2.1 Functions
void USB0_Initialize (void)
Initializes USB0.
void USB0_TrnComplCallbackRegister (USB_cb_t cb)
Registers a callback function handling the Interrupt Service Routine (ISR) if a Transaction Complete interrupt flag is set.
void USB0_BusEventCallbackRegister (USB_cb_t cb)
Registers a callback function handling the ISR if a Bus Event interrupt flag is set.
4.16.7.2.2 Typedefs
typedef void(* USB_cb_t) (void)
Data type for the interrupt handlers called by USB. The default value is set to NULL which means that no callback function will be used.
4.16.7.2.3 Detailed Description
USB0 Generated Driver API Header File
4.16.7.3 source/usb_peripheral.c File Reference
Interface for a usb_peripheral module that needs to be implemented by a device specific USB module driver.
#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include <usb_common_elements.h> #include <usb_config.h> #include <usb_peripheral.h> #include <usb_peripheral_avr_du.h> #include <usb_protocol_headers.h>
4.16.7.3.1 Functions
bool USB_SetupIsReceived (void)
Detects if the Setup event was received.
bool USB_EventSOFIsReceived (void)
Detects if the Start-of-Frame (SOF) event was received.
void USB_EventSOFClear (void)
Clears the SOF event.
bool USB_EventResetIsReceived (void)
Detects if the Reset event was received.
void USB_EventResetClear (void)
Clears the Reset event.
uint8_t USB_EventOverUnderflowIsReceived (void)
Detects if an Overflow and/or Underflow event was received.
uint8_t USB_ControlOverUnderflowIsReceived (void)
Detects if an Overflow and/or Underflow event was received on the control endpoints.
void USB_EventOverUnderflowClear (void)
Clears the Over/Underflow event.
bool USB_EventSuspendIsReceived (void)
Detects if a Suspend event was received.
void USB_EventSuspendClear (void)
Clears the Suspend event.
bool USB_EventResumeIsReceived (void)
Detects if a Resume event was received.
void USB_EventResumeClear (void)
Clears the Resume event.
bool USB_EventStalledIsReceived (void)
Detects if a Stalled event was received.
void USB_EventStalledClear (void)
Clears the Stalled event.
void USB_BusAttach (void)
Attaches the device to the USB bus.
void USB_BusDetach (void)
Detaches the device from the USB bus.
bool USB_IsBusAttached (void)
Checks if the device is attached to the USB bus not.
void USB_DeviceAddressConfigure (uint8_t deviceAddress)
Sets the device address.
uint16_t USB_FrameNumberGet (void)
Gets the current frame number.
RETURN_CODE_t USB_ControlEndpointsInit (void)
Ensures correct control endpoint initialization.
RETURN_CODE_t USB_ControlSetupReceived (void)
Verifies the received control setup.
RETURN_CODE_t USB_ControlTransactionComplete (USB_PIPE_t pipe)
Handles completed transactions on the control endpoints. Checks and verifies data OUT, data IN, ZLP OUT and ZLP IN.
RETURN_CODE_t USB_ControlTransferZLP (uint8_t direction)
Sends ZLP OUT and ZLP IN transactions on the control endpoints.
RETURN_CODE_t USB_ControlTransferReset (void)
Ensures correct control transfer reset.
RETURN_CODE_t USB_ControlTransferDataSet (uint8_t *dataPtr, uint16_t dataSize)
Updates the transfer data pointer and size in ControlTransfer.
RETURN_CODE_t USB_ControlTransferDataWriteBuffer (uint8_t *dataPtr, uint8_t dataSize)
Copies data to the transfer buffer and sets the transfer data pointer and size in ControlTransfer.
void USB_ControlEndOfRequestCallbackRegister (USB_SETUP_ENDOFREQUEST_CALLBACK_t callback)
Sets the callback for end of a control request.
void USB_ControlProcessSetupCallbackRegister (USB_SETUP_PROCESS_CALLBACK_t callback)
Sets the callback for the setup processing.
void USB_ControlOverUnderRunCallbackRegister (USB_SETUP_OVERUNDERRUN_CALLBACK_t callback)
Sets the callback for a control overrun or underrun.
RETURN_CODE_t USB_ControlProcessOverUnderflow (uint8_t overunderflow)
Handles the control Over/Underflow events.
RETURN_CODE_t USB_HandleEventStalled (USB_PIPE_t pipe)
Handles the Stall events.
void USB_PeripheralInitialize (void)
Enables the peripheral and the frame number, enables and resets FIFO, sets the endpoint table address and max endpoints.
void USB_PeripheralDisable (void)
Disables the USB peripheral and aborts any ongoing transaction.
4.16.7.3.2 Variables
STATIC USB_CONTROL_TRANSFER_t controlTransfer = { .transferDataPtr = controlTransfer.buffer }
4.16.7.3.3 Detailed Description
Interface for a usb_peripheral module that needs to be implemented by a device specific USB module driver.
USBPERIPHERAL Peripheral Source File
4.16.7.3.4 Variable Documentation
controlTransfer
STATIC USB_CONTROL_TRANSFER_t controlTransfer = { .transferDataPtr = controlTransfer.buffer }
4.16.7.4 source/usb_peripheral.h File Reference
#include <stdbool.h> #include <stdint.h> #include <usb_common_elements.h> #include <usb_peripheral_endpoint.h> #include <usb_peripheral_read_write.h> #include <usb_protocol_headers.h>
4.16.7.4.1 Data structures
struct USB_CONTROL_TRANSFER_struct
4.16.7.4.2 Functions
bool USB_SetupIsReceived (void)
Detects if the Setup event was received.
bool USB_EventSOFIsReceived (void)
Detects if the Start-of-Frame (SOF) event was received.
void USB_EventSOFClear (void)
Clears the SOF event.
bool USB_EventResetIsReceived (void)
Detects if the Reset event was received.
void USB_EventResetClear (void)
Clears the Reset event.
uint8_t USB_EventOverUnderflowIsReceived (void)
Detects if an Overflow and/or Underflow event was received.
uint8_t USB_ControlOverUnderflowIsReceived (void)
Detects if an Overflow and/or Underflow event was received on the control endpoints.
void USB_EventOverUnderflowClear (void)
Clears the Over/Underflow event.
bool USB_EventSuspendIsReceived (void)
Detects if a Suspend event was received.
void USB_EventSuspendClear (void)
Clears the Suspend event.
bool USB_EventResumeIsReceived (void)
Detects if a Resume event was received.
void USB_EventResumeClear (void)
Clears the Resume event.
bool USB_EventStalledIsReceived (void)
Detects if a Stalled event was received.
void USB_EventStalledClear (void)
Clears the Stalled event.
void USB_BusAttach (void)
Attaches the device to the USB bus.
void USB_BusDetach (void)
Detaches the device from the USB bus.
bool USB_IsBusAttached (void)
Checks if the device is attached to the USB bus not.
void USB_DeviceAddressConfigure (uint8_t deviceAddress)
Sets the device address.
uint16_t USB_FrameNumberGet (void)
Gets the current frame number.
RETURN_CODE_t USB_ControlEndpointsInit (void)
Ensures correct control endpoint initialization.
RETURN_CODE_t USB_ControlSetupReceived (void)
Verifies the received control setup.
RETURN_CODE_t USB_ControlTransactionComplete (USB_PIPE_t pipe)
Handles completed transactions on the control endpoints. Checks and verifies data OUT, data IN, ZLP OUT and ZLP IN.
RETURN_CODE_t USB_ControlTransferZLP (uint8_t direction)
Sends ZLP OUT and ZLP IN transactions on the control endpoints.
RETURN_CODE_t USB_ControlTransferReset (void)
Ensures correct control transfer reset.
RETURN_CODE_t USB_ControlTransferDataSet (uint8_t *dataPtr, uint16_t dataSize)
Updates the transfer data pointer and size in ControlTransfer.
RETURN_CODE_t USB_ControlTransferDataWriteBuffer (uint8_t *dataPtr, uint8_t dataSize)
Copies data to the transfer buffer and sets the transfer data pointer and size in ControlTransfer.
void USB_ControlEndOfRequestCallbackRegister (USB_SETUP_ENDOFREQUEST_CALLBACK_t callback)
Sets the callback for end of a control request.
void USB_ControlProcessSetupCallbackRegister (USB_SETUP_PROCESS_CALLBACK_t callback)
Sets the callback for the setup processing.
void USB_ControlOverUnderRunCallbackRegister (USB_SETUP_OVERUNDERRUN_CALLBACK_t callback)
Sets the callback for a control overrun or underrun.
RETURN_CODE_t USB_ControlProcessOverUnderflow (uint8_t overunderflow)
Handles the control Over/Underflow events.
RETURN_CODE_t USB_HandleEventStalled (USB_PIPE_t pipe)
Handles the Stall events.
void USB_PeripheralInitialize (void)
Enables the peripheral and the frame number, enables and resets FIFO, sets the endpoint table address and max endpoints.
void USB_PeripheralDisable (void)
Disables the USB peripheral and aborts any ongoing transaction.
4.16.7.4.3 Typedefs
typedef struct USB_CONTROL_TRANSFER_struct USB_CONTROL_TRANSFER_t
4.16.7.4.4 Detailed Description
USBPERIPHERAL Peripheral Header File
4.16.7.4.5 Typedef Documentation
USB_CONTROL_TRANSFER_t
typedef struct USB_CONTROL_TRANSFER_struct USB_CONTROL_TRANSFER_t
4.16.7.5 source/usb_peripheral_avr_du.h File Reference
#include <avr/io.h> #include <usb_config.h> #include <usb_protocol_headers.h>
4.16.7.5.1 Data structures
struct USB_ENDPOINT_TABLE_struct
Represents the endpoint configuration table based on the number of endpoints in use. The table data structure is defined by USB_EP_TABLE_struct in the device header file, modified to support configuration of size from USB_EP_NUM.
struct USB_PIPE_TRANSFER_struct
Represents a transfer created for a pipe, either IN or OUT.
4.16.7.5.2 Functions
static ALWAYS_INLINE void WaitUntilRMWDone (void)
Waits until a Read-Modify-Write operation is done. This blocking wait operation is expected to complete within 14 clock cycles.
static ALWAYS_INLINE void USB_EndPointOutDisable (uint8_t endpointAddress)
Disables the OUT endpoint with the given address.
static ALWAYS_INLINE void USB_EndPointInDisable (uint8_t endpointAddress)
Disables the IN endpoint with the given address.
static ALWAYS_INLINE bool USB_EndPointOutIsEnabled (uint8_t endpointAddress)
Checks if the OUT endpoint at the given address is enabled.
static ALWAYS_INLINE bool USB_EndPointInIsEnabled (uint8_t endpointAddress)
Checks if the IN endpoint at the given address is enabled.
static ALWAYS_INLINE uint8_t USB_EndPointOutTypeConfigGet (uint8_t endpointAddress)
Gets the OUT endpoint configuration at the given address.
static ALWAYS_INLINE uint8_t USB_EndPointInTypeConfigGet (uint8_t endpointAddress)
Gets the IN endpoint configuration at the given address.
static ALWAYS_INLINE void USB_EndpointOutControlSet (uint8_t endpointAddress, uint8_t value)
Sets endpoint control OUT.
static ALWAYS_INLINE void USB_EndpointInControlSet (uint8_t endpointAddress, uint8_t value)
Sets endpoint control IN.
static ALWAYS_INLINE void USB_EndpointOutStatusClear (uint8_t endpointAddress)
Clears OUT endpoint status.
static ALWAYS_INLINE void USB_EndpointInStatusClear (uint8_t endpointAddress)
Clears IN endpoint status.
static ALWAYS_INLINE void USB_EndpointOutDefaultSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for a default type OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInDefaultSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for a default type IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutIsoSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for an isochronous OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInIsoSizeSet (uint8_t endpointAddress, uint8_t endpointSizeConfig)
Sets the endpoint size for an isochronous IN endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointOutDefaultSizeGet (uint8_t endpointAddress)
Gets the size of a default type OUT endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointInDefaultSizeGet (uint8_t endpointAddress)
Gets the size of a default type IN endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointOutIsoSizeGet (uint8_t endpointAddress)
Gets the size of an isochronous OUT endpoint.
static ALWAYS_INLINE uint8_t USB_EndpointInIsoSizeGet (uint8_t endpointAddress)
Gets the size of an isochronous IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteInterruptEnable (uint8_t endpointAddress)
Enables transaction complete interrupt for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteInterruptEnable (uint8_t endpointAddress)
Enables transaction complete interrupt for the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteInterruptDisable (uint8_t endpointAddress)
Disables transaction complete interrupt for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteDisable (uint8_t endpointAddress)
Disables transaction complete interrupt for the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutMultipktEnable (uint8_t endpointAddress)
Enables multipacket for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInMultipktEnable (uint8_t endpointAddress)
Enables multipacket for the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutMultipktDisable (uint8_t endpointAddress)
Disables multipacket for the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInMultipktDisable (uint8_t endpointAddress)
Disables multipacket for the specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutMultipktIsEnabled (uint8_t endpointAddress)
Checks if multipacket is enabled on the specified OUT endpoint.
static ALWAYS_INLINE bool USB_EndpointInMultipktIsEnabled (uint8_t endpointAddress)
Checks if multipacket is enabled on the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutAzlpEnable (uint8_t endpointAddress)
Enables Auto Zero Length Packet (AZLP) on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInAlzpEnable (uint8_t endpointAddress)
Enables AZLP on the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutAzlpDisable (uint8_t endpointAddress)
Disables AZLP on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInAzlpDisable (uint8_t endpointAddress)
Disables AZLP on the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutStall (uint8_t endpointAddress)
Stalls the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInStall (uint8_t endpointAddress)
Stalls the specified IN endpoint.
static ALWAYS_INLINE void USB_EndpointOutStallClear (uint8_t endpointAddress)
Stops stalling the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInStallClear (uint8_t endpointAddress)
Stops stalling the specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutIsStalled (uint8_t endpointAddress)
Checks if the specified OUT endpoint is stalled.
static ALWAYS_INLINE bool USB_EndpointInIsStalled (uint8_t endpointAddress)
Checks if the specified IN endpoint is stalled.
static ALWAYS_INLINE void USB_EndpointOutStallAck (uint8_t endpointAddress)
Acknowledges that an OUT endpoint is stalled and Clears the USB STATUS register.
static ALWAYS_INLINE void USB_EndpointInStallAck (uint8_t endpointAddress)
Acknowledges that an IN endpoint is stalled and Clears the USB STATUS register.
static ALWAYS_INLINE void USB_EndpointOutNAKSet (uint8_t endpointAddress)
Sets OUT endpoint status to NAK.
static ALWAYS_INLINE void USB_EndpointInNAKSet (uint8_t endpointAddress)
Sets IN endpoint status to NAK.
static ALWAYS_INLINE void USB_EndpointOutNAKClear (uint8_t endpointAddress)
Clears the USB NAK status from the OUT endpoint STATUS register.
static ALWAYS_INLINE void USB_EndpointInNAKClear (uint8_t endpointAddress)
Clears the USB NAK status from the IN endpoint STATUS register.
static ALWAYS_INLINE bool USB_EndpointOutNAKIsSet (uint8_t endpointAddress)
Checks the OUT endpoint STATUS register for the NAK status.
static ALWAYS_INLINE bool USB_EndpointInNAKIsSet (uint8_t endpointAddress)
Checks the OUT endpoint STATUS register for the NAK status.
static ALWAYS_INLINE void USB_EndpointOutTransactionCompleteAck (uint8_t endpointAddress)
Acknowledges the transaction complete status on a specified OUT endpoint and Clears the USB STATUS register.
static ALWAYS_INLINE void USB_EndpointInTransactionCompleteAck (uint8_t endpointAddress)
Acknowledges the transaction complete status on a specified IN endpoint and Clears the USB STATUS register.
static ALWAYS_INLINE bool USB_EndpointOutTransactionIsComplete (uint8_t endpointAddress)
Checks if the USB OUT endpoint has the Transaction Complete status.
static ALWAYS_INLINE bool USB_EndpointInTransactionIsComplete (uint8_t endpointAddress)
Checks if the USB IN endpoint has the Transaction Complete status.
static ALWAYS_INLINE void USB_EndpointOutSetupReceivedAck (uint8_t endpointAddress)
Acknowledges the Setup Received status on a specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInSetupCompleteAck (uint8_t endpointAddress)
Acknowledges the Setup Received status on a specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutSetupIsReceived (uint8_t endpointAddress)
Checks if the USB OUT endpoint has the Setup Received status.
static ALWAYS_INLINE bool USB_EndpointInSetupIsReceived (uint8_t endpointAddress)
Checks if the USB IN endpoint has the Setup Received status.
static ALWAYS_INLINE void USB_EndpointOutDataToggleSet (uint8_t endpointAddress)
Sets OUT endpoint data toggle.
static ALWAYS_INLINE void USB_EndpointInDataToggleSet (uint8_t endpointAddress)
Sets IN endpoint data toggle.
static ALWAYS_INLINE void USB_EndpointOutDataToggleClear (uint8_t endpointAddress)
Clears OUT endpoint data toggle.
static ALWAYS_INLINE void USB_EndpointInDataToggleClear (uint8_t endpointAddress)
Clears IN endpoint data toggle.
static ALWAYS_INLINE bool USB_EndpointOutDataToggleIsSet (uint8_t endpointAddress)
Checks if data toggle is set on the specified OUT endpoint.
static ALWAYS_INLINE bool USB_EndpointInDataToggleIsSet (uint8_t endpointAddress)
Checks if data toggle is set on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointOutBufferSet (uint8_t endpointAddress, uint8_t *bufAddress)
Sets endpoint buffer OUT.
static ALWAYS_INLINE void USB_EndpointInBufferSet (uint8_t endpointAddress, uint8_t *bufAddress)
Sets endpoint buffer IN.
static ALWAYS_INLINE void USB_NumberBytesToSendSet (uint8_t endpointAddress, uint16_t numberBytes)
Sets how many bytes of data are intended to be sent from the specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesToSendGet (uint8_t endpointAddress)
Reads out the CNT register to know how many bytes of data are intended to be sent from the specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesToSendReset (uint8_t endpointAddress)
Clears the CNT register to tell the peripheral no data is intended to be sent from the specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesSentGet (uint8_t endpointAddress)
Reads out how many bytes have been sent from the specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesSentReset (uint8_t endpointAddress)
Clears the MCNT register that keeps track of how many bytes of data have been sent.
static ALWAYS_INLINE void USB_NumberBytesToReceiveSet (uint8_t endpointAddress, uint16_t numberBytes)
Sets how many bytes of data are expected to be received on a specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesToReceiveGet (uint8_t endpointAddress)
Gets how many bytes of data are expected to be received on a specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesToReceiveReset (uint8_t endpointAddress)
Clears the MCNT register to tell the peripheral no data is intended to be received on the specified endpoint.
static ALWAYS_INLINE uint16_t USB_NumberBytesReceivedGet (uint8_t endpointAddress)
Gets how many bytes of data have been received on a specified endpoint.
static ALWAYS_INLINE void USB_NumberBytesReceivedReset (uint8_t endpointAddress)
Resets the counter that counts amount of bytes of data received on a specific endpoint.
static ALWAYS_INLINE bool USB_EndpointOutOverUnderflowIsSet (uint8_t endpointAddress)
Checks if OUT endpoint has overflowed.
static ALWAYS_INLINE bool USB_EndpointInOverUnderflowIsSet (uint8_t endpointAddress)
Checks if IN endpoint has underflowed.
static ALWAYS_INLINE void USB_EndpointOutOverUnderflowAck (uint8_t endpointAddress)
Acknowledges overflow on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInOverUnderflowAck (uint8_t endpointAddress)
Acknowledges underflow on the specified IN endpoint.
static ALWAYS_INLINE bool USB_EndpointOutCRCHasFailed (uint8_t endpointAddress)
Checks if the specified OUT endpoint has a Cyclic Redundancy Check (CRC) failure.
static ALWAYS_INLINE bool USB_EndpointInCRCHasFailed (uint8_t endpointAddress)
Checks if the specified IN endpoint has a CRC failure.
static ALWAYS_INLINE void USB_EndpointOutCRCAck (uint8_t endpointAddress)
Acknowledges a CRC failure on the specified OUT endpoint.
static ALWAYS_INLINE void USB_EndpointInCRCAck (uint8_t endpointAddress)
Acknowledges a CRC failure on the specified IN endpoint.
static ALWAYS_INLINE void USB_GlobalNAKEnable (void)
Enables global NAK.
static ALWAYS_INLINE void USB_GlobalNAKDisable (void)
Disables global NAK.
static ALWAYS_INLINE bool USB_GlobalNAKIsEnable (void)
Checks the global NAK setting.
static ALWAYS_INLINE void USB_ConnectionAttach (void)
Tells the USB peripheral to attach.
static ALWAYS_INLINE void USB_ConnectionDetach (void)
Tells the USB peripheral to detach.
static ALWAYS_INLINE bool USB_ConnectionIsAttach (void)
Checks if the USB connection is attached.
static ALWAYS_INLINE void USB_Enable (void)
Enables the USB peripheral.
static ALWAYS_INLINE void USB_Disable (void)
Disables the USB peripheral.
static ALWAYS_INLINE bool USB_IsEnable (void)
Checks if the USB peripheral is enabled.
static ALWAYS_INLINE void USB_FifoEnable (void)
Enables USB FIFO.
static ALWAYS_INLINE void USB_FifoDisable (void)
Disables USB FIFO.
static ALWAYS_INLINE bool USB_FifoIsEnable (void)
Checks if USB FIFO has been enabled.
static ALWAYS_INLINE void USB_AutomaticGlobalNAKEnable (void)
Enables automatic global NAK for the USB peripheral.
static ALWAYS_INLINE void USB_AutomaticGlobalNAKDisable (void)
Disables automatic global NAK for the USB peripheral.
static ALWAYS_INLINE bool USB_AutomaticGlobalNAKIsEnable (void)
Checks if automatic global NAK has been enabled.
static ALWAYS_INLINE void USB_FrameNumEnable (void)
Enables storing the last SOF token frame number in FRAMENUM. This is a device-specific function.
static ALWAYS_INLINE void USB_FrameNumDisable (void)
Disables storing the last SOF token frame number in FRAMENUM. This is a device-specific function.
static ALWAYS_INLINE bool USB_FrameNumIsEnable (void)
Checks if storing of the last SOF token frame number is enabled. This is a device-specific function.
static ALWAYS_INLINE uint16_t USB_FrameNumGet (void)
Gets the current frame number.
static ALWAYS_INLINE void USB_MaxEndpointsSet (uint8_t maxEndpoint)
Sets maximum number of endpoint addresses used by the USB peripheral.
static ALWAYS_INLINE void USB_MaxEndpointsReset (void)
Clears the USB endpoint maximum, setting the maximum endpoint to EP0.
static ALWAYS_INLINE uint8_t USB_MaxEndpointsGet (void)
Checks what the maximum number of endpoint addresses is.
static ALWAYS_INLINE void USB_EndpointTableAddressSet (USB_EP_PAIR_t *endpointTableAddress)
Sets the address of the endpoint table. This is a device-specific function.
static ALWAYS_INLINE void USB_EndpointTableAddressReset (void)
Sets the address of the endpoint table to 0. This is a device-specific function.
static ALWAYS_INLINE uint16_t USB_EndpointTableAddressGet (void)
Gets the address of the endpoint table. This is a device-specific function.
static ALWAYS_INLINE void USB_FifoReadPointerReset (void)
Resets the read FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE int8_t USB_FifoReadPointerGet (void)
Gets the read FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE void USB_FifoWritePointerReset (void)
Resets the write FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE int8_t USB_FifoWritePointerGet (void)
Gets the write FIFO pointer. This is a device-specific function.
static ALWAYS_INLINE void USB_DeviceAddressSet (uint8_t usbAddress)
Sets the device address.
static ALWAYS_INLINE void USB_DeviceAddressReset (void)
Resets the device address.
static ALWAYS_INLINE uint8_t USB_DeviceAddressGet (void)
Gets the device address.
static ALWAYS_INLINE void USB_UpstreamResumeEnable (void)
Enables an upstream resume to be initated.
static ALWAYS_INLINE bool USB_UpstreamResumeIsEnable (void)
Checks if upstream resume is enabled, but not yet initiated.
static ALWAYS_INLINE uint8_t USB_BusStateGet (void)
Gets the USB bus state.
static ALWAYS_INLINE bool USB_BusStateIs (uint8_t bus_state_bm)
Checks if the USB bus has any specific status flags set.
static ALWAYS_INLINE void USB_SOFInterruptEnable (void)
Enables the USB Start-Of-Frame interrupt.
static ALWAYS_INLINE void USB_SOFInterruptDisable (void)
Disables the USB Start-Of-Frame interrupt.
static ALWAYS_INLINE void USB_SOFInterruptClear (void)
Clears the USB Start-Of-Frame Interrupt flag.
static ALWAYS_INLINE bool USB_SOFInterruptIs (void)
Checks if the USB Start-Of-Frame interrupt has been triggered.
static ALWAYS_INLINE void USB_SuspendInterruptEnable (void)
Enables the USB Suspend interrupt.
static ALWAYS_INLINE void USB_SuspendInterruptDisable (void)
Disables the USB Suspend interrupt.
static ALWAYS_INLINE void USB_SuspendInterruptClear (void)
Clears the USB Suspend Interrupt flag.
static ALWAYS_INLINE bool USB_SuspendInterruptIs (void)
Checks if the USB Suspend interrupt has been triggered.
static ALWAYS_INLINE void USB_ResumeInterruptEnable (void)
Enables the USB Resume interrupt.
static ALWAYS_INLINE void USB_ResumeInterruptDisable (void)
Disables the USB Resume interrupt.
static ALWAYS_INLINE void USB_ResumeInterruptClear (void)
Clears the USB Resume Interrupt flag.
static ALWAYS_INLINE bool USB_ResumeInterruptIs (void)
Checks if the USB Resume interrupt has been triggered.
static ALWAYS_INLINE void USB_ResetInterruptEnable (void)
Enables the USB Reset interrupt.
static ALWAYS_INLINE void USB_ResetInterruptDisable (void)
Disables the USB Reset interrupt.
static ALWAYS_INLINE void USB_ResetInterruptClear (void)
Clears the USB Reset Interrupt flag.
static ALWAYS_INLINE bool USB_ResetInterruptIs (void)
Checks if the USB Reset interrupt has been triggered.
static ALWAYS_INLINE void USB_StalledInterruptEnable (void)
Enables the USB Stalled interrupt.
static ALWAYS_INLINE void USB_StalledInterruptDisable (void)
Disables the USB Stalled interrupt.
static ALWAYS_INLINE void USB_StalledInterruptClear (void)
Clears the USB Stalled Interrupt flag.
static ALWAYS_INLINE bool USB_StalledInterruptIs (void)
Checks if the USB Stalled interrupt has been triggered.
static ALWAYS_INLINE void USB_UnderflowInterruptEnable (void)
Enables the USB Underflow interrupt.
static ALWAYS_INLINE void USB_UnderflowInterruptDisable (void)
Disables the USB Underflow interrupt.
static ALWAYS_INLINE void USB_UnderflowInterruptClear (void)
Clears the USB Underflow Interrupt flag.
static ALWAYS_INLINE bool USB_UnderflowInterruptIs (void)
Checks if an Underflow interrupt has been triggered.
static ALWAYS_INLINE void USB_OverflowInterruptEnable (void)
Enables the USB Overflow interrupt.
static ALWAYS_INLINE void USB_OverflowInterruptDisable (void)
Disables the USB Overflow interrupt.
static ALWAYS_INLINE void USB_OverflowInterruptClear (void)
Clears the USB Overflow Interrupt flag.
static ALWAYS_INLINE bool USB_OverflowInterruptIs (void)
Checks if an Overflow interrupt has been triggered.
static ALWAYS_INLINE void USB_TransactionCompleteInterruptEnable (void)
Enables the USB Transaction Complete interrupt.
static ALWAYS_INLINE void USB_TransactionCompleteInterruptDisable (void)
Disables the USB Transaction Complete interrupt.
static ALWAYS_INLINE void USB_TransactionCompleteInterruptAck (void)
Clears the USB Transaction Complete Interrupt flag.
static ALWAYS_INLINE bool USB_TransactionCompleteInterruptIs (void)
Checks if a Transaction Complete interrupt has been triggered.
static ALWAYS_INLINE bool USB_ReadModifyWriteInterruptIs (void)
Checks if the USB Read-Modify-Write Interrupt is enabled.
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptEnable (void)
Enables the USB Global NAK Done interrupt.
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptDisable (void)
Disables the USB Global NAK Done interrupt.
static ALWAYS_INLINE void USB_GlobalNAKDoneInterruptAck (void)
Clears the USB Global NAK Done Interrupt flag.
static ALWAYS_INLINE bool USB_GlobalNAKDoneInterruptIs (void)
Checks if the USB Global NAK Done interrupt has been triggered.
static ALWAYS_INLINE void USB_SetupInterruptEnable (void)
Enables the USB Setup interrupt.
static ALWAYS_INLINE void USB_SetupInterruptDisable (void)
Disables the USB Setup interrupt.
static ALWAYS_INLINE void USB_SetupInterruptClear (void)
Clears the USB Setup Interrupt flag.
static ALWAYS_INLINE bool USB_SetupInterruptIs (void)
Checks if a USB Setup interrupt has been triggered.
static ALWAYS_INLINE void USB_InterruptFlagsClear (void)
Clears all the USB Interrupt flags.
4.16.7.5.3 Macros
#define ALWAYS_INLINE __attribute__((always_inline)) inline
Alias that makes always inline function definitions more readable.
4.16.7.5.4 Typedefs
typedef struct USB_ENDPOINT_TABLE_struct USB_ENDPOINT_TABLE_t
typedef struct USB_PIPE_TRANSFER_struct USB_PIPE_TRANSFER_t
4.16.7.5.5 Variables
USB_ENDPOINT_TABLE_t endpointTable
SRAM tables for the FIFO and endpoint registers, as well as the FRAMENUM register. Represents the endpoint configuration table based on the number of endpoints in use. This line instantiates an object using the data structure type.
4.16.7.5.6 Detailed Description
USBPERIPHERALAVRDU Peripheral AVR DU Specific Header File
4.16.7.5.7 Typedef Documentation
USB_ENDPOINT_TABLE_t
typedef struct USB_ENDPOINT_TABLE_struct USB_ENDPOINT_TABLE_t
USB_PIPE_TRANSFER_t
typedef struct USB_PIPE_TRANSFER_struct USB_PIPE_TRANSFER_t
4.16.7.6 source/usb_peripheral_endpoint.c File Reference
API module for usb_peripheral covering endpoint related functions.
#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include <usb_common_elements.h> #include <usb_config.h> #include <usb_peripheral_avr_du.h> #include <usb_peripheral_endpoint.h> #include <usb_protocol_headers.h>
4.16.7.6.1 Functions
RETURN_CODE_t USB_EndpointConfigure (USB_PIPE_t pipe, uint16_t endpointSize, USB_ENDPOINT_t endpointType)
Configures the endpoint with the desired settings using the Control and Status Register. Used to set up an endpoint before using it in an application. Sets up all the control register settings by looking up the usb_config.h file and clears the count registers.
RETURN_CODE_t USB_EndpointDisable (USB_PIPE_t pipe)
Disables the endpoint by setting the endpoint type to 0x00.
uint16_t USB_EndpointSizeGet (USB_PIPE_t pipe)
Helper function to return the endpoint size.
USB_ENDPOINT_t USB_EndpointTypeGet (USB_PIPE_t pipe)
Helper function to return the endpoint type.
RETURN_CODE_t USB_EndpointStall (USB_PIPE_t pipe)
Helps stall an endpoint when a command received from the host is invalid or unrecognizable. Used if the host sends data that is not supported by the device.
RETURN_CODE_t USB_EndpointStallClear (USB_PIPE_t pipe)
Helps clear the Stall condition after the device has recovered from an unsupported command from the host. Used to reset stall before the next USB transfer. Used when the host issues a clear HALT/Feature request to reset stall.
bool USB_EndpointIsStalled (USB_PIPE_t pipe)
Helper function to return the endpoint Stall condition.
RETURN_CODE_t USB_EndpointStalledConditionAck (USB_PIPE_t pipe)
Acknowledges the stall status condition by clearing the Stall Status bit. Used to clear the Stall Status bit after a stall has been detected.
RETURN_CODE_t USB_DataToggleSet (USB_PIPE_t pipe)
Sets the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t USB_DataToggleClear (USB_PIPE_t pipe)
Clears the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t USB_DataToggle (USB_PIPE_t pipe)
Toggles the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t ConvertEndpointSizeToMask (uint16_t endpointSize, USB_ENDPOINT_t endpointType, uint8_t *endpointMaskPtr)
Converts an endpoint size in number of bytes into a register setting. Converts the endpoint size bit mask based on the EP_BUFSIZE setting of the endpoint control register.
RETURN_CODE_t EndpointBufferSet (USB_PIPE_t pipe, uint8_t *bufAddress)
Configures the endpoint data buffer to a location in RAM for the next transaction.
4.16.7.6.2 Macros
#define IsPowerOfTwo(number) ((0u != (number)) && (((number) & ((number)-1u)) == 0u))
Algorithm to detect if a given number is a power of two. A number is a power of two if it has exactly one '1' in its binary representation. This is true if subtracting '1' from the number and doing an AND operation on the result with the number itself returns 0.
4.16.7.6.3 Variables
USB_ENDPOINT_TABLE_t endpointTable
SRAM tables for the FIFO and endpoint registers, as well as the FRAMENUM register. Represents the endpoint configuration table based on the number of endpoints in use. This line instantiates an object using the data structure type.
4.16.7.6.4 Detailed Description
API module for usb_peripheral covering endpoint related functions.
USBPERIPHERALENDPOINT Peripheral Endpoint Source File
4.16.7.7 source/usb_peripheral_endpoint.h File Reference
#include <stdbool.h> #include <stdint.h> #include "usb_common_elements.h" #include "usb_protocol_headers.h"
4.16.7.7.1 Functions
RETURN_CODE_t USB_EndpointConfigure (USB_PIPE_t pipe, uint16_t endpointSize, USB_ENDPOINT_t endpointType)
Configures the endpoint with the desired settings using the Control and Status Register. Used to set up an endpoint before using it in an application. Sets up all the control register settings by looking up the usb_config.h file and clears the count registers.
RETURN_CODE_t USB_EndpointDisable (USB_PIPE_t pipe)
Disables the endpoint by setting the endpoint type to 0x00.
uint16_t USB_EndpointSizeGet (USB_PIPE_t pipe)
Helper function to return the endpoint size.
USB_ENDPOINT_t USB_EndpointTypeGet (USB_PIPE_t pipe)
Helper function to return the endpoint type.
RETURN_CODE_t USB_EndpointStall (USB_PIPE_t pipe)
Helps stall an endpoint when a command received from the host is invalid or unrecognizable. Used if the host sends data that is not supported by the device.
RETURN_CODE_t USB_EndpointStallClear (USB_PIPE_t pipe)
Helps clear the Stall condition after the device has recovered from an unsupported command from the host. Used to reset stall before the next USB transfer. Used when the host issues a clear HALT/Feature request to reset stall.
bool USB_EndpointIsStalled (USB_PIPE_t pipe)
Helper function to return the endpoint Stall condition.
RETURN_CODE_t USB_EndpointStalledConditionAck (USB_PIPE_t pipe)
Acknowledges the stall status condition by clearing the Stall Status bit. Used to clear the Stall Status bit after a stall has been detected.
RETURN_CODE_t USB_DataToggleSet (USB_PIPE_t pipe)
Sets the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t USB_DataToggleClear (USB_PIPE_t pipe)
Clears the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t USB_DataToggle (USB_PIPE_t pipe)
Toggles the Data Toggle bit on an endpoint which is used to ensure correct data sequence. Only used if hardware data toggling is not available. After a successful transaction, toggle the Data Toggle bit. For SETUP transactions, ensure that the SETUP stage clears the Data Toggle bit, while the data stage and status stage set the Data Toggle bit.
RETURN_CODE_t ConvertEndpointSizeToMask (uint16_t endpointSize, USB_ENDPOINT_t endpointType, uint8_t *endpointMaskPtr)
Converts an endpoint size in number of bytes into a register setting. Converts the endpoint size bit mask based on the EP_BUFSIZE setting of the endpoint control register.
RETURN_CODE_t EndpointBufferSet (USB_PIPE_t pipe, uint8_t *bufAddress)
Configures the endpoint data buffer to a location in RAM for the next transaction.
4.16.7.7.2 Detailed Description
USBPERIPHERALENDPOINT Peripheral Endpoint Header File
4.16.7.8 source/usb_peripheral_read_write.c File Reference
API module for usb_peripheral covering low level USB transaction functions.
#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <string.h> #include <usb_common_elements.h> #include <usb_config.h> #include <usb_peripheral_avr_du.h> #include <usb_peripheral_endpoint.h> #include <usb_peripheral_read_write.h> #include <usb_protocol_headers.h>
4.16.7.8.1 Functions
RETURN_CODE_t USB_TransactionStart (USB_PIPE_t pipe)
Starts sending or receiving data on an endpoint by clearing BUSNACK. Used as a final step while setting up a transaction on the bus.
RETURN_CODE_t USB_TransactionAbort (USB_PIPE_t pipe)
Aborts the next transaction on an endpoint by setting BUSNACK. Used to stop exchanging data on an endpoint. The device will start NAKing requests from the host after calling this API.
RETURN_CODE_t USB_TransactionCompleteAck (USB_PIPE_t pipe)
Acknowledges the Transaction Complete status condition by clearing the Transaction Complete status bit. Used to clear the Transaction Complete status bit after a transaction has successfully completed.
bool USB_TransactionIsCompleted (void)
Helper function to return the endpoint transaction complete condition.
RETURN_CODE_t USB_TransactionCompletedPipeGet (USB_PIPE_t *pipe)
Returns the pipe address and direction for the latest completed transaction.
RETURN_CODE_t USB_PipeReset (USB_PIPE_t pipe)
Resets the pipe.
USB_TRANSFER_STATUS_t USB_PipeStatusGet (USB_PIPE_t pipe)
Gets the current status of pipe.
bool USB_PipeStatusIsBusy (USB_PIPE_t pipe)
Checks if the pipe status is busy.
void USB_PipeDataPtrSet (USB_PIPE_t pipe, uint8_t *dataPtr)
Configures the pointer for the data transfer in a given pipe.
uint8_t * USB_PipeDataPtrGet (USB_PIPE_t pipe)
Gets the current data pointer for a given pipe.
void USB_PipeDataToTransferSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of pipe data to transfer.
uint16_t USB_PipeDataToTransferSizeGet (USB_PIPE_t pipe)
Gets the size of pipe data to transfer.
uint16_t USB_PipeDataTransferredSizeGet (USB_PIPE_t pipe)
Gets the size of the transferred pipe data.
void USB_PipeDataTransferredSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of the transferred pipe data.
void USB_PipeDataTransferredSizeReset (USB_PIPE_t pipe)
Resets the size of transferred pipe data.
void USB_PipeTransferZLP_Enable (USB_PIPE_t pipe)
Enables a ZLP on a transfer. It is enabled by default if the AZLP static config is enabled for the pipe.
void USB_PipeTransferEndCallbackRegister (USB_PIPE_t pipe, USB_TRANSFER_END_CALLBACK_t callback)
Sets the callback for transfer end.
void USB_PipeTransferEndCallback (USB_PIPE_t pipe)
Calls the callback for transfer end.
RETURN_CODE_t USB_InTransactionRun (USB_PIPE_t pipe)
Checks the correctness of IN transactions and runs them.
RETURN_CODE_t USB_OutTransactionRun (USB_PIPE_t pipe)
Checks the correctness OUT transactions and runs them.
RETURN_CODE_t USB_PipeTransactionComplete (USB_PIPE_t pipe)
Handles completed IN and OUT transactions. Processes the completed transaction and either completes the transfer or runs the next transaction. Will call the pipe transferEndCallback at the end of transfer, if configured.
4.16.7.8.2 Macros
#define PipeTransferIndexGet(pipe) (((pipe).address * 2) + (pipe).direction)
4.16.7.8.3 Variables
STATIC USB_PIPE_TRANSFER_t pipeTransfer [USB_EP_NUM *2]
4.16.7.8.4 Detailed Description
API module for usb_peripheral covering low level USB transaction functions.
USBPERIPHERALREADWRITE Peripheral Read/Write Source File
4.16.7.8.5 Macro Definition Documentation
PipeTransferIndexGet
#define PipeTransferIndexGet( pipe) (((pipe).address * 2) + (pipe).direction)
4.16.7.8.6 Variable Documentation
pipeTransfer
STATIC USB_PIPE_TRANSFER_t pipeTransfer[USB_EP_NUM *2]
4.16.7.9 source/usb_peripheral_read_write.h File Reference
#include <stdbool.h> #include <stdint.h> #include "usb_common_elements.h" #include "usb_protocol_headers.h"
4.16.7.9.1 Functions
RETURN_CODE_t USB_TransactionStart (USB_PIPE_t pipe)
Starts sending or receiving data on an endpoint by clearing BUSNACK. Used as a final step while setting up a transaction on the bus.
RETURN_CODE_t USB_TransactionAbort (USB_PIPE_t pipe)
Aborts the next transaction on an endpoint by setting BUSNACK. Used to stop exchanging data on an endpoint. The device will start NAKing requests from the host after calling this API.
RETURN_CODE_t USB_TransactionCompleteAck (USB_PIPE_t pipe)
Acknowledges the Transaction Complete status condition by clearing the Transaction Complete status bit. Used to clear the Transaction Complete status bit after a transaction has successfully completed.
bool USB_TransactionIsCompleted (void)
Helper function to return the endpoint transaction complete condition.
RETURN_CODE_t USB_TransactionCompletedPipeGet (USB_PIPE_t *pipe)
Returns the pipe address and direction for the latest completed transaction.
RETURN_CODE_t USB_PipeReset (USB_PIPE_t pipe)
Resets the pipe.
USB_TRANSFER_STATUS_t USB_PipeStatusGet (USB_PIPE_t pipe)
Gets the current status of pipe.
bool USB_PipeStatusIsBusy (USB_PIPE_t pipe)
Checks if the pipe status is busy.
void USB_PipeDataPtrSet (USB_PIPE_t pipe, uint8_t *dataPtr)
Configures the pointer for the data transfer in a given pipe.
uint8_t * USB_PipeDataPtrGet (USB_PIPE_t pipe)
Gets the current data pointer for a given pipe.
void USB_PipeDataToTransferSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of pipe data to transfer.
uint16_t USB_PipeDataToTransferSizeGet (USB_PIPE_t pipe)
Gets the size of pipe data to transfer.
uint16_t USB_PipeDataTransferredSizeGet (USB_PIPE_t pipe)
Gets the size of the transferred pipe data.
void USB_PipeDataTransferredSizeSet (USB_PIPE_t pipe, uint16_t dataSize)
Sets the size of the transferred pipe data.
void USB_PipeDataTransferredSizeReset (USB_PIPE_t pipe)
Resets the size of transferred pipe data.
void USB_PipeTransferZLP_Enable (USB_PIPE_t pipe)
Enables a ZLP on a transfer. It is enabled by default if the AZLP static config is enabled for the pipe.
void USB_PipeTransferEndCallbackRegister (USB_PIPE_t pipe, USB_TRANSFER_END_CALLBACK_t callback)
Sets the callback for transfer end.
void USB_PipeTransferEndCallback (USB_PIPE_t pipe)
Calls the callback for transfer end.
RETURN_CODE_t USB_InTransactionRun (USB_PIPE_t pipe)
Checks the correctness of IN transactions and runs them.
RETURN_CODE_t USB_OutTransactionRun (USB_PIPE_t pipe)
Checks the correctness OUT transactions and runs them.
RETURN_CODE_t USB_PipeTransactionComplete (USB_PIPE_t pipe)
Handles completed IN and OUT transactions. Processes the completed transaction and either completes the transfer or runs the next transaction. Will call the pipe transferEndCallback at the end of transfer, if configured.
4.16.7.9.2 Detailed Description
USBPERIPHERALREADWRITE Peripheral Read/Write Header File