Rev 5363 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5363 | Rev 5551 | ||
---|---|---|---|
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; Include file for apps which want to use FTDI device ;; |
6 | ;; Include file for apps which want to use FTDI device ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; GNU GENERAL PUBLIC LICENSE ;; |
8 | ;; GNU GENERAL PUBLIC LICENSE ;; |
9 | ;; Version 2, June 1991 ;; |
9 | ;; Version 2, June 1991 ;; |
10 | ;; ;; |
10 | ;; ;; |
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
11 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
12 | 12 | ||
13 | ;Bitmode constants |
13 | ;Bitmode constants |
14 | BITMODE_RESET = 0x00 ;Switch off bitbang mode, back to regular serial FIFO |
14 | BITMODE_RESET = 0x00 ;Switch off bitbang mode, back to regular serial FIFO |
15 | BITMODE_BITBANG= 0x01 ;Classical asynchronous bitbang mode, introduced with B-type chips */ |
15 | BITMODE_BITBANG= 0x01 ;Classical asynchronous bitbang mode, introduced with B-type chips */ |
16 | BITMODE_MPSSE = 0x02 ;MPSSE mode, available on 2232x chips */ |
16 | BITMODE_MPSSE = 0x02 ;MPSSE mode, available on 2232x chips */ |
17 | BITMODE_SYNCBB = 0x04 ;Synchronous bitbang mode, available on 2232x and R-type chips */ |
17 | BITMODE_SYNCBB = 0x04 ;Synchronous bitbang mode, available on 2232x and R-type chips */ |
18 | BITMODE_MCU = 0x08 ;MCU Host Bus Emulation mode, available on 2232x chips */ |
18 | BITMODE_MCU = 0x08 ;MCU Host Bus Emulation mode, available on 2232x chips */ |
19 | ;CPU-style fifo mode gets set via EEPROM (cuurenntly EEPROM burn not supported in KolibriOS) |
19 | ;CPU-style fifo mode gets set via EEPROM (cuurenntly EEPROM burn not supported in KolibriOS) |
20 | BITMODE_OPTO = 0x10 ;Fast Opto-Isolated Serial Interface Mode, available on 2232x chips */ |
20 | BITMODE_OPTO = 0x10 ;Fast Opto-Isolated Serial Interface Mode, available on 2232x chips */ |
21 | BITMODE_CBUS = 0x20 ;Bitbang on CBUS pins of R-type chips, configure in EEPROM before */ |
21 | BITMODE_CBUS = 0x20 ;Bitbang on CBUS pins of R-type chips, configure in EEPROM before */ |
22 | BITMODE_SYNCFF = 0x40 ;Single Channel Synchronous FIFO mode, available on 2232H chips */ |
22 | BITMODE_SYNCFF = 0x40 ;Single Channel Synchronous FIFO mode, available on 2232H chips */ |
23 | BITMODE_FT1284 = 0x80 ;FT1284 mode, available on 232H chips |
23 | BITMODE_FT1284 = 0x80 ;FT1284 mode, available on 232H chips |
24 | 24 | ||
25 | ;Line property constants |
25 | ;Line property constants |
26 | ;parity |
26 | ;parity |
27 | NONE = 0 shl 8 |
27 | NONE = 0 shl 8 |
28 | ODD = 1 shl 8 |
28 | ODD = 1 shl 8 |
29 | EVEN = 2 shl 8 |
29 | EVEN = 2 shl 8 |
30 | MARK = 3 shl 8 |
30 | MARK = 3 shl 8 |
31 | SPACE = 4 shl 8 |
31 | SPACE = 4 shl 8 |
32 | ;stop bits |
32 | ;stop bits |
33 | STOP_BIT_1 = 0 shl 11 |
33 | STOP_BIT_1 = 0 shl 11 |
34 | STOP_BIT_15 = 1 shl 11 |
34 | STOP_BIT_15 = 1 shl 11 |
35 | STOP_BIT_2 = 2 shl 11 |
35 | STOP_BIT_2 = 2 shl 11 |
36 | ;break type |
36 | ;break type |
37 | BREAK_OFF = 0 shl 14 |
37 | BREAK_OFF = 0 shl 14 |
38 | BREAK_OFF = 1 shl 14 |
38 | BREAK_ON = 1 shl 14 |
39 | ;number of bits has to be at lower byte |
39 | ;number of bits has to be at lower byte |
40 | 40 | ||
41 | ;Flow control |
41 | ;Flow control |
42 | SIO_DISABLE_FLOW_CTRL = 0x0 |
42 | SIO_DISABLE_FLOW_CTRL = 0x0 |
43 | SIO_RTS_CTS_HS = (0x1 shl 8) |
43 | SIO_RTS_CTS_HS = (0x1 shl 8) |
44 | SIO_DTR_DSR_HS = (0x2 shl 8) |
44 | SIO_DTR_DSR_HS = (0x2 shl 8) |
45 | SIO_XON_XOFF_HS= (0x4 shl 8) |
45 | SIO_XON_XOFF_HS= (0x4 shl 8) |
46 | 46 | ||
47 | ;Chip types |
47 | ;Chip types |
48 | TYPE_AM = 0 |
48 | TYPE_AM = 0 |
49 | TYPE_BM = 1 |
49 | TYPE_BM = 1 |
50 | TYPE_2232C = 2 |
50 | TYPE_2232C = 2 |
51 | TYPE_R = 3 |
51 | TYPE_R = 3 |
52 | TYPE_2232H = 4 |
52 | TYPE_2232H = 4 |
53 | TYPE_4232H = 5 |
53 | TYPE_4232H = 5 |
54 | TYPE_232H = 6 |
54 | TYPE_232H = 6 |
55 | TYPE_230X = 7 |
55 | TYPE_230X = 7 |
56 | 56 | ||
57 | ;IO codes |
57 | ;IO codes |
58 | ;Get list of detected ftdi chips |
58 | ;Get list of detected ftdi chips |
59 | FTDI_GET_LIST = 1 |
59 | FTDI_GET_LIST = 1 |
60 | ;Acquire lock on ftdi device |
60 | ;Acquire lock on ftdi device |
61 | ;[input+8] - none |
61 | ;[input+8] - none |
62 | ;[output] - PID device is locked by |
62 | ;[output] - PID device is locked by |
63 | FTDI_LOCK = 2 |
63 | FTDI_LOCK = 2 |
64 | ;Unlock ftdi device |
64 | ;Unlock ftdi device |
65 | ;[input+8] - none |
65 | ;[input+8] - none |
66 | ;[output] - 0 if unclock success, overwise PID device is locked by |
66 | ;[output] - 0 if unclock success, overwise PID device is locked by |
67 | FTDI_UNLOCK = 3 |
67 | FTDI_UNLOCK = 3 |
68 | ;[output] - chunksize |
68 | ;[output] - chunksize |
69 | FTDI_GET_WRITE_CHUNKSIZE = 4 |
69 | FTDI_GET_WRITE_CHUNKSIZE = 4 |
70 | ;[output] - chunksize |
70 | ;[output] - chunksize |
71 | FTDI_GET_READ_CHUNKSIZE = 5 |
71 | FTDI_GET_READ_CHUNKSIZE = 5 |
72 | ;[input+8] - chunksize |
72 | ;[input+8] - chunksize |
73 | FTDI_SET_WRITE_CHUNKSIZE = 6 |
73 | FTDI_SET_WRITE_CHUNKSIZE = 6 |
74 | ;[input+8] - chunksize |
74 | ;[input+8] - chunksize |
75 | FTDI_SET_READ_CHUNKSIZE = 7 |
75 | FTDI_SET_READ_CHUNKSIZE = 7 |
76 | ;Writes data in chunks to the chip |
76 | ;Writes data in chunks to the chip |
77 | ;[input+8] - size of data, [input+12] - beginning of data |
77 | ;[input+8] - size of data, [input+12] - beginning of data |
78 | FTDI_WRITE_DATA = 8 |
78 | FTDI_WRITE_DATA = 8 |
79 | ;Reads data in chunks from the chip |
79 | ;Reads data in chunks from the chip |
80 | ;[input+8] - size of data, [output] - red data |
80 | ;[input+8] - size of data, [output] - red data |
81 | FTDI_READ_DATA = 9 |
81 | FTDI_READ_DATA = 9 |
82 | ;Sets the chip baud rate |
82 | ;Sets the chip baud rate |
83 | ;[input+8] - baudrate |
83 | ;[input+8] - baudrate |
84 | FTDI_SET_BAUDRATE = 10 |
84 | FTDI_SET_BAUDRATE = 10 |
85 | ;Enable/disable bitbang modes |
85 | ;Enable/disable bitbang modes |
86 | ;[input+8] - 0xnnnnXXYY, where XX-bitmask, YY-bitmode |
86 | ;[input+8] - 0xnnnnXXYY, where XX-bitmask, YY-bitmode |
87 | FTDI_SET_BITMODE = 11 |
87 | FTDI_SET_BITMODE = 11 |
88 | ;Set rts line high |
88 | ;Set rts line high |
89 | ;[input+8] - none |
89 | ;[input+8] - none |
90 | FTDI_SET_RTS_HIGH = 12 |
90 | FTDI_SET_RTS_HIGH = 12 |
91 | ;Set rts line low |
91 | ;Set rts line low |
92 | ;[input+8] - none |
92 | ;[input+8] - none |
93 | FTDI_SET_RTS_LOW = 13 |
93 | FTDI_SET_RTS_LOW = 13 |
94 | ;Set dtr line high |
94 | ;Set dtr line high |
95 | ;[input+8] - none |
95 | ;[input+8] - none |
96 | FTDI_SET_DTR_HIGH = 14 |
96 | FTDI_SET_DTR_HIGH = 14 |
97 | ;Set dtr line low |
97 | ;Set dtr line low |
98 | ;[input+8] - none |
98 | ;[input+8] - none |
99 | FTDI_SET_DTR_LOW = 15 |
99 | FTDI_SET_DTR_LOW = 15 |
100 | ;Resets the ftdi device |
100 | ;Resets the ftdi device |
101 | ;[input+8] - none |
101 | ;[input+8] - none |
102 | FTDI_USB_RESET = 16 |
102 | FTDI_USB_RESET = 16 |
103 | ;Set flowcontrol for ftdi chip |
103 | ;Set flowcontrol for ftdi chip |
104 | ;dword[input+8] - one of flow control constants |
104 | ;dword[input+8] - one of flow control constants |
105 | FTDI_SET_FLOW_CONTROL = 17 |
105 | FTDI_SET_FLOW_CONTROL = 17 |
106 | ;Set the special event character |
106 | ;Set the special event character |
107 | ;[input+8] - 0xnnnnXXYY, where XX-1/0(enable/disable), YY-event char |
107 | ;[input+8] - 0xnnnnXXYY, where XX-1/0(enable/disable), YY-event char |
108 | FTDI_SET_EVENT_CHAR = 18 |
108 | FTDI_SET_EVENT_CHAR = 18 |
109 | ;Set error character |
109 | ;Set error character |
110 | ;[input+8] - 0xnnnnXXYY, where XX-1/0(enable/disable), YY-error char |
110 | ;[input+8] - 0xnnnnXXYY, where XX-1/0(enable/disable), YY-error char |
111 | FTDI_SET_ERROR_CHAR = 19 |
111 | FTDI_SET_ERROR_CHAR = 19 |
112 | ;FTDI chip keeps data in the internal buffer for a specific |
112 | ;FTDI chip keeps data in the internal buffer for a specific |
113 | ;amount of time if the buffer is not full yet to decrease |
113 | ;amount of time if the buffer is not full yet to decrease |
114 | ;load on the usb bus |
114 | ;load on the usb bus |
115 | ;[input+8] - 0xnnnnXXXX, where XX-latency |
115 | ;[input+8] - 0xnnnnXXXX, where XX-latency |
116 | FTDI_SET_LATENCY_TIMER = 20 |
116 | FTDI_SET_LATENCY_TIMER = 20 |
117 | ;Get latency timer |
117 | ;Get latency timer |
118 | ;[output] - latency |
118 | ;[output] - latency |
119 | FTDI_GET_LATENCY_TIMER = 21 |
119 | FTDI_GET_LATENCY_TIMER = 21 |
120 | ;Directly read pin state, circumventing the read buffer. Useful for bitbang mode |
120 | ;Directly read pin state, circumventing the read buffer. Useful for bitbang mode |
121 | ;[output] - pins' values |
121 | ;[output] - pins' values |
122 | FTDI_READ_PINS = 22 |
122 | FTDI_READ_PINS = 22 |
123 | ;This function allows the retrieve the two status bytes of the device. |
123 | ;This function allows the retrieve the two status bytes of the device. |
124 | ;The device sends these bytes also as a header for each read access |
124 | ;The device sends these bytes also as a header for each read access |
125 | ;where they are discarded by ftdi_read_data(). The chip generates |
125 | ;where they are discarded by ftdi_read_data(). The chip generates |
126 | ;the two stripped status bytes in the absence of data every 40 ms |
126 | ;the two stripped status bytes in the absence of data every 40 ms |
127 | ; |
127 | ; |
128 | ; Layout of the first byte: |
128 | ; Layout of the first byte: |
129 | ; - B0..B3 - must be 0 |
129 | ; - B0..B3 - must be 0 |
130 | ; - B4 Clear to send (CTS) |
130 | ; - B4 Clear to send (CTS) |
131 | ; 0 = inactive |
131 | ; 0 = inactive |
132 | ; 1 = active |
132 | ; 1 = active |
133 | ; - B5 Data set ready (DTS) |
133 | ; - B5 Data set ready (DTS) |
134 | ; 0 = inactive |
134 | ; 0 = inactive |
135 | ; 1 = active |
135 | ; 1 = active |
136 | ; - B6 Ring indicator (RI) |
136 | ; - B6 Ring indicator (RI) |
137 | ; 0 = inactive |
137 | ; 0 = inactive |
138 | ; 1 = active |
138 | ; 1 = active |
139 | ; - B7 Receive line signal detect (RLSD) |
139 | ; - B7 Receive line signal detect (RLSD) |
140 | ; 0 = inactive |
140 | ; 0 = inactive |
141 | ; 1 = active |
141 | ; 1 = active |
142 | 142 | ||
143 | ; Layout of the second byte: |
143 | ; Layout of the second byte: |
144 | ; - B0 Data ready (DR) |
144 | ; - B0 Data ready (DR) |
145 | ; - B1 Overrun error (OE) |
145 | ; - B1 Overrun error (OE) |
146 | ; - B2 Parity error (PE) |
146 | ; - B2 Parity error (PE) |
147 | ; - B3 Framing error (FE) |
147 | ; - B3 Framing error (FE) |
148 | ; - B4 Break interrupt (BI) |
148 | ; - B4 Break interrupt (BI) |
149 | ; - B5 Transmitter holding register (THRE) |
149 | ; - B5 Transmitter holding register (THRE) |
150 | ; - B6 Transmitter empty (TEMT) |
150 | ; - B6 Transmitter empty (TEMT) |
151 | ; - B7 Error in RCVR FIFO |
151 | ; - B7 Error in RCVR FIFO |
152 | ;[output] - poll modem status |
152 | ;[output] - poll modem status |
153 | FTDI_POLL_MODEM_STATUS = 23 |
153 | FTDI_POLL_MODEM_STATUS = 23 |
154 | ;Set (RS232) line characteristics |
154 | ;Set (RS232) line characteristics |
155 | ;dword[input+8] - line property constants combination |
155 | ;dword[input+8] - line property constants combination |
156 | FTDI_SET_LINE_PROPERTY = 24 |
156 | FTDI_SET_LINE_PROPERTY = 24 |
157 | ;Clears the read buffer on the chip |
157 | ;Clears the read buffer on the chip |
158 | ;[input+8] - none |
158 | ;[input+8] - none |
159 | FTDI_PURGE_RX_BUFFER = 25 |
159 | FTDI_PURGE_RX_BUFFER = 25 |
160 | ;Clears the write buffer on the chip |
160 | ;Clears the write buffer on the chip |
161 | ;[input+8] - none |
161 | ;[input+8] - none |
162 | FTDI_PURGE_RX_BUFFER = 26 |
162 | FTDI_PURGE_RX_BUFFER = 26 |
163 | 163 | ||
164 | ;Structures |
164 | ;Structures |
165 | ;list layout from FTDI_GET_LIST |
165 | ;list layout from FTDI_GET_LIST |
166 | struct dev_list |
166 | struct dev_list |
167 | size dd ? |
167 | size dd ? |
168 | nodes rd size*sizeof.node |
168 | nodes rd size*sizeof.node |
169 | ends |
169 | ends |
170 | 170 | ||
171 | struct node |
171 | struct node |
172 | islocked dd ? ; Will be 'LCKD', if dev is already locked; or 'NLKD', if dev is free |
172 | islocked dd ? ; Will be 'LCKD', if dev is already locked; or 'NLKD', if dev is free |
173 | chip_type dd ? ; FTDI chip type (see Chip types constants) |
173 | chip_type dd ? ; FTDI chip type (see Chip types constants) |
174 | dev_handle dd ? ; Device handle, value the same as in in_buf_map.dev_handle |
174 | dev_handle dd ? ; Device handle, value the same as in in_buf_map.dev_handle |
175 | ends |
175 | ends |
176 | 176 | ||
177 | ;input buffer map for requests above FTDI_GET_LIST |
177 | ;input buffer map for requests above FTDI_GET_LIST |
178 | struc in_buf_map |
178 | struc in_buf_map |
179 | pid dd ? ; Should be PID of application using this file |
179 | pid dd ? ; Should be PID of application using this file |
180 | dev_handle dd ? ; Should be value acquired from one of dev_list's nodes |
180 | dev_handle dd ? ; Should be value acquired from one of dev_list's nodes |
- | 181 | ends |