]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/USBHost/USBHost/TARGET_RENESAS/TARGET_RZ_A1H/inc/devdrv_usb_host_api.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / USBHost / USBHost / TARGET_RENESAS / TARGET_RZ_A1H / inc / devdrv_usb_host_api.h
1 /*******************************************************************************
2 * DISCLAIMER
3 * This software is supplied by Renesas Electronics Corporation and is only
4 * intended for use with Renesas products. No other uses are authorized. This
5 * software is owned by Renesas Electronics Corporation and is protected under
6 * all applicable laws, including copyright laws.
7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
16 * Renesas reserves the right, without notice, to make changes to this software
17 * and to discontinue the availability of this software. By using this software,
18 * you agree to the additional terms and conditions found by accessing the
19 * following link:
20 * http://www.renesas.com/disclaimer
21 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
22 *******************************************************************************/
23 /*******************************************************************************
24 * File Name : devdrv_usb_host_api.h
25 * $Rev: 1116 $
26 * $Date:: 2014-07-09 16:29:19 +0900#$
27 * Description : RZ/A1H R7S72100 USB Sample Program
28 *******************************************************************************/
29 #ifndef USB_HOST_API_H
30 #define USB_HOST_API_H
31
32 #include "r_typedefs.h"
33
34
35 /*******************************************************************************
36 Typedef definitions
37 *******************************************************************************/
38
39
40 /*******************************************************************************
41 Macro definitions
42 *******************************************************************************/
43 #define USB_HOST_PORTNUM (2)
44
45 #define USB_HOST_ELT_INTERRUPT_LEVEL (9)
46
47 #define USBHCLOCK_X1_48MHZ (0x0000u) /* USB_X1_48MHz */
48 #define USBHCLOCK_EXTAL_12MHZ (0x0004u) /* EXTAL_12MHz */
49
50 #define USB_HOST_MAX_DEVICE (10)
51
52 #define USB_HOST_ON (1)
53 #define USB_HOST_OFF (0)
54 #define USB_HOST_YES (1)
55 #define USB_HOST_NO (0)
56
57 #define USB_HOST_NON_SPEED (0)
58 #define USB_HOST_LOW_SPEED (1)
59 #define USB_HOST_FULL_SPEED (2)
60 #define USB_HOST_HIGH_SPEED (3)
61
62 /* DEVDRV_SUCCESS(0) & DEVDRV_ERROR(-1) is dev_drv.h */
63 #define DEVDRV_USBH_STALL (-2)
64 #define DEVDRV_USBH_TIMEOUT (-3)
65 #define DEVDRV_USBH_NAK_TIMEOUT (-4)
66 #define DEVDRV_USBH_DETACH_ERR (-5)
67 #define DEVDRV_USBH_SETUP_ERR (-6)
68 #define DEVDRV_USBH_CTRL_COM_ERR (-7)
69 #define DEVDRV_USBH_COM_ERR (-8)
70 #define DEVDRV_USBH_DEV_ADDR_ERR (-9)
71
72 #define USB_HOST_ATTACH (1)
73 #define USB_HOST_DETACH (0)
74
75 #define USB_HOST_MAX_PIPE_NO (9u)
76 #define USB_HOST_PIPE0 (0)
77 #define USB_HOST_PIPE1 (1)
78 #define USB_HOST_PIPE2 (2)
79 #define USB_HOST_PIPE3 (3)
80 #define USB_HOST_PIPE4 (4)
81 #define USB_HOST_PIPE5 (5)
82 #define USB_HOST_PIPE6 (6)
83 #define USB_HOST_PIPE7 (7)
84 #define USB_HOST_PIPE8 (8)
85 #define USB_HOST_PIPE9 (9)
86
87 #define USB_HOST_ISO (0xc000u)
88 #define USB_HOST_INTERRUPT (0x8000u)
89 #define USB_HOST_BULK (0x4000u)
90
91 #define USB_HOST_PIPE_IDLE (0x00)
92 #define USB_HOST_PIPE_WAIT (0x01)
93 #define USB_HOST_PIPE_DONE (0x02)
94 #define USB_HOST_PIPE_NORES (0x03)
95 #define USB_HOST_PIPE_STALL (0x04)
96 #define USB_HOST_PIPE_ERROR (0x05)
97
98 #define USB_HOST_NONE (0x0000u)
99 #define USB_HOST_BFREFIELD (0x0400u)
100 #define USB_HOST_BFREON (0x0400u)
101 #define USB_HOST_BFREOFF (0x0000u)
102 #define USB_HOST_DBLBFIELD (0x0200u)
103 #define USB_HOST_DBLBON (0x0200u)
104 #define USB_HOST_DBLBOFF (0x0000u)
105 #define USB_HOST_CNTMDFIELD (0x0100u)
106 #define USB_HOST_CNTMDON (0x0100u)
107 #define USB_HOST_CNTMDOFF (0x0000u)
108 #define USB_HOST_SHTNAKON (0x0080u)
109 #define USB_HOST_SHTNAKOFF (0x0000u)
110 #define USB_HOST_DIRFIELD (0x0010u)
111 #define USB_HOST_DIR_H_OUT (0x0010u)
112 #define USB_HOST_DIR_H_IN (0x0000u)
113 #define USB_HOST_EPNUMFIELD (0x000fu)
114
115 #define USB_HOST_CUSE (0)
116 #define USB_HOST_D0USE (1)
117 #define USB_HOST_D0DMA (2)
118 #define USB_HOST_D1USE (3)
119 #define USB_HOST_D1DMA (4)
120
121 #define USB_HOST_CFIFO_USE (0x0000)
122 #define USB_HOST_D0FIFO_USE (0x1000)
123 #define USB_HOST_D1FIFO_USE (0x2000)
124 #define USB_HOST_D0FIFO_DMA (0x5000)
125 #define USB_HOST_D1FIFO_DMA (0x6000)
126
127 #define USB_HOST_BUF2FIFO (0)
128 #define USB_HOST_FIFO2BUF (1)
129
130 #define USB_HOST_DRV_DETACHED (0x0000)
131 #define USB_HOST_DRV_ATTACHED (0x0001)
132 #define USB_HOST_DRV_GET_DEVICE_DESC_64 (0x0002)
133 #define USB_HOST_DRV_POWERED (0x0003)
134 #define USB_HOST_DRV_DEFAULT (0x0004)
135 #define USB_HOST_DRV_SET_ADDRESS (0x0005)
136 #define USB_HOST_DRV_ADDRESSED (0x0006)
137 #define USB_HOST_DRV_GET_DEVICE_DESC_18 (0x0007)
138 #define USB_HOST_DRV_GET_CONGIG_DESC_9 (0x0008)
139 #define USB_HOST_DRV_GET_CONGIG_DESC (0x0009)
140 #define USB_HOST_DRV_SET_CONFIG (0x000a)
141 #define USB_HOST_DRV_CONFIGURED (0x000b)
142 #define USB_HOST_DRV_SUSPEND (0x1000)
143 #define USB_HOST_DRV_NORES (0x0100)
144 #define USB_HOST_DRV_STALL (0x0200)
145
146 #define USB_HOST_TESTMODE_FORCE (0x000du)
147 #define USB_HOST_TESTMODE_TESTPACKET (0x000cu)
148 #define USB_HOST_TESTMODE_SE0_NAK (0x000bu)
149 #define USB_HOST_TESTMODE_K (0x000au)
150 #define USB_HOST_TESTMODE_J (0x0009u)
151 #define USB_HOST_TESTMODE_NORMAL (0x0000u)
152
153 #define USB_HOST_DT_DEVICE (0x01)
154 #define USB_HOST_DT_CONFIGURATION (0x02)
155 #define USB_HOST_DT_STRING (0x03)
156 #define USB_HOST_DT_INTERFACE (0x04)
157 #define USB_HOST_DT_ENDPOINT (0x05)
158 #define USB_HOST_DT_DEVICE_QUALIFIER (0x06)
159 #define USB_HOST_DT_OTHER_SPEED_CONFIGURATION (0x07)
160 #define USB_HOST_DT_INTERFACE_POWER (0x08)
161
162 #define USB_HOST_IF_CLS_NOT (0x00)
163 #define USB_HOST_IF_CLS_AUDIO (0x01)
164 #define USB_HOST_IF_CLS_CDC_CTRL (0x02)
165 #define USB_HOST_IF_CLS_HID (0x03)
166 #define USB_HOST_IF_CLS_PHYSICAL (0x05)
167 #define USB_HOST_IF_CLS_IMAGE (0x06)
168 #define USB_HOST_IF_CLS_PRINTER (0x07)
169 #define USB_HOST_IF_CLS_MASS (0x08)
170 #define USB_HOST_IF_CLS_HUB (0x09)
171 #define USB_HOST_IF_CLS_CDC_DATA (0x0a)
172 #define USB_HOST_IF_CLS_CRAD (0x0b)
173 #define USB_HOST_IF_CLS_CONTENT (0x0d)
174 #define USB_HOST_IF_CLS_VIDEO (0x0e)
175 #define USB_HOST_IF_CLS_DIAG (0xdc)
176 #define USB_HOST_IF_CLS_WIRELESS (0xe0)
177 #define USB_HOST_IF_CLS_APL (0xfe)
178 #define USB_HOST_IF_CLS_VENDOR (0xff)
179 #define USB_HOST_IF_CLS_HELE (0xaa)
180
181 #define USB_HOST_EP_DIR_MASK (0x80)
182 #define USB_HOST_EP_OUT (0x00)
183 #define USB_HOST_EP_IN (0x80)
184 #define USB_HOST_EP_TYPE (0x03)
185 #define USB_HOST_EP_CNTRL (0x00)
186 #define USB_HOST_EP_ISO (0x01)
187 #define USB_HOST_EP_BULK (0x02)
188 #define USB_HOST_EP_INT (0x03)
189 #define USB_HOST_EP_NUM_MASK (0x0f)
190
191 #define USB_HOST_PIPE_IN (0)
192 #define USB_HOST_PIPE_OUT (1)
193
194 #define USB_END_POINT_ERROR (0xffff)
195
196 #define USB_HOST_REQ_GET_STATUS (0x0000)
197 #define USB_HOST_REQ_CLEAR_FEATURE (0x0100)
198 #define USB_HOST_REQ_RESERVED2 (0x0200)
199 #define USB_HOST_REQ_SET_FEATURE (0x0300)
200 #define USB_HOST_REQ_RESERVED4 (0x0400)
201 #define USB_HOST_REQ_SET_ADDRESS (0x0500)
202 #define USB_HOST_REQ_GET_DESCRIPTOR (0x0600)
203 #define USB_HOST_REQ_SET_DESCRIPTOR (0x0700)
204 #define USB_HOST_REQ_GET_CONFIGURATION (0x0800)
205 #define USB_HOST_REQ_SET_CONFIGURATION (0x0900)
206 #define USB_HOST_REQ_GET_INTERFACE (0x0a00)
207 #define USB_HOST_REQ_SET_INTERFACE (0x0b00)
208 #define USB_HOST_REQ_SYNCH_FRAME (0x0c00)
209
210 #define USB_HOST_REQTYPE_HOST_TO_DEVICE (0x0000)
211 #define USB_HOST_REQTYPE_DEVICE_TO_HOST (0x0080)
212 #define USB_HOST_REQTYPE_STANDARD (0x0020)
213 #define USB_HOST_REQTYPE_CLASS (0x0040)
214 #define USB_HOST_REQTYPE_VENDOR (0x0060)
215 #define USB_HOST_REQTYPE_DEVICE (0x0000)
216 #define USB_HOST_REQTYPE_INTERFACE (0x0001)
217 #define USB_HOST_REQTYPE_ENDPOINT (0x0002)
218 #define USB_HOST_REQTYPE_OTHER (0x0003)
219
220 #define USB_HOST_DESCTYPE_DEVICE (0x0100)
221 #define USB_HOST_DESCTYPE_CONFIGURATION (0x0200)
222 #define USB_HOST_DESCTYPE_STRING (0x0300)
223 #define USB_HOST_DESCTYPE_INTERFACE (0x0400)
224 #define USB_HOST_DESCTYPE_ENDPOINT (0x0500)
225 #define USB_HOST_DESCTYPE_DEVICE_QUALIFIER (0x0600)
226 #define USB_HOST_DESCTYPE_OTHER_SPEED_CONFIGURATION (0x0700)
227 #define USB_HOST_DESCTYPE_INTERFACE_POWER (0x0800)
228
229
230 /*******************************************************************************
231 Variable Externs
232 *******************************************************************************/
233 typedef struct
234 {
235 uint16_t pipe_number;
236 uint16_t pipe_cfg;
237 uint16_t pipe_buf;
238 uint16_t pipe_max_pktsize;
239 uint16_t pipe_cycle;
240 uint16_t fifo_port;
241 } USB_HOST_CFG_PIPETBL_t;
242
243 typedef struct
244 {
245 uint32_t fifo;
246 uint32_t buffer;
247 uint32_t bytes;
248 uint32_t dir;
249 uint32_t size;
250 } USB_HOST_DMA_t;
251
252
253 /*******************************************************************************
254 Imported global variables and functions (from other files)
255 *******************************************************************************/
256 uint16_t R_USB_api_host_init(uint16_t root, uint8_t int_level, uint16_t mode, uint16_t clockmode);
257 int32_t R_USB_api_host_enumeration(uint16_t root, uint16_t devadr);
258 int32_t R_USB_api_host_detach(uint16_t root);
259 int32_t R_USB_api_host_data_in(uint16_t root, uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t *data_buf);
260 int32_t R_USB_api_host_data_in2(uint16_t root, uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t *data_buf, uint32_t *bytes);
261 int32_t R_USB_api_host_data_out(uint16_t root, uint16_t devadr, uint16_t Pipe, uint32_t Size, uint8_t *data_buf);
262 int32_t R_USB_api_host_control_transfer(uint16_t root, uint16_t devadr, uint16_t Req, uint16_t Val, uint16_t Indx, uint16_t Len, uint8_t *Buf);
263 int32_t R_USB_api_host_set_endpoint(uint16_t root, uint16_t devadr, USB_HOST_CFG_PIPETBL_t *user_table, uint8_t *configdescriptor);
264 int32_t R_USB_api_host_clear_endpoint(uint16_t root, USB_HOST_CFG_PIPETBL_t *user_table);
265 int32_t R_USB_api_host_clear_endpoint_pipe(uint16_t root, uint16_t pipe_sel, USB_HOST_CFG_PIPETBL_t *user_table);
266 uint16_t R_USB_api_host_SetEndpointTable(uint16_t root, uint16_t devadr, USB_HOST_CFG_PIPETBL_t *user_table, uint8_t* Table);
267
268 int32_t R_USB_api_host_GetDeviceDescriptor(uint16_t root, uint16_t devadr, uint16_t size, uint8_t *buf);
269 int32_t R_USB_api_host_GetConfigDescriptor(uint16_t root, uint16_t devadr, uint16_t size, uint8_t *buf);
270 int32_t R_USB_api_host_SetConfig(uint16_t root, uint16_t devadr, uint16_t confignum);
271 int32_t R_USB_api_host_SetInterface(uint16_t root, uint16_t devadr, uint16_t interface_alt, uint16_t interface_index);
272 int32_t R_USB_api_host_ClearStall(uint16_t root, uint16_t devadr, uint16_t ep_dir);
273 uint16_t R_USB_api_host_GetUsbDeviceState(uint16_t root);
274
275 void R_USB_api_host_elt_clocksel(uint16_t clockmode);
276 void R_USB_api_host_elt_4_4(uint16_t root);
277 void R_USB_api_host_elt_4_5(uint16_t root);
278 void R_USB_api_host_elt_4_6(uint16_t root);
279 void R_USB_api_host_elt_4_7(uint16_t root);
280 void R_USB_api_host_elt_4_8(uint16_t root);
281 void R_USB_api_host_elt_4_9(uint16_t root);
282 void R_USB_api_host_elt_get_desc(uint16_t root);
283
284
285 /*******************************************************************************
286 Includes <System Includes> , "Project Includes"
287 *******************************************************************************/
288 #include "usb0_host_api.h"
289 #include "usb1_host_api.h"
290
291
292 /*******************************************************************************
293 Imported global variables and functions (from other files)
294 *******************************************************************************/
295 #ifdef USB0_HOST_API_H
296 uint16_t Userdef_USB_usb0_host_d0fifo_dmaintid(void);
297 uint16_t Userdef_USB_usb0_host_d1fifo_dmaintid(void);
298 void Userdef_USB_usb0_host_attach(void);
299 void Userdef_USB_usb0_host_detach(void);
300 void Userdef_USB_usb0_host_delay_1ms(void);
301 void Userdef_USB_usb0_host_delay_xms(uint32_t msec);
302 void Userdef_USB_usb0_host_delay_10us(uint32_t usec);
303 void Userdef_USB_usb0_host_delay_500ns(void);
304 void Userdef_USB_usb0_host_start_dma(USB_HOST_DMA_t * dma, uint16_t dfacc);
305 uint32_t Userdef_USB_usb0_host_stop_dma0(void);
306 uint32_t Userdef_USB_usb0_host_stop_dma1(void);
307 void Userdef_USB_usb0_host_notice(const char * format);
308 void Userdef_USB_usb0_host_user_rdy(const char * format, uint16_t data);
309 #endif
310
311 #ifdef USB1_HOST_API_H
312 uint16_t Userdef_USB_usb1_host_d0fifo_dmaintid(void);
313 uint16_t Userdef_USB_usb1_host_d1fifo_dmaintid(void);
314 void Userdef_USB_usb1_host_attach(void);
315 void Userdef_USB_usb1_host_detach(void);
316 void Userdef_USB_usb1_host_delay_1ms(void);
317 void Userdef_USB_usb1_host_delay_xms(uint32_t msec);
318 void Userdef_USB_usb1_host_delay_10us(uint32_t usec);
319 void Userdef_USB_usb1_host_delay_500ns(void);
320 void Userdef_USB_usb1_host_start_dma(USB_HOST_DMA_t * dma, uint16_t dfacc);
321 uint32_t Userdef_USB_usb1_host_stop_dma0(void);
322 uint32_t Userdef_USB_usb1_host_stop_dma1(void);
323 void Userdef_USB_usb1_host_notice(const char * format);
324 void Userdef_USB_usb1_host_user_rdy(const char * format, uint16_t data);
325 #endif
326
327 #endif /* USB_HOST_API_H */
328
329 /* End of File */
Imprint / Impressum