-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathads1110.h
97 lines (77 loc) · 2.27 KB
/
ads1110.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef _ADS1110_H_
#define _ADS1110_H_
/*
Author: Nima Askari
WebSite: http://www.github.com/NimaLTD
Instagram: http://instagram.com/github.NimaLTD
Youtube: https://www.youtube.com/channel/UCUhY7qY1klJm1d2kulr9ckw
Version: 1.0.0
Reversion History:
(1.0.0)
First release.
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include "main.h"
/***************************************************************************************************************/
#define ADS1110_REF 2048.0f
typedef enum
{
ads1110_address_A0 = 0x48 << 1,
ads1110_address_A1,
ads1110_address_A2,
ads1110_address_A3,
ads1110_address_A4,
ads1110_address_A5,
ads1110_address_A6,
ads1110_address_A7,
ads1110_address_auto = 0xFF
}ads1110_address_t;
typedef enum
{
ads1110_gain_1 = 0,
ads1110_gain_2 = 1,
ads1110_gain_4 = 2,
ads1110_gain_8 = 3
}ads1110_gain_t;
typedef enum
{
ads1110_rate_240 = 0,
ads1110_rate_60 = 1,
ads1110_rate_30 = 2,
ads1110_rate_15 = 3
}ads1110_rate_t;
typedef struct
{
uint8_t PGA:2;
uint8_t DR:2;
uint8_t SC:1;
uint8_t reserved:2;
uint8_t ST_DRDY:1;
}ads1110_config_t;
typedef struct
{
I2C_HandleTypeDef* i2c_handle;
ads1110_address_t address;
ads1110_config_t config;
}ads1110_t;
/***************************************************************************************************************/
bool ads1110_init(ads1110_t *handle, I2C_HandleTypeDef *i2c_handle, ads1110_address_t address);
bool ads1110_set_gain(ads1110_t *handle, ads1110_gain_t gain);
bool ads1110_set_rate(ads1110_t *handle, ads1110_rate_t rate);
bool ads1110_set_single_mode(ads1110_t *handle);
bool ads1110_set_continues_mode(ads1110_t *handle);
bool ads1110_start_conversion(ads1110_t *handle);
bool ads1110_available(ads1110_t *handle);
bool ads1110_read_raw(ads1110_t *handle, int16_t *adc_raw);
bool ads1110_read_mv(ads1110_t *handle, float *adc_mv);
/***************************************************************************************************************/
#ifdef __cplusplus
}
#endif
#endif