no-OS
Loading...
Searching...
No Matches
max42500.h File Reference

Header file of MAX42500 Driver. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_i2c.h"
#include "no_os_gpio.h"
Include dependency graph for max42500.h:

Classes

struct  max42500_init_param
 Initialization parameter for the device descriptor. More...
 
struct  max42500_dev
 max42500 device descriptor More...
 

Macros

#define MAX42500_REG_ID   0x00
 
#define MAX42500_REG_CONFIG1   0x01
 
#define MAX42500_REG_CONFIG2   0x02
 
#define MAX42500_REG_VMON   0x03
 
#define MAX42500_REG_RSTMAP   0x04
 
#define MAX42500_REG_STATOV   0x05
 
#define MAX42500_REG_STATUV   0x06
 
#define MAX42500_REG_STATOFF   0x07
 
#define MAX42500_REG_VIN1   0x08
 
#define MAX42500_REG_VIN2   0x09
 
#define MAX42500_REG_VIN3   0x0A
 
#define MAX42500_REG_VIN4   0x0B
 
#define MAX42500_REG_VIN5   0x0C
 
#define MAX42500_REG_VINO6   0x0D
 
#define MAX42500_REG_VINU6   0x0E
 
#define MAX42500_REG_VINO7   0x0F
 
#define MAX42500_REG_VINU7   0x10
 
#define MAX42500_REG_OVUV1   0x11
 
#define MAX42500_REG_OVUV2   0x12
 
#define MAX42500_REG_OVUV3   0x13
 
#define MAX42500_REG_OVUV4   0x14
 
#define MAX42500_REG_OVUV5   0x15
 
#define MAX42500_REG_FPSSTAT1   0x16
 
#define MAX42500_REG_FPSCFG1   0x17
 
#define MAX42500_REG_UTIME1   0x18
 
#define MAX42500_REG_UTIME2   0x19
 
#define MAX42500_REG_UTIME3   0x1A
 
#define MAX42500_REG_UTIME4   0x1B
 
#define MAX42500_REG_UTIME5   0x1C
 
#define MAX42500_REG_UTIME6   0x1D
 
#define MAX42500_REG_UTIME7   0x1E
 
#define MAX42500_REG_DTIME1   0x1F
 
#define MAX42500_REG_DTIME2   0x20
 
#define MAX42500_REG_DTIME3   0x21
 
#define MAX42500_REG_DTIME4   0x22
 
#define MAX42500_REG_DTIME5   0x23
 
#define MAX42500_REG_DTIME6   0x24
 
#define MAX42500_REG_DTIME7   0x25
 
#define MAX42500_REG_WDSTAT   0x26
 
#define MAX42500_REG_WDCDIV   0x27
 
#define MAX42500_REG_WDCFG1   0x28
 
#define MAX42500_REG_WDCFG2   0x29
 
#define MAX42500_REG_WDKEY   0x2A
 
#define MAX42500_REG_WDLOCK   0x2B
 
#define MAX42500_REG_RSTCTRL   0x2C
 
#define MAX42500_REG_CID   0x2D
 
#define MAX42500_ADDR(x)
 
#define MAX42500_SILICON_ID   (0x30)
 
#define MAX42500_I2C_WR_FRAME_SIZE   (4)
 
#define MAX42500_I2C_RD_FRAME_SIZE   (5)
 
#define MAX42500_VNOM_MAX_VM1_VM4   3.6875
 
#define MAX42500_VNOM_MAX_VM5   5.6
 
#define MAX42500_MIN_VNOM   0.5
 
#define MAX42500_VNOM_STEP_VM1_VM4   0.0125
 
#define MAX42500_VNOM_STEP_VM5   0.02
 
#define MAX42500_MAX_THRESH_VM1_VM5   10
 
#define MAX42500_MIN_THRESH_VM1_VM5   2.5
 
#define MAX42500_MAX_THRESH_VM6_V7   1.775
 
#define MAX42500_MIN_THRESH_VM6_V7   0.5
 

Enumerations

enum  max42500_state {
  MAX42500_STATE_OFF ,
  MAX42500_STATE_SLEEP ,
  MAX42500_STATE_ON ,
  MAX42500_STATE_MAX
}
 
enum  max42500_vm_input {
  MAX42500_VM1 ,
  MAX42500_VM2 ,
  MAX42500_VM3 ,
  MAX42500_VM4 ,
  MAX42500_VM5 ,
  MAX42500_VM6 ,
  MAX42500_VM7 ,
  MAX42500_VM_MAX
}
 
enum  max42500_comp_stat {
  MAX42500_COMP_STAT_OFF ,
  MAX42500_COMP_STAT_UV ,
  MAX42500_COMP_STAT_OV ,
  MAX42500_COMP_STAT_MAX
}
 
enum  max42500_wd_mode {
  MAX42500_WD_MODE_CH_RESP ,
  MAX42500_WD_MODE_SIMPLE ,
  MAX42500_WD_MODE_MAX
}
 
enum  max42500_wd_rhld {
  MAX42500_WD_RHOLD_0_MS ,
  MAX42500_WD_RHOLD_8_MS ,
  MAX42500_WD_RHOLD_16_MS ,
  MAX42500_WD_RHOLD_32_MS ,
  MAX42500_WD_RHOLD_MAX
}
 

Functions

int max42500_set_state (struct max42500_dev *desc, enum max42500_state state)
 Set device state through EN0 and EN1 pins.
 
int max42500_reg_read (struct max42500_dev *desc, uint8_t reg_addr, uint8_t *reg_data)
 Read a raw value from a register.
 
int max42500_reg_write (struct max42500_dev *desc, uint8_t reg_addr, uint8_t data)
 Write a raw value to a register.
 
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.
 
int max42500_set_nominal_voltage (struct max42500_dev *desc, enum max42500_vm_input vm_in, float voltage)
 Set nominal voltage for VM1 to VM5.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
int max42500_set_watchdog_enable (struct max42500_dev *desc, bool wd_enable)
 Enable/Disable watchdog.
 
int max42500_set_watchdog_key (struct max42500_dev *desc)
 Update the watchdog key based on the mode and current value.
 
int max42500_set_watchdog_rhld (struct max42500_dev *desc, enum max42500_wd_rhld rhld)
 Set watchdog reset hold time.
 
int max42500_init (struct max42500_dev **, struct max42500_init_param *)
 Initialize the device structure.
 
int max42500_remove (struct max42500_dev *)
 Free the device descriptor.
 

Detailed Description

Header file of MAX42500 Driver.

Author
Mark Sapungan (Mark..nosp@m.Sapu.nosp@m.ngan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)
Joshua Maniti (Joshu.nosp@m.a.Ma.nosp@m.niti@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2024(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ MAX42500_ADDR

#define MAX42500_ADDR ( x)
Value:
(0x28 + (x))

X is set based on the pull configuration of the ADDR pin

◆ MAX42500_I2C_RD_FRAME_SIZE

#define MAX42500_I2C_RD_FRAME_SIZE   (5)

◆ MAX42500_I2C_WR_FRAME_SIZE

#define MAX42500_I2C_WR_FRAME_SIZE   (4)

◆ MAX42500_MAX_THRESH_VM1_VM5

#define MAX42500_MAX_THRESH_VM1_VM5   10

MAX42500 Undervoltage/Overvoltage maximum and minimum thresholds

◆ MAX42500_MAX_THRESH_VM6_V7

#define MAX42500_MAX_THRESH_VM6_V7   1.775

◆ MAX42500_MIN_THRESH_VM1_VM5

#define MAX42500_MIN_THRESH_VM1_VM5   2.5

◆ MAX42500_MIN_THRESH_VM6_V7

#define MAX42500_MIN_THRESH_VM6_V7   0.5

◆ MAX42500_MIN_VNOM

#define MAX42500_MIN_VNOM   0.5

◆ MAX42500_REG_CID

#define MAX42500_REG_CID   0x2D

◆ MAX42500_REG_CONFIG1

#define MAX42500_REG_CONFIG1   0x01

◆ MAX42500_REG_CONFIG2

#define MAX42500_REG_CONFIG2   0x02

◆ MAX42500_REG_DTIME1

#define MAX42500_REG_DTIME1   0x1F

◆ MAX42500_REG_DTIME2

#define MAX42500_REG_DTIME2   0x20

◆ MAX42500_REG_DTIME3

#define MAX42500_REG_DTIME3   0x21

◆ MAX42500_REG_DTIME4

#define MAX42500_REG_DTIME4   0x22

◆ MAX42500_REG_DTIME5

#define MAX42500_REG_DTIME5   0x23

◆ MAX42500_REG_DTIME6

#define MAX42500_REG_DTIME6   0x24

◆ MAX42500_REG_DTIME7

#define MAX42500_REG_DTIME7   0x25

◆ MAX42500_REG_FPSCFG1

#define MAX42500_REG_FPSCFG1   0x17

◆ MAX42500_REG_FPSSTAT1

#define MAX42500_REG_FPSSTAT1   0x16

◆ MAX42500_REG_ID

#define MAX42500_REG_ID   0x00

◆ MAX42500_REG_OVUV1

#define MAX42500_REG_OVUV1   0x11

◆ MAX42500_REG_OVUV2

#define MAX42500_REG_OVUV2   0x12

◆ MAX42500_REG_OVUV3

#define MAX42500_REG_OVUV3   0x13

◆ MAX42500_REG_OVUV4

#define MAX42500_REG_OVUV4   0x14

◆ MAX42500_REG_OVUV5

#define MAX42500_REG_OVUV5   0x15

◆ MAX42500_REG_RSTCTRL

#define MAX42500_REG_RSTCTRL   0x2C

◆ MAX42500_REG_RSTMAP

#define MAX42500_REG_RSTMAP   0x04

◆ MAX42500_REG_STATOFF

#define MAX42500_REG_STATOFF   0x07

◆ MAX42500_REG_STATOV

#define MAX42500_REG_STATOV   0x05

◆ MAX42500_REG_STATUV

#define MAX42500_REG_STATUV   0x06

◆ MAX42500_REG_UTIME1

#define MAX42500_REG_UTIME1   0x18

◆ MAX42500_REG_UTIME2

#define MAX42500_REG_UTIME2   0x19

◆ MAX42500_REG_UTIME3

#define MAX42500_REG_UTIME3   0x1A

◆ MAX42500_REG_UTIME4

#define MAX42500_REG_UTIME4   0x1B

◆ MAX42500_REG_UTIME5

#define MAX42500_REG_UTIME5   0x1C

◆ MAX42500_REG_UTIME6

#define MAX42500_REG_UTIME6   0x1D

◆ MAX42500_REG_UTIME7

#define MAX42500_REG_UTIME7   0x1E

◆ MAX42500_REG_VIN1

#define MAX42500_REG_VIN1   0x08

◆ MAX42500_REG_VIN2

#define MAX42500_REG_VIN2   0x09

◆ MAX42500_REG_VIN3

#define MAX42500_REG_VIN3   0x0A

◆ MAX42500_REG_VIN4

#define MAX42500_REG_VIN4   0x0B

◆ MAX42500_REG_VIN5

#define MAX42500_REG_VIN5   0x0C

◆ MAX42500_REG_VINO6

#define MAX42500_REG_VINO6   0x0D

◆ MAX42500_REG_VINO7

#define MAX42500_REG_VINO7   0x0F

◆ MAX42500_REG_VINU6

#define MAX42500_REG_VINU6   0x0E

◆ MAX42500_REG_VINU7

#define MAX42500_REG_VINU7   0x10

◆ MAX42500_REG_VMON

#define MAX42500_REG_VMON   0x03

◆ MAX42500_REG_WDCDIV

#define MAX42500_REG_WDCDIV   0x27

◆ MAX42500_REG_WDCFG1

#define MAX42500_REG_WDCFG1   0x28

◆ MAX42500_REG_WDCFG2

#define MAX42500_REG_WDCFG2   0x29

◆ MAX42500_REG_WDKEY

#define MAX42500_REG_WDKEY   0x2A

◆ MAX42500_REG_WDLOCK

#define MAX42500_REG_WDLOCK   0x2B

◆ MAX42500_REG_WDSTAT

#define MAX42500_REG_WDSTAT   0x26

◆ MAX42500_SILICON_ID

#define MAX42500_SILICON_ID   (0x30)

◆ MAX42500_VNOM_MAX_VM1_VM4

#define MAX42500_VNOM_MAX_VM1_VM4   3.6875

MAX42500 Nominal voltage computation

◆ MAX42500_VNOM_MAX_VM5

#define MAX42500_VNOM_MAX_VM5   5.6

◆ MAX42500_VNOM_STEP_VM1_VM4

#define MAX42500_VNOM_STEP_VM1_VM4   0.0125

◆ MAX42500_VNOM_STEP_VM5

#define MAX42500_VNOM_STEP_VM5   0.02

Enumeration Type Documentation

◆ max42500_comp_stat

Enumerator
MAX42500_COMP_STAT_OFF 
MAX42500_COMP_STAT_UV 
MAX42500_COMP_STAT_OV 
MAX42500_COMP_STAT_MAX 

◆ max42500_state

Enumerator
MAX42500_STATE_OFF 
MAX42500_STATE_SLEEP 
MAX42500_STATE_ON 
MAX42500_STATE_MAX 

◆ max42500_vm_input

Enumerator
MAX42500_VM1 
MAX42500_VM2 
MAX42500_VM3 
MAX42500_VM4 
MAX42500_VM5 
MAX42500_VM6 
MAX42500_VM7 
MAX42500_VM_MAX 

◆ max42500_wd_mode

Enumerator
MAX42500_WD_MODE_CH_RESP 
MAX42500_WD_MODE_SIMPLE 
MAX42500_WD_MODE_MAX 

◆ max42500_wd_rhld

Enumerator
MAX42500_WD_RHOLD_0_MS 
MAX42500_WD_RHOLD_8_MS 
MAX42500_WD_RHOLD_16_MS 
MAX42500_WD_RHOLD_32_MS 
MAX42500_WD_RHOLD_MAX 

Function Documentation

◆ max42500_get_comp_status()

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.

Get the status of the voltage monitor input

Parameters
desc- The device structure.
vm_in- The voltage monitor input.
comp_stat- Status to read. Example: MAX42500_COMP_STAT_OFF - Comparator off status MAX42500_COMP_STAT_UV - Undervoltage status MAX42500_COMP_STAT_OV - Overvoltage status
status- Pointer to store the status. Example: 0 - below OV threshold; above UV, OFF threshold 1 - above OV threshold; below UV, OFF threshold
Returns
0 in case of success, negative error code otherwise.

◆ max42500_get_power_down_timestamp()

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.

Get the power-down timestamp for a specified voltage monitor input

Parameters
desc- The device structure.
vm_in- The voltage monitor input for which to get the timestamp.
timestamp- The timestamp in microseconds. If the input voltage never rose above the UV threshold, the timestamp will be set to 0.
Returns
0 in case of success, negative error code otherwise.

◆ max42500_get_power_up_timestamp()

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.

Get the power-up timestamp for a specified voltage monitor input

Parameters
desc- The device structure.
vm_in- The voltage monitor input for which to get the timestamp.
timestamp- The timestamp in microseconds. If the input voltage never rose above the UV threshold, the timestamp will be set to 0.
Returns
0 in case of success, negative error code otherwise.

◆ max42500_init()

int max42500_init ( struct max42500_dev ** desc,
struct max42500_init_param * init_param )

Initialize the device structure.

Initialize the device structure

Parameters
desc- The device structure to be initialized.
init_param- Initialization parameter for the device descriptor.
Returns
0 in case of success, negative error code otherwise.

◆ max42500_reg_read()

int max42500_reg_read ( struct max42500_dev * desc,
uint8_t reg_addr,
uint8_t * reg_data )

Read a raw value from a register.

Read a register value

Parameters
desc- The device structure.
reg_addr- Address of the register to be written.
reg_data- Pointer to store the read data.
Returns
0 in case of success, error code otherwise.

◆ max42500_reg_update()

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.

Update a register's value based on a mask

Parameters
desc- The device structure.
reg_addr- Address of the register to be written.
mask- The bits that may be modified.
data- Data to write to register
Returns
0 in case of success, negative error code otherwise.

◆ max42500_reg_write()

int max42500_reg_write ( struct max42500_dev * desc,
uint8_t reg_addr,
uint8_t data )

Write a raw value to a register.

Write a register value

Parameters
desc- The device structure.
reg_addr- Address of the register to be written.
data- Data to write to register.
Returns
0 in case of success, negative error code otherwise.

◆ max42500_remove()

int max42500_remove ( struct max42500_dev * desc)

Free the device descriptor.

Free the device descriptor

Parameters
desc- The device structure.
Returns
0 in case of success, -EINVAL otherwise.

◆ max42500_set_nominal_voltage()

int max42500_set_nominal_voltage ( struct max42500_dev * desc,
enum max42500_vm_input vm_in,
float voltage )

Set nominal voltage for VM1 to VM5.

Set nominal voltage for VM1 to VM5

Parameters
desc- The device structure.
vm_in- The voltage monitor input.
voltage- Nominal voltage to set in volts. Example: 0.5 to 3.6875 for VM1 to VM4 0.5 to 5.6 for VM5
Returns
0 in case of success, negative error code otherwise.

◆ max42500_set_ov_thresh1()

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.

Set the overvoltage threshold of VM1 to VM5

Parameters
desc- The device structure.
vm_in- The voltage monitor input.
thresh- The overvoltage threshold in percentage (2.5% to 10%).
Returns
0 in case of success, negative error code otherwise.

◆ max42500_set_ov_thresh2()

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.

Set the overvoltage threshold of VM6 and VM7

Parameters
desc- The device structure.
vm_in- The voltage monitor input.
thresh- The overvoltage threshold in volts (0.5V to 1.775V).
Returns
0 in case of success, negative error code otherwise.

◆ max42500_set_state()

int max42500_set_state ( struct max42500_dev * desc,
enum max42500_state state )

Set device state through EN0 and EN1 pins.

Set device state through EN0 and EN1 pins

Parameters
desc- The device structure.
state- Device state.
Returns
0 in case of success, error code otherwise.

◆ max42500_set_uv_thresh1()

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.

Set the undervoltage threshold of VM1 to VM5

Parameters
desc- The device structure.
vm_in- The voltage monitor input.
thresh- The undervoltage threshold in percentage (2.5% to 10%).
Returns
0 in case of success, negative error code otherwise.

◆ max42500_set_uv_thresh2()

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.

Set the undervoltage threshold of VM6 and VM7

Parameters
desc- The device structure.
vm_in- The voltage monitor input.
thresh- The overvoltage threshold in volts (0.5V to 1.775V).
Returns
0 in case of success, negative error code otherwise.

◆ max42500_set_watchdog_enable()

int max42500_set_watchdog_enable ( struct max42500_dev * desc,
bool wd_enable )

Enable/Disable watchdog.

Enable/Disable watchdog

Parameters
desc- The device structure.
wd_enable- Enable/disable MAX42500 watchdog.
Returns
0 in case of success, error code otherwise

◆ max42500_set_watchdog_key()

int max42500_set_watchdog_key ( struct max42500_dev * desc)

Update the watchdog key based on the mode and current value.

Update the watchdog key based on the mode and current value

Parameters
desc- The device structure.
Returns
0 in case of success, error code otherwise.

◆ max42500_set_watchdog_rhld()

int max42500_set_watchdog_rhld ( struct max42500_dev * desc,
enum max42500_wd_rhld rhld )

Set watchdog reset hold time.

Set watchdog reset hold time

Parameters
desc- The device structure.
rhld- Reset hold time to set.
Returns
0 in case of success, error code otherwise