1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-11-22 13:44:59 +02:00

fw/accel.c (measure_ref): GND and Vbg measurement function (for diagnostics)

This commit is contained in:
Werner Almesberger 2012-07-01 10:35:29 -03:00
parent a4eeb43963
commit 1be433e65f
2 changed files with 14 additions and 0 deletions

View File

@ -50,6 +50,19 @@ static inline void adcsra(bool start)
}
uint16_t measure_ref(bool gnd)
{
while (ADCSRA & (1 << ADSC));
adcsra(0);
ADMUX =
1 << REFS0 | /* Vref is AVcc */
(gnd ? 15 : 14); /* GND (0 V) or Vbg (1.1 V) */
adcsra(1);
while (ADCSRA & (1 << ADSC));
return ADC;
}
ISR(ADC_vect)
{
uint16_t v;

View File

@ -21,6 +21,7 @@
extern void (*sample)(bool x, uint16_t v);
uint16_t measure_ref(bool gnd);
void accel_start(void);
#endif /* !ACCEL_H */