29#if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
55 hw |= (uint16_t)*p << 8U;
90 ((uint32_t)usbp->
setup[1] << 8U))) {
117#if USB_SET_ADDRESS_MODE == USB_EARLY_SET_ADDRESS
145#if defined(USB_SET_CONFIGURATION_OLD_BEHAVIOR)
162 if (usbp->
setup[2] != 0U) {
181 if ((usbp->
setup[4] & 0x80U) != 0U) {
221 if ((usbp->
setup[4] & 0x0FU) != 0U) {
222 if ((usbp->
setup[4] & 0x80U) != 0U) {
237 if ((usbp->
setup[4] & 0x0FU) != 0U) {
238 if ((usbp->
setup[4] & 0x80U) != 0U) {
319#if defined(USB_LLD_ENHANCED_API)
363#if USB_USE_WAIT == TRUE
364 if (usbp->
epc[i] != NULL) {
403 usbp->
epc[ep] = epcp;
439#if USB_USE_WAIT == TRUE
441 if (usbp->
epc[i] != NULL) {
480 uint8_t *buf,
size_t n) {
488 usbp->
receiving |= (uint16_t)((
unsigned)1U << (
unsigned)ep);
497#if USB_USE_WAIT == TRUE
519 const uint8_t *buf,
size_t n) {
527 usbp->
transmitting |= (uint16_t)((
unsigned)1U << (
unsigned)ep);
536#if USB_USE_WAIT == TRUE
544#if (USB_USE_WAIT == TRUE) || defined(__DOXYGEN__)
711#if USB_USE_WAIT == TRUE
713 if (usbp->
epc[i] != NULL) {
763 #if USB_USE_WAIT == TRUE
768 if (usbp->
epc[i] != NULL) {
854#if (USB_SET_ADDRESS_ACK_HANDLING == USB_SET_ADDRESS_ACK_HW)
865 if (usbp->
ep0n > max) {
870 if (usbp->
ep0n != 0U) {
881#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
886 usb_lld_end_setup(usbp, ep);
892 if (usbp->
ep0n != 0U) {
903#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
908 usb_lld_end_setup(usbp, ep);
934 if ((usbp->
ep0n < max) &&
946#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
951 usb_lld_end_setup(usbp, ep);
998#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
1003 usb_lld_end_setup(usbp, ep);
1009#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
static void osalSysLock(void)
Enters a critical zone from thread context.
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
static void osalSysLockFromISR(void)
Enters a critical zone from ISR context.
msg_t osalThreadSuspendS(thread_reference_t *trp)
Sends the current thread sleeping and sets a reference variable.
void osalOsRescheduleS(void)
Checks if a reschedule is required and performs it.
void osalThreadResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
static void osalSysUnlockFromISR(void)
Leaves a critical zone from ISR context.
#define osalDbgAssert(c, remark)
Condition assertion.
#define osalDbgCheck(c)
Function parameters check.
#define osalDbgCheckClassI()
I-Class state check.
#define USB_RTYPE_RECIPIENT_MASK
static void set_address(USBDriver *usbp)
SET ADDRESS transaction callback.
#define usbGetDriverStateI(usbp)
Returns the driver state.
static bool default_handler(USBDriver *usbp)
Standard requests handler.
void usb_lld_stop(USBDriver *usbp)
Deactivates the USB peripheral.
void usb_lld_set_address(USBDriver *usbp)
Sets the USB address.
#define USB_FEATURE_ENDPOINT_HALT
#define USB_REQ_GET_INTERFACE
uint8_t usbep_t
Type of an endpoint identifier.
void usb_lld_clear_in(USBDriver *usbp, usbep_t ep)
Brings an IN endpoint in the active state.
void _usb_suspend(USBDriver *usbp)
USB suspend routine.
static const uint8_t zero_status[]
void usbDisableEndpointsI(USBDriver *usbp)
Disables all the active endpoints.
void usb_lld_init(void)
Low level USB driver initialization.
#define USB_REQ_SET_INTERFACE
msg_t usbTransmit(USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n)
Performs a transmit transaction on an IN endpoint.
void usbStartReceiveI(USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n)
Starts a receive transaction on an OUT endpoint.
#define USB_REQ_SET_FEATURE
void _usb_wakeup(USBDriver *usbp)
USB wake-up routine.
#define usbGetReceiveTransactionSizeX(usbp, ep)
Returns the exact size of a receive transaction.
#define USB_REQ_CLEAR_FEATURE
void usbInit(void)
USB Driver initialization.
#define USB_RTYPE_TYPE_STD
bool usbStallTransmitI(USBDriver *usbp, usbep_t ep)
Stalls an IN endpoint.
msg_t usbReceive(USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n)
Performs a receive transaction on an OUT endpoint.
void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep)
Enables an endpoint.
usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep)
Returns the status of an OUT endpoint.
void _usb_ep0setup(USBDriver *usbp, usbep_t ep)
Default EP0 SETUP callback.
void usbStartTransmitI(USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n)
Starts a transmit transaction on an IN endpoint.
msg_t usbStart(USBDriver *usbp, const USBConfig *config)
Configures and activates the USB peripheral.
#define USB_RTYPE_DIR_DEV2HOST
#define USB_REQ_SET_CONFIGURATION
static uint16_t get_hword(uint8_t *p)
#define USB_RTYPE_RECIPIENT_ENDPOINT
void usbInitEndpointI(USBDriver *usbp, usbep_t ep, const USBEndpointConfig *epcp)
Enables an endpoint.
#define USB_REQ_SYNCH_FRAME
#define usbGetReceiveStatusI(usbp, ep)
Returns the status of an OUT endpoint.
#define usbSetupTransfer(usbp, buf, n, endcb)
Request transfer setup.
#define USB_MAX_ENDPOINTS
Maximum endpoint address.
void usb_lld_reset(USBDriver *usbp)
USB low level reset routine.
#define usbGetTransmitStatusI(usbp, ep)
Returns the status of an IN endpoint.
usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep)
Returns the status of an IN endpoint.
void usb_lld_disable_endpoints(USBDriver *usbp)
Disables all the active endpoints except the endpoint zero.
#define USB_REQ_GET_STATUS
static const uint8_t active_status[]
void usb_lld_start_out(USBDriver *usbp, usbep_t ep)
Starts a receive operation on an OUT endpoint.
#define usbReadSetup(usbp, ep, buf)
Reads a setup packet from the dedicated packet buffer.
#define usb_lld_wakeup_host(usbp)
Start of host wake-up procedure.
void usb_lld_start(USBDriver *usbp)
Configures and activates the USB peripheral.
#define USB_REQ_SET_ADDRESS
void usb_lld_start_in(USBDriver *usbp, usbep_t ep)
Starts a transmit operation on an IN endpoint.
void usbStop(USBDriver *usbp)
Deactivates the USB peripheral.
#define USB_FEATURE_DEVICE_REMOTE_WAKEUP
static const uint8_t halted_status[]
void _usb_ep0in(USBDriver *usbp, usbep_t ep)
Default EP0 IN callback.
#define _usb_isr_invoke_event_cb(usbp, evt)
Common ISR code, usb event callback.
void _usb_reset(USBDriver *usbp)
USB reset routine.
#define USB_RTYPE_DIR_MASK
void usb_lld_clear_out(USBDriver *usbp, usbep_t ep)
Brings an OUT endpoint in the active state.
void usbWakeupHost(USBDriver *usbp)
Host wake-up procedure.
#define USB_RTYPE_RECIPIENT_INTERFACE
void usb_lld_stall_out(USBDriver *usbp, usbep_t ep)
Brings an OUT endpoint in the stalled state.
void usb_lld_stall_in(USBDriver *usbp, usbep_t ep)
Brings an IN endpoint in the stalled state.
#define USB_REQ_GET_DESCRIPTOR
void usbObjectInit(USBDriver *usbp)
Initializes the standard part of a USBDriver structure.
#define USB_REQ_GET_CONFIGURATION
#define USB_REQ_SET_DESCRIPTOR
bool usbStallReceiveI(USBDriver *usbp, usbep_t ep)
Stalls an OUT endpoint.
#define USB_RTYPE_TYPE_MASK
void _usb_ep0out(USBDriver *usbp, usbep_t ep)
Default EP0 OUT callback.
#define USB_RTYPE_RECIPIENT_DEVICE
@ USB_EP0_OUT_WAITING_STS
#define MSG_RESET
Wakeup caused by a reset condition.
Type of an USB driver configuration structure.
usbgetdescriptor_t get_descriptor_cb
Device GET_DESCRIPTOR request callback.
usbreqhandler_t requests_hook_cb
Requests hook callback.
Type of an USB descriptor.
const uint8_t * ud_string
Pointer to the descriptor.
size_t ud_size
Descriptor size in unicode characters.
Structure representing an USB driver.
uint8_t setup[8]
Setup packet buffer.
size_t ep0n
Number of bytes yet to be transferred through endpoint 0.
uint16_t status
Current USB device status.
void * out_params[USB_MAX_ENDPOINTS]
Fields available to user, it can be used to associate an application-defined handler to an OUT endpoi...
void * in_params[USB_MAX_ENDPOINTS]
Fields available to user, it can be used to associate an application-defined handler to an IN endpoin...
uint8_t configuration
Current USB device configuration.
usbstate_t saved_state
State of the driver when a suspend happened.
usbep0state_t ep0state
Endpoint 0 state.
const USBEndpointConfig * epc[USB_MAX_ENDPOINTS+1]
Active endpoints configurations.
usbstate_t state
Driver state.
uint16_t receiving
Bit map of the receiving OUT endpoints.
usbcallback_t ep0endcb
Endpoint 0 end transaction callback.
const USBConfig * config
Current configuration data.
uint8_t address
Assigned USB address.
uint16_t transmitting
Bit map of the transmitting IN endpoints.
uint8_t * ep0next
Next position in the buffer to be transferred through endpoint 0.
Type of an USB endpoint configuration structure.
USBOutEndpointState * out_state
USBEndpointState associated to the OUT endpoint.
uint16_t in_maxsize
IN endpoint maximum packet size.
USBInEndpointState * in_state
USBEndpointState associated to the IN endpoint.
Type of an IN endpoint state structure.
const uint8_t * txbuf
Pointer to the transmission linear buffer.
thread_reference_t thread
Waiting thread.
size_t txsize
Requested transmit transfer size.
size_t txcnt
Transmitted bytes so far.
Type of an OUT endpoint state structure.
size_t rxsize
Requested receive transfer size.
uint8_t * rxbuf
Pointer to the receive linear buffer.
thread_reference_t thread
Waiting thread.
size_t rxcnt
Received bytes so far.