Subversion Repositories Kolibri OS

Rev

Rev 5086 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5086 gtament 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
5363 yogev_ezra 3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
5086 gtament 4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
6
;;  Include file for apps which want to use FTDI device         ;;
7
;;                                                              ;;
8
;;         GNU GENERAL PUBLIC LICENSE                           ;;
9
;;          Version 2, June 1991                                ;;
10
;;                                                              ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12
 
13
;Bitmode constants
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 */
16
BITMODE_MPSSE  = 0x02       ;MPSSE mode, available on 2232x 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 */
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  */
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 */
23
BITMODE_FT1284 = 0x80       ;FT1284 mode, available on 232H chips
24
 
25
;Line property constants
26
  ;parity
27
NONE        = 0 shl 8
28
ODD         = 1 shl 8
29
EVEN        = 2 shl 8
30
MARK        = 3 shl 8
31
SPACE       = 4 shl 8
32
  ;stop bits
33
STOP_BIT_1  = 0 shl 11
34
STOP_BIT_15 = 1 shl 11
35
STOP_BIT_2  = 2 shl 11
36
  ;break type
37
BREAK_OFF   = 0 shl 14
38
BREAK_OFF   = 1 shl 14
39
  ;number of bits has to be at lower byte
40
 
41
;Flow control
42
SIO_DISABLE_FLOW_CTRL = 0x0
43
SIO_RTS_CTS_HS = (0x1 shl 8)
44
SIO_DTR_DSR_HS = (0x2 shl 8)
45
SIO_XON_XOFF_HS= (0x4 shl 8)
46
 
47
;Chip types
48
TYPE_AM     = 0
49
TYPE_BM     = 1
50
TYPE_2232C  = 2
51
TYPE_R      = 3
52
TYPE_2232H  = 4
53
TYPE_4232H  = 5
54
TYPE_232H   = 6
55
TYPE_230X   = 7
56
 
57
;IO codes
58
;Get list of detected ftdi chips
59
FTDI_GET_LIST = 1
60
;Acquire lock on ftdi device
61
;[input+8] - none
62
;[output] - PID device is locked by
63
FTDI_LOCK     = 2
64
;Unlock ftdi device
65
;[input+8] - none
66
;[output] - 0 if unclock success, overwise PID device is locked by
67
FTDI_UNLOCK   = 3
68
;[output] - chunksize
69
FTDI_GET_WRITE_CHUNKSIZE = 4
70
;[output] - chunksize
71
FTDI_GET_READ_CHUNKSIZE  = 5
72
;[input+8] - chunksize
73
FTDI_SET_WRITE_CHUNKSIZE = 6
74
;[input+8] - chunksize
75
FTDI_SET_READ_CHUNKSIZE  = 7
76
;Writes data in chunks to the chip
77
;[input+8] - size of data, [input+12] - beginning of data
78
FTDI_WRITE_DATA          = 8
79
;Reads data in chunks from the chip
80
;[input+8] - size of data, [output] - red data
81
FTDI_READ_DATA           = 9
82
;Sets the chip baud rate
83
;[input+8] - baudrate
84
FTDI_SET_BAUDRATE        = 10
85
;Enable/disable bitbang modes
86
;[input+8] - 0xnnnnXXYY, where XX-bitmask, YY-bitmode
87
FTDI_SET_BITMODE         = 11
88
;Set rts line high
89
;[input+8] - none
90
FTDI_SET_RTS_HIGH        = 12
91
;Set rts line low
92
;[input+8] - none
93
FTDI_SET_RTS_LOW         = 13
94
;Set dtr line high
95
;[input+8] - none
96
FTDI_SET_DTR_HIGH        = 14
97
;Set dtr line low
98
;[input+8] - none
99
FTDI_SET_DTR_LOW         = 15
100
;Resets the ftdi device
101
;[input+8] - none
102
FTDI_USB_RESET           = 16
103
;Set flowcontrol for ftdi chip
104
;dword[input+8] - one of flow control constants
105
FTDI_SET_FLOW_CONTROL    = 17
106
;Set the special event character
107
;[input+8] - 0xnnnnXXYY, where XX-1/0(enable/disable), YY-event char
108
FTDI_SET_EVENT_CHAR      = 18
109
;Set error character
110
;[input+8] - 0xnnnnXXYY, where XX-1/0(enable/disable), YY-error char
111
FTDI_SET_ERROR_CHAR      = 19
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
114
;load on the usb bus
115
;[input+8] - 0xnnnnXXXX, where XX-latency
116
FTDI_SET_LATENCY_TIMER   = 20
117
;Get latency timer
118
;[output] - latency
119
FTDI_GET_LATENCY_TIMER   = 21
120
;Directly read pin state, circumventing the read buffer. Useful for bitbang mode
121
;[output] - pins' values
122
FTDI_READ_PINS           = 22
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
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
127
;
128
; Layout of the first byte:
129
; - B0..B3 - must be 0
130
; - B4       Clear to send (CTS)
131
             ; 0 = inactive
132
             ; 1 = active
133
; - B5       Data set ready (DTS)
134
             ; 0 = inactive
135
             ; 1 = active
136
; - B6       Ring indicator (RI)
137
             ; 0 = inactive
138
             ; 1 = active
139
; - B7       Receive line signal detect (RLSD)
140
             ; 0 = inactive
141
             ; 1 = active
142
 
143
; Layout of the second byte:
144
; - B0       Data ready (DR)
145
; - B1       Overrun error (OE)
146
; - B2       Parity error (PE)
147
; - B3       Framing error (FE)
148
; - B4       Break interrupt (BI)
149
; - B5       Transmitter holding register (THRE)
150
; - B6       Transmitter empty (TEMT)
151
; - B7       Error in RCVR FIFO
152
;[output] - poll modem status
153
FTDI_POLL_MODEM_STATUS   = 23
154
;Set (RS232) line characteristics
155
;dword[input+8] - line property constants combination
156
FTDI_SET_LINE_PROPERTY   = 24
157
;Clears the read buffer on the chip
158
;[input+8] - none
159
FTDI_PURGE_RX_BUFFER     = 25
160
;Clears the write buffer on the chip
161
;[input+8] - none
162
FTDI_PURGE_RX_BUFFER     = 26
163
 
164
;Structures
165
  ;list layout from FTDI_GET_LIST
166
struct dev_list
167
size        dd  ?
168
nodes       rd  size*sizeof.node
169
ends
170
 
171
struct node
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)
174
dev_handle  dd ? ; Device handle, value the same as in in_buf_map.dev_handle
175
ends
176
 
177
  ;input buffer map for requests above FTDI_GET_LIST
178
struc in_buf_map
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