PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
usb.h File Reference
#include "mcu.h"
#include "usbconfig.h"
#include "string.h"
#include "pdl.h"
#include "base_types.h"
Include dependency graph for usb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

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 FM3MCUTYPE_TYPE0   0
 
#define FM3MCUTYPE_TYPE1   1
 
#define FM3MCUTYPE_TYPE2   2
 
#define FM3MCUTYPE_TYPE3   3
 
#define FM3MCUTYPE_TYPE4   4
 
#define FM3MCUTYPE_TYPE5   5
 
#define FM3MCUTYPE_TYPE6   6
 
#define FM3MCUTYPE_TYPE7   7
 
#define FM4MCUTYPE_TYPE0   0
 
#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_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 USB_MASK_EPS_BFINI   0x8000
 
#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))
 
#define haha123   1
 

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...
 

Detailed Description

Headerfile for USB functions

A detailed description is available at USB Module description

History:

  • 2012-08-28 2.0 MSc First version (starting at version 2.0)
  • 2012-10-02 2.1 MSc use of external interrupts without L3 implemented
  • 2012-11-13 2.2 MSc Some problems while switching from Host to Device fixed
  • 2013-01-31 2.3 MSc DMA added
  • 2013-05-07 2.4 MSc Minor optimizations
  • 2013-06-04 2.5 MSc FM4 support added
  • 2013-09-23 2.6 MSc FM4 PDL support added
  • 2013-11-29 2.7 MSc PDL adjustments done
  • 2014-02-28 2.8 MSc Fixes for FM4 (IRQ naming, mcu headerfile typedef) Fixes in SwitchUsb Routine
  • 2014-05-27 2.9 MSc IRQ double definition with use of PDL > V1.0 solved

Definition in file usb.h.

Macro Definition Documentation

#define FM3MCUTYPE_TYPE0   0
#define FM3MCUTYPE_TYPE1   1
#define FM3MCUTYPE_TYPE2   2
#define FM3MCUTYPE_TYPE3   3
#define FM3MCUTYPE_TYPE4   4
#define FM3MCUTYPE_TYPE5   5
#define FM3MCUTYPE_TYPE6   6
#define FM3MCUTYPE_TYPE7   7
#define FM4MCUTYPE_TYPE0   0
#define haha123   1