Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/src/sl811.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download) (as text)
Sun Jun 17 17:19:04 2012 UTC (11 years, 11 months ago) by tekken_boss
File MIME type: text/x-chdr
File size: 9395 byte(s)
000.001.010: 2012/06/18 02:14 : A part of end user mode is added.

== modification
*  "UI" A part of end user mode is added.

== Confirmation
* Compilable. 
* End user mode is working.

1
2 /* --------------------------------------------- */
3 /* H8-3069F SL811HS control function */
4 /* */
5 /* CPU : Renesus H8/3069F 25MHz */
6 /* Memory : ROM 512KB, RAM 16KB E-RAM 2MB */
7 /* (c) KAZ.Imamura */
8 /* --------------------------------------------- */
9
10 #ifndef __SL811_H__
11 #define __SL811_H__
12
13 #include "common.h"
14 #include "ui.h"
15 #include "key.h"
16
17 // ”Ä—p’è‹`
18 #define PID_SETUP 0xd0
19 #define PID_SOF 0x50
20 #define PID_IN 0x90
21 #define PID_OUT 0x10
22
23
24 #define DATA0_WR 0x07 // (Arm+Enable+tranmist to Host+DATA0)
25 #define DATA1_WR 0x47 // (Arm+Enable+tranmist to Host on DATA1)
26 #define ZDATA0_WR 0x05 // (Arm+Transaction Ignored+tranmist to Host+DATA0)
27 #define ZDATA1_WR 0x45 // (Arm+Transaction Ignored+tranmist to Host+DATA1)
28 #define DATA0_RD 0x03 // (Arm+Enable+received from Host+DATA0)
29 #define DATA1_RD 0x43 // (Arm+Enable+received from Host+DATA1)
30
31
32 #define USB_ACK 1
33 #define USB_NAK 2
34 #define USB_STALL 4
35
36
37 #define USB_EP 1
38 #define USB_TOGGLE 2
39 #define USB_HDRSIZ 2
40
41 #define SL_NUM 1
42
43 #define USB_RESET 46
44 #define USB_SETUP 47
45 #define USB_GETSPEED 48
46
47 #define USB_LOW 1
48 #define USB_FULL 2
49
50 #define DEFAULT_DEVICE_ADDRESS 2
51
52
53
54
55 // ----------------------------------------------------
56 // Characteristics of request (for bmRequest)
57 // ----------------------------------------------------
58 #define DIR_HOST2DEV 0x00
59 #define DIR_DEV2HOST 0x80
60
61 #define USB_REQUEST_TYPE_STANDARD 0x00
62 #define USB_REQUEST_TYPE_CLASS 0x20
63
64 #define RECEIPIENT_DEVICE 0x00
65 #define RECEIPIENT_INTERFACE 0x01
66 #define RECEIPIENT_ENDPOINT 0x02
67
68 // ----------------------------------------------------
69 // Standard Request Codes (for bRequest)
70 // ----------------------------------------------------
71 #define REQ_TYPE_GET_STATUS 0x00
72 #define REQ_TYPE_CLEAR_FEATURE 0x01
73 #define REQ_TYPE_SET_FEATURE 0x03
74 #define REQ_TYPE_SET_ADDRESS 0x05
75 #define REQ_TYPE_GET_DESCRIPTOR 0x06
76 #define REQ_TYPE_SET_DESCRIPTOR 0x07
77 #define REQ_TYPE_GET_CONFIG 0x08
78 #define REQ_TYPE_SET_CONFIG 0x09
79 #define REQ_TYPE_GET_INTERFACE 0x0a
80 #define REQ_TYPE_SET_INTERFACE 0x0b
81 #define REQ_TYPE_SYNCH_FRAME 0x0c
82
83 #define REQ_TYPE_GET_MAX_LUN 0xfe
84 #define REQ_TYPE_MS_RESET 0xff
85
86 // ----------------------------------------------------
87 // Descriptor Types
88 // ----------------------------------------------------
89 #define DESCRIPTOR_TYPE_DEVICE 0x01
90 #define DESCRIPTOR_TYPE_CONFIG 0x02
91 #define DESCRIPTOR_TYPE_STRING 0x03
92 #define DESCRIPTOR_TYPE_INTERFACE 0x04
93 #define DESCRIPTOR_TYPE_ENDPOINT 0x05
94 #define DESCRIPTOR_TYPE_DEVICE_QUALIFIER 0x06
95
96
97 // SL811HSƒŒƒWƒXƒ^
98 #define SL811HS_USBA_HOSTCTRL 0x00
99 #define SL811HS_USBA_HOSTBASEADDR 0x01
100 #define SL811HS_USBA_HOSTBASEDLEN 0x02
101 #define SL811HS_USBA_HOSTPID 0x03 // �‘‚«�ž‚ÝŽž
102 #define SL811HS_USBA_HOSTSTATUS 0x03 // “Ç‚Ý�o‚µŽž
103 #define SL811HS_USBA_HOSTDEVADDR 0x04 // �‘‚«�ž‚ÝŽž
104 #define SL811HS_USBA_HOSTSTLEN 0x04 // “Ç‚Ý�o‚µŽž
105 #define SL811HS_CONTROL1 0x05
106 #define SL811HS_INTENV 0x06
107 #define SL811HS_USBB_HOSTCTRL 0x08
108 #define SL811HS_USBB_HOSTBASEADDR 0x09
109 #define SL811HS_USBB_HOSTBASEDLEN 0x0A
110 #define SL811HS_USBB_HOSTPID 0x0B // �‘‚«�ž‚ÝŽž
111 #define SL811HS_USBB_HOSTSTATUS 0x0B // “Ç‚Ý�o‚µŽž
112 #define SL811HS_USBB_HOSTDEVADDR 0x0C // �‘‚«�ž‚ÝŽž
113 #define SL811HS_USBB_HOSTSTLEN 0x0C // “Ç‚Ý�o‚µŽž
114 #define SL811HS_STATUS 0x0D
115 #define SL811HS_SOFCOUNTL 0x0E // �‘‚«�ž‚ÝŽž
116 #define SL811HS_REVISION 0x0E // “Ç‚Ý�o‚µŽž
117 #define SL811HS_SOFCOUNTH 0x0F
118 #define SL811HS_MEMBUFF 0x10
119
120 /*
121 * SL811HS ƒŒƒWƒXƒ^Šeƒrƒbƒg
122 */
123 // SL811HS_USB[AB]_HOSTCTRL(0x00,0x08)
124 #define SL811HS_HOSTCTRL_BIT_ARM 0x01
125 #define SL811HS_HOSTCTRL_BIT_ENV 0x02
126 #define SL811HS_HOSTCTRL_BIT_DIR 0x04
127 #define SL811HS_HOSTCTRL_BIT_ISO 0x10
128 #define SL811HS_HOSTCTRL_BIT_SOF 0x20
129 #define SL811HS_HOSTCTRL_BIT_DTB 0x40
130 #define SL811HS_HOSTCTRL_BIT_PRE 0x80
131
132 // SL811HS_USB[AB]_HOSTSTATUS(0x03,0x0B) “Ç‚Ý�o‚µŽž
133 #define SL811HS_HOSTSTATUS_BIT_ACK 0x01
134 #define SL811HS_HOSTSTATUS_BIT_ERR 0x02
135 #define SL811HS_HOSTSTATUS_BIT_TOUT 0x04
136 #define SL811HS_HOSTSTATUS_BIT_SEQ 0x08
137 #define SL811HS_HOSTSTATUS_BIT_SETUP 0x10
138 #define SL811HS_HOSTSTATUS_BIT_OVF 0x20
139 #define SL811HS_HOSTSTATUS_BIT_NAK 0x40
140 #define SL811HS_HOSTSTATUS_BIT_STALL 0x80
141
142 // SL811HS_USB[AB]_HOSTPID(0x03,0x0B) Bit7-4 �‘‚«�ž‚ÝŽž
143 #define SL811HS_HOSTPID_BIT_SETUP 0xD0
144 #define SL811HS_HOSTPID_BIT_IN 0x90
145 #define SL811HS_HOSTPID_BIT_OUT 0x10
146 #define SL811HS_HOSTPID_BIT_SOF 0x50
147 #define SL811HS_HOSTPID_BIT_PRE 0xC0
148 #define SL811HS_HOSTPID_BIT_NAK 0xA0
149 #define SL811HS_HOSTPID_BIT_STALL 0xE0
150 #define SL811HS_HOSTPID_BIT_DATA0 0x30
151 #define SL811HS_HOSTPID_BIT_DATA1 0xB0
152
153 // SL811HS_CONTROL1(0x05)
154 #define SL811HS_CONTROL1_BIT_SOF 0x01
155 #define SL811HS_CONTROL1_BIT_NORMAL 0x00 // Bit3:4
156 #define SL811HS_CONTROL1_BIT_RESET 0x08 // Bit3:4
157 #define SL811HS_CONTROL1_BIT_JKSTAT 0x10 // Bit3:4
158 #define SL811HS_CONTROL1_BIT_KJSTAT 0x18 // Bit3:4
159 #define SL811HS_CONTROL1_BIT_LOWSPD 0x20
160 #define SL811HS_CONTROL1_BIT_SUSPEND 0x40
161
162 // SL811HS_INTENV(0x06)
163 #define SL811HS_INTENV_BIT_USBA 0x01
164 #define SL811HS_INTENV_BIT_USBB 0x02
165 #define SL811HS_INTENV_BIT_SOFTIMER 0x10
166 #define SL811HS_INTENV_BIT_INSRMV 0x20
167 #define SL811HS_INTENV_BIT_DEVDTC 0x40
168 #define SL811HS_INTENV_BIT_DPLUS 0x80
169
170 // SL811HS_STATUS(0x0D)
171 #define SL811HS_STATUS_BIT_USBA 0x01
172 #define SL811HS_STATUS_BIT_USBB 0x02
173 #define SL811HS_STATUS_BIT_SOFTIMER 0x10
174 #define SL811HS_STATUS_BIT_INSRMV 0x20
175 #define SL811HS_STATUS_BIT_DEVDTC 0x40
176 #define SL811HS_STATUS_BIT_DPLUS 0x80
177
178 // SL811HS_REVISION(0x0E)
179 #define SL811HS_REVISION_BIT_REV12 0x10
180 #define SL811HS_REVISION_BIT_REV15 0x20
181
182 // SL811HS_SOFCOUNTH(0x0F)
183 #define SL811HS_SOFCOUNTH_BIT_PLTYSWAP 0x40
184 #define SL811HS_SOFCOUNTH_BIT_MSTRSLV 0x80
185
186 #define MAX_EP 8
187
188 // ----------------------------------------------------
189 // Descriptor information (DEVICE)
190 // ----------------------------------------------------
191 typedef struct {
192 unsigned char bLength;
193 unsigned char bDescriptorType;
194 unsigned short bcdUSB;
195 unsigned char bDeviceClass;
196 unsigned char bDeviceSubClass;
197 unsigned char bDeviceProtocol;
198 unsigned char bMaxPacketSize0;
199 unsigned short idVendor;
200 unsigned short idProduct;
201 unsigned short bcdDevice;
202 unsigned char iManufacturer;
203 unsigned char iProduct;
204 unsigned char iSerialNumber;
205 unsigned char bNumConfigurations;
206 } DESCRIPTOR_DEVICE, *P_DESCRIPTOR_DEVICE;
207
208 // ----------------------------------------------------
209 // Descriptor information (CONFIG)
210 // ----------------------------------------------------
211 typedef struct {
212 unsigned char bLength;
213 unsigned char bDescriptorType;
214 unsigned short wTotalLength;
215 unsigned char bNumInterface;
216 unsigned char bConfigurationValue;
217 unsigned char iConfiguration;
218 unsigned char bmAttributes;
219 unsigned char bMaxPower;
220 } DESCRIPTOR_CONFIG, *P_DESCRIPTOR_CONFIG;
221
222 // ----------------------------------------------------
223 // Descriptor information (INTERFACE)
224 // ----------------------------------------------------
225 typedef struct {
226 unsigned char bLength;
227 unsigned char bDescriptorType;
228 unsigned char bInterfaceNumber;
229 unsigned char bAlternateSetting;
230 unsigned char bNumEndpoints;
231 unsigned char bInterfaceClass;
232 unsigned char bInterfaceSubClass;
233 unsigned char bInterfaceProtocol;
234 unsigned char iInterface;
235 } DESCRIPTOR_INTERFACE, *P_DESCRIPTOR_INTERFACE;
236
237 // ----------------------------------------------------
238 // Descriptor information (ENDPOINT)
239 // ----------------------------------------------------
240 typedef struct {
241 unsigned char bLength;
242 unsigned char bDescriptorType;
243 unsigned char bEndpointAddress;
244 unsigned char bmAttributes;
245 unsigned short wMaxPacketSize;
246 unsigned char bInterval;
247 } DESCRIPTOR_ENDPOINT, *P_DESCRIPTOR_ENDPOINT;
248
249
250 // ----------------------------------------------------
251 // SETUP command format
252 // ----------------------------------------------------
253 typedef struct {
254 unsigned char bmRequestType;
255 unsigned char bRequest;
256 unsigned short wValue;
257 unsigned short wIndex;
258 unsigned short wLength;
259 } SETUP_FORMAT, *P_SETUP_FORMAT;
260
261 // ----------------------------------------------------
262 // Endpoints information
263 // ----------------------------------------------------
264 typedef struct {
265 int host_buf_size;
266 unsigned char* p_host_buf;
267 unsigned char address;
268 unsigned char size;
269 unsigned char toggle;
270 } EP_INFO, *P_EP_INFOs;
271
272
273 extern void sl811_1ms_handler(void);
274 extern void sl811_chip_irq(void);
275 extern int sl811_initialize(void);
276 extern int sl811_process(void);
277 extern int ui_function_usb(UI_COMMAND uicmd);
278 extern unsigned char sl811_status(REQUEST_TO_CLASS cmd);
279 extern unsigned char sl811_ctrl_receive(P_SETUP_FORMAT p_fmt);
280 extern void sl811_buffer_copy( unsigned char* p_buf, int size);
281 extern unsigned char sl811_bulk_out_request( unsigned char* p_buf, int size );
282 extern unsigned char sl811_bulk_in_request( unsigned char* p_buf, int size );
283 extern unsigned char IsBulkInEP( void );
284 extern unsigned char IsBulkOutEP( void );
285 extern unsigned char IsPacketStatus(void);
286
287 #endif
288

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26