Rev 6878 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6878 | Rev 7298 | ||
---|---|---|---|
Line 55... | Line 55... | ||
55 | ; Enable ADC |
55 | ; Enable ADC |
56 | invoke PciRead32, [bus], [dev], 0xBC |
56 | invoke PciRead32, [bus], [dev], 0xBC |
57 | and eax, not (1 shl 28) |
57 | and eax, not (1 shl 28) |
58 | invoke PciWrite32, [bus], [dev], 0xBC, eax |
58 | invoke PciWrite32, [bus], [dev], 0xBC, eax |
Line 59... | Line -... | ||
59 | - | ||
60 | DEBUGF 1,"1\n" |
- | |
61 | 59 | ||
62 | ; Set ADC base address |
60 | ; Set ADC base address |
63 | mov ebx, [dev] |
61 | mov ebx, [dev] |
64 | inc ebx |
62 | inc ebx |
65 | invoke PciRead16, [bus], ebx, 0xDE |
63 | invoke PciRead16, [bus], ebx, 0xDE |
66 | or ax, 0x02 |
64 | or ax, 0x02 |
Line 67... | Line 65... | ||
67 | invoke PciWrite16, [bus], ebx, 0xDE, eax |
65 | invoke PciWrite16, [bus], ebx, 0xDE, eax |
Line 68... | Line -... | ||
68 | - | ||
69 | invoke PciWrite32, [bus], ebx, 0xE0, 0x00500000 or ADC_ADDR |
- | |
70 | 66 | ||
71 | DEBUGF 1,"2\n" |
67 | invoke PciWrite32, [bus], ebx, 0xE0, 0x00500000 or ADC_ADDR |
72 | 68 | ||
73 | ; set up ADC |
69 | ; set up ADC |
Line 74... | Line -... | ||
74 | mov dx, ADC_ADDR + 1 |
- | |
75 | xor al, al |
- | |
76 | out dx, al |
70 | mov dx, ADC_ADDR + 1 |
77 | 71 | xor al, al |
|
78 | DEBUGF 1,"3\n" |
72 | out dx, al |
79 | 73 | ||
80 | ; Empty FIFO |
74 | ; Empty FIFO |
Line 86... | Line 80... | ||
86 | mov dx, ADC_ADDR + 4 |
80 | mov dx, ADC_ADDR + 4 |
87 | in ax, dx |
81 | in ax, dx |
88 | jmp @r |
82 | jmp @r |
89 | @@: |
83 | @@: |
Line 90... | Line -... | ||
90 | - | ||
91 | DEBUGF 1,"4\n" |
- | |
92 | 84 | ||
93 | ; Enable GPIO0-9 |
85 | ; Enable GPIO0-9 |
94 | mov dx, GPIO_PORT_CONFIG_ADDR + 0 ; General-Purpose I/O Data & Direction Decode Enable |
86 | mov dx, GPIO_PORT_CONFIG_ADDR + 0 ; General-Purpose I/O Data & Direction Decode Enable |
95 | mov eax, 0x000001ff |
87 | mov eax, 0x000001ff |
Line 109... | Line 101... | ||
109 | add dx, 2 |
101 | add dx, 2 |
110 | ; loop |
102 | ; loop |
111 | dec ecx |
103 | dec ecx |
112 | jnz .gpio_init |
104 | jnz .gpio_init |
Line 113... | Line 105... | ||
113 | 105 | ||
114 | ; Set GPIO0 pin 0 as output |
106 | ; Set GPIO0 pin 0-7 as output |
115 | mov al, 0x01 |
107 | mov al, 0xff |
116 | mov dx, GPIO_DATA_ADDR + 0*4 + 2 |
108 | mov dx, GPIO_DATA_ADDR + 0*4 + 2 |
Line 117... | Line 109... | ||
117 | out dx, al |
109 | out dx, al |
118 | 110 | ||
Line 151... | Line 143... | ||
151 | mov dx, GPIO_DATA_ADDR + 0x00 |
143 | mov dx, GPIO_DATA_ADDR + 0x00 |
152 | out dx, al |
144 | out dx, al |
153 | xor eax, eax |
145 | xor eax, eax |
154 | ret |
146 | ret |
155 | .no_gpiowrite: |
147 | .no_gpiowrite: |
156 | cmp eax, 3 ; read ADC channel 0 |
148 | cmp eax, 3 ; read single ADC channel |
157 | jne .no_adcread |
149 | jne .no_adcread |
Line -... | Line 150... | ||
- | 150 | ||
- | 151 | mov ecx, [ebx + IOCTL.input] |
|
- | 152 | cmp ecx, 8 |
|
- | 153 | jae .fail |
|
158 | 154 | ||
159 | mov dx, ADC_ADDR + 1 |
155 | mov dx, ADC_ADDR + 1 |
160 | mov al, 1 shl 3 ; Power down ADC |
156 | mov al, 1 shl 3 ; Power down ADC |
Line 161... | Line 157... | ||
161 | out dx, al |
157 | out dx, al |
162 | 158 | ||
- | 159 | mov dx, ADC_ADDR + 0 ; AUX channel select register |
|
163 | mov dx, ADC_ADDR + 0 ; AUX channel select register |
160 | mov al, 1 |
Line 164... | Line 161... | ||
164 | mov al, 1 shl 0 ; Enable AUX0 scan |
161 | shl ax, cl |
165 | out dx, al |
162 | out dx, al |
166 | 163 | ||
Line 173... | Line 170... | ||
173 | in al, dx |
170 | in al, dx |
174 | test al, 1 shl 0 ; data ready? |
171 | test al, 1 shl 0 ; data ready? |
175 | jz @r |
172 | jz @r |
Line 176... | Line 173... | ||
176 | 173 | ||
177 | mov dx, ADC_ADDR + 4 |
174 | mov dx, ADC_ADDR + 4 |
178 | in ax, dx ; read the data and return to user call |
- | |
179 | DEBUGF 1, "ADC read: 0x%x\n", eax:4 |
175 | in ax, dx ; read the data from the FIFO and return to user call |
180 | ret |
176 | ret |
181 | .no_adcread: |
177 | .no_adcread: |
182 | .fail: |
178 | .fail: |
183 | or eax, -1 |
179 | or eax, -1 |