mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 19:06:15 +02:00
fw/accel.c (measure_ref): GND and Vbg measurement function (for diagnostics)
This commit is contained in:
parent
a4eeb43963
commit
1be433e65f
13
fw/accel.c
13
fw/accel.c
@ -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)
|
ISR(ADC_vect)
|
||||||
{
|
{
|
||||||
uint16_t v;
|
uint16_t v;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
extern void (*sample)(bool x, uint16_t v);
|
extern void (*sample)(bool x, uint16_t v);
|
||||||
|
|
||||||
|
|
||||||
|
uint16_t measure_ref(bool gnd);
|
||||||
void accel_start(void);
|
void accel_start(void);
|
||||||
|
|
||||||
#endif /* !ACCEL_H */
|
#endif /* !ACCEL_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user