blob: cd9ce826f75e2fee18435e8794ed21c71784ce91 [file] [log] [blame]
Brian Silverman95244d82013-12-14 12:15:46 -08001#ifndef CAPE_ANALOG_H_
2#define CAPE_ANALOG_H_
3
4#include <stdint.h>
5
Brian Silvermanf482b4c2014-03-17 19:44:20 -07006#include <STM32F2XX.h>
7
Brian Silverman95244d82013-12-14 12:15:46 -08008// Starts up constantly reading analog values and storing them in an array to
9// be retrieved by analog_get.
10void analog_init(void);
11
12static inline uint16_t analog_get(int num) {
13 if (num < 0 || num > 7) return 0xFFFF;
14
15 extern uint16_t analog_readings[8] __attribute__((aligned(8)));
16 return analog_readings[num];
17}
18
Brian Silvermanf482b4c2014-03-17 19:44:20 -070019// Returns the number of errors since last called.
20// Must be called from something with priority equal to or lower than our
21// timer's IRQ.
22int analog_get_errors(void);
23
Brian Silverman95244d82013-12-14 12:15:46 -080024#endif // CAPE_ANALOG_H_