no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
max42500.h
Go to the documentation of this file.
1/***************************************************************************/
40#ifndef __MAX42500_H__
41#define __MAX42500_H__
42
43#include <stdint.h>
44#include <stdbool.h>
45#include "no_os_i2c.h"
46#include "no_os_gpio.h"
47
48#define MAX42500_REG_ID 0x00
49#define MAX42500_REG_CONFIG1 0x01
50#define MAX42500_REG_CONFIG2 0x02
51#define MAX42500_REG_VMON 0x03
52#define MAX42500_REG_RSTMAP 0x04
53#define MAX42500_REG_STATOV 0x05
54#define MAX42500_REG_STATUV 0x06
55#define MAX42500_REG_STATOFF 0x07
56#define MAX42500_REG_VIN1 0x08
57#define MAX42500_REG_VIN2 0x09
58#define MAX42500_REG_VIN3 0x0A
59#define MAX42500_REG_VIN4 0x0B
60#define MAX42500_REG_VIN5 0x0C
61#define MAX42500_REG_VINO6 0x0D
62#define MAX42500_REG_VINU6 0x0E
63#define MAX42500_REG_VINO7 0x0F
64#define MAX42500_REG_VINU7 0x10
65#define MAX42500_REG_OVUV1 0x11
66#define MAX42500_REG_OVUV2 0x12
67#define MAX42500_REG_OVUV3 0x13
68#define MAX42500_REG_OVUV4 0x14
69#define MAX42500_REG_OVUV5 0x15
70#define MAX42500_REG_FPSSTAT1 0x16
71#define MAX42500_REG_FPSCFG1 0x17
72#define MAX42500_REG_UTIME1 0x18
73#define MAX42500_REG_UTIME2 0x19
74#define MAX42500_REG_UTIME3 0x1A
75#define MAX42500_REG_UTIME4 0x1B
76#define MAX42500_REG_UTIME5 0x1C
77#define MAX42500_REG_UTIME6 0x1D
78#define MAX42500_REG_UTIME7 0x1E
79#define MAX42500_REG_DTIME1 0x1F
80#define MAX42500_REG_DTIME2 0x20
81#define MAX42500_REG_DTIME3 0x21
82#define MAX42500_REG_DTIME4 0x22
83#define MAX42500_REG_DTIME5 0x23
84#define MAX42500_REG_DTIME6 0x24
85#define MAX42500_REG_DTIME7 0x25
86#define MAX42500_REG_WDSTAT 0x26
87#define MAX42500_REG_WDCDIV 0x27
88#define MAX42500_REG_WDCFG1 0x28
89#define MAX42500_REG_WDCFG2 0x29
90#define MAX42500_REG_WDKEY 0x2A
91#define MAX42500_REG_WDLOCK 0x2B
92#define MAX42500_REG_RSTCTRL 0x2C
93#define MAX42500_REG_CID 0x2D
94
96#define MAX42500_ADDR(x) (0x28 + (x))
97#define MAX42500_SILICON_ID (0x30)
98#define MAX42500_I2C_WR_FRAME_SIZE (4)
99#define MAX42500_I2C_RD_FRAME_SIZE (5)
100
102#define MAX42500_VNOM_MAX_VM1_VM4 3.6875
103#define MAX42500_VNOM_MAX_VM5 5.6
104#define MAX42500_MIN_VNOM 0.5
105#define MAX42500_VNOM_STEP_VM1_VM4 0.0125
106#define MAX42500_VNOM_STEP_VM5 0.02
107
109#define MAX42500_MAX_THRESH_VM1_VM5 10
110#define MAX42500_MIN_THRESH_VM1_VM5 2.5
111#define MAX42500_MAX_THRESH_VM6_V7 1.775
112#define MAX42500_MIN_THRESH_VM6_V7 0.5
113
114/* MAX42500 device state */
121
122/* MAX42500 voltage monitor input */
133
134/* MAX42500 comparator status */
141
142/* MAX42500 watchdog mode */
148
149/* MAX42500 reset hold/active timeout time. */
157
162 /* I2C */
164 /* EN0 pin GPIO */
166 /* EN1 pin GPIO */
168 /* ADDR pin GPIO */
170 /* ADDR selection */
171 uint8_t addr_sel;
172 /* Packet error checking enable */
173 uint8_t pece;
174 /* Enabled voltage monitor inputs */
175 uint8_t vmon_en;
176 /* Voltage monitor power down enable */
177 uint8_t vmon_vmpd;
178 /* Enabled voltage monitor reset mapping */
179 uint8_t reset_map;
180 /* Watchdog mode */
182 /* Watchdog clock div */
183 uint8_t wd_cdiv;
184 /* Watchdog close window */
185 uint8_t wd_close;
186 /* Watchdog open window */
187 uint8_t wd_open;
188 /* Watchdog first update window */
189 uint8_t wd_1ud;
190 /* Watchdog enable */
191 uint8_t wd_en;
192};
193
198 /* I2C */
200 /* EN0 pin GPIO */
202 /* EN1 pin GPIO */
204 /* ADDR pin GPIO */
206 /* ADDR selection */
207 uint8_t addr_sel;
208 /* Packet error checking enable */
209 uint8_t pece;
210 /* Enabled voltage monitor inputs */
211 uint8_t vmon_en;
212 /* Voltage monitor power down enable */
213 uint8_t vmon_vmpd;
214 /* Enabled voltage monitor reset mapping */
215 uint8_t reset_map;
216 /* Watchdog mode */
218 /* Watchdog clock div */
219 uint8_t wd_cdiv;
220 /* Watchdog close window */
221 uint8_t wd_close;
222 /* Watchdog open window */
223 uint8_t wd_open;
224 /* Watchdog first update window */
225 uint8_t wd_1ud;
226 /* Watchdog enable */
227 uint8_t wd_en;
228};
229
231int max42500_set_state(struct max42500_dev *desc, enum max42500_state state);
232
234int max42500_reg_read(struct max42500_dev *desc,
235 uint8_t reg_addr,
236 uint8_t *reg_data);
237
239int max42500_reg_write(struct max42500_dev *desc,
240 uint8_t reg_addr,
241 uint8_t data);
242
244int max42500_reg_update(struct max42500_dev *desc,
245 uint8_t reg_addr,
246 uint8_t mask,
247 uint8_t data);
248
251 enum max42500_vm_input vm_in,
252 float voltage);
253
256 enum max42500_vm_input vm_in,
257 enum max42500_comp_stat comp_stat,
258 uint8_t *status);
259
262 enum max42500_vm_input vm_in,
263 float thresh);
264
267 enum max42500_vm_input vm_in,
268 float thresh);
269
272 enum max42500_vm_input vm_in,
273 float thresh);
274
277 enum max42500_vm_input vm_in,
278 float thresh);
279
282 enum max42500_vm_input vm_in,
283 uint8_t *timestamp);
284
287 enum max42500_vm_input vm_in,
288 uint8_t *timestamp);
289
291int max42500_set_watchdog_enable(struct max42500_dev *desc, bool wd_enable);
292
295
298 enum max42500_wd_rhld rhld);
299
301int max42500_init(struct max42500_dev **, struct max42500_init_param *);
302
304int max42500_remove(struct max42500_dev *);
305
306#endif // __MAX42500_H__
int max42500_get_power_down_timestamp(struct max42500_dev *desc, enum max42500_vm_input vm_in, uint8_t *timestamp)
Get the power-down timestamp for a specified voltage monitor input.
Definition max42500.c:493
int max42500_set_state(struct max42500_dev *desc, enum max42500_state state)
Set device state through EN0 and EN1 pins.
Definition max42500.c:59
int max42500_set_uv_thresh2(struct max42500_dev *desc, enum max42500_vm_input vm_in, float thresh)
Set the undervoltage threshold of VM6 and VM7.
Definition max42500.c:398
max42500_state
Definition max42500.h:115
@ MAX42500_STATE_ON
Definition max42500.h:118
@ MAX42500_STATE_MAX
Definition max42500.h:119
@ MAX42500_STATE_SLEEP
Definition max42500.h:117
@ MAX42500_STATE_OFF
Definition max42500.h:116
int max42500_set_ov_thresh1(struct max42500_dev *desc, enum max42500_vm_input vm_in, float thresh)
Set the overvoltage threshold of VM1 to VM5.
Definition max42500.c:292
int max42500_set_watchdog_enable(struct max42500_dev *desc, bool wd_enable)
Enable/Disable watchdog.
Definition max42500.c:527
max42500_wd_mode
Definition max42500.h:143
@ MAX42500_WD_MODE_SIMPLE
Definition max42500.h:145
@ MAX42500_WD_MODE_CH_RESP
Definition max42500.h:144
@ MAX42500_WD_MODE_MAX
Definition max42500.h:146
int max42500_set_nominal_voltage(struct max42500_dev *desc, enum max42500_vm_input vm_in, float voltage)
Set nominal voltage for VM1 to VM5.
Definition max42500.c:205
int max42500_set_uv_thresh1(struct max42500_dev *desc, enum max42500_vm_input vm_in, float thresh)
Set the undervoltage threshold of VM1 to VM5.
Definition max42500.c:363
int max42500_remove(struct max42500_dev *)
Free the device descriptor.
Definition max42500.c:793
int max42500_init(struct max42500_dev **, struct max42500_init_param *)
Initialize the device structure.
Definition max42500.c:621
int max42500_reg_update(struct max42500_dev *desc, uint8_t reg_addr, uint8_t mask, uint8_t data)
Update a register's value based on a mask.
Definition max42500.c:178
int max42500_reg_read(struct max42500_dev *desc, uint8_t reg_addr, uint8_t *reg_data)
Read a raw value from a register.
Definition max42500.c:102
max42500_wd_rhld
Definition max42500.h:150
@ MAX42500_WD_RHOLD_16_MS
Definition max42500.h:153
@ MAX42500_WD_RHOLD_8_MS
Definition max42500.h:152
@ MAX42500_WD_RHOLD_MAX
Definition max42500.h:155
@ MAX42500_WD_RHOLD_32_MS
Definition max42500.h:154
@ MAX42500_WD_RHOLD_0_MS
Definition max42500.h:151
max42500_vm_input
Definition max42500.h:123
@ MAX42500_VM1
Definition max42500.h:124
@ MAX42500_VM_MAX
Definition max42500.h:131
@ MAX42500_VM7
Definition max42500.h:130
@ MAX42500_VM4
Definition max42500.h:127
@ MAX42500_VM3
Definition max42500.h:126
@ MAX42500_VM5
Definition max42500.h:128
@ MAX42500_VM2
Definition max42500.h:125
@ MAX42500_VM6
Definition max42500.h:129
int max42500_reg_write(struct max42500_dev *desc, uint8_t reg_addr, uint8_t data)
Write a raw value to a register.
Definition max42500.c:151
int max42500_set_watchdog_rhld(struct max42500_dev *desc, enum max42500_wd_rhld rhld)
Set watchdog reset hold time.
Definition max42500.c:606
int max42500_get_comp_status(struct max42500_dev *desc, enum max42500_vm_input vm_in, enum max42500_comp_stat comp_stat, uint8_t *status)
Get the status of the voltage monitor input.
Definition max42500.c:252
max42500_comp_stat
Definition max42500.h:135
@ MAX42500_COMP_STAT_UV
Definition max42500.h:137
@ MAX42500_COMP_STAT_MAX
Definition max42500.h:139
@ MAX42500_COMP_STAT_OFF
Definition max42500.h:136
@ MAX42500_COMP_STAT_OV
Definition max42500.h:138
int max42500_set_ov_thresh2(struct max42500_dev *desc, enum max42500_vm_input vm_in, float thresh)
Set the overvoltage threshold of VM6 and VM7.
Definition max42500.c:329
int max42500_get_power_up_timestamp(struct max42500_dev *desc, enum max42500_vm_input vm_in, uint8_t *timestamp)
Get the power-up timestamp for a specified voltage monitor input.
Definition max42500.c:456
int max42500_set_watchdog_key(struct max42500_dev *desc)
Update the watchdog key based on the mode and current value.
Definition max42500.c:577
Header file of GPIO Interface.
Header file of I2C Interface.
max42500 device descriptor
Definition max42500.h:197
uint8_t vmon_vmpd
Definition max42500.h:213
uint8_t wd_1ud
Definition max42500.h:225
uint8_t wd_en
Definition max42500.h:227
struct no_os_gpio_desc * addr
Definition max42500.h:205
uint8_t vmon_en
Definition max42500.h:211
uint8_t wd_cdiv
Definition max42500.h:219
struct no_os_gpio_desc * en1
Definition max42500.h:203
uint8_t reset_map
Definition max42500.h:215
struct no_os_gpio_desc * en0
Definition max42500.h:201
uint8_t addr_sel
Definition max42500.h:207
uint8_t wd_close
Definition max42500.h:221
struct no_os_i2c_desc * comm_desc
Definition max42500.h:199
uint8_t pece
Definition max42500.h:209
uint8_t wd_open
Definition max42500.h:223
enum max42500_wd_mode wd_mode
Definition max42500.h:217
Initialization parameter for the device descriptor.
Definition max42500.h:161
struct no_os_gpio_init_param en0_param
Definition max42500.h:165
uint8_t pece
Definition max42500.h:173
uint8_t wd_en
Definition max42500.h:191
enum max42500_wd_mode wd_mode
Definition max42500.h:181
struct no_os_gpio_init_param addr_param
Definition max42500.h:169
struct no_os_gpio_init_param en1_param
Definition max42500.h:167
uint8_t reset_map
Definition max42500.h:179
uint8_t vmon_en
Definition max42500.h:175
uint8_t wd_close
Definition max42500.h:185
uint8_t wd_open
Definition max42500.h:187
uint8_t wd_1ud
Definition max42500.h:189
struct no_os_i2c_init_param comm_param
Definition max42500.h:163
uint8_t wd_cdiv
Definition max42500.h:183
uint8_t vmon_vmpd
Definition max42500.h:177
uint8_t addr_sel
Definition max42500.h:171
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding I2C address descriptor.
Definition no_os_i2c.h:89
Structure holding the parameters for I2C initialization.
Definition no_os_i2c.h:52