441392561323d575db46522e3966a6b965c4ee20
[fw/altos] / src / drivers / ao_ads1256.h
1 /*
2  * Copyright © 2019 Bdale Garbee <bdale@gag.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  */
14
15 #ifndef _AO_ADS1256_H_
16 #define _AO_ADS1256_H_
17
18 /* commands */
19 #define AO_ADS1256_WAKEUP               0x00
20 #define AO_ADS1256_RDATA                0x01
21 #define AO_ADS1256_RDATAC               0x03
22 #define AO_ADS1256_SDATAC               0x0f
23 #define AO_ADS1256_RREG                 0x10
24 #define AO_ADS1256_WREG                 0x50
25 #define AO_ADS1256_SELFCAL              0xf0
26 #define AO_ADS1256_SELFOCAL             0xf1
27 #define AO_ADS1256_SELFGCAL             0xf2
28 #define AO_ADS1256_SYSOCAL              0xf3
29 #define AO_ADS1256_SYSGCAL              0xf4
30 #define AO_ADS1256_SYNC                 0xfc
31 #define AO_ADS1256_STANDBY              0xfd
32 #define AO_ADS1256_RESET                0xfe
33 #define AO_ADS1256_WAKEUP2              0xff
34
35 /* register map */
36 #define AO_ADS1256_STATUS       0x00
37 #define AO_ADS1256_MUX          0x01
38 #define AO_ADS1256_ADCON        0x02
39 #define AO_ADS1256_DRATE        0x03
40 #define AO_ADS1256_IO           0x04
41 #define AO_ADS1256_OFC0         0x05
42 #define AO_ADS1256_OFC1         0x06
43 #define AO_ADS1256_OFC2         0x07
44 #define AO_ADS1256_FSC0         0x08
45 #define AO_ADS1256_FSC1         0x09
46 #define AO_ADS1256_FSC2         0x0a
47
48 struct ao_ads1256_sample {
49         int32_t ain[AO_ADS1256_CHANNELS];
50 };
51
52 extern struct ao_ads1256_sample ao_ads1256_current;
53
54 void
55 ao_ads1256_init(void);
56
57 #endif /* _AO_ADS1256_H_ */