1 /***************************************************************************
2 * Copyright (C) 2009 - 2010 by Simon Qian <SimonQian@SimonQian.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
19 #ifndef __USBTOXXX_INTERNAL_H_INCLUDED__
20 #define __USBTOXXX_INTERNAL_H_INCLUDED__
22 // USB_TO_XXX USB Commands
24 #define USB_TO_USART (VERSALOON_USB_TO_XXX_CMD_START + 0x00)
25 #define USB_TO_SPI (VERSALOON_USB_TO_XXX_CMD_START + 0x01)
26 #define USB_TO_I2C (VERSALOON_USB_TO_XXX_CMD_START + 0x02)
27 #define USB_TO_GPIO (VERSALOON_USB_TO_XXX_CMD_START + 0x03)
28 #define USB_TO_CAN (VERSALOON_USB_TO_XXX_CMD_START + 0x04)
29 #define USB_TO_PWM (VERSALOON_USB_TO_XXX_CMD_START + 0x05)
30 #define USB_TO_ADC (VERSALOON_USB_TO_XXX_CMD_START + 0x06)
31 #define USB_TO_DAC (VERSALOON_USB_TO_XXX_CMD_START + 0x07)
32 #define USB_TO_MICROWIRE (VERSALOON_USB_TO_XXX_CMD_START + 0x08)
33 #define USB_TO_SWIM (VERSALOON_USB_TO_XXX_CMD_START + 0x09)
34 #define USB_TO_DUSI (VERSALOON_USB_TO_XXX_CMD_START + 0x0A)
36 #define USB_TO_JTAG_LL (VERSALOON_USB_TO_XXX_CMD_START + 0x20)
37 #define USB_TO_JTAG_HL (VERSALOON_USB_TO_XXX_CMD_START + 0x21)
38 #define USB_TO_ISSP (VERSALOON_USB_TO_XXX_CMD_START + 0x22)
39 #define USB_TO_C2 (VERSALOON_USB_TO_XXX_CMD_START + 0x23)
40 #define USB_TO_SBW (VERSALOON_USB_TO_XXX_CMD_START + 0x24)
41 #define USB_TO_LPCICP (VERSALOON_USB_TO_XXX_CMD_START + 0x25)
42 #define USB_TO_SWD (VERSALOON_USB_TO_XXX_CMD_START + 0x26)
43 #define USB_TO_JTAG_RAW (VERSALOON_USB_TO_XXX_CMD_START + 0x27)
44 #define USB_TO_BDM (VERSALOON_USB_TO_XXX_CMD_START + 0x28)
45 #define USB_TO_MSP430_JTAG (VERSALOON_USB_TO_XXX_CMD_START + 0x38)
47 #define USB_TO_POWER (VERSALOON_USB_TO_XXX_CMD_START + 0x40)
48 #define USB_TO_DELAY (VERSALOON_USB_TO_XXX_CMD_START + 0x41)
49 #define USB_TO_POLL (VERSALOON_USB_TO_XXX_CMD_START + 0x42)
50 #define USB_TO_INFO (VERSALOON_USB_TO_XXX_CMD_START + 0x5E)
51 #define USB_TO_ALL (VERSALOON_USB_TO_XXX_CMD_START + 0x5F)
56 #define USB_TO_XXX_CMDMASK 0xF8
57 #define USB_TO_XXX_CMDSHIFT 3
58 #define USB_TO_XXX_IDXMASK 0x07
59 // USB_TO_XXX Sub Commands
60 // Common Sub Commands
61 #define USB_TO_XXX_INIT (0x00 << USB_TO_XXX_CMDSHIFT)
62 #define USB_TO_XXX_FINI (0x01 << USB_TO_XXX_CMDSHIFT)
63 #define USB_TO_XXX_CONFIG (0x02 << USB_TO_XXX_CMDSHIFT)
64 #define USB_TO_XXX_GETHWINFO (0x03 << USB_TO_XXX_CMDSHIFT)
65 #define USB_TO_XXX_STATUS (0X04 << USB_TO_XXX_CMDSHIFT)
66 #define USB_TO_XXX_IN_OUT (0x05 << USB_TO_XXX_CMDSHIFT)
67 #define USB_TO_XXX_IN (0x06 << USB_TO_XXX_CMDSHIFT)
68 #define USB_TO_XXX_OUT (0x07 << USB_TO_XXX_CMDSHIFT)
69 #define USB_TO_XXX_POLL (0x08 << USB_TO_XXX_CMDSHIFT)
70 #define USB_TO_XXX_SPECIAL (0x09 << USB_TO_XXX_CMDSHIFT)
71 #define USB_TO_XXX_RESET (0x0A << USB_TO_XXX_CMDSHIFT)
72 #define USB_TO_XXX_SYNC (0x0B << USB_TO_XXX_CMDSHIFT)
73 #define USB_TO_XXX_ENABLE (0x0C << USB_TO_XXX_CMDSHIFT)
74 #define USB_TO_XXX_DISABLE (0x0D << USB_TO_XXX_CMDSHIFT)
76 #define USB_TO_POLL_START 0x00
77 #define USB_TO_POLL_END 0x01
78 #define USB_TO_POLL_CHECKOK 0x02
79 #define USB_TO_POLL_CHECKFAIL 0x03
80 #define USB_TO_POLL_VERIFYBUFF 0x04
85 #define USB_TO_XXX_OK 0x00
86 #define USB_TO_XXX_FAILED 0x01
87 #define USB_TO_XXX_TIME_OUT 0x02
88 #define USB_TO_XXX_INVALID_INDEX 0x03
89 #define USB_TO_XXX_INVALID_PARA 0x04
90 #define USB_TO_XXX_INVALID_CMD 0x05
91 #define USB_TO_XXX_CMD_NOT_SUPPORT 0x06
96 RESULT usbtoxxx_add_pending(uint8_t type, uint8_t cmd, uint16_t
97 actual_szie, uint16_t want_pos,
98 uint16_t want_size, uint8_t *buffer);
100 RESULT usbtoxxx_add_command(uint8_t type, uint8_t cmd, uint8_t *cmdbuf,
101 uint16_t cmdlen, uint16_t retlen,
102 uint8_t *wantbuf, uint16_t wantpos,
103 uint16_t wantlen, uint8_t collect);
105 #define usbtoxxx_init_command(type, port) \
106 usbtoxxx_add_command((type), (USB_TO_XXX_INIT | (port)), \
107 NULL, 0, 0, NULL, 0, 0, 0)
108 #define usbtoxxx_fini_command(type, port) \
109 usbtoxxx_add_command((type), (USB_TO_XXX_FINI | (port)), \
110 NULL, 0, 0, NULL, 0, 0, 0)
111 #define usbtoxxx_conf_command(type, port, cmdbuf, cmdlen) \
112 usbtoxxx_add_command((type), (USB_TO_XXX_CONFIG | (port)), \
113 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
114 #define usbtoxxx_inout_command(type, port, cmdbuf, cmdlen, retlen, wantbuf, \
115 wantpos, wantlen, c) \
116 usbtoxxx_add_command((type), (USB_TO_XXX_IN_OUT | (port)), \
117 (cmdbuf), (cmdlen), (retlen), (wantbuf), \
118 (wantpos), (wantlen), (c))
119 #define usbtoxxx_in_command(type, port, cmdbuf, cmdlen, retlen, wantbuf, \
120 wantpos, wantlen, c) \
121 usbtoxxx_add_command((type), (USB_TO_XXX_IN | (port)), (cmdbuf), \
122 (cmdlen), (retlen), (wantbuf), (wantpos), \
124 #define usbtoxxx_out_command(type, port, cmdbuf, cmdlen, c) \
125 usbtoxxx_add_command((type), (USB_TO_XXX_OUT | (port)), (cmdbuf), \
126 (cmdlen), 0, NULL, 0, 0, (c))
127 #define usbtoxxx_poll_command(type, port, cmdbuf, cmdlen, retbuf, retlen) \
128 usbtoxxx_add_command((type), (USB_TO_XXX_POLL | (port)), (cmdbuf),\
129 (cmdlen), (retlen), (retbuf), 0, (retlen), 0)
130 #define usbtoxxx_status_command(type, port, retlen, wantbuf, wantpos, wantlen, c)\
131 usbtoxxx_add_command((type), (USB_TO_XXX_STATUS | (port)), \
132 NULL, 0, (retlen), (wantbuf), (wantpos), \
134 #define usbtoxxx_special_command(type, port, cmdbuf, cmdlen, retlen, wantbuf, \
135 wantpos, wantlen, c) \
136 usbtoxxx_add_command((type), (USB_TO_XXX_SPECIAL | (port)), \
137 (cmdbuf), (cmdlen), retlen, wantbuf, \
138 wantpos, wantlen, (c))
139 #define usbtoxxx_reset_command(type, port, cmdbuf, cmdlen) \
140 usbtoxxx_add_command((type), (USB_TO_XXX_RESET | (port)), \
141 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
142 #define usbtoxxx_sync_command(type, port, cmdbuf, cmdlen, retlen, wantbuf) \
143 usbtoxxx_add_command((type), (USB_TO_XXX_SYNC | (port)), \
144 (cmdbuf), (cmdlen), (retlen), (wantbuf), 0, \
146 #define usbtoxxx_enable_command(type, port, cmdbuf, cmdlen) \
147 usbtoxxx_add_command((type), (USB_TO_XXX_ENABLE | (port)), \
148 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
149 #define usbtoxxx_disable_command(type, port, cmdbuf, cmdlen) \
150 usbtoxxx_add_command((type), (USB_TO_XXX_DISABLE | (port)), \
151 (cmdbuf), (cmdlen), 0, NULL, 0, 0, 0)
154 #define USB_TO_SPI_BAUDRATE_MSK 0x1F
155 #define USB_TO_SPI_CPOL_MSK 0x20
156 #define USB_TO_SPI_CPHA_MSK 0x40
157 #define USB_TO_SPI_MSB_FIRST 0x80
160 #define USB_TO_DUSI_BAUDRATE_MSK 0x1F
161 #define USB_TO_DUSI_CPOL_MSK 0x20
162 #define USB_TO_DUSI_CPHA_MSK 0x40
163 #define USB_TO_DUSI_MSB_FIRST 0x80
166 #define USB_TO_GPIO_DIR_MSK 0x01
168 #endif /* __USBTOXXX_INTERNAL_H_INCLUDED__ */