no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ades1754.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef __ADES1754_H__
34#define __ADES1754_H__
35
36#include "no_os_spi.h"
37#include "no_os_uart.h"
38#include "no_os_util.h"
39#include "no_os_units.h"
40
41#define ADES1754_VERSION_REG 0x00
42#define ADES1754_ADDRESS_REG 0x01
43#define ADES1754_STATUS1_REG 0x02
44#define ADES1754_STATUS2_REG 0x03
45#define ADES1754_STATUS3_REG 0x04
46#define ADES1754_FMEA1_REG 0x05
47#define ADES1754_FMEA2_REG 0x06
48#define ADES1754_ALRTSUM_REG 0x07
49#define ADES1754_ALRTOVCELL_REG 0x08
50#define ADES1754_ALRTUVCELL_REG 0x09
51#define ADES1754_MINMAXCELL_REG 0x0A
52#define ADES1754_ALRTAUXPRTCT_REG 0x0B
53#define ADES1754_ALRTUAUXOV_REG 0x0C
54#define ADES1754_ALRTAUXUV_REG 0x0D
55#define ADES1754_ALRTCOMPOVR_REG 0x0E
56#define ADES1754_ALRTCOMPUVR_REG 0x0F
57#define ADES1754_ALRTCOMPAUXOVR_REG 0x10
58#define ADES1754_ALRTCOMPAUXUV_REG 0x11
59#define ADES1754_ALRTBALSWRE_REG 0x12
60#define ADES1754_SWACTION_REG 0x13
61#define ADES1754_DEVCFG_REG 0x14
62#define ADES1754_DEVCFG2_REG 0x15
63#define ADES1754_AUXGPIOCFG_REG 0x16
64#define ADES1754_GPIOCFG_REG 0x17
65#define ADES1754_PACKCFG_REG 0x18
66
67#define ADES1754_ALRTIRQEN_REG 0x19
68#define ADES1754_ALRTOVEN_REG 0x1A
69#define ADES1754_ALRTUVEN_REG 0x1B
70#define ADES1754_ALRTAUXOVEN_REG 0x1C
71#define ADES1754_ALRTAUXUVEN_REG 0x1D
72#define ADES1754_ALRTCALTST_REG 0x1E
73
74#define ADES1754_OVTHCLR_REG 0x1F
75#define ADES1754_OVTHSET_REG 0x20
76#define ADES1754_UVTHCLR_REG 0x21
77#define ADES1754_UVTHSET_REG 0x22
78#define ADES1754_MSMTCH_REG 0x23
79#define ADES1754_BIPOVTHCLR_REG 0x24
80#define ADES1754_BIPOVTHSET_REG 0x25
81#define ADES1754_BIPUVTHCLR_REG 0x26
82#define ADES1754_BIPUVTHSET_REG 0x27
83#define ADES1754_BLKOVTHCLR_REG 0x28
84#define ADES1754_BLKOVTHSET_REG 0x29
85#define ADES1754_BLKUVTHCLR_REG 0x2A
86#define ADES1754_BLKUVTHSET_REG 0x2B
87#define ADES1754_AUXROVTHCLR_REG 0x30
88#define ADES1754_AUXROVTHSET_REG 0x31
89#define ADES1754_AUXRUVTHCLR_REG 0x32
90#define ADES1754_AUXRUVTHSET_REG 0x33
91#define ADES1754_AUXAOVTHCLR_REG 0x34
92#define ADES1754_AUXAOVTHSET_REG 0x35
93#define ADES1754_AUXAUVTHCLR_REG 0x36
94#define ADES1754_AUXAUVTHSET_REG 0x37
95#define ADES1754_COMPOVTH_REG 0x38
96#define ADES1754_COMPUVTH_REG 0x39
97#define ADES1754_COMPAUXROVTH_REG 0x3A
98#define ADES1754_COMPAUXRUVTH_REG 0x3B
99#define ADES1754_COMPAUXAOVTH_REG 0x3C
100#define ADES1754_COMPAUXAUVTH_REG 0x3D
101
102#define ADES1754_COMPOPNTH_REG 0x3E
103#define ADES1754_COMPAUXROPNTH_REG 0x3F
104#define ADES1754_COMPAUXOPNTH_REG 0x40
105#define ADES1754_COMPACCOVTH_REG 0x41
106#define ADES1754_COMPACCUVTH_REG 0x42
107#define ADES1754_BALSHRTTHR_REG 0x43
108#define ADES1754_BALLOWTHR_REG 0x44
109#define ADES1754_BALHIGHTHR_REG 0x45
110
111#define ADES1754_CELLN_REG(n) (0x47 + (n))
112#define ADES1754_BLOCK_REG 0x55
113
114#define ADES1754_TOTAL_REG 0x56
115#define ADES1754_DIAG1_REG 0x57
116#define ADES1754_DIAG2_REG 0x58
117#define ADES1754_AUX0_REG 0x59
118#define ADES1754_AUX1_REG 0x5A
119#define ADES1754_AUX2_REG 0x5B
120#define ADES1754_AUX3_REG 0x5C
121#define ADES1754_AUX4_REG 0x5D
122#define ADES1754_AUX5_REG 0x5E
123
124#define ADES1754_POLARITYCTRL_REG 0x5F
125#define ADES1754_AUXREFCTRL_REG 0x60
126#define ADES1754_AUXTIME_REG 0x61
127#define ADES1754_ACQCFG_REG 0x62
128#define ADES1754_BALSWDLY_REG 0x63
129
130#define ADES1754_MEASUREEN1_REG 0x64
131#define ADES1754_MEASUREEN2_REG 0x65
132#define ADES1754_SCANCTRL_REG 0x66
133
134#define ADES1754_ADCTEST1A_REG 0x67
135#define ADES1754_ADCTEST1B_REG 0x68
136#define ADES1754_ADCTEST2A_REG 0x69
137#define ADES1754_ADCTEST2B_REG 0x6A
138#define ADES1754_DIAGCFG_REG 0x6B
139#define ADES1754_CTSTCFG_REG 0x6C
140#define ADES1754_AUXTSTCFG_REG 0x6D
141#define ADES1754_DIAGGENCFG_REG 0x6E
142
143#define ADES1754_BALSWCTRL_REG 0x6F
144#define ADES1754_BALEXP1_REG 0x70
145#define ADES1754_BALEXP2_REG 0x71
146#define ADES1754_BALEXP3_REG 0x72
147#define ADES1754_BALEXP4_REG 0x73
148#define ADES1754_BALEXP5_REG 0x74
149#define ADES1754_BALEXP6_REG 0x75
150#define ADES1754_BALEXP7_REG 0x76
151#define ADES1754_BALEXP8_REG 0x77
152#define ADES1754_BALEXP9_REG 0x78
153#define ADES1754_BALEXP10_REG 0x79
154#define ADES1754_BALEXP11_REG 0x7A
155#define ADES1754_BALEXP12_REG 0x7B
156#define ADES1754_BALEXP13_REG 0x7C
157#define ADES1754_BALEXP14_REG 0x7D
158#define ADES1754_BALAUTOUVTH_REG 0x7E
159#define ADES1754_BALDLYCTRL_REG 0x7F
160#define ADES1754_BALCTRL_REG 0x80
161#define ADES1754_BALSTAT_REG 0x81
162#define ADES1754_BALUVSTAT_REG 0x82
163#define ADES1754_BALDATA_REG 0x83
164
165#define ADES1754_I2CPNTR_REG 0x84
166#define ADES1754_I2CWDATA1_REG 0x85
167#define ADES1754_I2CWDATA2_REG 0x86
168#define ADES1754_I2CRDATA1_REG 0x87
169#define ADES1754_I2CRDATA2_REG 0x88
170#define ADES1754_I2CCFG_REG 0x89
171#define ADES1754_I2CSTAT_REG 0x8A
172#define ADES1754_I2CSEND_REG 0x8B
173
174#define ADES1754_ID1_REG 0x8C
175#define ADES1754_ID2_REG 0x8D
176#define ADES1754_ID3_REG 0x8E
177#define ADES1754_OTP3_REG 0x8F
178#define ADES1754_OTP4_REG 0x90
179#define ADES1754_OTP5_REG 0x91
180#define ADES1754_OTP6_REG 0x92
181#define ADES1754_OTP7_REG 0x93
182#define ADES1754_OTP8_REG 0x94
183#define ADES1754_OTP9_REG 0x95
184#define ADES1754_OTP10_REG 0x96
185#define ADES1754_OTP11_REG 0x97
186#define ADES1754_OTP12_REG 0x98
187
188#define ADES1754_PREAMBLE_BYTE 0x15
189#define ADES1754_STOP_BYTE 0x54
190#define ADES1754_HELLO_ALL_BYTE 0x57
191
192#define ADES1754_DEV_ADDR_MAX 0x1F
193#define ADES1754_WR_ALL 0x02
194#define ADES1754_RD_ALL 0x03
195#define ADES1754_DEFAULT_DC_BYTE_SEED 0x00
196#define ADES1754_FILL_BYTE_C2 0xC2
197#define ADES1754_FILL_BYTE_D3 0xD3
198
199#define ADES1754_WR_MASK NO_OS_BIT(2)
200#define ADES1754_RD_MASK ADES1754_WR_MASK | NO_OS_BIT(0)
201#define ADES1754_BL_MASK NO_OS_GENMASK(2, 1)
202#define ADES1754_RW_ADDR_MASK NO_OS_GENMASK(7, 3)
203
204#define ADES1754_LSB_MASK NO_OS_GENMASK(7, 0)
205#define ADES1754_MSB_MASK NO_OS_GENMASK(15, 8)
206#define ADES1754_LOWER_NIBBLE_MASK NO_OS_GENMASK(3, 0)
207#define ADES1754_UPPER_NIBBLE_MASK NO_OS_GENMASK(7, 4)
208
209#define ADES1754_ADC_METHOD_MASK NO_OS_BIT(1)
210#define ADES1754_SCAN_MODE_MASK NO_OS_GENMASK(8, 6)
211#define ADES1754_SCAN_REQUEST_MASK NO_OS_BIT(0)
212#define ADES1754_IIR_MASK NO_OS_GENMASK(15, 13)
213#define ADES1754_ALRTFILT_MASK NO_OS_BIT(2)
214#define ADES1754_AMENDFILT_MASK NO_OS_BIT(1)
215#define ADES1754_RDFILT_MASK NO_OS_BIT(0)
216#define ADES1754_IIR_SCAN_MASK NO_OS_GENMASK(11, 9)
217#define ADES1754_DBLBUFEN_MASK NO_OS_BIT(0)
218#define ADES1754_CBMODE_MASK NO_OS_GENMASK(13, 11)
219#define ADES1754_CBMEASEN_MASK NO_OS_GENMASK(1, 0)
220#define ADES1754_CBCALDLY_MASK NO_OS_GENMASK(2, 0)
221#define ADES1754_UARTCFG_MASK NO_OS_GENMASK(15, 14)
222#define ADES1754_CELL_POLARITY_MASK NO_OS_BIT(15)
223
231
236
247
252
263
268
280
291
297
307
315
326
327int ades1754_hello_all(struct ades1754_desc *desc);
328
329int ades1754_write_dev(struct ades1754_desc *desc, uint8_t reg, uint16_t data);
330
331int ades1754_write_all(struct ades1754_desc *desc, uint8_t reg, uint16_t data);
332
333int ades1754_read_dev(struct ades1754_desc *desc, uint8_t reg, uint16_t *data);
334
335int ades1754_read_all(struct ades1754_desc *desc, uint8_t reg, uint16_t *data);
336
337int ades1754_read_block(struct ades1754_desc *desc, uint8_t block, uint8_t reg,
338 uint16_t *data, bool double_size);
339
340int ades1754_update_dev(struct ades1754_desc *desc, uint8_t reg, uint16_t mask,
341 uint16_t val);
342
344 enum ades1754_scan_method scan_method);
345
347 enum ades1754_scan_mode mode);
348
349int ades1754_set_cell_pol(struct ades1754_desc *desc,
350 enum ades1754_cell_polarity cell_polarity);
351
352int ades1754_start_scan(struct ades1754_desc *desc, bool meas,
353 uint16_t cell_mask);
354
355int ades1754_get_cell_data(struct ades1754_desc *desc, uint8_t cell_nb,
356 int32_t *cell_voltage);
357
358int ades1754_set_iir(struct ades1754_desc *desc,
359 enum ades1754_iir_filter_coef coef);
360
361int ades1754_set_iir_ctrl(struct ades1754_desc *desc, bool alrtfilt, bool acc,
362 bool output);
363
365 enum ades1754_buffer_mode mode);
366
368 enum ades1754_alert alert,
369 uint16_t thr);
370
371int ades1754_get_alert(struct ades1754_desc *desc, enum ades1754_alert alert,
372 bool *enable);
373
375 enum ades1754_bal_mode mode);
376
378 enum ades1754_bal_meas meas);
379
381 enum ades1754_bal_calib calib);
382
383int ades1754_init(struct ades1754_desc **desc,
385
386int ades1754_remove(struct ades1754_desc *desc);
387
388#endif /* __ADES1754_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
int ades1754_get_cell_data(struct ades1754_desc *desc, uint8_t cell_nb, int32_t *cell_voltage)
ADES1754 read cell data.
Definition ades1754.c:941
ades1754_scan_mode
Definition ades1754.h:237
@ ADES1754_ON_DEMAND_CALIB
Definition ades1754.h:241
@ ADES1754_SCAN_ADC_COMP
Definition ades1754.h:240
@ ADES1754_CELL_SENSE_OPEN_ODDS
Definition ades1754.h:244
@ ADES1754_SCAN_COMP
Definition ades1754.h:239
@ ADES1754_BALANCING_SW_OPEN
Definition ades1754.h:243
@ ADES1754_BALANCING_SW_SHRT
Definition ades1754.h:242
@ ADES1754_SCAN_ADC
Definition ades1754.h:238
@ ADES1754_CELL_SENSE_OPEN_EVENS
Definition ades1754.h:245
ades1754_bal_meas
Definition ades1754.h:292
@ ADES1754_ADC_CAL_ON_CBUVTHR_OFF
Definition ades1754.h:294
@ ADES1754_ALL_MEAS_DISABLED
Definition ades1754.h:293
@ ADES1754_ALL_MEAS_ENABLED
Definition ades1754.h:295
int ades1754_read_all(struct ades1754_desc *desc, uint8_t reg, uint16_t *data)
ADES1754 read all command message.
Definition ades1754.c:431
ades1754_bal_mode
Definition ades1754.h:281
@ ADES1754_BAL_AUTO_SEC
Definition ades1754.h:286
@ ADES1754_BAL_EMERGENCY
Definition ades1754.h:283
@ ADES1754_BAL_MANUAL_MIN
Definition ades1754.h:285
@ ADES1754_BAL_AUTO_MIN
Definition ades1754.h:287
@ ADES1754_BAL_AUTO_GROUP_MIN
Definition ades1754.h:289
@ ADES1754_BAL_DISABLED
Definition ades1754.h:282
@ ADES1754_BAL_AUTO_GROUP_SEC
Definition ades1754.h:288
@ ADES1754_BAL_MANUAL_SEC
Definition ades1754.h:284
int ades1754_set_buffer_mode(struct ades1754_desc *desc, enum ades1754_buffer_mode mode)
Set Buffer mode for data acquisition.
Definition ades1754.c:1004
int ades1754_read_dev(struct ades1754_desc *desc, uint8_t reg, uint16_t *data)
ADES1754 read device command message.
Definition ades1754.c:283
int ades1754_start_scan(struct ades1754_desc *desc, bool meas, uint16_t cell_mask)
ADES1754 Start/Stop Scanning function.
Definition ades1754.c:918
ades1754_alert
Definition ades1754.h:269
@ ADES1754_AUXIN_OV
Definition ades1754.h:277
@ ADES1754_CELL_OV
Definition ades1754.h:270
@ ADES1754_BLOCK_OV
Definition ades1754.h:274
@ ADES1754_AUXIN_UV
Definition ades1754.h:278
@ ADES1754_BLOCK_UV
Definition ades1754.h:275
@ ADES1754_CELL_MISMATCH
Definition ades1754.h:276
@ ADES1754_BIPOLAR_OV
Definition ades1754.h:272
@ ADES1754_CELL_UV
Definition ades1754.h:271
@ ADES1754_BIPOLAR_UV
Definition ades1754.h:273
int ades1754_set_alert_thr(struct ades1754_desc *desc, enum ades1754_alert alert, uint16_t thr)
Set specific alert thershold value.
Definition ades1754.c:1018
int ades1754_set_balancing_meas(struct ades1754_desc *desc, enum ades1754_bal_meas meas)
Cell-Ballancing Measurement Enable/Disable.
Definition ades1754.c:1154
ades1754_cell_polarity
Definition ades1754.h:248
@ ADES1754_BIPOLAR
Definition ades1754.h:250
@ ADES1754_UNIPOLAR
Definition ades1754.h:249
ades1754_buffer_mode
Definition ades1754.h:264
@ ADES1754_DOUBLE_BUFF
Definition ades1754.h:266
@ ADES1754_SINGLE_BUFF
Definition ades1754.h:265
int ades1754_read_block(struct ades1754_desc *desc, uint8_t block, uint8_t reg, uint16_t *data, bool double_size)
ADES1754 read block command message.
Definition ades1754.c:602
int ades1754_set_balancing_calib(struct ades1754_desc *desc, enum ades1754_bal_calib calib)
Cell-Balancing Calibration Period Selection.
Definition ades1754.c:1168
ades1754_scan_method
Definition ades1754.h:232
@ ADES1754_RAMP_METHOD
Definition ades1754.h:234
@ ADES1754_PYRAMID_METHOD
Definition ades1754.h:233
int ades1754_init(struct ades1754_desc **desc, struct ades1754_init_param *init_param)
ADES1754 device intialization function.
Definition ades1754.c:1181
int ades1754_hello_all(struct ades1754_desc *desc)
ADES1754 HELLO ALL specific command message to wake-up devices alongside daisy-chain.
Definition ades1754.c:85
int ades1754_set_cell_pol(struct ades1754_desc *desc, enum ades1754_cell_polarity cell_polarity)
Set Cell Polarity.
Definition ades1754.c:890
ades1754_id
Definition ades1754.h:224
@ ID_ADES1752
Definition ades1754.h:229
@ ID_ADES1751
Definition ades1754.h:228
@ ID_ADES1754
Definition ades1754.h:225
@ ID_ADES1756
Definition ades1754.h:227
@ ID_ADES1755
Definition ades1754.h:226
int ades1754_set_iir(struct ades1754_desc *desc, enum ades1754_iir_filter_coef coef)
Set IIR filter coefficient.
Definition ades1754.c:965
int ades1754_switch_scan_mode(struct ades1754_desc *desc, enum ades1754_scan_mode mode)
Select Scan Mode of the cells.
Definition ades1754.c:869
int ades1754_set_balancing_mode(struct ades1754_desc *desc, enum ades1754_bal_mode mode)
Set Cell Balancing mode.
Definition ades1754.c:1140
ades1754_bal_calib
Definition ades1754.h:298
@ ADES1754_BAL_CALIB_DISABLED
Definition ades1754.h:299
@ ADES1754_BAL_2_CYCLE
Definition ades1754.h:300
@ ADES1754_BAL_24_CYCLE
Definition ades1754.h:305
@ ADES1754_BAL_4_CYCLE
Definition ades1754.h:301
@ ADES1754_BAL_8_CYCLE
Definition ades1754.h:302
@ ADES1754_BAL_12_CYCLE
Definition ades1754.h:303
@ ADES1754_BAL_16_CYCLE
Definition ades1754.h:304
int ades1754_get_alert(struct ades1754_desc *desc, enum ades1754_alert alert, bool *enable)
Read specific alert state.
Definition ades1754.c:1091
int ades1754_remove(struct ades1754_desc *desc)
Deallocate any resources used by the initialization function..
Definition ades1754.c:1230
int ades1754_write_dev(struct ades1754_desc *desc, uint8_t reg, uint16_t data)
ADES1754 write device command message.
Definition ades1754.c:130
int ades1754_set_adc_method(struct ades1754_desc *desc, enum ades1754_scan_method scan_method)
Set ADC scan method.
Definition ades1754.c:856
ades1754_iir_filter_coef
Definition ades1754.h:253
@ ADES1754_IIR_0_125
Definition ades1754.h:254
@ ADES1754_IIR_0_500
Definition ades1754.h:257
@ ADES1754_IIR_0_375
Definition ades1754.h:256
@ ADES1754_IIR_1_000_OFF
Definition ades1754.h:261
@ ADES1754_IIR_0_250
Definition ades1754.h:255
@ ADES1754_IIR_0_750
Definition ades1754.h:259
@ ADES1754_IIR_0_625
Definition ades1754.h:258
@ ADES1754_IIR_0_875
Definition ades1754.h:260
int ades1754_update_dev(struct ades1754_desc *desc, uint8_t reg, uint16_t mask, uint16_t val)
ADES1754 update device command message.
Definition ades1754.c:834
int ades1754_set_iir_ctrl(struct ades1754_desc *desc, bool alrtfilt, bool acc, bool output)
Set speciic IIR filter settings.
Definition ades1754.c:985
int ades1754_write_all(struct ades1754_desc *desc, uint8_t reg, uint16_t data)
ADES1754 write all command message.
Definition ades1754.c:211
Header file of SPI Interface.
Header file of UART interface.
Header file of Units.
Header file of utility functions.
Definition ades1754.h:316
uint8_t dev_addr
Definition ades1754.h:322
enum ades1754_scan_mode scan_mode
Definition ades1754.h:320
bool alive
Definition ades1754.h:324
enum ades1754_cell_polarity cell_polarity
Definition ades1754.h:321
enum ades1754_id id
Definition ades1754.h:318
uint8_t no_dev
Definition ades1754.h:323
bool uart_bridge
Definition ades1754.h:319
struct no_os_uart_desc * uart_desc
Definition ades1754.h:317
Definition ades1754.h:308
uint8_t dev_addr
Definition ades1754.h:312
bool uart_bridge
Definition ades1754.h:311
enum ades1754_id id
Definition ades1754.h:310
struct no_os_uart_init_param * uart_param
Definition ades1754.h:309
uint8_t no_dev
Definition ades1754.h:313
Stucture holding the UART descriptor.
Definition no_os_uart.h:122
Structure holding the parameters for UART initialization.
Definition no_os_uart.h:98