no-OS
Macros | Functions
max42500.c File Reference

Source file of MAX42500 Driver. More...

#include "max42500.h"
#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
#include "no_os_crc8.h"
Include dependency graph for max42500.c:

Macros

#define CRC8_PEC   0x07 /* Implements Polynomial X^8 + X^2 + X^1 +1 */
 

Functions

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

Detailed Description

Source 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.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Macro Definition Documentation

◆ CRC8_PEC

#define CRC8_PEC   0x07 /* Implements Polynomial X^8 + X^2 + X^1 +1 */

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.

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.
Here is the caller graph for this function:

◆ 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.

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.

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.

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.
Here is the caller graph for this function:

◆ 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.

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.
Here is the caller graph for this function:

◆ 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.

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.
Here is the caller graph for this function:

◆ 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.

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.
Here is the caller graph for this function:

◆ max42500_remove()

int max42500_remove ( struct max42500_dev desc)

Free the device descriptor.

Parameters
desc- The device structure.
Returns
0 in case of success, -EINVAL otherwise.
Here is the caller graph for this function:

◆ 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.

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.
Here is the caller graph for this function:

◆ 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.

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.
Here is the caller graph for this function:

◆ 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.

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.

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.

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.
Here is the caller graph for this function:

◆ 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.

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.

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.

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.

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

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( max42500_crc8  )