#include "base_type.h"#include "mcu.h"#include "dbg.h"#include "UsbFunctionHW.h"

Go to the source code of this file.
History:
Definition in file UsbFunction.h.
| #define CLEAR_MASK | ( | x, | |||
| y | ) | x &= ~y |
Definition at line 66 of file UsbFunction.h.
| #define CLEAR_USB_STATUS_FLAG | ( | x | ) | u8UsbStatus &= ~x |
Definition at line 80 of file UsbFunction.h.
| #define CLEAR_USB_STATUS_FLAGS | ( | ) | u8UsbStatus = 0 |
Definition at line 81 of file UsbFunction.h.
| #define DMA_DIR_HOST_IN 1 |
Definition at line 208 of file UsbFunction.h.
| #define DMA_DIR_HOST_OUT 0 |
Definition at line 207 of file UsbFunction.h.
| #define DMA_OFFSET_BAPH 2 |
Definition at line 201 of file UsbFunction.h.
| #define DMA_OFFSET_BAPL 0 |
Definition at line 199 of file UsbFunction.h.
| #define DMA_OFFSET_BAPM 1 |
Definition at line 200 of file UsbFunction.h.
| #define DMA_OFFSET_DCTH 7 |
Definition at line 206 of file UsbFunction.h.
| #define DMA_OFFSET_DCTL 6 |
Definition at line 205 of file UsbFunction.h.
| #define DMA_OFFSET_DMACS 3 |
Definition at line 202 of file UsbFunction.h.
| #define DMA_OFFSET_IOAH 5 |
Definition at line 204 of file UsbFunction.h.
| #define DMA_OFFSET_IOAL 4 |
Definition at line 203 of file UsbFunction.h.
| #define EP_CONTROL | ( | x | ) | *(aEndpoint[x].EPnC) |
Definition at line 67 of file UsbFunction.h.
| #define EP_STATUS | ( | x | ) | *(aEndpoint[x].EPnS) |
Definition at line 68 of file UsbFunction.h.
| #define EP_STATUS_CONFIGURED 1 |
Definition at line 71 of file UsbFunction.h.
| #define EP_STATUS_DISABLED 2 |
Definition at line 72 of file UsbFunction.h.
| #define EP_STATUS_DMA_ENABLED 64 |
Definition at line 77 of file UsbFunction.h.
| #define EP_STATUS_DMA_TRANSFER 32 |
Definition at line 76 of file UsbFunction.h.
| #define EP_STATUS_ENABLED 4 |
Definition at line 73 of file UsbFunction.h.
| #define EP_STATUS_IDLE 0 |
Definition at line 70 of file UsbFunction.h.
| #define EP_STATUS_RECEIVING 8 |
Definition at line 74 of file UsbFunction.h.
| #define EP_STATUS_SENDING 16 |
Definition at line 75 of file UsbFunction.h.
| #define IS_CLEARED | ( | x, | |||
| y | ) | ((x & y) == 0) |
Definition at line 64 of file UsbFunction.h.
| #define IS_SET | ( | x, | |||
| y | ) | ((x & y) > 0) |
Definition at line 63 of file UsbFunction.h.
| #define MASK_EPC_DIR 0x1000 |
Definition at line 91 of file UsbFunction.h.
| #define MASK_EPC_DMAE 0x0800 |
Definition at line 90 of file UsbFunction.h.
| #define MASK_EPC_EPEN 0x8000 |
Definition at line 93 of file UsbFunction.h.
| #define MASK_EPC_NULE 0x0400 |
Definition at line 89 of file UsbFunction.h.
| #define MASK_EPC_PKS 0x007F |
Definition at line 86 of file UsbFunction.h.
| #define MASK_EPC_PKS1 0x01FF |
Definition at line 87 of file UsbFunction.h.
| #define MASK_EPC_STAL 0x0200 |
Definition at line 88 of file UsbFunction.h.
| #define MASK_EPC_TYPE 0x6000 |
Definition at line 92 of file UsbFunction.h.
| #define MASK_EPS_BFINI 0x8000 |
Definition at line 107 of file UsbFunction.h.
| #define MASK_EPS_BFINI 0x8000 |
Definition at line 107 of file UsbFunction.h.
| #define MASK_EPS_BUSY 0x0800 |
Definition at line 103 of file UsbFunction.h.
| #define MASK_EPS_DRQ 0x0400 |
Definition at line 102 of file UsbFunction.h.
| #define MASK_EPS_DRQI 0x0400 |
Definition at line 100 of file UsbFunction.h.
| #define MASK_EPS_DRQIE 0x4000 |
Definition at line 105 of file UsbFunction.h.
| #define MASK_EPS_DRQIIE 0x4000 |
Definition at line 95 of file UsbFunction.h.
| #define MASK_EPS_DRQO 0x0400 |
Definition at line 101 of file UsbFunction.h.
| #define MASK_EPS_DRQOIE 0x4000 |
Definition at line 106 of file UsbFunction.h.
| #define MASK_EPS_SIZE 0x007F |
Definition at line 98 of file UsbFunction.h.
| #define MASK_EPS_SIZE1 0x01FF |
Definition at line 97 of file UsbFunction.h.
| #define MASK_EPS_SPK 0x0200 |
Definition at line 99 of file UsbFunction.h.
| #define MASK_EPS_SPKIE 0x2000 |
Definition at line 104 of file UsbFunction.h.
| #define MAX_RECV_BUFFER 512 |
Definition at line 124 of file UsbFunction.h.
| #define pu16EndpointStatusReg_DRQ (*pu16EndpointStatusReg & 0x0400) |
Definition at line 82 of file UsbFunction.h.
| #define sendEP0 | ( | x, | |||
| y | ) | UsbFunction_SendData(0,x,y,1) |
Definition at line 191 of file UsbFunction.h.
| #define sendEP1 | ( | x, | |||
| y | ) | UsbFunction_SendData(1,x,y,1) |
Definition at line 192 of file UsbFunction.h.
| #define sendEP2 | ( | x, | |||
| y | ) | UsbFunction_SendData(2,x,y,1) |
Definition at line 193 of file UsbFunction.h.
| #define sendEP3 | ( | x, | |||
| y | ) | UsbFunction_SendData(3,x,y,1) |
Definition at line 194 of file UsbFunction.h.
| #define sendEP4 | ( | x, | |||
| y | ) | UsbFunction_SendData(4,x,y,1) |
Definition at line 195 of file UsbFunction.h.
| #define sendEP5 | ( | x, | |||
| y | ) | UsbFunction_SendData(5,x,y,1) |
Definition at line 196 of file UsbFunction.h.
| #define SET_MASK | ( | x, | |||
| y | ) | x |= y |
Definition at line 65 of file UsbFunction.h.
| #define SET_pu16EndpointStatusReg_BFINI | ( | x | ) | *pu16EndpointStatusReg = ((*pu16EndpointStatusReg & 0x7FFF) | x << 15) |
Definition at line 84 of file UsbFunction.h.
| #define SET_pu16EndpointStatusReg_DRQ | ( | x | ) | *pu16EndpointStatusReg = ((*pu16EndpointStatusReg & 0xFBFF) | x << 10) |
Definition at line 83 of file UsbFunction.h.
| #define SET_USB_STATUS_FLAG | ( | x | ) | u8UsbStatus |= x |
Definition at line 79 of file UsbFunction.h.
| #define USB_BUFFER_FAR 0 |
Definition at line 60 of file UsbFunction.h.
| #define USB_CLEAR_FEATURE 0x01 |
Definition at line 135 of file UsbFunction.h.
| #define USB_DEVREQ_CLSTYPE 0x20 |
Definition at line 127 of file UsbFunction.h.
| #define USB_DEVREQ_GET_DESC 0x06 |
Definition at line 130 of file UsbFunction.h.
| #define USB_DEVREQ_SET_DESC 0x07 |
Definition at line 131 of file UsbFunction.h.
| #define USB_DEVREQ_SET_IDLE 0x0A |
Definition at line 132 of file UsbFunction.h.
| #define USB_DEVREQ_STDTYPE 0x00 |
Definition at line 126 of file UsbFunction.h.
| #define USB_DEVREQ_VNDTYPE 0x40 |
Definition at line 128 of file UsbFunction.h.
| #define USB_EP0 0x00 |
Definition at line 184 of file UsbFunction.h.
| #define USB_EP_1 0x01 |
Definition at line 185 of file UsbFunction.h.
| #define USB_EP_2 0x02 |
Definition at line 186 of file UsbFunction.h.
| #define USB_EP_3 0x03 |
Definition at line 187 of file UsbFunction.h.
| #define USB_EP_4 0x04 |
Definition at line 188 of file UsbFunction.h.
| #define USB_EP_5 0x05 |
Definition at line 189 of file UsbFunction.h.
| #define USB_EVENT_CLASSREQUEST 0x10 |
Definition at line 176 of file UsbFunction.h.
| #define USB_EVENT_CONFIGURED 0x20 |
Definition at line 177 of file UsbFunction.h.
| #define USB_EVENT_CONNECT 0x01 |
Definition at line 172 of file UsbFunction.h.
| #define USB_EVENT_DECONFIGURED 0x40 |
Definition at line 178 of file UsbFunction.h.
| #define USB_EVENT_DISCONNECT 0x02 |
Definition at line 173 of file UsbFunction.h.
| #define USB_EVENT_RECEIVE 0x04 |
Definition at line 174 of file UsbFunction.h.
| #define USB_EVENT_SENT 0x08 |
Definition at line 175 of file UsbFunction.h.
| #define USB_EVENT_TARGET_GENERAL 0x01 |
Definition at line 167 of file UsbFunction.h.
| #define USB_EVENT_TARGET_INTERFACE 0x04 |
Definition at line 170 of file UsbFunction.h.
| #define USB_EVENT_TARGET_MAINAPP 0x02 |
Definition at line 168 of file UsbFunction.h.
| #define USB_EVENT_TARGET_VENDOR 0x03 |
Definition at line 169 of file UsbFunction.h.
| #define USB_FUNC_BULK_IN 0xD000 |
Definition at line 121 of file UsbFunction.h.
| #define USB_FUNC_BULK_OUT 0xC000 |
Definition at line 122 of file UsbFunction.h.
| #define USB_FUNC_INTR_IN 0xF000 |
Definition at line 119 of file UsbFunction.h.
| #define USB_FUNC_INTR_OUT 0xE000 |
Definition at line 120 of file UsbFunction.h.
| #define USB_GET_CONFIGURATION 0x08 |
Definition at line 140 of file UsbFunction.h.
| #define USB_GET_DESCRIPTOR 0x06 |
Definition at line 138 of file UsbFunction.h.
| #define USB_GET_INTERFACE 0x0A |
Definition at line 142 of file UsbFunction.h.
| #define USB_GET_STATUS 0x00 |
Definition at line 134 of file UsbFunction.h.
| #define USB_REQUEST_CONFIG_DESCRIPTOR 0x02 |
Definition at line 158 of file UsbFunction.h.
| #define USB_REQUEST_DEVICE_DESCRIPTOR 0x01 |
Definition at line 157 of file UsbFunction.h.
| #define USB_REQUEST_DEVQUA_DESCRIPTOR 0x06 |
Definition at line 162 of file UsbFunction.h.
| #define USB_REQUEST_ENDPNT_DESCRIPTOR 0x05 |
Definition at line 161 of file UsbFunction.h.
| #define USB_REQUEST_IFPOWR_DESCRIPTOR 0x08 |
Definition at line 164 of file UsbFunction.h.
| #define USB_REQUEST_INTERF_DESCRIPTOR 0x04 |
Definition at line 160 of file UsbFunction.h.
| #define USB_REQUEST_OTHSPE_DESCRIPTOR 0x07 |
Definition at line 163 of file UsbFunction.h.
| #define USB_REQUEST_REPORT_DESCRIPTOR 0x22 |
Definition at line 165 of file UsbFunction.h.
| #define USB_REQUEST_STRING_DESCRIPTOR 0x03 |
Definition at line 159 of file UsbFunction.h.
| #define USB_REQUEST_TYPE_CLASS 1 |
Definition at line 154 of file UsbFunction.h.
| #define USB_REQUEST_TYPE_STANDARD 0 |
Definition at line 153 of file UsbFunction.h.
| #define USB_REQUEST_TYPE_VENDOR 2 |
Definition at line 155 of file UsbFunction.h.
| #define USB_SENDING_MODE_DMA 2 |
Definition at line 182 of file UsbFunction.h.
| #define USB_SENDING_MODE_INTERRUPT 0 |
Definition at line 180 of file UsbFunction.h.
| #define USB_SENDING_MODE_POLLED 1 |
Definition at line 181 of file UsbFunction.h.
| #define USB_SET_ADDRESS 0x05 |
Definition at line 137 of file UsbFunction.h.
| #define USB_SET_CONFIGURATION 0x09 |
Definition at line 141 of file UsbFunction.h.
| #define USB_SET_DESCRIPTOR 0x07 |
Definition at line 139 of file UsbFunction.h.
| #define USB_SET_FEATURE 0x03 |
Definition at line 136 of file UsbFunction.h.
| #define USB_SET_INTERFACE 0x0B |
Definition at line 143 of file UsbFunction.h.
| #define USB_STATUS_CONFDESC 0x04 |
Definition at line 149 of file UsbFunction.h.
| #define USB_STATUS_CONFIGURED 0x08 |
Definition at line 150 of file UsbFunction.h.
| #define USB_STATUS_CONNECTED 0x01 |
Definition at line 147 of file UsbFunction.h.
| #define USB_STATUS_DEVDESC 0x02 |
Definition at line 148 of file UsbFunction.h.
| #define USB_SYNCH_FRAME 0x0C |
Definition at line 144 of file UsbFunction.h.
| #define USB_USE_DMA 1 |
Definition at line 59 of file UsbFunction.h.
| #define USBATTR_BUSPOWER 0x80 |
Definition at line 115 of file UsbFunction.h.
| #define USBATTR_REMOTEWAKE 0x20 |
Definition at line 117 of file UsbFunction.h.
| #define USBATTR_SELFPOWER 0xC0 |
Definition at line 116 of file UsbFunction.h.
| #define USBDESCR_CONFIG 2 |
Definition at line 110 of file UsbFunction.h.
| #define USBDESCR_DEVICE 1 |
Definition at line 109 of file UsbFunction.h.
| #define USBDESCR_ENDPOINT 5 |
Definition at line 113 of file UsbFunction.h.
| #define USBDESCR_INTERFACE 4 |
Definition at line 112 of file UsbFunction.h.
| #define USBDESCR_STRING 3 |
Definition at line 111 of file UsbFunction.h.
| typedef struct stc_dma_handler dma_handler_t |
Definition at line 219 of file UsbFunction.h.
Definition at line 218 of file UsbFunction.h.
| typedef struct stc_usb_buffer usb_buffer_t |
| typedef struct stc_usb_EP usb_EP_t |
| typedef struct stc_usb_event usb_event_t |
| typedef struct stc_usb_request usb_request_t |
| void ConnectEvent | ( | ) |

| void DisableEndpoints | ( | void | ) |

| void DisconnectEvent | ( | ) |

| uint8_t DummyEventHandler | ( | usb_event_t * | ) |
| void EnableEndpoints | ( | void | ) |

| void ReleaseDma | ( | uint8_t | u8EndpointNumber | ) |
| void SendReceiveBufferViaDma | ( | uint8_t | u8EndpointNumber | ) |

| void SetupEndpoints | ( | ) |
| void UsbFunction_ChangeDmaSettings | ( | uint8_t | u8EndpointNumber, | |
| volatile uint8_t * | DISELn, | |||
| volatile uint8_t * | pu8DmaDescriptor | |||
| ) |
| void UsbFunction_ClearStartOfFrameHandler | ( | void | ) |
Connect USB function (only used if auto connect is disabled)
| bAutoConnect | can be used to auto connect/disconnect (standard) |
Definition at line 949 of file UsbFunction.c.

| void UsbFunction_DisableSOF | ( | void | ) |
Disconnect USB function
| bForceDisconnect | can be used to force disconnect |
Definition at line 975 of file UsbFunction.c.

| void UsbFunction_EnableSOF | ( | void | ) |
| void UsbFunction_EnableWakeup | ( | boolean_t | bEnableDisable | ) |
send wakeup to computer
| bEnableDisable | TRUE to enable, FALSE to disable |
Definition at line 1213 of file UsbFunction.c.
| __interrupt void UsbFunction_EndpointIsr | ( | void | ) |
Interrupt Routine (USB-Function Endpoint1-5 Interrupt)
Example Vectors.c
Definition at line 1728 of file UsbFunction.c.
Get the current endpoint status
| u8Endpoint | Endpoint Number (0..5) |
Definition at line 460 of file UsbFunction.c.
| uint8_t UsbFunction_GetStatus | ( | void | ) |
Get the current USB status
Definition at line 448 of file UsbFunction.c.

| void UsbFunction_Initialize | ( | ) |
| void UsbFunction_SendData | ( | uint8_t | u8EndpointNumber, | |
| puint8_t | buffer, | |||
| uint32_t | buffersize, | |||
| uint8_t | u8PollingMode | |||
| ) |
Procedure to send buffer with Endpoint 0..5
| u8EndpointNumber | Endpoint number (0..5) | |
| buffer | pointer of buffer to send | |
| buffersize | size of buffer to send |
Definition at line 1004 of file UsbFunction.c.


| void UsbFunction_SetCustomEndpointBuffer | ( | uint8_t | u8Endpoint, | |
| usb_buffer_t * | pstcEndpointBuffer | |||
| ) |
Set a custom endpoint buffer
| u8Endpoint | Endpoint number | |
| pstcEndpointBuffer | pointer to buffer struct |
Example:
Definition at line 612 of file UsbFunction.c.

only for Endpoint 0, used in data stage to send replies for requests
| buffer | pointer of buffer to send | |
| buffersize | size of buffer to send |
Definition at line 1181 of file UsbFunction.c.
| void UsbFunction_SetStartOfFrameHandler | ( | void(*)(uint16_t u16FrameNumber) | handler | ) |
Set a Start of Frame handler
| handler | Start Of Framehandler, type: handler(uint16_t u16FrameNumber); |
Definition at line 582 of file UsbFunction.c.
| void UsbFunction_Stall | ( | uint8_t | u8EndpointNumber | ) |
| void UsbFunction_StallRemove | ( | uint8_t | u8EndpointNumber | ) |
Routine to unstall endpoint 0
Definition at line 1230 of file UsbFunction.c.

| __interrupt void UsbFunction_StatusControlIsr | ( | void | ) |
Interrupt Routine (USB-Function Status & Control Interrupt)
Example Vectors.c
Definition at line 1839 of file UsbFunction.c.
| __interrupt void UsbFunction_VbusIsr | ( | void | ) |
Interrupt Routine (USB-Function VBUS Interrupt)
Example Vectors.c
Definition at line 1920 of file UsbFunction.c.
| uint8_t UsbGetDescriptor | ( | usb_request_t * | ) |
| void UsbReceiveDataEndpoint0 | ( | ) |

| void UsbReceiveSetup | ( | ) |

1.6.1