1 /*********************************************************/
2 /*** Module : PDIUSB D11,H11,H11A,D12 - header file ***/
3 /*** Author : Roman Bartosinski (C) 03.10.2002 ***/
4 /*** Description : Integrate common functions for ***/
5 /*** PDIUSBD11,PDIUSBD12,PDIUSBH11(old) ***/
6 /*** PDIUSBH11A in Single/Multiple mode ***/
7 /*** to one common file. ***/
8 /*** Modify : 10.10.2002 - add H11 ***/
9 /*** 13.10.2002 - add spec.fnc for 'using' ***/
10 /*** 22.12.2002 - rebuild for smaller out ***/
11 /*********************************************************/
13 #ifndef _PDIUSB_BASE_MODULE
14 #define _PDIUSB_BASE_MODULE
16 /*********************************************************/
17 // Comments - !!! Please, read this section !!!
20 // If you can use included functions for read and write
21 // byte from/to PDIUSB, please uncomment defined PDI_CMD_RWD_INTERNAL
22 // and check defined addresses for communication with PDIUSB.
23 // Else you must uncomment defined PDI_CMD_RWD_EXTERNAL and declare
24 // and implement next functions :
25 // void pdiSendCommand( unsigned char byCmd);
26 // unsigned char pdiReadData( unsigned char byCount, void *pbyData);
27 // void pdiWriteData( unsigned char byCount, const void *pbyData);
28 // - if you want use 'using' (see below), you must implement next function(on i51 is NEEDED).
29 // unsigned short pdiIntCmdReadData( unsigned char byCmd, unsigned char byShort) _PDI_USING;
30 // -- all in section 'External functions'
33 // Next you must select type of chip.(uncomment line with defined type)
34 // -- in section 'Type of PDIUSB'
37 // If you want use functions 'pdiGetInterrupt' and 'pdiGetLastTransStatus'
38 // with keyword 'using' (for i51 it means using spec.reg.bank), uncomment
39 // define 'USING'. Only these two functions need pdiIntCmdReadData.
40 // -- in section 'Use using in interrupt functions'
42 // *** External choice ***
43 // Or you can make all previous choises externally before including this file
44 // by defining one of PDIUSBD11,PDIUSBD12,PDIUSBH11,PDIUSBH11A_SINGLE,PDIUSBH11A_MULTIPLE
46 // defining one of PDI_CMD_RWD_INTERNAL,PDI_CMD_RWD_EXTERNAL
47 // (you can define externally PDIUSB_COMMAND_ADDR, PDIUSB_READ_DATA_ADDR, PDIUSB_WRITE_DATA_ADDR)
49 // and defining one of PDI_USE_USING,PDI_DONTUSE_USING
50 // (you can define externally _PDI_USING_NUMBER)
54 /*********************************************************/
59 // PDIUSBD11 - USB device with serial interface
60 // PDIUSBH11 - USB hub with one embedded fnc and serial interface
61 // PDIUSBH11A_SINGLE - USB hub with one embedded fnc, serial interface and additional functions
62 // PDIUSBH11A_MULTIPLE - USB hub with multiple(3) embedded fncs, serial interface and add.fncs
63 // - H11A_SINGLE and H11A_MULTIPLE is divided by pdiusb command SetMode (bit is set automatically)
64 // PDIUSBD12 - USB device with parallel interface
67 // uncomment right chip type below
71 //#define PDIUSBH11A_SINGLE
72 //#define PDIUSBH11A_MULTIPLE
76 /*********************************************************/
77 // Create common type PDIUSBH11A for SINGLE and MULTIPLE
78 // for mux H11A_S & H11A_M
79 #if defined(PDIUSBH11A_SINGLE) || defined(PDIUSBH11A_MULTIPLE)
87 /*********************************************************/
88 // Use using in interrupt functions
90 // If you want use keyword 'using' in function
91 // 'pdiGetInterrupt' and 'pdiGetLastTransStatus',
92 // uncomment next line.(and check and correct number in _PDI_USING_NUMBER)
93 //#define PDI_USE_USING
94 // If you don't want use keyword 'using',
95 // uncomment next line.
96 #define PDI_DONTUSE_USING
98 #if defined(PDI_USE_USING)
99 #if !defined(_PDI_USING_NUMBER)
100 #define _PDI_USING_NUMBER 2
102 #define _PDI_USING using _PDI_USING_NUMBER
108 /*********************************************************/
109 // External functions
111 // If you want use internal functions, uncomment next line.
112 //#define PDI_CMD_RWD_INTERNAL
113 // If you want use your own external functions, uncomment next line.
114 //#define PDI_CMD_RWD_EXTERNAL
116 // this is automatically selected by your choice
118 #if defined(PDI_CMD_RWD_INTERNAL)
119 #if !defined(PDIUSB_COMMAND_ADDR) // if not defined address for select command
120 #if defined(PDIUSBD12)
121 #define PDIUSB_COMMAND_ADDR 0x7001 // sel.cmd address for D12 (this is address for my application)
123 #define PDIUSB_COMMAND_ADDR 0x36 // sel.cmd address for all other
126 #if !defined(PDIUSB_READ_DATA_ADDR) // if not defined address for read data from chip
127 #if defined(PDIUSBD12)
128 #define PDIUSB_READ_DATA_ADDR 0x7000 // read data address for D12
130 #define PDIUSB_READ_DATA_ADDR 0x35 // read data address for all other
133 #if !defined(PDIUSB_WRITE_DATA_ADDR) // if not defined address for write data to chip
134 #if defined(PDIUSBD12)
135 #define PDIUSB_WRITE_DATA_ADDR 0x7000 // write data address for D12
137 #define PDIUSB_WRITE_DATA_ADDR 0x34 // write data address for all other
143 /* Build internal version of functions, but do not define addresses */
144 #define PDI_CMD_RWD_INTERNAL
146 extern void pdiSendCommand( unsigned char byCmd);
147 extern unsigned char pdiReadData( unsigned char byCount, void *pbyData);
148 extern void pdiWriteData( unsigned char byCount, const void *pbyData);
149 #if defined(PDI_USE_USING)
150 extern unsigned short pdiIntCmdReadData( unsigned char byCmd, unsigned char byShort) _PDI_USING;
154 /*********************************************************/
155 // Check chip selection, int/ext rw functions, using
157 #if !defined(PDIUSBD11) && !defined(PDIUSBH11) && !defined(PDIUSBH11A) && !defined(PDIUSBD12)
158 #define _PDI_ERROR_NO_CONTINUE
159 #error "!!! Any type of PDIUSB wasn't selected !!!"
160 #error "Please select one of PDIUSB in file pdiusb.h in section 'Type of PDIUSB'."
162 #if !defined(PDI_CMD_RWD_INTERNAL) && !defined(PDI_CMD_RWD_EXTERNAL)
163 #define _PDI_ERROR_NO_CONTINUE
164 #error "!!! You must select if you want use internal or external basic fncs for PDIUSB !!!"
165 #error "Please select your choice in file pdiusb.h in section 'External functions'."
167 #if !defined(PDI_USE_USING) && !defined(PDI_DONTUSE_USING)
168 #define _PDI_ERROR_NO_CONTINUE
169 #error "!!! You must choose if you want keyword 'using' !!!"
170 #error "Please see into file pdiusb.h in section 'Use using in interrupt functions'."
173 #if defined(_PDI_ERROR_NO_CONTINUE)
174 #error " For help ... read in file pdiusb.h section 'Comments'."
178 /*********************************************************/
179 /*********************************************************/
180 #if !defined(_PDI_ERROR_NO_CONTINUE)
182 /*********************************************************/
183 // Endpoints - size and index defines
185 // PDI_CNT_EP - number of endpoints without control endpoints
186 #if defined(PDIUSBD11) || defined(PDIUSBH11A_SINGLE) // D11, H11A_S
187 #define PDI_CNT_EP 0x03
188 #elif defined(PDIUSBH11) || defined(PDIUSBH11A_MULTIPLE) // H11, H11A_M
189 #define PDI_CNT_EP 0x01
190 #elif defined(PDIUSBD12) // D12
191 #define PDI_CNT_EP 0x02
194 // PDI_EPx_yyyy_SIZE - max packet size for endpoint x
195 #if defined(PDIUSBH11) || defined(PDIUSBH11A) // H11, H11A
196 #define PDI_HUB_TX_SIZE 8
197 #define PDI_HUB_RX_SIZE 8
198 #define PDI_HUB_PACKET_SIZE 8
199 #if defined(PDIUSBH11)
200 #define PDI_HUB_INT_SIZE 1
205 #if !defined(PDIUSBD12) // D11,H11,H11A
206 #define PDI_EP0_TX_SIZE 8
207 #define PDI_EP0_RX_SIZE 8
208 #define PDI_EP0_PACKET_SIZE 8
209 #define PDI_EP1_TX_SIZE 8
210 #define PDI_EP1_RX_SIZE 8
211 #define PDI_EP1_PACKET_SIZE 8
212 #if defined(PDIUSBD11) || defined(PDIUSBH11A_SINGLE)
213 #define PDI_EP2_TX_SIZE 8
214 #define PDI_EP2_RX_SIZE 8
215 #define PDI_EP2_PACKET_SIZE 8
216 #define PDI_EP3_TX_SIZE 8
217 #define PDI_EP3_RX_SIZE 8
218 #define PDI_EP3_PACKET_SIZE 8
221 #define PDI_EP0_TX_SIZE 16
222 #define PDI_EP0_RX_SIZE 16
223 #define PDI_EP0_PACKET_SIZE 16
224 #define PDI_EP1_TX_SIZE 16
225 #define PDI_EP1_RX_SIZE 16
226 #define PDI_EP1_PACKET_SIZE 16
227 #define PDI_EP2_TX_SIZE 64
228 #define PDI_EP2_RX_SIZE 64
229 #define PDI_EP2_PACKET_SIZE 64
232 // PDI_EPx_TX, PDI_EPx_RX - index for endpoint x (write/read)
233 #if defined(PDIUSBH11) || defined(PDIUSBH11A) // H11
234 #define PDI_HUB_EP0_RX 0
235 #define PDI_HUB_EP0_TX 1
236 // another index names
237 #define PDI_HUB_EP0_OUT PDI_HUB_EP0_RX
238 #define PDI_HUB_EP0_IN PDI_HUB_EP0_TX
241 #if defined(PDIUSBH11)
245 // another index names
246 #define PDI_EP0_OUT PDI_EP0_RX
247 #define PDI_EP0_IN PDI_EP0_TX
248 #define PDI_EP1_IN PDI_EP1_TX
249 #elif defined(PDIUSBD11) || defined(PDIUSBH11A_SINGLE) // D11,H11A_S
258 // another index names
259 #define PDI_EP0_OUT PDI_EP0_RX
260 #define PDI_EP0_IN PDI_EP0_TX
261 #define PDI_EP1_OUT PDI_EP1_RX
262 #define PDI_EP1_IN PDI_EP1_TX
263 #define PDI_EP2_OUT PDI_EP2_RX
264 #define PDI_EP2_IN PDI_EP2_TX
265 #define PDI_EP3_OUT PDI_EP3_RX
266 #define PDI_EP3_IN PDI_EP3_TX
267 #elif defined(PDIUSBH11A_MULTIPLE) // H11_M
268 #define PDI_F1_EP0_RX 2
269 #define PDI_F1_EP0_TX 3
270 #define PDI_F1_EP1_RX 5
271 #define PDI_F1_EP1_TX 4
272 #define PDI_F6_EP0_RX 10
273 #define PDI_F6_EP0_TX 11
274 #define PDI_F6_EP1_RX 6
275 #define PDI_F6_EP1_TX 7
276 #define PDI_F7_EP0_RX 12
277 #define PDI_F7_EP0_TX 13
278 #define PDI_F7_EP1_RX 8
279 #define PDI_F7_EP1_TX 9
280 // another index names
281 #define PDI_F1_EP0_OUT PDI_F1_EP0_RX
282 #define PDI_F1_EP0_IN PDI_F1_EP0_TX
283 #define PDI_F1_EP1_OUT PDI_F1_EP1_RX
284 #define PDI_F1_EP1_IN PDI_F1_EP1_TX
285 #define PDI_F6_EP0_OUT PDI_F6_EP0_RX
286 #define PDI_F6_EP0_IN PDI_F6_EP0_TX
287 #define PDI_F6_EP1_OUT PDI_F6_EP1_RX
288 #define PDI_F6_EP1_IN PDI_F6_EP1_TX
289 #define PDI_F7_EP0_OUT PDI_F7_EP0_RX
290 #define PDI_F7_EP0_IN PDI_F7_EP0_TX
291 #define PDI_F7_EP1_OUT PDI_F7_EP1_RX
292 #define PDI_F7_EP1_IN PDI_F7_EP1_TX
293 #elif defined(PDIUSBD12) // D12
300 // another index names
301 #define PDI_EP0_OUT PDI_EP0_RX
302 #define PDI_EP0_IN PDI_EP0_TX
303 #define PDI_EP1_OUT PDI_EP1_RX
304 #define PDI_EP1_IN PDI_EP1_TX
305 #define PDI_EP2_OUT PDI_EP2_RX
306 #define PDI_EP2_IN PDI_EP2_TX
309 /*********************************************************/
310 // Commands - index and bits, description
312 // Set Address/Enable
313 #if defined(PDIUSBH11) || defined(PDIUSBH11A) || defined(PDIUSBD11) // only H11 or H11A
314 #define PDI_CMD_HUB_ENB_ADDR 0x00D0
315 #if defined(PDIUSBH11) || defined(PDIUSBH11A_SINGLE) // for H11 and H11A_SINGLE
316 #define PDI_CMD_FNC_ENB_ADDR 0x00D1
317 #else // for H11A_MULTIPLE
318 #define PDI_CMD_FNC1_ENB_ADDR 0x00D1
319 #define PDI_CMD_FNC6_ENB_ADDR 0x00D2
320 #define PDI_CMD_FNC7_ENB_ADDR 0x00D3
321 // for compatible with H11A_SINGLE and other
322 #define PDI_CMD_FNC_ENB_ADDR PDI_CMD_FNC1_ENB_ADDR
324 #elif defined(PDIUSBD11) // for D11
325 #define PDI_CMD_FNC_ENB_ADDR 0x00D1
326 #elif defined(PDIUSBD12) // for D12
327 #define PDI_CMD_FNC_ENB_ADDR 0x00D0
329 // set address/enable bits - for all
330 #define PDI_ENAD_ENABLE 0x0080
331 #define PDI_ENAD_ADDRMASK 0x007F
333 // Set Endpoint enable
334 #define PDI_CMD_EPEN 0x00D8
335 // set endpoint enable bits
336 #if defined(PDIUSBD12) // D12 - generic ep
337 #define PDI_EPEN_ENABLE 0x0001
338 #elif defined(PDIUSBD11) // D11 - generic ep
339 #define PDI_EPEN_ENABLE 0x0002
340 #elif defined(PDIUSBH11A) || defined(PDIUSBH11) // H11,H11A
341 #define PDI_EPEN_HUB_ENB 0x0001
342 #if defined(PDIUSBH11A_MULTIPLE) // H11A_M
343 #define PDI_EPEN_FNC1_ENB 0x0002
344 #define PDI_EPEN_FNC6_ENB 0x0004
345 #define PDI_EPEN_FNC7_ENB 0x0008
347 #define PDI_EPEN_FNC_ENB 0x0002
351 #if !defined(PDIUSBH11)
353 #define PDI_CMD_SET_MODE 0x00F3
354 // set mode bits - configuration
355 #if !defined(PDIUSBD12)
356 #define PDI_MODE_REMOTE_WAKEUP 0x0001 // D11,H11A
358 #define PDI_MODE_NO_LAZY_CLOCK 0x0002 // all
359 #define PDI_MODE_CLOCK_RUNNING 0x0004 // all
360 #if defined(PDIUSBD12)
361 #define PDI_MODE_INTERRUPT_MODE 0x0008 // D12
363 #define PDI_MODE_DEBUG_MODE 0x0008 // D11,H11A
365 #define PDI_MODE_SOFT_CONNECT 0x0010 // all
366 #if defined(PDIUSBH11A)
367 #define PDI_MODE_DWN_RESISTORS 0x0020 // H11A
368 #define PDI_MODE_NONBLINK_LED 0x0040 // H11A
369 #define PDI_MODE_SINGLE_FNC 0x0080 // H11A
370 #elif defined(PDIUSBD11)
371 #define PDI_MODE_MUSTBEONE 0x0080 // D11
373 #define PDI_MODE_EP_NONISO 0x0000 // D12
374 #define PDI_MODE_EP_ISOOUT 0x0040
375 #define PDI_MODE_EP_ISOIN 0x0080
376 #define PDI_MODE_EP_ISOIO 0x00C0
379 // set mode bits - clock div factor [48Mhz/(N+1)]
380 #if defined(PDIUSBH11A)
381 #define PDI_CLOCK_CRYSTAL_12M 0x3000 // for 12Mhz crystal
382 #define PDI_CLOCK_CRYSTAL_48M 0x0000 // for 48Mhz crystal
384 #if defined(PDIUSBD12) // D12
385 #define PDI_CLOCK_48M 0x0000 // 48 Mhz
387 #define PDI_CLOCK_24M 0x0100 // 24 Mhz
388 #define PDI_CLOCK_16M 0x0200 // 16 Mhz
389 #define PDI_CLOCK_12M 0x0300 // 12 Mhz
390 #define PDI_CLOCK_9M6 0x0400 // 9.6 Mhz
391 #define PDI_CLOCK_8M 0x0500 // 8 Mhz
392 #define PDI_CLOCK_6M8 0x0600 // 6.857142857 Mhz
393 #define PDI_CLOCK_6M 0x0700 // 6 Mhz
394 #define PDI_CLOCK_5M3 0x0800 // 5.333333333 Mhz
395 #define PDI_CLOCK_4M8 0x0900 // 4.8 Mhz
396 #define PDI_CLOCK_4M3 0x0A00 // 4.363636364 Mhz
397 #define PDI_CLOCK_4M 0x0B00 // 4 Mhz
398 #if defined(PDIUSBD12) // D12
399 #define PDI_CLOCK_SET_TO_ONE 0x4000
400 #define PDI_CLOCK_SOF_ONLY 0x8000
405 #if defined(PDIUSBD12)
406 #define PDI_CMD_SET_DMA 0x00FB
407 #define PDI_CMD_GET_DMA 0x00FB
409 #define PDI_DMA_SINGLE_DMA 0x0000
410 #define PDI_DMA_BURST_4 0x0001
411 #define PDI_DMA_BURST_8 0x0002
412 #define PDI_DMA_BURST_16 0x0003
413 #define PDI_DMA_ENABLE 0x0004
414 #define PDI_DMA_DIRECTION 0x0008
415 #define PDI_DMA_AUTOLOAD 0x0010
416 #define PDI_DMA_INT_SOF 0x0020
417 #define PDI_DMA_EP4_INT 0x0040
418 #define PDI_DMA_EP5_INT 0x0080
421 // Read Interrupt Register
422 // be careful with PDIUSBH11 - you must read only 1 byte
423 #define PDI_CMD_GET_INT_REG 0x00F4
424 // read interrupt register bits
425 #if defined(PDIUSBD11) || defined(PDIUSBH11) || defined(PDIUSBH11A) // D11,H11,H11A
426 #if defined(PDIUSBH11) || defined(PDIUSBH11A)
427 #define PDI_INT_HUB_OUT 0x0001
428 #define PDI_INT_HUB_IN 0x0002
430 #if defined(PDIUSBH11)
431 #define PDI_INT_EP0_OUT 0x0004
432 #define PDI_INT_EP0_IN 0x0008
433 #define PDI_INT_EP1_IN 0x0010
434 #elif defined(PDIUSBD11) || defined(PDIUSBH11A_SINGLE) // D11,H11_S
435 #define PDI_INT_EP0_OUT 0x0004
436 #define PDI_INT_EP0_IN 0x0008
437 #define PDI_INT_EP1_OUT 0x0020
438 #define PDI_INT_EP1_IN 0x0010
439 #define PDI_INT_EP2_OUT 0x0040
440 #define PDI_INT_EP2_IN 0x0080
441 #define PDI_INT_EP3_OUT 0x0100
442 #define PDI_INT_EP3_IN 0x0200
444 #define PDI_INT_F1_EP0_OUT 0x0004
445 #define PDI_INT_F1_EP0_IN 0x0008
446 #define PDI_INT_F1_EP1_OUT 0x0020
447 #define PDI_INT_F1_EP1_IN 0x0010
448 #define PDI_INT_F6_EP0_OUT 0x0400
449 #define PDI_INT_F6_EP0_IN 0x0800
451 #define PDI_INT_F6_EP1_OUT 0x0040
452 #define PDI_INT_F6_EP1_IN 0x0080
453 #define PDI_INT_F7_EP0_OUT 0x1000
454 #define PDI_INT_F7_EP0_IN 0x2000
455 #define PDI_INT_F7_EP1_OUT 0x0100
456 #define PDI_INT_F7_EP1_IN 0x0200
458 #define PDI_INT_BUSRESET 0x4000
459 #elif defined(PDIUSBD12)
460 #define PDI_INT_EP0_OUT 0x0001
461 #define PDI_INT_EP0_IN 0x0002
462 #define PDI_INT_EP1_OUT 0x0004
463 #define PDI_INT_EP1_IN 0x0008
464 #define PDI_INT_EP2_OUT 0x0010
465 #define PDI_INT_EP2_IN 0x0020
466 #define PDI_INT_BUSRESET 0x0040
467 #define PDI_INT_SUSPEND 0x0080
468 #define PDI_INT_DMA_EOT 0x0100
472 #define PDI_CMD_SELECT_EP 0x0000 // base index for select endpoint
473 // select endpoint bits
474 #define PDI_SELEP_FULL 0x0001
475 #if defined(PDIUSBD12)
476 #define PDI_SELEP_STALL 0x0002
479 // Read Last Transaction Status Register
480 #define PDI_CMD_GET_LAST_STAT 0x0040 // base index for read last transaction
481 // read last transaction bits and errors
482 #define PDI_LTSTAT_RXTX_OK 0x0001
483 #define PDI_LTSTAT_ERR_MASK 0x001E
484 #define PDI_LTSTAT_SETUP 0x0020
485 #define PDI_LTSTAT_DATA1 0x0040
486 #define PDI_LTSTAT_PREV_NRD 0x0080
488 #define PDI_ERR_NO_ERROR 0x0000
489 #define PDI_ERR_PID_ENCODING 0x0001
490 #define PDI_ERR_PID_UNKNOWN 0x0002
491 #define PDI_ERR_UNEXPECT_PKT 0x0003
493 #define PDI_ERR_TOKEN_CRC 0x0004
494 #define PDI_ERR_DATA_CRC 0x0005
495 #define PDI_ERR_TIME_OUT 0x0006
496 #define PDI_ERR_NEVER_HAPPENS 0x0007
497 #define PDI_ERR_UNEXPECT_EOP 0x0008
498 #define PDI_ERR_NAK 0x0009
499 #define PDI_ERR_STALL 0x000A
500 #define PDI_ERR_OVERFLOW 0x000B
501 #define PDI_ERR_BITSTUFF 0x000D
502 #define PDI_ERR_DATA_PID 0x000F
504 // Read Endpoint Status
505 #if defined(PDIUSBD11) || defined(PDIUSBH11) || defined(PDIUSBH11A)
506 #define PDI_CMD_GET_EP_STAT 0x0080 // base index for read ep status
507 // read ep status bits
508 #define PDI_EPSTAT_SETUP 0x0004
509 #define PDI_EPSTAT_STALL 0x0008
510 #define PDI_EPSTAT_DATA1 0x0010
511 #define PDI_EPSTAT_FULL 0x0020
515 #define PDI_CMD_READ_BUFFER 0x00F0
518 #define PDI_CMD_WRITE_BUFFER 0x00F0
521 #define PDI_CMD_CLEAR_BUFFER 0x00F2
524 #define PDI_CMD_VALID_BUFFER 0x00FA
527 // Set Endpoint Status
528 #define PDI_CMD_SET_EP_STAT 0x0040 // base index for endpoint status
529 // set endpoint status bits
530 #define PDI_SET_EP_STALLED 0x0001
533 #define PDI_CMD_ACK_SETUP 0x00F1
536 #define PDI_CMD_SEND_RESUME 0x00F6
538 // Read Current Frame Number
539 #define PDI_CMD_GET_FRAME 0x00F5
542 #define PDI_CMD_GET_CHIP_ID 0x00FD
545 #if defined(PDIUSBH11) || defined(PDIUSBH11A)
546 // Clear Port Feature
547 #define PDI_CMD_P2_CLR_FEATURE 0x00E0
548 #define PDI_CMD_P3_CLR_FEATURE 0x00E1
549 #define PDI_CMD_P4_CLR_FEATURE 0x00E2
550 #define PDI_CMD_P5_CLR_FEATURE 0x00E3
552 #define PDI_CMD_P2_SET_FEATURE 0x00E8
553 #define PDI_CMD_P3_SET_FEATURE 0x00E9
554 #define PDI_CMD_P4_SET_FEATURE 0x00EA
555 #define PDI_CMD_P5_SET_FEATURE 0x00EB
557 #define PDI_F_PORT_ENABLE 0
558 #define PDI_F_PORT_SUSPEND 1
559 #define PDI_FC_PORT_RESET 2
560 #define PDI_F_PORT_POWER 3
561 #define PDI_C_PORT_CONNECTION 4
562 #define PDI_C_PORT_ENABLE 5
563 #define PDI_C_PORT_SUSPEND 6
564 #define PDI_C_PORT_OVERCURRENT 7
567 #define PDI_CMD_P2_GET_STATUS 0x00E0
568 #define PDI_CMD_P3_GET_STATUS 0x00E1
569 #define PDI_CMD_P4_GET_STATUS 0x00E2
570 #define PDI_CMD_P5_GET_STATUS 0x00E3
571 // get port status bits - port status byte
572 #define PDI_PSTAT_CONNECT 0x0001
573 #define PDI_PSTAT_ENABLED 0x0002
574 #define PDI_PSTAT_SUSPEND 0x0004
575 #define PDI_PSTAT_OVERCUR 0x0008
576 #define PDI_PSTAT_RESET 0x0010
577 #define PDI_PSTAT_POWER 0x0020
578 #define PDI_PSTAT_LOWSPEED 0x0040
579 // get port status bits - port status change byte
580 #define PDI_PSTAT_CHANGE_CONNECT 0x0100
581 #define PDI_PSTAT_CHANGE_ENABLED 0x0200
582 #define PDI_PSTAT_CHANGE_SUSPEND 0x0400
583 #define PDI_PSTAT_CHANGE_OVERCUR 0x0800
584 #define PDI_PSTAT_CHANGE_RESET 0x1000
585 // Set Status Change Bits
586 #define PDI_CMD_SET_CHNG_BITS 0x00F7
587 // set status change bits - bits
588 #define PDI_SCHB_LOCAL_POWER 0x0001
589 #define PDI_SCHB_FNC1 0x0002
590 #if !defined(PDIUSBH11) && !defined(PDIUSBH11A_SINGLE)
591 #define PDI_SCHB_FNC6 0x0004
592 #define PDI_SCHB_FNC7 0x0008
597 /*********************************************************/
598 // Function prototypes
600 // PDIUSB common commands
602 #if defined(PDIUSBH11) || defined(PDIUSBH11A) || defined(PDIUSBD11)
603 void pdiSetHUBAddressEnable( unsigned char byAddress, unsigned char byEnable);
606 #if !defined(PDIUSBH11A_MULTIPLE) // D11,D12,H11,H11A_S(emb.fnc)
607 void pdiSetAddressEnable( unsigned char byAddr_Enb);
608 // void pdiSetAddressEnable( unsigned char byAddress, unsigned char byEnable);
610 void pdiSetEmbFncAddressEnable( unsigned char byFnc, unsigned char byAddress, unsigned char byEnable);
613 void pdiSetEndpointEnable( unsigned char byEnable);
615 #if !defined(PDIUSBH11) // H11 has not it ( !!! is great - try give single quote mark into comments ;-)
616 void pdiSetMode( unsigned short wMode_Clock);
619 #if defined(PDIUSBD12)
620 void pdiSetDMA( unsigned char byDma);
621 unsigned char pdiGetDMA( void);
624 #if defined(PDIUSBH11)
625 unsigned char pdiGetInterrupt( void) _PDI_USING;
627 unsigned short pdiGetInterrupt( void) _PDI_USING;
630 unsigned char pdiSelectEp( unsigned char byEpIdx);
631 unsigned char pdiGetLastTransStatus( unsigned char byEpIdx) _PDI_USING;
633 #if defined(PDIUSBD11) || defined(PDIUSBH11) || defined(PDIUSBH11A)
634 unsigned char pdiGetEpStatus( unsigned char byEpIdx);
637 unsigned char pdiReadFromEpBuffer( unsigned char byLength, unsigned char *pToBuff);
638 void pdiWriteToEpBuffer( unsigned char byLength, const unsigned char *pFromBuff);
639 void pdiSetEpStatus( unsigned char byEpIdx, unsigned char byStatus);
640 void pdiAcknowledgeSetup( void);
641 void pdiClearBuffer( void);
642 void pdiValidateBuffer( void);
644 void pdiSendResume( void);
645 unsigned short pdiGetFrameNumber( void);
646 unsigned short pdiGetChipID( void); // this function is undocumented
649 #if defined(PDIUSBH11) || defined(PDIUSBH11A)
650 void pdiClearPortFeature( unsigned char byEpIdx, unsigned char byFeature);
651 void pdiSetPortFeature( unsigned char byEpIdx, unsigned char byFeature);
652 unsigned short pdiGetPortFeature( unsigned char byEpIdx);
653 void pdiSetStatusChangeBits( unsigned char byBits);
656 // PDIUSB other commands
657 void pdiWriteEndpoint( unsigned char byEpIdx, unsigned char byLength, const unsigned char *pbyData);
658 unsigned char pdiReadEndpoint( unsigned char byEpIdx, unsigned char byMaxLength, unsigned char *pbyData);
660 unsigned char pdiCmdData( unsigned char byCmd, unsigned char *pbyData,
661 unsigned char byCount, unsigned char byRead);
663 #if !defined(PDIUSBH11A_MULTIPLE)
664 void pdiAckSetupControl( void);
666 void pdiAckSetupFncControl( unsigned char Fnc);
669 unsigned char pdiEp2Idx(unsigned char ep);
671 /*********************************************************/
672 #endif // from _PDI_ERROR_NO_CONTINUE
673 /*********************************************************/
674 #endif // from _PDI_BASE_MODULE