Go to the documentation of this file.
40 #ifndef __MAX42500_H__
41 #define __MAX42500_H__
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
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)
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
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
306 #endif // __MAX42500_H__
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:163
@ MAX42500_VM4
Definition: max42500.h:127
uint8_t wd_open
Definition: max42500.h:223
max42500_wd_mode
Definition: max42500.h:143
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
struct no_os_gpio_init_param en1_param
Definition: max42500.h:167
uint8_t reset_map
Definition: max42500.h:179
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
@ MAX42500_WD_RHOLD_32_MS
Definition: max42500.h:154
uint8_t pece
Definition: max42500.h:209
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
int max42500_set_watchdog_key(struct max42500_dev *desc)
Update the watchdog key based on the mode and current value.
Definition: max42500.c:589
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:304
max42500_state
Definition: max42500.h:115
#define NO_OS_GENMASK(h, l)
Definition: no_os_util.h:82
#define MAX42500_REG_VINU6
Definition: max42500.h:62
int max42500_remove(struct max42500_dev *)
Free the device descriptor.
Definition: max42500.c:805
#define MAX42500_I2C_WR_FRAME_SIZE
Definition: max42500.h:98
@ MAX42500_COMP_STAT_OFF
Definition: max42500.h:136
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
uint8_t addr_sel
Definition: max42500.h:207
@ MAX42500_WD_MODE_SIMPLE
Definition: max42500.h:145
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:217
uint8_t vmon_en
Definition: max42500.h:175
@ MAX42500_VM_MAX
Definition: max42500.h:131
#define MAX42500_MIN_THRESH_VM1_VM5
Definition: max42500.h:110
uint8_t wd_cdiv
Definition: max42500.h:219
#define MAX42500_REG_VINO6
Definition: max42500.h:61
#define MAX42500_I2C_RD_FRAME_SIZE
Definition: max42500.h:99
max42500_wd_rhld
Definition: max42500.h:150
uint8_t wd_close
Definition: max42500.h:221
int max42500_set_state(struct max42500_dev *desc, enum max42500_state state)
Set device state through EN0 and EN1 pins.
Definition: max42500.c:71
max42500_vm_input
Definition: max42500.h:123
int max42500_set_watchdog_rhld(struct max42500_dev *desc, enum max42500_wd_rhld rhld)
Set watchdog reset hold time.
Definition: max42500.c:618
#define MAX42500_SILICON_ID
Definition: max42500.h:97
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:114
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
struct no_os_i2c_desc * comm_desc
Definition: max42500.h:199
#define MAX42500_REG_VMON
Definition: max42500.h:51
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:505
#define MAX42500_REG_WDKEY
Definition: max42500.h:90
enum max42500_wd_mode wd_mode
Definition: max42500.h:181
@ MAX42500_VM6
Definition: max42500.h:129
struct no_os_gpio_init_param en0_param
Definition: max42500.h:165
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
uint8_t pece
Definition: max42500.h:173
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:190
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:304
@ MAX42500_VM7
Definition: max42500.h:130
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:264
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
#define MAX42500_REG_STATOFF
Definition: max42500.h:55
@ MAX42500_COMP_STAT_MAX
Definition: max42500.h:139
uint8_t wd_close
Definition: max42500.h:185
uint8_t slave_address
Definition: no_os_i2c.h:109
uint8_t vmon_vmpd
Definition: max42500.h:213
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
uint8_t addr_sel
Definition: max42500.h:171
uint8_t vmon_en
Definition: max42500.h:211
@ MAX42500_VM3
Definition: max42500.h:126
Initialization parameter for the device descriptor.
Definition: max42500.h:161
uint8_t wd_open
Definition: max42500.h:187
int max42500_set_watchdog_enable(struct max42500_dev *desc, bool wd_enable)
Enable/Disable watchdog.
Definition: max42500.c:539
@ MAX42500_COMP_STAT_UV
Definition: max42500.h:137
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:341
void no_os_crc8_populate_msb(uint8_t *table, const uint8_t polynomial)
#define MAX42500_REG_WDCDIV
Definition: max42500.h:87
int max42500_remove(struct max42500_dev *desc)
Free the device descriptor.
Definition: max42500.c:805
int max42500_set_watchdog_rhld(struct max42500_dev *desc, enum max42500_wd_rhld rhld)
Set watchdog reset hold time.
Definition: max42500.c:618
@ MAX42500_VM2
Definition: max42500.h:125
#define MAX42500_VNOM_MAX_VM1_VM4
Definition: max42500.h:102
#define MAX42500_REG_STATOV
Definition: max42500.h:53
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:505
uint8_t reset_map
Definition: max42500.h:215
@ MAX42500_STATE_OFF
Definition: max42500.h:116
struct no_os_gpio_init_param addr_param
Definition: max42500.h:169
#define MAX42500_REG_DTIME1
Definition: max42500.h:79
uint8_t vmon_vmpd
Definition: max42500.h:177
@ MAX42500_VM1
Definition: max42500.h:124
@ MAX42500_WD_RHOLD_8_MS
Definition: max42500.h:152
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
#define MAX42500_MIN_VNOM
Definition: max42500.h:104
#define MAX42500_REG_UTIME1
Definition: max42500.h:72
#define MAX42500_REG_VIN1
Definition: max42500.h:56
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
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:375
struct no_os_i2c_init_param comm_param
Definition: max42500.h:163
#define MAX42500_MIN_THRESH_VM6_V7
Definition: max42500.h:112
uint8_t wd_1ud
Definition: max42500.h:189
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
Header file of I2C Interface.
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:468
@ MAX42500_WD_MODE_CH_RESP
Definition: max42500.h:144
#define MAX42500_REG_STATUV
Definition: max42500.h:54
#define MAX42500_REG_VINO7
Definition: max42500.h:63
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:410
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
#define MAX42500_REG_VIN5
Definition: max42500.h:60
#define MAX42500_VNOM_STEP_VM1_VM4
Definition: max42500.h:105
#define MAX42500_VNOM_MAX_VM5
Definition: max42500.h:103
#define NO_OS_BIT(x)
Definition: no_os_util.h:45
uint8_t no_os_crc8(const uint8_t *table, const uint8_t *pdata, size_t nbytes, uint8_t crc)
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
@ MAX42500_WD_RHOLD_16_MS
Definition: max42500.h:153
#define MAX42500_REG_ID
Definition: max42500.h:48
@ MAX42500_WD_MODE_MAX
Definition: max42500.h:146
Header file of MAX42500 Driver.
#define MAX42500_REG_CONFIG1
Definition: max42500.h:49
max42500_comp_stat
Definition: max42500.h:135
@ MAX42500_STATE_MAX
Definition: max42500.h:119
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
int max42500_init(struct max42500_dev **, struct max42500_init_param *)
Initialize the device structure.
Definition: max42500.c:633
#define MAX42500_VNOM_STEP_VM5
Definition: max42500.h:106
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
#define MAX42500_REG_RSTCTRL
Definition: max42500.h:92
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
#define MAX42500_MAX_THRESH_VM6_V7
Definition: max42500.h:111
uint8_t wd_en
Definition: max42500.h:227
uint8_t wd_en
Definition: max42500.h:191
@ MAX42500_VM5
Definition: max42500.h:128
#define MAX42500_REG_FPSCFG1
Definition: max42500.h:71
@ MAX42500_STATE_ON
Definition: max42500.h:118
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:163
#define MAX42500_REG_VINU7
Definition: max42500.h:64
@ MAX42500_STATE_SLEEP
Definition: max42500.h:117
int max42500_set_state(struct max42500_dev *desc, enum max42500_state state)
Set device state through EN0 and EN1 pins.
Definition: max42500.c:71
int max42500_set_watchdog_enable(struct max42500_dev *desc, bool wd_enable)
Enable/Disable watchdog.
Definition: max42500.c:539
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:375
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:341
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:114
struct no_os_gpio_desc * en1
Definition: max42500.h:203
NO_OS_DECLARE_CRC8_TABLE(max42500_crc8)
Header file of GPIO Interface.
int max42500_set_watchdog_key(struct max42500_dev *desc)
Update the watchdog key based on the mode and current value.
Definition: max42500.c:589
#define MAX42500_REG_RSTMAP
Definition: max42500.h:52
#define CRC8_PEC
Definition: max42500.c:53
struct no_os_gpio_desc * addr
Definition: max42500.h:205
#define MAX42500_REG_WDCFG1
Definition: max42500.h:88
uint8_t wd_1ud
Definition: max42500.h:225
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:190
max42500 device descriptor
Definition: max42500.h:197
@ MAX42500_WD_RHOLD_MAX
Definition: max42500.h:155
Header file of utility functions.
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:468
#define MAX42500_REG_WDCFG2
Definition: max42500.h:89
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:410
enum max42500_wd_mode wd_mode
Definition: max42500.h:217
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:264
struct no_os_gpio_desc * en0
Definition: max42500.h:201
#define MAX42500_REG_OVUV1
Definition: max42500.h:65
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
int max42500_init(struct max42500_dev **desc, struct max42500_init_param *init_param)
Initialize the device structure.
Definition: max42500.c:633
#define MAX42500_MAX_THRESH_VM1_VM5
Definition: max42500.h:109
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:217
@ MAX42500_WD_RHOLD_0_MS
Definition: max42500.h:151
Header file of CRC-8 computation.
@ MAX42500_COMP_STAT_OV
Definition: max42500.h:138
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54
uint8_t wd_cdiv
Definition: max42500.h:183