diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/adc.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index 4b11c7dbab..46890badd4 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c | |||
@@ -179,6 +179,17 @@ unsigned short adc_read(int channel) | |||
179 | return adcdata[channel]; | 179 | return adcdata[channel]; |
180 | } | 180 | } |
181 | 181 | ||
182 | static int adc_counter; | ||
183 | |||
184 | static void adc_tick(void) | ||
185 | { | ||
186 | if(++adc_counter == HZ) | ||
187 | { | ||
188 | adc_counter = 0; | ||
189 | adcdata[ADC_BATTERY] = adc_scan(ADC_BATTERY); | ||
190 | } | ||
191 | } | ||
192 | |||
182 | void adc_init(void) | 193 | void adc_init(void) |
183 | { | 194 | { |
184 | GPIO_FUNCTION |= 0x80600080; /* GPIO7: CS | 195 | GPIO_FUNCTION |= 0x80600080; /* GPIO7: CS |
@@ -188,6 +199,10 @@ void adc_init(void) | |||
188 | GPIO_ENABLE |= 0x00600080; | 199 | GPIO_ENABLE |= 0x00600080; |
189 | GPIO_OUT |= 0x80; /* CS high */ | 200 | GPIO_OUT |= 0x80; /* CS high */ |
190 | GPIO_OUT &= ~0x00400000; /* CLK low */ | 201 | GPIO_OUT &= ~0x00400000; /* CLK low */ |
202 | |||
203 | tick_add_task(adc_tick); | ||
204 | |||
205 | adcdata[3] = adc_scan(3); | ||
191 | } | 206 | } |
192 | 207 | ||
193 | #endif | 208 | #endif |