PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
USB General HAL Functionalities

Data Structures

struct  stc_bmRequestType
 
struct  stc_usb_request
 
struct  stc_usb_setup_package
 
struct  stc_usbdevice_stringdescriptor
 
struct  stc_usbdevice_reportdescriptor
 
struct  stc_usb_sof_timeout_handler
 
struct  stc_usbn_endpoint_buffer
 
struct  stc_usbn_endpoint_data
 
struct  stc_usb_intern_data
 
struct  stc_usbn_instance_data
 USB module internal data, storing internal information for each enabled USB instance. More...
 
struct  stc_usb_config
 Usb configuration. More...
 

Macros

#define OFF   0U
 
#define ON   1U
 
#define USB_USES_DMA   OFF
 
#define USB_USE_STANDALONE   OFF
 
#define USB0_DEVICE_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB0_DEVICE
 
#define USB0_HOST_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB0_HOST
 
#define USB1_DEVICE_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB1_DEVICE
 
#define USB1_HOST_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB1_HOST
 
#define FM_PERIPHERAL_ENABLE_USB0_HOST   PDL_PERIPHERAL_ENABLE_USB0_HOST
 
#define FM_PERIPHERAL_ENABLE_USB0_DEVICE   PDL_PERIPHERAL_ENABLE_USB0_DEVICE
 
#define FM_PERIPHERAL_ENABLE_USB1_HOST   PDL_PERIPHERAL_ENABLE_USB1_HOST
 
#define FM_PERIPHERAL_ENABLE_USB1_DEVICE   PDL_PERIPHERAL_ENABLE_USB1_DEVICE
 
#define USBDEVICECDCCOM_ENABLED   PDL_USBDEVICECDCCOM_ENABLED
 
#define USBDEVICEHIDCOM_ENABLED   PDL_USBDEVICEHIDCOM_ENABLED
 
#define USBDEVICEHIDJOYSTICK_ENABLED   PDL_USBDEVICEHIDJOYSTICK_ENABLED
 
#define USBDEVICEHIDKEYBOARD_ENABLED   PDL_USBDEVICEHIDKEYBOARD_ENABLED
 
#define USBDEVICEHIDMOUSE_ENABLED   PDL_USBDEVICEHIDMOUSE_ENABLED
 
#define USBDEVICELIBUSB_ENABLED   PDL_USBDEVICELIBUSB_ENABLED
 
#define USBDEVICEPRINTER_ENABLED   PDL_USBDEVICEPRINTER_ENABLED
 
#define USBHOSTHIDCOM_ENABLED   PDL_USBHOSTHIDCOM_ENABLED
 
#define USBHOSTHIDKEYBOARD_ENABLED   PDL_USBHOSTHIDKEYBOARD_ENABLED
 
#define USBHOSTHIDMOUSE_ENABLED   PDL_USBHOSTHIDMOUSE_ENABLED
 
#define USBHOSTMASSSTORAGE_ENABLED   PDL_USBHOSTMASSSTORAGE_ENABLED
 
#define FM_PERIPHERAL_ENABLE_USB0   OFF
 
#define FM_PERIPHERAL_ENABLE_USB1   OFF
 
#define FM_PERIPHERAL_USB_HOST_ENABLED   OFF
 
#define USB_DISBALE_HOST_FUNCTIONALITY   OFF
 
#define FM_PERIPHERAL_USB_DEVICE_ENABLED   OFF
 
#define USB_DISBALE_DEVICE_FUNCTIONALITY   OFF
 
#define USB_ENABLED   ((FM_PERIPHERAL_ENABLE_USB0 == ON) || (FM_PERIPHERAL_ENABLE_USB1 == ON))
 
#define USB_INTERFACES_COUNT   ((FM_PERIPHERAL_ENABLE_USB0) + (FM_PERIPHERAL_ENABLE_USB1))
 
#define USB_INSTANCE_COUNT   ((FM_PERIPHERAL_ENABLE_USB0) + (FM_PERIPHERAL_ENABLE_USB1))
 
#define USB_DEVICE_INTERFACES_COUNT   ((FM_PERIPHERAL_ENABLE_USB0_DEVICE) + (FM_PERIPHERAL_ENABLE_USB1_DEVICE))
 
#define USB_HOST_INTERFACES_COUNT   ((FM_PERIPHERAL_ENABLE_USB0_HOST) + (FM_PERIPHERAL_ENABLE_USB1_HOST))
 
#define USBDBG(x)
 
#define USBDBGVAL8(x, y)
 
#define USBDBGVAL16(x, y)
 
#define USBDBGVAL32(x, y)
 
#define DBGPROCENTER(x)
 
#define DBGPROCRETURN(x)
 
#define DBGSPACES(x)
 
#define SETACTIVEFLAG(x)   while((x) == FALSE) (x) = TRUE;
 
#define CLEARACTIVEFLAG(x)   while((x) == TRUE) (x) = FALSE;
 
#define USB_ZERO_STRUCT(x)   memset(&x,0,sizeof(x))
 
#define ZERO_STRUCT(x)   memset(&x,0,sizeof(x))
 
#define USBDESCR_DEVICE   1
 
#define USBDESCR_CONFIG   2
 
#define USBDESCR_STRING   3
 
#define USBDESCR_INTERFACE   4
 
#define USBDESCR_ENDPOINT   5
 
#define USB_DEVREQ_STDTYPE   0x00
 
#define USB_DEVREQ_CLSTYPE   0x20
 
#define USB_DEVREQ_VNDTYPE   0x40
 
#define USB_DEVREQ_GET_DESC   0x06
 
#define USB_DEVREQ_SET_DESC   0x07
 
#define USB_DEVREQ_SET_IDLE   0x0A
 
#define USB_GET_STATUS   0x00
 
#define USB_CLEAR_FEATURE   0x01
 
#define USB_SET_FEATURE   0x03
 
#define USB_SET_ADDRESS   0x05
 
#define USB_GET_DESCRIPTOR   0x06
 
#define USB_SET_DESCRIPTOR   0x07
 
#define USB_GET_CONFIGURATION   0x08
 
#define USB_SET_CONFIGURATION   0x09
 
#define USB_GET_INTERFACE   0x0A
 
#define USB_SET_INTERFACE   0x0B
 
#define USB_SYNCH_FRAME   0x0C
 
#define USBATTR_BUSPOWER   0x80
 
#define USBATTR_SELFPOWER   0xC0
 
#define USBATTR_REMOTEWAKE   0x20
 
#define USB_FUNC_INTR_IN   0xF000
 
#define USB_FUNC_INTR_OUT   0xE000
 
#define USB_FUNC_BULK_IN   0xD000
 
#define USB_FUNC_BULK_OUT   0xC000
 
#define USB_MASK_EPC_PKS   0x007F
 
#define USB_MASK_EPC_PKS1   0x01FF
 
#define USB_MASK_EPC_STAL   0x0200
 
#define USB_MASK_EPC_NULE   0x0400
 
#define USB_MASK_EPC_DMAE   0x0800
 
#define USB_MASK_EPC_DIR   0x1000
 
#define USB_MASK_EPC_TYPE   0x6000
 
#define USB_MASK_EPC_EPEN   0x8000
 
#define USB_MASK_EPS_DRQIIE   0x4000
 
#define USB_MASK_EPS_BFINI   0x8000
 
#define USB_MASK_EPS_BFINI   0x8000
 
#define USB_MASK_EPS_SIZE1   0x01FF
 
#define USB_MASK_EPS_SIZE   0x007F
 
#define USB_MASK_EPS_SPK   0x0200
 
#define USB_MASK_EPS_DRQI   0x0400
 
#define USB_MASK_EPS_DRQO   0x0400
 
#define USB_MASK_EPS_DRQ   0x0400
 
#define USB_MASK_EPS_BUSY   0x0800
 
#define USB_MASK_EPS_SPKIE   0x2000
 
#define USB_MASK_EPS_DRQIE   0x4000
 
#define USB_MASK_EPS_DRQOIE   0x4000
 
#define BITMASK_ISSET(x, y)   ((x & y) > 0)
 
#define BITMASK_ISCLEARED(x, y)   ((x & y) == 0)
 
#define BITMASK_SET(x, y)   x |= y
 
#define BITMASK_CLEAR(x, y)   x &= ~y
 
#define __USBBITDEFINITIONS_H__
 
#define _UDCC_RST   (1 << 7)
 Function reset bit. More...
 
#define _UDCC_RESUM   (1 << 6)
 Resume setting bit. More...
 
#define _UDCC_HCONX   (1 << 5)
 Host connection bit. More...
 
#define _UDCC_USTP   (1 << 4)
 USB operation clock stop bit. More...
 
#define _UDCC_RFBK   (1 << 1)
 Data toggle mode bit (Rate feedback mode) More...
 
#define _UDCC_PWC   (1 << 0)
 Power supply control bit. More...
 
#define _EP0C_PKS0   0x7F
 EP0 packet size setting bits. More...
 
#define _EP0C_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EPNC_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EPNC_NULE   (1 << 10)
 NULL automatic transfer enable bit. More...
 
#define _EPNC_DMAE   (1 << 11)
 DMA automatic transfer enable bit. More...
 
#define _EPNC_DIR   (1 << 12)
 Endpoint direction selection bit. More...
 
#define _EPNC_TYPE   0x6000
 Endpoint transfer type bit. More...
 
#define _EPNC_EPEN   (1 << 15)
 Endpoint Enable bit. More...
 
#define _EP1C_PKS1   0x1FF
 EP1 packet size setting bits. More...
 
#define _EP1C_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EP1C_NULE   (1 << 10)
 NULL automatic transfer enable bit. More...
 
#define _EP1C_DMAE   (1 << 11)
 DMA automatic transfer enable bit. More...
 
#define _EP1C_DIR   (1 << 12)
 Endpoint direction selection bit. More...
 
#define _EP1C_TYPE   0x6000
 Endpoint transfer type bit. More...
 
#define _EP1C_EPEN   (1 << 15)
 Endpoint Enable bit. More...
 
#define _EP2C_PKS2   0xFF
 EP2 packet size setting bits. More...
 
#define _EP2C_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EP2C_NULE   (1 << 10)
 NULL automatic transfer enable bit. More...
 
#define _EP2C_DMAE   (1 << 11)
 DMA automatic transfer enable bit. More...
 
#define _EP2C_DIR   (1 << 12)
 Endpoint direction selection bit. More...
 
#define _EP2C_TYPE   0x6000
 Endpoint transfer type bit. More...
 
#define _EP2C_EPEN   (1 << 15)
 Endpoint Enable bit. More...
 
#define _EP3C_PKS3   0xFF
 EP3 packet size setting bits. More...
 
#define _EP3C_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EP3C_NULE   (1 << 10)
 NULL automatic transfer enable bit. More...
 
#define _EP3C_DMAE   (1 << 11)
 DMA automatic transfer enable bit. More...
 
#define _EP3C_DIR   (1 << 12)
 Endpoint direction selection bit. More...
 
#define _EP3C_TYPE   0x6000
 Endpoint transfer type bit. More...
 
#define _EP3C_EPEN   (1 << 15)
 Endpoint Enable bit. More...
 
#define _EP4C_PKS4   0xFF
 EP4 packet size setting bits. More...
 
#define _EP4C_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EP4C_NULE   (1 << 10)
 NULL automatic transfer enable bit. More...
 
#define _EP4C_DMAE   (1 << 11)
 DMA automatic transfer enable bit. More...
 
#define _EP4C_DIR   (1 << 12)
 Endpoint direction selection bit. More...
 
#define _EP4C_TYPE   0x6000
 Endpoint transfer type bit. More...
 
#define _EP4C_EPEN   (1 << 15)
 Endpoint Enable bit. More...
 
#define _EP5C_PKS5   0xFF
 EP packet size setting bits. More...
 
#define _EP5C_STAL   (1 << 9)
 STALL set bit. More...
 
#define _EP5C_NULE   (1 << 10)
 NULL automatic transfer enable bit. More...
 
#define _EP5C_DMAE   (1 << 11)
 DMA automatic transfer enable bit. More...
 
#define _EP5C_DIR   (1 << 12)
 Endpoint direction selection bit. More...
 
#define _EP5C_TYPE   0x6000
 Endpoint transfer type bit. More...
 
#define _EP5C_EPEN   (1 << 15)
 Endpoint Enable bit. More...
 
#define _EPC_TYPE_BULK   0x4000
 
#define _EPC_TYPE_INTERRUPT   0x6000
 
#define _UDCS_CONF   (1 << 0)
 Configuration detection bit. More...
 
#define _UDCS_SETP   (1 << 1)
 Setup stage detection bit. More...
 
#define _UDCS_WKUP   (1 << 2)
 Wake-up detection bit. More...
 
#define _UDCS_BRST   (1 << 3)
 Bus reset detection bit. More...
 
#define _UDCS_SOF   (1 << 4)
 SOF reception detection bit. More...
 
#define _UDCS_SUSP   (1 << 5)
 Suspend detection bit. More...
 
#define _UDCIE_CONFIE   (1 << 0)
 Configuration interrupt enable bit. More...
 
#define _UDCIE_CONFN   (1 << 1)
 Configuration number bit. More...
 
#define _UDCIE_WKUPIE   (1 << 2)
 Wake-up interrupt enable bit. More...
 
#define _UDCIE_BRSTIE   (1 << 3)
 Bus reset interrupt enable bit. More...
 
#define _UDCIE_SOFIE   (1 << 4)
 SOF receive interrupt enable bit. More...
 
#define _UDCIE_SUSPIE   (1 << 5)
 Suspend interrupt enable bit. More...
 
#define _EPNS_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EPNS_DRQ   (1 << 10)
 Packet transfer interrupt flag bit. More...
 
#define _EPNS_BUSY   (1 << 11)
 Busy flag bit. More...
 
#define _EPNS_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EPNS_DRQIE   (1 << 14)
 DRQ Interrupt enable bit. More...
 
#define _EPNS_BFINI   (1 << 15)
 Transmission/Reception buffer initialization bit. More...
 
#define _EP0IS_DRQI   (1 << 10)
 Transmit Data interrupt request bit. More...
 
#define _EP0IS_DRQIIE   (1 << 14)
 Transmit Data Interrupt enable bit. More...
 
#define _EP0IS_BFINI   (1 << 15)
 Transmission buffer initialization bit. More...
 
#define _EP0OS_SIZE   0x7F
 Packet size bits. More...
 
#define _EP0OS_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EP0OS_DRQO   (1 << 10)
 Received data interrupt flag bit. More...
 
#define _EP0OS_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EP0OS_DRQOIE   (1 << 14)
 Receive Data Interrupt enable bit. More...
 
#define _EP0OS_BFINI   (1 << 15)
 Receive buffer initialization bit. More...
 
#define _EP1S_SIZE   0x1FF
 Packet size bits. More...
 
#define _EP1S_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EP1S_DRQ   (1 << 10)
 Packet transfer interrupt flag bit. More...
 
#define _EP1S_BUSY   (1 << 11)
 Busy flag bit. More...
 
#define _EP1S_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EP1S_DRQIE   (1 << 14)
 DRQ Interrupt enable bit. More...
 
#define _EP1S_BFINI   (1 << 15)
 Transmission/Reception buffer initialization bit. More...
 
#define _EP2S_SIZE   0xFF
 Packet size bits. More...
 
#define _EP2S_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EP2S_DRQ   (1 << 10)
 Packet transfer interrupt flag bit. More...
 
#define _EP2S_BUSY   (1 << 11)
 Busy flag bit. More...
 
#define _EP2S_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EP2S_DRQIE   (1 << 14)
 DRQ Interrupt enable bit. More...
 
#define _EP2S_BFINI   (1 << 15)
 Transmission/Reception buffer initialization bit. More...
 
#define _EP3S_SIZE   0xFF
 Packet size bits. More...
 
#define _EP3S_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EP3S_DRQ   (1 << 10)
 Packet transfer interrupt flag bit. More...
 
#define _EP3S_BUSY   (1 << 11)
 Busy flag bit. More...
 
#define _EP3S_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EP3S_DRQIE   (1 << 14)
 DRQ Interrupt enable bit. More...
 
#define _EP3S_BFINI   (1 << 15)
 Transmission/Reception buffer initialization bit. More...
 
#define _EP4S_SIZE   0xFF
 Packet size bits. More...
 
#define _EP4S_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EP4S_DRQ   (1 << 10)
 Packet transfer interrupt flag bit. More...
 
#define _EP4S_BUSY   (1 << 11)
 Busy flag bit. More...
 
#define _EP4S_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EP4S_DRQIE   (1 << 14)
 DRQ Interrupt enable bit. More...
 
#define _EP4S_BFINI   (1 << 15)
 Transmission/Reception buffer initialization bit. More...
 
#define _EP5S_SIZE   0xFF
 Packet size bits. More...
 
#define _EP5S_SPK   (1 << 9)
 Short Packet interrupt flag bit. More...
 
#define _EP5S_DRQ   (1 << 10)
 Packet transfer interrupt flag bit. More...
 
#define _EP5S_BUSY   (1 << 11)
 Busy flag bit. More...
 
#define _EP5S_SPKIE   (1 << 13)
 Short packet interrupt enable bit. More...
 
#define _EP5S_DRQIE   (1 << 14)
 DRQ Interrupt enable bit. More...
 
#define _EP5S_BFINI   (1 << 15)
 Transmission/Reception buffer initialization bit. More...
 
#define _HCNT_HOST   (1 << 0)
 HOST Mode bit. More...
 
#define _HCNT_URST   (1 << 1)
 USB Bus Reset bit. More...
 
#define _HCNT_SOFIRE   (1 << 2)
 SOF interrupt Enable bit. More...
 
#define _HCNT_DIRE   (1 << 3)
 Disconnection interrupt Enable bit. More...
 
#define _HCNT_CNNIRE   (1 << 4)
 Connection interrupt Enable bit. More...
 
#define _HCNT_CMPIRE   (1 << 5)
 Completion interrupt Enable bit. More...
 
#define _HCNT_URIRE   (1 << 6)
 USB bus Reset interrupt Enable bit. More...
 
#define _HCNT_RWKIRE   (1 << 7)
 Remote Wake-up interrupt Enable bit. More...
 
#define _HCNT_RETRY   (1 << 8)
 Retry enable bit. More...
 
#define _HCNT_CANCEL   (1 << 9)
 Token cancel enable bit. More...
 
#define _HCNT_SOFSTEP   (1 << 10)
 SOF interrupt trigger bit. More...
 
#define _HIRQ_SOFIRQ   (1 << 0)
 HOST Mode bit. More...
 
#define _HIRQ_DIRQ   (1 << 1)
 USB Bus Reset bit. More...
 
#define _HIRQ_CNNIRQ   (1 << 2)
 SOF interrupt Enable bit. More...
 
#define _HIRQ_CMPIRQ   (1 << 3)
 Disconnection interrupt Enable bit. More...
 
#define _HIRQ_URIRQ   (1 << 4)
 Connection interrupt Enable bit. More...
 
#define _HIRQ_RWKIRQ   (1 << 5)
 Completion interrupt Enable bit. More...
 
#define _HIRQ_TCAN   (1 << 7)
 Remote Wake-up interrupt Enable bit. More...
 
#define _HERR_HS   0x03
 Handshake Status. More...
 
#define _HERR_STUFF   (1 << 2)
 Stuffing Error bit. More...
 
#define _HERR_TGERR   (1 << 3)
 Toggle Error bit. More...
 
#define _HERR_CRC   (1 << 4)
 CRC Error bit. More...
 
#define _HERR_TOUT   (1 << 5)
 Time Out bit. More...
 
#define _HERR_RERR   (1 << 6)
 Receive Error bit. More...
 
#define _HERR_LSTSOF   (1 << 7)
 Lost SOF bit. More...
 
#define _HSTATE_CSTAT   (1 << 0)
 Connection status bit. More...
 
#define _HSTATE_TMODE   (1 << 1)
 Transfer Mode bit. More...
 
#define _HSTATE_SUSP   (1 << 2)
 Suspend bit. More...
 
#define _HSTATE_SOFBUSY   (1 << 3)
 SOF timer operation bit. More...
 
#define _HSTATE_CLKSEL   (1 << 4)
 Clock Selection bit (Full / Low Speed) More...
 
#define _HSTATE_ALIVE   (1 << 5)
 keep alive bit (for low speed) More...
 
#define __IO   volatile
 
#define __USBSPEC_H__
 
#define GET_DESCRIPTOR   0x06
 
#define USB_DEVICE_DESCRIPTOR_TYPE   0x01
 Usb Device Descriptor Type. More...
 
#define USB_CONFIGURATION_DESCRIPTOR_TYPE   0x02
 Usb Configuration Descriptor Type. More...
 
#define USB_STRING_DESCRIPTOR_TYPE   0x03
 Usb String Descriptor Type. More...
 
#define USB_INTERFACE_DESCRIPTOR_TYPE   0x04
 Usb Interface Descriptor Type. More...
 
#define USB_ENDPOINT_DESCRIPTOR_TYPE   0x05
 Usb Endpoint Descriptor Type. More...
 
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE   0x06
 Usb Device Qualifier Descriptor Type. More...
 
#define USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE   0x07
 Usb Other Speed Configuratuion Descriptor Type. More...
 
#define USB_HID_DESCRIPTOR_TYPE   0x21
 Usb HID Descriptor Type. More...
 
#define USB_IN_DIRECTION   0x80
 Usb IN direction. More...
 
#define USB_OUT_DIRECTION   0x00
 Usb OUT direction. More...
 
#define USB_EP_TYPE_CONTROL   0x00
 Control Endpoint Type. More...
 
#define USB_EP_TYPE_ISO   0x01
 ISO Endpoint Type. More...
 
#define USB_EP_TYPE_BULK   0x02
 Bulk Endpoint Type. More...
 
#define USB_EP_TYPE_INT   0x03
 Interrupt Endpoint Type. More...
 
#define bL3_FM3_GPIO_EPFR00_USB0PE   *((volatile unsigned int*)(0x4266C024UL))
 
#define bL3_FM3_GPIO_PFR6_P1   *((volatile unsigned int*)(0x42660304UL))
 
#define bL3_FM3_GPIO_SPSR_USB0C   *((volatile unsigned int*)(0x4266B010UL))
 
#define bL3_FM3_GPIO_EPFR00_USB1PE   *((volatile unsigned int*)(0x4266C034UL))
 
#define bL3_FM3_GPIO_PFR2_P0   *((volatile unsigned int*)(0x42660100UL))
 
#define bL3_FM3_GPIO_SPSR_USB1C   *((volatile unsigned int*)(0x4266B014UL))
 

Typedefs

typedef struct stc_bmRequestType stc_bmRequestType_t
 
typedef struct stc_usb_request stc_usb_request_t
 
typedef struct
stc_usb_setup_package 
stc_usb_setup_package_t
 
typedef struct
stc_usbdevice_stringdescriptor 
stc_usbdevice_stringdescriptor_t
 
typedef struct
stc_usbdevice_reportdescriptor 
stc_usbdevice_reportdescriptor_t
 
typedef struct
stc_usb_sof_timeout_handler 
stc_usb_sof_timeout_handler_t
 
typedef enum en_usb_extint_param en_usb_extint_param_t
 
typedef enum en_usb_gpio_param en_usb_gpio_param_t
 
typedef boolean_t(* usb_device_alternative_hconx_t )(en_usb_gpio_param_t enType)
 
typedef boolean_t(* usb_device_vbus_t )(en_usb_extint_param_t enType)
 
typedef boolean_t(* usb_host_vbus_t )(en_usb_gpio_param_t enType)
 
typedef boolean_t(* usb_host_pulldown_t )(en_usb_gpio_param_t enType)
 
typedef boolean_t(* usb_host_overcurrent_t )(en_usb_extint_param_t enType)
 
typedef enum en_usb_ep_type en_usb_ep_type_t
 
typedef struct
stc_usbn_endpoint_buffer 
stc_usbn_endpoint_buffer_t
 
typedef void(* usb_device_init_t )(stc_usbn_t *pstcUsb, struct stc_usb_config *pstcConfig)
 
typedef void(* usb_host_init_t )(stc_usbn_t *pstcUsb, struct stc_usb_config *pstcConfig)
 
typedef void(* usb_endpoint_datatransferred_func_ptr_t )(stc_usbn_t *pstcUsb, struct stc_usbn_endpoint_data *pstcEndpoint)
 
typedef void(* usb_connect_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_disconnect_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_conf_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_setp_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_susp_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_wkup_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_brst_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_sof_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_tcan_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_rwkirq_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_urirq_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_cmpirq_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_cnnirq_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef void(* usb_dirq_isr_func_ptr_t )(stc_usbn_t *pstcUsb)
 
typedef enum en_usb_endpoint_status en_usb_endpoint_status_t
 USB control stage. More...
 
typedef struct
stc_usbn_endpoint_data 
stc_usbn_endpoint_data_t
 
typedef enum en_usb_instance_index en_usb_instance_index_t
 Enumeration to define an index for each enabled USB instance. More...
 
typedef enum
en_usb_dma_instance_index 
en_usb_dma_instance_index_t
 Enumeration to define an index for each enabled USB DMA instance. More...
 
typedef struct stc_usb_intern_data stc_usb_intern_data_t
 
typedef struct
stc_usbn_instance_data 
stc_usbn_instance_data_t
 USB module internal data, storing internal information for each enabled USB instance. More...
 
typedef enum en_usb_control_stage en_usb_control_stage_t
 USB control stage. More...
 
typedef enum en_usb_status en_usb_status_t
 Usb Status. More...
 
typedef enum en_usb_mode en_usb_mode_t
 Usb mode. More...
 
typedef enum en_usb_switch en_usb_switch_t
 Usb force switch to. More...
 
typedef struct stc_usb_config stc_usb_config_t
 Usb configuration. More...
 

Enumerations

enum  en_usb_extint_param {
  UsbExtIntDeinit = 0,
  UsbExtIntInit = 1,
  UsbExtIntDisableIsr = 2,
  UsbExtIntEnableIsr = 3,
  UsbExtIntClearIsrFlag = 4,
  UsbExtIntIsSetIsrFlag = 5,
  UsbExtIntSetLowDetect = 6,
  UsbExtIntSetHighDetect = 7,
  UsbExtIntGetLevel = 8
}
 
enum  en_usb_gpio_param {
  UsbGpioDeinit = 0,
  UsbGpioInit = 1,
  UsbGpioSet = 2,
  UsbGpioClear = 3,
  UsbGpioGet = 4
}
 
enum  en_usb_ep_type {
  EpTypeHost = 0,
  EpTypeIso = 1,
  EpTypeBulk = 2,
  EpTypeInterrupt = 3
}
 
enum  en_usb_endpoint_status {
  UsbEndpointStatusNotReady = 0,
  UsbEndpointStatusIdle = 1,
  UsbEndpointStatusTransfer = 2,
  UsbEndpointStatusStall = 3
}
 USB control stage. More...
 
enum  en_usb_instance_index {
  UsbInstanceIndexUsb0,
  UsbInstanceIndexUsb1,
  UsbInstanceIndexMax
}
 Enumeration to define an index for each enabled USB instance. More...
 
enum  en_usb_dma_instance_index { UsbDmaInstanceIndexMax }
 Enumeration to define an index for each enabled USB DMA instance. More...
 
enum  en_usb_control_stage {
  ControlStageUnknown = 0,
  SetupStage = 1,
  DataStageIN = 2,
  DataStageOUT = 3,
  StatusStage = 4
}
 USB control stage. More...
 
enum  en_usb_status {
  UsbDisconnected = 0,
  UsbConnected = 1,
  UsbAddressed = 2,
  UsbConfigured = 3
}
 Usb Status. More...
 
enum  en_usb_mode {
  UsbDisabled = 0,
  UsbDeviceEnabled = 1,
  UsbHostEnabled = 2,
  UsbHostDeviceEnabled = 3
}
 Usb mode. More...
 
enum  en_usb_switch {
  UsbSwitchDependingDeviceVbus = 0,
  UsbSwitchToDevice = 1,
  UsbSwitchToHost = 2,
  UsbSwitchAllOff = 3
}
 Usb force switch to. More...
 

Functions

en_result_t Usb_Configure (stc_usbn_t *pstcUsb, stc_usb_config_t *pstcConfig)
 Initialize USB in general. More...
 
en_result_t Usb_Init (void)
 Initialize USB in general. More...
 
en_result_t Usb_SetupHalEndpoint (stc_usbn_t *pstcUsb, uint8_t u8EndpointAddress, uint16_t u16FifoSize, en_usb_ep_type_t enType, boolean_t bInterruptsEnabled)
 Setup USB HAL endpoint. More...
 
en_result_t Usb_SwitchUsb (stc_usbn_t *pstcUsb, en_usb_switch_t enType, uint32_t u32SwitchDelay)
 Switch "Task" between host / device mode. More...
 
en_result_t Usb_InitInstance (stc_usbn_t *pstcUsb)
 Init USB instance. More...
 
en_result_t Usb_DeinitInstance (stc_usbn_t *pstcUsb)
 Deinit USB instance. More...
 
stc_usbn_endpoint_data_t * Usb_GetEndpointPtr (stc_usbn_t *pstcUsb, uint8_t u8EndpointAddress)
 Get endpoint pointer from endpointaddress. More...
 
en_result_t Usb_HalSend (stc_usbn_endpoint_data_t *pstcEpHandle, uint8_t *pu8Data, uint16_t u16Size, uint16_t *pu16ByteCount)
 Send data via endpoint. More...
 
en_result_t Usb_HalReceive (stc_usbn_endpoint_data_t *pstcEpHandle, uint8_t *pu8Data, uint16_t *pu16ByteCount, boolean_t bClearDrq)
 Read data via endpoint. More...
 
en_result_t Usb_HalClearDrq (stc_usbn_endpoint_data_t *pstcEpHandle)
 Clear Drq flag of FIFO: FIFO ready for next data. More...
 
en_result_t Usb_HalStallEndpoint (stc_usbn_endpoint_data_t *pstcEpHandle)
 Stall endpoint. More...
 
en_result_t Usb_HalUnstallEndpoint (stc_usbn_endpoint_data_t *pstcEpHandle)
 Unstall endpoint. More...
 
boolean_t Usb_HalEpReady (stc_usbn_endpoint_data_t *pstcEpHandle)
 Get information if the specified endpoint is ready. More...
 
boolean_t Usb_HalEndpointIsBusy (stc_usbn_endpoint_data_t *pstcEpHandle)
 Unstall endpoint. More...
 
uint8_t Usb_GetConfiguration (stc_usbn_t *pstcUsb)
 
boolean_t Usb_AddTimeOut (stc_usbn_t *pstcUsb, void(*Handler)(stc_usbn_t *pstcUsb), uint16_t u16TimeOut)
 
void Usb_RemoveTimeOut (stc_usbn_t *pstcUsb, void(*Handler)(stc_usbn_t *pstcUsb))
 
void Usb_SetEndpointRxTxCallback (stc_usbn_endpoint_data_t *pstcEndpoint, usb_endpoint_datatransferred_func_ptr_t pfnRxTxCallback)
 Set RxTx Callback of an endpoint. More...
 
void Usb_OsTickHandle (void)
 
void UsbIrqHandler (stc_usbn_t *pstcUsb, stc_usb_intern_data_t *pstcUsbInternData)
 
void UsbConfig_UsbInit (void)
 
void UsbConfig_SwitchMode (void)
 

Variables

stc_usbn_instance_data_t m_astcUsbInstanceDataLut []
 Look-up table for all enabled USB instances and their internal data. More...
 
static boolean_t UsbInitDone = FALSE
 
stc_usbn_instance_data_t m_astcUsbInstanceDataLut []
 Macro to return the number of enabled USB instances. More...
 
static stc_usb_intern_data_t * UsbGetInternDataPtr (stc_usbn_t *pstcUsb)
 Return the internal data for a certain USB instance. More...
 
static en_result_t Usb_InitIrq (stc_usbn_t *pstcUsb)
 Device dependent initialization of interrupts according CMSIS with level defined in l3.h. More...
 
static en_result_t Usb_DeinitIrq (stc_usbn_t *pstcUsb)
 Device dependent deinitialization of interrupts according CMSIS with level defined in l3.h. More...
 
static void Usb_TimeoutHandler (stc_usbn_t *pstcUsb)
 
void UsbHost_DisconnectionCallback (stc_usbn_t *pstcUsb)
 
en_usb_endpoint_status_t Usb_HalEndpointStatus (stc_usbn_endpoint_data_t *pstcEpHandle)
 Get information about the specified endpoint status. More...
 
void Usb_Tick (void)
 
void USB_Handler (void)
 
void USB0_Handler (void)
 
void USB0_HOST_IRQHandler (void)
 
void USB1_Handler (void)
 

Detailed Description

Provided functions of USB module:

Used to initialize the HAL and using low level functionality. Usb_Configure() is used to setup the low level driver. Usb_SetupHalEndpoint() is used to setup an endpoint in hardware (for device mode). Usb_SwitchUsb() can be called, to switch USB on or off or between host and device functionality. Usb_SwitchUsb() is called cyclic or via external interrupt when VBUS state changes. Usb_InitInstance() initializes all neccesary registers. Usb_GetEndpointPtr() returns pointer of endpoint struct. Usb_HalSend() and Usb_HalReceive() can be used to transfer data to or from the endpoint FIFO. Usb_HalEpReady() gives an information wether the endpoint is ready to use while Usb_HalEndpointIsBusy() gives the information if the endpoint is transferring data. While endpoints having double buffers, the endpoint can be ready for next data, but is still busy. Usb_GetConfiguration() returns if the HAL in device mode is configured or not. Usb_AddTimeOut() adds timeout functionality via SOF interrupt. Usb_RemoveTimeOut() removes timeouts.

Note
For USB Host functionality, see also USB Host Module description For USB Device functionality see also USB Device Module description

Macro Definition Documentation

#define __IO   volatile

Defines 'read / write' permissions

Definition at line 1202 of file usb.h.

Referenced by Usb_HalReceive(), and Usb_HalSend().

#define __USBBITDEFINITIONS_H__

Definition at line 1031 of file usb.h.

#define __USBSPEC_H__

Definition at line 1206 of file usb.h.

#define _EP0C_PKS0   0x7F

EP0 packet size setting bits.

Definition at line 1039 of file usb.h.

#define _EP0C_STAL   (1 << 9)

STALL set bit.

Definition at line 1040 of file usb.h.

#define _EP0IS_BFINI   (1 << 15)

Transmission buffer initialization bit.

Definition at line 1116 of file usb.h.

#define _EP0IS_DRQI   (1 << 10)

Transmit Data interrupt request bit.

Definition at line 1114 of file usb.h.

#define _EP0IS_DRQIIE   (1 << 14)

Transmit Data Interrupt enable bit.

Definition at line 1115 of file usb.h.

#define _EP0OS_BFINI   (1 << 15)

Receive buffer initialization bit.

Definition at line 1123 of file usb.h.

#define _EP0OS_DRQO   (1 << 10)

Received data interrupt flag bit.

Definition at line 1120 of file usb.h.

#define _EP0OS_DRQOIE   (1 << 14)

Receive Data Interrupt enable bit.

Definition at line 1122 of file usb.h.

#define _EP0OS_SIZE   0x7F

Packet size bits.

Definition at line 1118 of file usb.h.

#define _EP0OS_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1119 of file usb.h.

#define _EP0OS_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1121 of file usb.h.

#define _EP1C_DIR   (1 << 12)

Endpoint direction selection bit.

Definition at line 1054 of file usb.h.

#define _EP1C_DMAE   (1 << 11)

DMA automatic transfer enable bit.

Definition at line 1053 of file usb.h.

#define _EP1C_EPEN   (1 << 15)

Endpoint Enable bit.

Definition at line 1056 of file usb.h.

#define _EP1C_NULE   (1 << 10)

NULL automatic transfer enable bit.

Definition at line 1052 of file usb.h.

#define _EP1C_PKS1   0x1FF

EP1 packet size setting bits.

Definition at line 1050 of file usb.h.

#define _EP1C_STAL   (1 << 9)

STALL set bit.

Definition at line 1051 of file usb.h.

#define _EP1C_TYPE   0x6000

Endpoint transfer type bit.

Definition at line 1055 of file usb.h.

#define _EP1S_BFINI   (1 << 15)

Transmission/Reception buffer initialization bit.

Definition at line 1131 of file usb.h.

#define _EP1S_BUSY   (1 << 11)

Busy flag bit.

Definition at line 1128 of file usb.h.

#define _EP1S_DRQ   (1 << 10)

Packet transfer interrupt flag bit.

Definition at line 1127 of file usb.h.

#define _EP1S_DRQIE   (1 << 14)

DRQ Interrupt enable bit.

Definition at line 1130 of file usb.h.

#define _EP1S_SIZE   0x1FF

Packet size bits.

Definition at line 1125 of file usb.h.

#define _EP1S_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1126 of file usb.h.

#define _EP1S_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1129 of file usb.h.

#define _EP2C_DIR   (1 << 12)

Endpoint direction selection bit.

Definition at line 1062 of file usb.h.

#define _EP2C_DMAE   (1 << 11)

DMA automatic transfer enable bit.

Definition at line 1061 of file usb.h.

#define _EP2C_EPEN   (1 << 15)

Endpoint Enable bit.

Definition at line 1064 of file usb.h.

#define _EP2C_NULE   (1 << 10)

NULL automatic transfer enable bit.

Definition at line 1060 of file usb.h.

#define _EP2C_PKS2   0xFF

EP2 packet size setting bits.

Definition at line 1058 of file usb.h.

#define _EP2C_STAL   (1 << 9)

STALL set bit.

Definition at line 1059 of file usb.h.

#define _EP2C_TYPE   0x6000

Endpoint transfer type bit.

Definition at line 1063 of file usb.h.

#define _EP2S_BFINI   (1 << 15)

Transmission/Reception buffer initialization bit.

Definition at line 1139 of file usb.h.

#define _EP2S_BUSY   (1 << 11)

Busy flag bit.

Definition at line 1136 of file usb.h.

#define _EP2S_DRQ   (1 << 10)

Packet transfer interrupt flag bit.

Definition at line 1135 of file usb.h.

#define _EP2S_DRQIE   (1 << 14)

DRQ Interrupt enable bit.

Definition at line 1138 of file usb.h.

#define _EP2S_SIZE   0xFF

Packet size bits.

Definition at line 1133 of file usb.h.

#define _EP2S_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1134 of file usb.h.

#define _EP2S_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1137 of file usb.h.

#define _EP3C_DIR   (1 << 12)

Endpoint direction selection bit.

Definition at line 1070 of file usb.h.

#define _EP3C_DMAE   (1 << 11)

DMA automatic transfer enable bit.

Definition at line 1069 of file usb.h.

#define _EP3C_EPEN   (1 << 15)

Endpoint Enable bit.

Definition at line 1072 of file usb.h.

#define _EP3C_NULE   (1 << 10)

NULL automatic transfer enable bit.

Definition at line 1068 of file usb.h.

#define _EP3C_PKS3   0xFF

EP3 packet size setting bits.

Definition at line 1066 of file usb.h.

#define _EP3C_STAL   (1 << 9)

STALL set bit.

Definition at line 1067 of file usb.h.

#define _EP3C_TYPE   0x6000

Endpoint transfer type bit.

Definition at line 1071 of file usb.h.

#define _EP3S_BFINI   (1 << 15)

Transmission/Reception buffer initialization bit.

Definition at line 1147 of file usb.h.

#define _EP3S_BUSY   (1 << 11)

Busy flag bit.

Definition at line 1144 of file usb.h.

#define _EP3S_DRQ   (1 << 10)

Packet transfer interrupt flag bit.

Definition at line 1143 of file usb.h.

#define _EP3S_DRQIE   (1 << 14)

DRQ Interrupt enable bit.

Definition at line 1146 of file usb.h.

#define _EP3S_SIZE   0xFF

Packet size bits.

Definition at line 1141 of file usb.h.

#define _EP3S_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1142 of file usb.h.

#define _EP3S_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1145 of file usb.h.

#define _EP4C_DIR   (1 << 12)

Endpoint direction selection bit.

Definition at line 1078 of file usb.h.

#define _EP4C_DMAE   (1 << 11)

DMA automatic transfer enable bit.

Definition at line 1077 of file usb.h.

#define _EP4C_EPEN   (1 << 15)

Endpoint Enable bit.

Definition at line 1080 of file usb.h.

#define _EP4C_NULE   (1 << 10)

NULL automatic transfer enable bit.

Definition at line 1076 of file usb.h.

#define _EP4C_PKS4   0xFF

EP4 packet size setting bits.

Definition at line 1074 of file usb.h.

#define _EP4C_STAL   (1 << 9)

STALL set bit.

Definition at line 1075 of file usb.h.

#define _EP4C_TYPE   0x6000

Endpoint transfer type bit.

Definition at line 1079 of file usb.h.

#define _EP4S_BFINI   (1 << 15)

Transmission/Reception buffer initialization bit.

Definition at line 1155 of file usb.h.

#define _EP4S_BUSY   (1 << 11)

Busy flag bit.

Definition at line 1152 of file usb.h.

#define _EP4S_DRQ   (1 << 10)

Packet transfer interrupt flag bit.

Definition at line 1151 of file usb.h.

#define _EP4S_DRQIE   (1 << 14)

DRQ Interrupt enable bit.

Definition at line 1154 of file usb.h.

#define _EP4S_SIZE   0xFF

Packet size bits.

Definition at line 1149 of file usb.h.

#define _EP4S_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1150 of file usb.h.

#define _EP4S_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1153 of file usb.h.

#define _EP5C_DIR   (1 << 12)

Endpoint direction selection bit.

Definition at line 1086 of file usb.h.

#define _EP5C_DMAE   (1 << 11)

DMA automatic transfer enable bit.

Definition at line 1085 of file usb.h.

#define _EP5C_EPEN   (1 << 15)

Endpoint Enable bit.

Definition at line 1088 of file usb.h.

#define _EP5C_NULE   (1 << 10)

NULL automatic transfer enable bit.

Definition at line 1084 of file usb.h.

#define _EP5C_PKS5   0xFF

EP packet size setting bits.

Definition at line 1082 of file usb.h.

#define _EP5C_STAL   (1 << 9)

STALL set bit.

Definition at line 1083 of file usb.h.

#define _EP5C_TYPE   0x6000

Endpoint transfer type bit.

Definition at line 1087 of file usb.h.

#define _EP5S_BFINI   (1 << 15)

Transmission/Reception buffer initialization bit.

Definition at line 1163 of file usb.h.

#define _EP5S_BUSY   (1 << 11)

Busy flag bit.

Definition at line 1160 of file usb.h.

#define _EP5S_DRQ   (1 << 10)

Packet transfer interrupt flag bit.

Definition at line 1159 of file usb.h.

#define _EP5S_DRQIE   (1 << 14)

DRQ Interrupt enable bit.

Definition at line 1162 of file usb.h.

#define _EP5S_SIZE   0xFF

Packet size bits.

Definition at line 1157 of file usb.h.

#define _EP5S_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1158 of file usb.h.

#define _EP5S_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1161 of file usb.h.

#define _EPC_TYPE_BULK   0x4000

Definition at line 1090 of file usb.h.

#define _EPC_TYPE_INTERRUPT   0x6000

Definition at line 1091 of file usb.h.

#define _EPNC_DIR   (1 << 12)

Endpoint direction selection bit.

Definition at line 1046 of file usb.h.

#define _EPNC_DMAE   (1 << 11)

DMA automatic transfer enable bit.

Definition at line 1045 of file usb.h.

#define _EPNC_EPEN   (1 << 15)

Endpoint Enable bit.

Definition at line 1048 of file usb.h.

Referenced by Usb_HalEndpointStatus(), Usb_HalEpReady(), and Usb_SetupHalEndpoint().

#define _EPNC_NULE   (1 << 10)

NULL automatic transfer enable bit.

Definition at line 1044 of file usb.h.

#define _EPNC_STAL   (1 << 9)

STALL set bit.

Definition at line 1043 of file usb.h.

Referenced by Usb_HalEndpointStatus(), Usb_HalStallEndpoint(), and Usb_HalUnstallEndpoint().

#define _EPNC_TYPE   0x6000

Endpoint transfer type bit.

Definition at line 1047 of file usb.h.

#define _EPNS_BFINI   (1 << 15)

Transmission/Reception buffer initialization bit.

Definition at line 1112 of file usb.h.

Referenced by UsbIrqHandler().

#define _EPNS_BUSY   (1 << 11)

Busy flag bit.

Definition at line 1109 of file usb.h.

Referenced by Usb_HalEndpointIsBusy().

#define _EPNS_DRQ   (1 << 10)

Packet transfer interrupt flag bit.

Definition at line 1108 of file usb.h.

Referenced by Usb_HalClearDrq(), Usb_HalEndpointStatus(), Usb_HalEpReady(), Usb_HalReceive(), and Usb_HalSend().

#define _EPNS_DRQIE   (1 << 14)

DRQ Interrupt enable bit.

Definition at line 1111 of file usb.h.

Referenced by Usb_SetEndpointRxTxCallback(), and Usb_SetupHalEndpoint().

#define _EPNS_SPK   (1 << 9)

Short Packet interrupt flag bit.

Definition at line 1107 of file usb.h.

#define _EPNS_SPKIE   (1 << 13)

Short packet interrupt enable bit.

Definition at line 1110 of file usb.h.

#define _HCNT_CANCEL   (1 << 9)

Token cancel enable bit.

Definition at line 1174 of file usb.h.

#define _HCNT_CMPIRE   (1 << 5)

Completion interrupt Enable bit.

Definition at line 1170 of file usb.h.

#define _HCNT_CNNIRE   (1 << 4)

Connection interrupt Enable bit.

Definition at line 1169 of file usb.h.

#define _HCNT_DIRE   (1 << 3)

Disconnection interrupt Enable bit.

Definition at line 1168 of file usb.h.

#define _HCNT_HOST   (1 << 0)

HOST Mode bit.

Definition at line 1165 of file usb.h.

#define _HCNT_RETRY   (1 << 8)

Retry enable bit.

Definition at line 1173 of file usb.h.

#define _HCNT_RWKIRE   (1 << 7)

Remote Wake-up interrupt Enable bit.

Definition at line 1172 of file usb.h.

#define _HCNT_SOFIRE   (1 << 2)

SOF interrupt Enable bit.

Definition at line 1167 of file usb.h.

#define _HCNT_SOFSTEP   (1 << 10)

SOF interrupt trigger bit.

Definition at line 1175 of file usb.h.

#define _HCNT_URIRE   (1 << 6)

USB bus Reset interrupt Enable bit.

Definition at line 1171 of file usb.h.

#define _HCNT_URST   (1 << 1)

USB Bus Reset bit.

Definition at line 1166 of file usb.h.

#define _HERR_CRC   (1 << 4)

CRC Error bit.

Definition at line 1188 of file usb.h.

#define _HERR_HS   0x03

Handshake Status.

Definition at line 1185 of file usb.h.

#define _HERR_LSTSOF   (1 << 7)

Lost SOF bit.

Definition at line 1191 of file usb.h.

#define _HERR_RERR   (1 << 6)

Receive Error bit.

Definition at line 1190 of file usb.h.

#define _HERR_STUFF   (1 << 2)

Stuffing Error bit.

Definition at line 1186 of file usb.h.

#define _HERR_TGERR   (1 << 3)

Toggle Error bit.

Definition at line 1187 of file usb.h.

#define _HERR_TOUT   (1 << 5)

Time Out bit.

Definition at line 1189 of file usb.h.

#define _HIRQ_CMPIRQ   (1 << 3)

Disconnection interrupt Enable bit.

Definition at line 1180 of file usb.h.

#define _HIRQ_CNNIRQ   (1 << 2)

SOF interrupt Enable bit.

Definition at line 1179 of file usb.h.

#define _HIRQ_DIRQ   (1 << 1)

USB Bus Reset bit.

Definition at line 1178 of file usb.h.

#define _HIRQ_RWKIRQ   (1 << 5)

Completion interrupt Enable bit.

Definition at line 1182 of file usb.h.

#define _HIRQ_SOFIRQ   (1 << 0)

HOST Mode bit.

Definition at line 1177 of file usb.h.

#define _HIRQ_TCAN   (1 << 7)

Remote Wake-up interrupt Enable bit.

Definition at line 1183 of file usb.h.

#define _HIRQ_URIRQ   (1 << 4)

Connection interrupt Enable bit.

Definition at line 1181 of file usb.h.

#define _HSTATE_ALIVE   (1 << 5)

keep alive bit (for low speed)

Definition at line 1198 of file usb.h.

#define _HSTATE_CLKSEL   (1 << 4)

Clock Selection bit (Full / Low Speed)

Definition at line 1197 of file usb.h.

#define _HSTATE_CSTAT   (1 << 0)

Connection status bit.

Definition at line 1193 of file usb.h.

#define _HSTATE_SOFBUSY   (1 << 3)

SOF timer operation bit.

Definition at line 1196 of file usb.h.

#define _HSTATE_SUSP   (1 << 2)

Suspend bit.

Definition at line 1195 of file usb.h.

#define _HSTATE_TMODE   (1 << 1)

Transfer Mode bit.

Definition at line 1194 of file usb.h.

#define _UDCC_HCONX   (1 << 5)

Host connection bit.

Definition at line 1034 of file usb.h.

#define _UDCC_PWC   (1 << 0)

Power supply control bit.

Definition at line 1037 of file usb.h.

#define _UDCC_RESUM   (1 << 6)

Resume setting bit.

Definition at line 1033 of file usb.h.

#define _UDCC_RFBK   (1 << 1)

Data toggle mode bit (Rate feedback mode)

Definition at line 1036 of file usb.h.

#define _UDCC_RST   (1 << 7)

Function reset bit.

Definition at line 1032 of file usb.h.

#define _UDCC_USTP   (1 << 4)

USB operation clock stop bit.

Definition at line 1035 of file usb.h.

#define _UDCIE_BRSTIE   (1 << 3)

Bus reset interrupt enable bit.

Definition at line 1103 of file usb.h.

#define _UDCIE_CONFIE   (1 << 0)

Configuration interrupt enable bit.

Definition at line 1100 of file usb.h.

#define _UDCIE_CONFN   (1 << 1)

Configuration number bit.

Definition at line 1101 of file usb.h.

#define _UDCIE_SOFIE   (1 << 4)

SOF receive interrupt enable bit.

Definition at line 1104 of file usb.h.

#define _UDCIE_SUSPIE   (1 << 5)

Suspend interrupt enable bit.

Definition at line 1105 of file usb.h.

#define _UDCIE_WKUPIE   (1 << 2)

Wake-up interrupt enable bit.

Definition at line 1102 of file usb.h.

#define _UDCS_BRST   (1 << 3)

Bus reset detection bit.

Definition at line 1096 of file usb.h.

#define _UDCS_CONF   (1 << 0)

Configuration detection bit.

Definition at line 1093 of file usb.h.

#define _UDCS_SETP   (1 << 1)

Setup stage detection bit.

Definition at line 1094 of file usb.h.

#define _UDCS_SOF   (1 << 4)

SOF reception detection bit.

Definition at line 1097 of file usb.h.

#define _UDCS_SUSP   (1 << 5)

Suspend detection bit.

Definition at line 1098 of file usb.h.

#define _UDCS_WKUP   (1 << 2)

Wake-up detection bit.

Definition at line 1095 of file usb.h.

#define BITMASK_CLEAR (   x,
  y 
)    x &= ~y
#define BITMASK_ISCLEARED (   x,
  y 
)    ((x & y) == 0)
#define BITMASK_ISSET (   x,
  y 
)    ((x & y) > 0)

Definition at line 1015 of file usb.h.

Referenced by Usb_HalEndpointIsBusy(), and Usb_HalEndpointStatus().

#define BITMASK_SET (   x,
  y 
)    x |= y
#define bL3_FM3_GPIO_EPFR00_USB0PE   *((volatile unsigned int*)(0x4266C024UL))

Definition at line 1228 of file usb.h.

Referenced by Usb_Init().

#define bL3_FM3_GPIO_EPFR00_USB1PE   *((volatile unsigned int*)(0x4266C034UL))

Definition at line 1231 of file usb.h.

Referenced by Usb_Init().

#define bL3_FM3_GPIO_PFR2_P0   *((volatile unsigned int*)(0x42660100UL))

Definition at line 1232 of file usb.h.

Referenced by Usb_Init().

#define bL3_FM3_GPIO_PFR6_P1   *((volatile unsigned int*)(0x42660304UL))

Definition at line 1229 of file usb.h.

Referenced by Usb_Init().

#define bL3_FM3_GPIO_SPSR_USB0C   *((volatile unsigned int*)(0x4266B010UL))

Definition at line 1230 of file usb.h.

Referenced by Usb_Init().

#define bL3_FM3_GPIO_SPSR_USB1C   *((volatile unsigned int*)(0x4266B014UL))

Definition at line 1233 of file usb.h.

Referenced by Usb_Init().

#define CLEARACTIVEFLAG (   x)    while((x) == TRUE) (x) = FALSE;

Definition at line 399 of file usb.h.

#define DBGPROCENTER (   x)

Definition at line 393 of file usb.h.

#define DBGPROCRETURN (   x)

Definition at line 394 of file usb.h.

#define DBGSPACES (   x)

Definition at line 395 of file usb.h.

#define FM_PERIPHERAL_ENABLE_USB0   OFF

Definition at line 347 of file usb.h.

#define FM_PERIPHERAL_ENABLE_USB0_DEVICE   PDL_PERIPHERAL_ENABLE_USB0_DEVICE

Definition at line 274 of file usb.h.

#define FM_PERIPHERAL_ENABLE_USB0_HOST   PDL_PERIPHERAL_ENABLE_USB0_HOST

Definition at line 273 of file usb.h.

#define FM_PERIPHERAL_ENABLE_USB1   OFF

Definition at line 353 of file usb.h.

#define FM_PERIPHERAL_ENABLE_USB1_DEVICE   PDL_PERIPHERAL_ENABLE_USB1_DEVICE

Definition at line 276 of file usb.h.

#define FM_PERIPHERAL_ENABLE_USB1_HOST   PDL_PERIPHERAL_ENABLE_USB1_HOST

Definition at line 275 of file usb.h.

#define FM_PERIPHERAL_USB_DEVICE_ENABLED   OFF

Definition at line 366 of file usb.h.

#define FM_PERIPHERAL_USB_HOST_ENABLED   OFF

Definition at line 359 of file usb.h.

#define GET_DESCRIPTOR   0x06

Definition at line 1209 of file usb.h.

#define OFF   0U

Definition at line 137 of file usb.h.

#define ON   1U

Definition at line 140 of file usb.h.

#define SETACTIVEFLAG (   x)    while((x) == FALSE) (x) = TRUE;

Definition at line 398 of file usb.h.

#define USB0_DEVICE_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB0_DEVICE

Definition at line 268 of file usb.h.

#define USB0_HOST_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB0_HOST

Definition at line 269 of file usb.h.

#define USB1_DEVICE_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB1_DEVICE

Definition at line 270 of file usb.h.

#define USB1_HOST_IRQ_ENABLED   PDL_INTERRUPT_ENABLE_USB1_HOST

Definition at line 271 of file usb.h.

#define USB_CLEAR_FEATURE   0x01

Definition at line 971 of file usb.h.

#define USB_CONFIGURATION_DESCRIPTOR_TYPE   0x02

Usb Configuration Descriptor Type.

Definition at line 1211 of file usb.h.

Referenced by ReturnedConfigurationDescriptor().

#define USB_DEVICE_DESCRIPTOR_TYPE   0x01

Usb Device Descriptor Type.

Definition at line 1210 of file usb.h.

#define USB_DEVICE_INTERFACES_COUNT   ((FM_PERIPHERAL_ENABLE_USB0_DEVICE) + (FM_PERIPHERAL_ENABLE_USB1_DEVICE))

Definition at line 373 of file usb.h.

#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE   0x06

Usb Device Qualifier Descriptor Type.

Definition at line 1215 of file usb.h.

#define USB_DEVREQ_CLSTYPE   0x20

Definition at line 963 of file usb.h.

#define USB_DEVREQ_GET_DESC   0x06

Definition at line 966 of file usb.h.

#define USB_DEVREQ_SET_DESC   0x07

Definition at line 967 of file usb.h.

#define USB_DEVREQ_SET_IDLE   0x0A

Definition at line 968 of file usb.h.

#define USB_DEVREQ_STDTYPE   0x00

Definition at line 962 of file usb.h.

#define USB_DEVREQ_VNDTYPE   0x40

Definition at line 964 of file usb.h.

#define USB_DISBALE_DEVICE_FUNCTIONALITY   OFF

Definition at line 367 of file usb.h.

#define USB_DISBALE_HOST_FUNCTIONALITY   OFF

Definition at line 360 of file usb.h.

#define USB_ENABLED   ((FM_PERIPHERAL_ENABLE_USB0 == ON) || (FM_PERIPHERAL_ENABLE_USB1 == ON))

Definition at line 370 of file usb.h.

#define USB_ENDPOINT_DESCRIPTOR_TYPE   0x05

Usb Endpoint Descriptor Type.

Definition at line 1214 of file usb.h.

#define USB_EP_TYPE_BULK   0x02

Bulk Endpoint Type.

Definition at line 1224 of file usb.h.

#define USB_EP_TYPE_CONTROL   0x00

Control Endpoint Type.

Definition at line 1222 of file usb.h.

#define USB_EP_TYPE_INT   0x03

Interrupt Endpoint Type.

Definition at line 1225 of file usb.h.

#define USB_EP_TYPE_ISO   0x01

ISO Endpoint Type.

Definition at line 1223 of file usb.h.

#define USB_FUNC_BULK_IN   0xD000

Definition at line 988 of file usb.h.

#define USB_FUNC_BULK_OUT   0xC000

Definition at line 989 of file usb.h.

#define USB_FUNC_INTR_IN   0xF000

Definition at line 986 of file usb.h.

#define USB_FUNC_INTR_OUT   0xE000

Definition at line 987 of file usb.h.

#define USB_GET_CONFIGURATION   0x08

Definition at line 976 of file usb.h.

#define USB_GET_DESCRIPTOR   0x06

Definition at line 974 of file usb.h.

#define USB_GET_INTERFACE   0x0A

Definition at line 978 of file usb.h.

#define USB_GET_STATUS   0x00

Definition at line 970 of file usb.h.

#define USB_HID_DESCRIPTOR_TYPE   0x21

Usb HID Descriptor Type.

Definition at line 1217 of file usb.h.

#define USB_HOST_INTERFACES_COUNT   ((FM_PERIPHERAL_ENABLE_USB0_HOST) + (FM_PERIPHERAL_ENABLE_USB1_HOST))

Definition at line 374 of file usb.h.

#define USB_IN_DIRECTION   0x80
#define USB_INSTANCE_COUNT   ((FM_PERIPHERAL_ENABLE_USB0) + (FM_PERIPHERAL_ENABLE_USB1))

Definition at line 372 of file usb.h.

Referenced by Usb_Init(), and UsbGetInternDataPtr().

#define USB_INTERFACE_DESCRIPTOR_TYPE   0x04

Usb Interface Descriptor Type.

Definition at line 1213 of file usb.h.

#define USB_INTERFACES_COUNT   ((FM_PERIPHERAL_ENABLE_USB0) + (FM_PERIPHERAL_ENABLE_USB1))

Definition at line 371 of file usb.h.

#define USB_MASK_EPC_DIR   0x1000

Definition at line 996 of file usb.h.

#define USB_MASK_EPC_DMAE   0x0800

Definition at line 995 of file usb.h.

#define USB_MASK_EPC_EPEN   0x8000

Definition at line 998 of file usb.h.

#define USB_MASK_EPC_NULE   0x0400

Definition at line 994 of file usb.h.

#define USB_MASK_EPC_PKS   0x007F

Definition at line 991 of file usb.h.

#define USB_MASK_EPC_PKS1   0x01FF

Definition at line 992 of file usb.h.

#define USB_MASK_EPC_STAL   0x0200

Definition at line 993 of file usb.h.

#define USB_MASK_EPC_TYPE   0x6000

Definition at line 997 of file usb.h.

#define USB_MASK_EPS_BFINI   0x8000

Definition at line 1012 of file usb.h.

#define USB_MASK_EPS_BFINI   0x8000

Definition at line 1012 of file usb.h.

#define USB_MASK_EPS_BUSY   0x0800

Definition at line 1008 of file usb.h.

#define USB_MASK_EPS_DRQ   0x0400

Definition at line 1007 of file usb.h.

#define USB_MASK_EPS_DRQI   0x0400

Definition at line 1005 of file usb.h.

#define USB_MASK_EPS_DRQIE   0x4000

Definition at line 1010 of file usb.h.

#define USB_MASK_EPS_DRQIIE   0x4000

Definition at line 1000 of file usb.h.

#define USB_MASK_EPS_DRQO   0x0400

Definition at line 1006 of file usb.h.

#define USB_MASK_EPS_DRQOIE   0x4000

Definition at line 1011 of file usb.h.

#define USB_MASK_EPS_SIZE   0x007F

Definition at line 1003 of file usb.h.

#define USB_MASK_EPS_SIZE1   0x01FF

Definition at line 1002 of file usb.h.

#define USB_MASK_EPS_SPK   0x0200

Definition at line 1004 of file usb.h.

#define USB_MASK_EPS_SPKIE   0x2000

Definition at line 1009 of file usb.h.

#define USB_OTHER_SPEED_CONFIGURATION_DESCRIPTOR_TYPE   0x07

Usb Other Speed Configuratuion Descriptor Type.

Definition at line 1216 of file usb.h.

#define USB_OUT_DIRECTION   0x00

Usb OUT direction.

Definition at line 1220 of file usb.h.

#define USB_SET_ADDRESS   0x05

Definition at line 973 of file usb.h.

#define USB_SET_CONFIGURATION   0x09

Definition at line 977 of file usb.h.

#define USB_SET_DESCRIPTOR   0x07

Definition at line 975 of file usb.h.

#define USB_SET_FEATURE   0x03

Definition at line 972 of file usb.h.

#define USB_SET_INTERFACE   0x0B

Definition at line 979 of file usb.h.

#define USB_STRING_DESCRIPTOR_TYPE   0x03

Usb String Descriptor Type.

Definition at line 1212 of file usb.h.

#define USB_SYNCH_FRAME   0x0C

Definition at line 980 of file usb.h.

#define USB_USE_STANDALONE   OFF

Definition at line 159 of file usb.h.

#define USB_USES_DMA   OFF

Definition at line 152 of file usb.h.

#define USB_ZERO_STRUCT (   x)    memset(&x,0,sizeof(x))

Definition at line 401 of file usb.h.

#define USBATTR_BUSPOWER   0x80

Definition at line 982 of file usb.h.

#define USBATTR_REMOTEWAKE   0x20

Definition at line 984 of file usb.h.

#define USBATTR_SELFPOWER   0xC0

Definition at line 983 of file usb.h.

#define USBDBGVAL16 (   x,
  y 
)

Definition at line 391 of file usb.h.

#define USBDBGVAL32 (   x,
  y 
)

Definition at line 392 of file usb.h.

#define USBDBGVAL8 (   x,
  y 
)

Definition at line 390 of file usb.h.

Referenced by Usb_HalSend(), UsbHostHidKeyboard_InitHandler(), and UsbHostHidMouse_InitHandler().

#define USBDESCR_CONFIG   2

Definition at line 957 of file usb.h.

#define USBDESCR_DEVICE   1

FM3DeviceTypes End FM3 Device Types

Definition at line 956 of file usb.h.

#define USBDESCR_INTERFACE   4

Definition at line 959 of file usb.h.

#define USBDESCR_STRING   3

Definition at line 958 of file usb.h.

#define USBDEVICECDCCOM_ENABLED   PDL_USBDEVICECDCCOM_ENABLED

Definition at line 311 of file usb.h.

#define USBDEVICEHIDCOM_ENABLED   PDL_USBDEVICEHIDCOM_ENABLED

Definition at line 312 of file usb.h.

#define USBDEVICEHIDJOYSTICK_ENABLED   PDL_USBDEVICEHIDJOYSTICK_ENABLED

Definition at line 313 of file usb.h.

#define USBDEVICEHIDKEYBOARD_ENABLED   PDL_USBDEVICEHIDKEYBOARD_ENABLED

Definition at line 314 of file usb.h.

#define USBDEVICEHIDMOUSE_ENABLED   PDL_USBDEVICEHIDMOUSE_ENABLED

Definition at line 315 of file usb.h.

#define USBDEVICELIBUSB_ENABLED   PDL_USBDEVICELIBUSB_ENABLED

Definition at line 316 of file usb.h.

#define USBDEVICEPRINTER_ENABLED   PDL_USBDEVICEPRINTER_ENABLED

Definition at line 317 of file usb.h.

#define USBHOSTHIDCOM_ENABLED   PDL_USBHOSTHIDCOM_ENABLED

Definition at line 319 of file usb.h.

#define USBHOSTHIDKEYBOARD_ENABLED   PDL_USBHOSTHIDKEYBOARD_ENABLED

Definition at line 320 of file usb.h.

#define USBHOSTHIDMOUSE_ENABLED   PDL_USBHOSTHIDMOUSE_ENABLED

Definition at line 321 of file usb.h.

#define USBHOSTMASSSTORAGE_ENABLED   PDL_USBHOSTMASSSTORAGE_ENABLED

Definition at line 322 of file usb.h.

Typedef Documentation

USB control stage.

Enumeration to define an index for each enabled USB DMA instance.

USB control stage.

Enumeration to define an index for each enabled USB instance.

typedef enum en_usb_mode en_usb_mode_t

Usb mode.

To select between device and host

Usb Status.

Usb force switch to.

Usb configuration.

Contains all parameter for configuratin an USB channel.

USB_MODULE End USB Module

USB module internal data, storing internal information for each enabled USB instance.

typedef void(* usb_brst_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2306 of file usb.h.

typedef void(* usb_cmpirq_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2346 of file usb.h.

typedef void(* usb_cnnirq_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2354 of file usb.h.

typedef void(* usb_conf_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2274 of file usb.h.

typedef void(* usb_connect_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2258 of file usb.h.

typedef boolean_t(* usb_device_alternative_hconx_t)(en_usb_gpio_param_t enType)

Definition at line 2151 of file usb.h.

typedef void(* usb_device_init_t)(stc_usbn_t *pstcUsb, struct stc_usb_config *pstcConfig)

Definition at line 2230 of file usb.h.

typedef boolean_t(* usb_device_vbus_t)(en_usb_extint_param_t enType)

Definition at line 2161 of file usb.h.

typedef void(* usb_dirq_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2362 of file usb.h.

typedef void(* usb_disconnect_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2266 of file usb.h.

typedef void(* usb_endpoint_datatransferred_func_ptr_t)(stc_usbn_t *pstcUsb, struct stc_usbn_endpoint_data *pstcEndpoint)

Definition at line 2250 of file usb.h.

typedef void(* usb_host_init_t)(stc_usbn_t *pstcUsb, struct stc_usb_config *pstcConfig)

Definition at line 2240 of file usb.h.

typedef boolean_t(* usb_host_overcurrent_t)(en_usb_extint_param_t enType)

Definition at line 2191 of file usb.h.

typedef boolean_t(* usb_host_pulldown_t)(en_usb_gpio_param_t enType)

Definition at line 2181 of file usb.h.

typedef boolean_t(* usb_host_vbus_t)(en_usb_gpio_param_t enType)

Definition at line 2171 of file usb.h.

typedef void(* usb_rwkirq_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2330 of file usb.h.

typedef void(* usb_setp_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2282 of file usb.h.

typedef void(* usb_sof_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2314 of file usb.h.

typedef void(* usb_susp_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2290 of file usb.h.

typedef void(* usb_tcan_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2322 of file usb.h.

typedef void(* usb_urirq_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2338 of file usb.h.

typedef void(* usb_wkup_isr_func_ptr_t)(stc_usbn_t *pstcUsb)

Definition at line 2298 of file usb.h.

Enumeration Type Documentation

USB control stage.

Enumerator
ControlStageUnknown 

USB control stage unknown.

SetupStage 

USB control stage setup.

DataStageIN 

USB control stage data IN.

DataStageOUT 

USB control stage data OUT.

StatusStage 

USB control stage status.

Definition at line 2497 of file usb.h.

Enumeration to define an index for each enabled USB DMA instance.

Enumerator
UsbDmaInstanceIndexMax 

Definition at line 2413 of file usb.h.

USB control stage.

Enumerator
UsbEndpointStatusNotReady 

USB endpoint not ready.

UsbEndpointStatusIdle 

USB endpoint status idle.

UsbEndpointStatusTransfer 

USB endpoint status transferring data.

UsbEndpointStatusStall 

USB endpoint status stall.

Definition at line 2369 of file usb.h.

Enumerator
EpTypeHost 

used as host endpoint

EpTypeIso 

ISO.

EpTypeBulk 

Bulk.

EpTypeInterrupt 

Interrupt.

Definition at line 2198 of file usb.h.

Enumerator
UsbExtIntDeinit 

Deinitialize GPIO / external interrupt.

UsbExtIntInit 

Initialize GPIO / external interrupt.

UsbExtIntDisableIsr 

Disable external interrupt.

UsbExtIntEnableIsr 

Enable external interrupt.

UsbExtIntClearIsrFlag 

Clear external interrupt flag.

UsbExtIntIsSetIsrFlag 

Check external interrupt flag is set.

UsbExtIntSetLowDetect 

Set low level external interrupt.

UsbExtIntSetHighDetect 

Set high level external interrupt.

UsbExtIntGetLevel 

Get level of external interrupt.

Definition at line 2115 of file usb.h.

Enumerator
UsbGpioDeinit 

Deinitialize GPIO.

UsbGpioInit 

Initialize GPIO.

UsbGpioSet 

Set GPIO.

UsbGpioClear 

Clear GPIO.

UsbGpioGet 

Get state of GPIO.

Definition at line 2133 of file usb.h.

Enumeration to define an index for each enabled USB instance.

Enumerator
UsbInstanceIndexUsb0 
UsbInstanceIndexUsb1 
UsbInstanceIndexMax 

Definition at line 2400 of file usb.h.

Usb mode.

To select between device and host

Enumerator
UsbDisabled 

USB disabled.

UsbDeviceEnabled 

USB device enabled, USB host disabled.

UsbHostEnabled 

USB device disabled, USB host enabled.

UsbHostDeviceEnabled 

USB device enabled, USB host enabled.

Definition at line 2527 of file usb.h.

Usb Status.

Enumerator
UsbDisconnected 

USB is disconnected.

UsbConnected 

USB is connected.

UsbAddressed 

USB is addressed.

UsbConfigured 

USB is configured.

Definition at line 2512 of file usb.h.

Usb force switch to.

Enumerator
UsbSwitchDependingDeviceVbus 

Do not force switch.

UsbSwitchToDevice 

USB device enabled, USB host disabled.

UsbSwitchToHost 

USB device disabled, USB host enabled.

UsbSwitchAllOff 

USB device disabled, USB host disabled.

Definition at line 2540 of file usb.h.

Function Documentation

void USB0_Handler ( void  )

USB 0 interrupt handler (only used in standalone mode)

Definition at line 1888 of file usb.c.

References UsbInstanceIndexUsb0, and UsbIrqHandler().

Here is the call graph for this function:

void USB0_HOST_IRQHandler ( void  )

Definition at line 1924 of file usb.c.

References UsbInstanceIndexUsb0, and UsbIrqHandler().

Here is the call graph for this function:

void USB1_Handler ( void  )

USB 1 interrupt handler (only used in standalone mode)

Definition at line 1949 of file usb.c.

References UsbInstanceIndexUsb1, and UsbIrqHandler().

Here is the call graph for this function:

boolean_t Usb_AddTimeOut ( stc_usbn_t *  pstcUsb,
void(*)(stc_usbn_t *pstcUsb)  Handler,
uint16_t  u16TimeOut 
)

Add a timeout handler

Parameters
pstcUsbUSB handle
Handlerhandler executed after timeout
u16TimeOuttimeout in ms
Returns
TRUE if command was successful

Definition at line 1768 of file usb.c.

References stc_usb_intern_data::bSofTimeoutEnabled, ErrorUninitialized, FALSE, stc_usb_sof_timeout_handler::Handler, stc_usb_intern_data::pstcUsbTimeOutHandler, TRUE, stc_usb_sof_timeout_handler::u16TimeOut, and UsbGetInternDataPtr().

Referenced by ReturnedConfigurationDescriptor(), ReturnedDeviceDescriptor(), UsbClassSupervisor_Init(), and UsbClassSupervisor_SysTickHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

en_result_t Usb_DeinitInstance ( stc_usbn_t *  pstcUsb)

Deinit USB instance.

Parameters
pstcUsbPointer to USB instance

Definition at line 1203 of file usb.c.

References Ok.

static en_result_t Usb_DeinitIrq ( stc_usbn_t *  pstcUsb)
static

Device dependent deinitialization of interrupts according CMSIS with level defined in l3.h.

Parameters
pstcUsbPointer to USB instance
Returns
Ok Successful deinitialization

Definition at line 330 of file usb.c.

References Ok.

Referenced by Usb_Configure().

Here is the caller graph for this function:

uint8_t Usb_GetConfiguration ( stc_usbn_t *  pstcUsb)

Usb Device get current configuration

Parameters
pstcUsbUSB handle

Definition at line 1705 of file usb.c.

stc_usbn_endpoint_data_t* Usb_GetEndpointPtr ( stc_usbn_t *  pstcUsb,
uint8_t  u8EndpointAddress 
)

Get endpoint pointer from endpointaddress.

Parameters
pstcUsbPointer to USB instance
u8EndpointAddressu8EndpointAddress
Returns
Pointer to endpoint, NULL if no enpoint was found

Definition at line 1261 of file usb.c.

References stc_usb_intern_data::astcEndpoints, stc_usbn_endpoint_data::u8EndpointAddress, stc_usb_intern_data::u8NumberOfEndpoints, and UsbGetInternDataPtr().

Here is the call graph for this function:

en_result_t Usb_HalClearDrq ( stc_usbn_endpoint_data_t *  pstcEpHandle)

Clear Drq flag of FIFO: FIFO ready for next data.

Parameters
pstcEpHandlePointer to endpoint instance
Returns
Ok on success

Definition at line 1611 of file usb.c.

References _EPNS_DRQ, BITMASK_CLEAR, BITMASK_ISCLEARED, ErrorInvalidParameter, ErrorNotReady, Ok, and stc_usbn_endpoint_data::pstcEpStatusRegister.

boolean_t Usb_HalEndpointIsBusy ( stc_usbn_endpoint_data_t *  pstcEpHandle)

Unstall endpoint.

Parameters
pstcEpHandlePointer to endpoint instance
Returns
Ok on success

Definition at line 1332 of file usb.c.

References _EPNS_BUSY, BITMASK_ISSET, FALSE, stc_usbn_endpoint_data::pstcEpStatusRegister, and TRUE.

en_usb_endpoint_status_t Usb_HalEndpointStatus ( stc_usbn_endpoint_data_t *  pstcEpHandle)

Get information about the specified endpoint status.

Parameters
pstcEpHandleEndpoint handle
Returns
Status

Definition at line 1635 of file usb.c.

References _EPNC_EPEN, _EPNC_STAL, _EPNS_DRQ, BITMASK_ISCLEARED, BITMASK_ISSET, stc_usbn_endpoint_data::pstcEpControlRegister, stc_usbn_endpoint_data::pstcEpStatusRegister, UsbEndpointStatusIdle, UsbEndpointStatusNotReady, UsbEndpointStatusStall, and UsbEndpointStatusTransfer.

boolean_t Usb_HalEpReady ( stc_usbn_endpoint_data_t *  pstcEpHandle)

Get information if the specified endpoint is ready.

Parameters
pstcEpHandleEndpoint handle
Returns
TRUE if ready

Definition at line 1675 of file usb.c.

References _EPNC_EPEN, _EPNS_DRQ, BITMASK_ISCLEARED, FALSE, stc_usbn_endpoint_data::pstcEpControlRegister, stc_usbn_endpoint_data::pstcEpStatusRegister, and TRUE.

en_result_t Usb_HalReceive ( stc_usbn_endpoint_data_t *  pstcEpHandle,
uint8_t *  pu8Data,
uint16_t *  pu16ByteCount,
boolean_t  bClearDrq 
)

Read data via endpoint.

Parameters
pstcEpHandlePointer to endpoint instance
pu8DataDatabuffer to write in
pu16ByteCountPointer to data read
bClearDrqSet FIFO ready for next data
Returns
Ok on success

< Defines 'read / write' permissions

Definition at line 1553 of file usb.c.

References __IO, _EPNS_DRQ, BITMASK_CLEAR, BITMASK_ISCLEARED, ErrorInvalidParameter, ErrorNotReady, Ok, stc_usbn_endpoint_data::pstcEpDataRegister, stc_usbn_endpoint_data::pstcEpStatusRegister, and TRUE.

en_result_t Usb_HalSend ( stc_usbn_endpoint_data_t *  pstcEpHandle,
uint8_t *  pu8Data,
uint16_t  u16Size,
uint16_t *  pu16ByteCount 
)

Send data via endpoint.

Parameters
pstcEpHandlePointer to endpoint instance
pu8DataData to write
u16SizeData size
pu16ByteCountPointer to data written
Returns
Ok on success

< Defines 'read / write' permissions

Definition at line 1359 of file usb.c.

References __IO, _EPNS_DRQ, BITMASK_CLEAR, BITMASK_ISCLEARED, ErrorInvalidParameter, ErrorNotReady, Ok, stc_usbn_endpoint_data::pstcEpDataRegister, stc_usbn_endpoint_data::pstcEpStatusRegister, TRUE, stc_usbn_endpoint_data::u16EndpointSize, stc_usbn_endpoint_data::u8EndpointAddress, and USBDBGVAL8.

en_result_t Usb_HalStallEndpoint ( stc_usbn_endpoint_data_t *  pstcEpHandle)

Stall endpoint.

Parameters
pstcEpHandlePointer to endpoint instance
Returns
Ok on success

Definition at line 1302 of file usb.c.

References _EPNC_STAL, BITMASK_SET, Ok, and stc_usbn_endpoint_data::pstcEpControlRegister.

en_result_t Usb_HalUnstallEndpoint ( stc_usbn_endpoint_data_t *  pstcEpHandle)

Unstall endpoint.

Parameters
pstcEpHandlePointer to endpoint instance
Returns
Ok on success

Definition at line 1317 of file usb.c.

References _EPNC_STAL, BITMASK_CLEAR, Ok, and stc_usbn_endpoint_data::pstcEpControlRegister.

void USB_Handler ( void  )

USB 0 interrupt handler (only used in standalone mode)

Definition at line 1866 of file usb.c.

References UsbInstanceIndexUsb0, and UsbIrqHandler().

Here is the call graph for this function:

en_result_t Usb_Init ( void  )

Initialize USB in general.

Returns
en_result_t

Definition at line 474 of file usb.c.

References bL3_FM3_GPIO_EPFR00_USB0PE, bL3_FM3_GPIO_EPFR00_USB1PE, bL3_FM3_GPIO_PFR2_P0, bL3_FM3_GPIO_PFR6_P1, bL3_FM3_GPIO_SPSR_USB0C, bL3_FM3_GPIO_SPSR_USB1C, Ok, TRUE, Usb_InitInstance(), USB_INSTANCE_COUNT, UsbEthernetClock_Init(), and UsbInitDone.

Referenced by Usb_Configure().

Here is the call graph for this function:

Here is the caller graph for this function:

static en_result_t Usb_InitIrq ( stc_usbn_t *  pstcUsb)
static

Device dependent initialization of interrupts according CMSIS with level defined in l3.h.

Parameters
pstcUsbPointer to USB instance
Returns
Ok Successful initialization

Definition at line 269 of file usb.c.

References Ok, and USBDBG.

Referenced by Usb_Configure().

Here is the caller graph for this function:

void Usb_OsTickHandle ( void  )

Operation System Tick Handle

Definition at line 2091 of file usb.c.

References UsbInstanceIndexUsb0, UsbInstanceIndexUsb1, and UsbIrqHandler().

Here is the call graph for this function:

void Usb_RemoveTimeOut ( stc_usbn_t *  pstcUsb,
void(*)(stc_usbn_t *pstcUsb)  Handler 
)

Remove a timeout handler

Parameters
pstcUsbUSB handle
Handlerhandler executed after timeout
Returns
none

Definition at line 1805 of file usb.c.

References stc_usb_sof_timeout_handler::Handler, stc_usb_intern_data::pstcUsbTimeOutHandler, stc_usb_sof_timeout_handler::u16TimeOut, and UsbGetInternDataPtr().

Referenced by ReturnedConfigurationDescriptor(), ReturnedDeviceDescriptor(), and UsbClassSupervisor_Init().

Here is the call graph for this function:

Here is the caller graph for this function:

void Usb_SetEndpointRxTxCallback ( stc_usbn_endpoint_data_t *  pstcEndpoint,
usb_endpoint_datatransferred_func_ptr_t  pfnRxTxCallback 
)

Set RxTx Callback of an endpoint.

Parameters
pstcEndpointPointer to endpoint instance
pfnRxTxCallbackCallback routine
Returns
none

Definition at line 1240 of file usb.c.

References _EPNS_DRQIE, BITMASK_CLEAR, BITMASK_SET, stc_usbn_endpoint_data::pfnRxTxCallback, stc_usbn_endpoint_data::pstcEpStatusRegister, and stc_usbn_endpoint_data::u8EndpointAddress.

en_result_t Usb_SetupHalEndpoint ( stc_usbn_t *  pstcUsb,
uint8_t  u8EndpointAddress,
uint16_t  u16FifoSize,
en_usb_ep_type_t  enType,
boolean_t  bInterruptsEnabled 
)

Setup USB HAL endpoint.

Parameters
pstcUsbPointer to USB instance
u8EndpointAddressEndpoint address
u16FifoSizeEndpoint FIFO size
enTypeType of endpoint, see also en_usb_ep_type_t
bInterruptsEnabledUse interrupts
Returns
en_result_t

Definition at line 579 of file usb.c.

References _EPNC_EPEN, _EPNS_DRQIE, stc_usb_intern_data::astcEndpoints, BITMASK_CLEAR, BITMASK_SET, ErrorUninitialized, Ok, stc_usbn_endpoint_data::pstcEpControlRegister, stc_usbn_endpoint_data::pstcEpStatusRegister, TRUE, stc_usbn_endpoint_data::u16EndpointSize, stc_usbn_endpoint_data::u8EndpointAddress, and UsbGetInternDataPtr().

Here is the call graph for this function:

en_result_t Usb_SwitchUsb ( stc_usbn_t *  pstcUsb,
en_usb_switch_t  enType,
uint32_t  u32SwitchDelay 
)

Switch "Task" between host / device mode.

Parameters
pstcUsbPointer to USB instance
enTypeType of switching, see also en_usb_switch_t
u32SwitchDelayoptional delay
Returns
en_result_t

Definition at line 620 of file usb.c.

References stc_usb_intern_data::bDeviceActive, stc_usb_intern_data::bDeviceEnabled, stc_usb_intern_data::bHostActive, stc_usb_intern_data::bHostEnabled, ErrorNotReady, ErrorUninitialized, FALSE, Ok, stc_usb_intern_data::pfnDeviceVbus, TRUE, UsbExtIntGetLevel, UsbGetInternDataPtr(), UsbSwitchAllOff, UsbSwitchDependingDeviceVbus, UsbSwitchToDevice, and UsbSwitchToHost.

Here is the call graph for this function:

void Usb_Tick ( void  )

Definition at line 1829 of file usb.c.

References UsbInstanceIndexUsb0, UsbInstanceIndexUsb1, and UsbIrqHandler().

Here is the call graph for this function:

static void Usb_TimeoutHandler ( stc_usbn_t *  pstcUsb)
static

SOF callback - Realize Timeouts

Parameters
pstcUsbUSB handle

Definition at line 1722 of file usb.c.

References stc_usb_intern_data::bSofTimeoutEnabled, FALSE, stc_usb_sof_timeout_handler::Handler, stc_usb_intern_data::pstcUsbTimeOutHandler, TRUE, stc_usb_sof_timeout_handler::u16TimeOut, and UsbGetInternDataPtr().

Referenced by UsbIrqHandler().

Here is the call graph for this function:

Here is the caller graph for this function:

void UsbConfig_SwitchMode ( void  )
void UsbConfig_UsbInit ( void  )
static stc_usb_intern_data_t * UsbGetInternDataPtr ( stc_usbn_t *  pstcUsb)
static

Return the internal data for a certain USB instance.

Parameters
pstcUsbPointer to USB instance
Returns
Pointer to internal data or NULL if instance is not enabled (or not known)

Definition at line 244 of file usb.c.

References stc_usbn_instance_data::stcInternData, and USB_INSTANCE_COUNT.

Referenced by Usb_AddTimeOut(), Usb_Configure(), Usb_GetEndpointPtr(), Usb_InitInstance(), Usb_RemoveTimeOut(), Usb_SetupHalEndpoint(), Usb_SwitchUsb(), and Usb_TimeoutHandler().

Here is the caller graph for this function:

void UsbHost_DisconnectionCallback ( stc_usbn_t *  pstcUsb)

Variable Documentation

stc_usbn_instance_data_t m_astcUsbInstanceDataLut[]
Initial value:
=
{
}

Macro to return the number of enabled USB instances.

Look-up table for all enabled USB instances and their internal data.

Look-up table for all enabled USB instances and their internal data

Definition at line 130 of file usb.c.

stc_usbn_instance_data_t m_astcUsbInstanceDataLut[]

Look-up table for all enabled USB instances and their internal data.

Look-up table for all enabled USB instances and their internal data.

Look-up table for all enabled USB instances and their internal data

Definition at line 130 of file usb.c.

boolean_t UsbInitDone = FALSE
static

Definition at line 98 of file usb.c.

Referenced by Usb_Configure(), and Usb_Init().