initial commit
[armstart-ibdap] / inc / usb_driver.h
1 /*
2  * usb_driver.h
3  *
4  *  Created on: Jun 18, 2015
5  *      Author: yliu
6  */
7
8 #ifndef USB_DRIVER_H_
9 #define USB_DRIVER_H_
10
11
12 #include "app_usbd_cfg.h"
13 #include "usbd_rom_api.h"
14
15
16 typedef struct {
17         const uint32_t usbdApiBase;                             /*!< USBD API function table base address */
18         const uint32_t reserved0;                               /*!< Reserved */
19         const uint32_t candApiBase;                             /*!< CAN API function table base address */
20         const uint32_t pwrApiBase;                              /*!< Power API function table base address */
21         const uint32_t reserved1;                               /*!< Reserved */
22         const uint32_t reserved2;                               /*!< Reserved */
23         const uint32_t reserved3;                               /*!< Reserved */
24         const uint32_t reserved4;                               /*!< Reserved */
25 } LPC_ROM_API_T;
26
27
28
29 #define LPC_ROM_API_BASE_LOC      0x1FFF1FF8
30 #define LPC_ROM_API               (*((LPC_ROM_API_T        * *) LPC_ROM_API_BASE_LOC))
31
32
33 typedef ErrorCode_t (*HID_GetReport_Func_T)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
34 typedef ErrorCode_t (*HID_SetReport_Func_T)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
35 typedef ErrorCode_t (*HID_EpIn_Hdlr_Func_T) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
36 typedef ErrorCode_t (*HID_EpOut_Hdlr_Func_T) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
37
38 void init_usb_clock ();
39 void init_usb_power ();
40 int init_usb_driver (USBD_API_INIT_PARAM_T *usb_param);
41 int init_usb_hid (USBD_API_INIT_PARAM_T *usb_param,
42                 HID_GetReport_Func_T getreport_fun, HID_SetReport_Func_T setreport_fun,
43                 HID_EpIn_Hdlr_Func_T epin_hdlr_fun, HID_EpOut_Hdlr_Func_T epout_hdlr_fun,
44                 uint8_t** report_saddr, int report_size);
45
46 void connect_to_usb_bus ();
47 void disconnect_to_usb_bus ();
48
49
50 extern USBD_HANDLE_T g_usb_hnd;
51
52
53 #endif /* USB_DRIVER_H_ */