no-OS
Classes | Macros | Enumerations | Functions
max14001.h File Reference

Implementation of max14001.h. More...

#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_util.h"
Include dependency graph for max14001.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  max14001_dev
 
struct  max14001_init_param
 

Macros

#define MAX14001_REG_READ(x)   (((x) << 11) & NO_OS_GENMASK(15, 11))
 
#define MAX14001_REG_WRITE(x, y)
 
#define MAX14001_REG_DATA_MASK   NO_OS_GENMASK(9, 0)
 
#define VERIFICATION_REG(x)   ((x) + 0x10)
 
#define MAX14001_SPI_REG_WRITE_ENABLE   0x294
 
#define MAX14001_SPI_REG_WRITE_DISABLE   0x000
 
#define MAX14001_ADC_REG   0x00
 
#define MAX14001_FADC_REG   0x01
 
#define MAX14001_FLAGS_REG   0x02
 
#define MAX14001_FLTEN_REG   0x03
 
#define MAX14001_THL_REG   0x04
 
#define MAX14001_THU_REG   0x05
 
#define MAX14001_INRR_REG   0x06
 
#define MAX14001_INRT_REG   0x07
 
#define MAX14001_INRP_REG   0x08
 
#define MAX14001_CFG_REG   0x09
 
#define MAX14001_ENBL_REG   0x0A
 
#define MAX14001_ACT_REG   0x0B
 
#define MAX14001_WEN_REG   0x0C
 
#define MAX14001_FLTV_REG   0x13
 
#define MAX14001_THLV_REG   0x14
 
#define MAX14001_THUV_REG   0x15
 
#define MAX14001_INRRV_REG   0x16
 
#define MAX14001_INRTV_REG   0x17
 
#define MAX14001_INRPV_REG   0x18
 
#define MAX14001_CFGV_REG   0x19
 
#define MAX14001_ENBLV_REG   0x1A
 
#define MAX14001_RSET_MASK   NO_OS_BIT(7)
 
#define MAX14001_SRES_MASK   NO_OS_BIT(6)
 
#define MAX14001_INPLS_MASK   NO_OS_BIT(9)
 
#define MAX14001_ADC_FLAG_MASK   NO_OS_BIT(1)
 
#define MAX14001_INRD_FLAG_MASK   NO_OS_BIT(2)
 
#define MAX14001_SPI_FLAG_MASK   NO_OS_BIT(3)
 
#define MAX14001_COM_FLAG_MASK   NO_OS_BIT(4)
 
#define MAX14001_CRCL_FLAG_MASK   NO_OS_BIT(5)
 
#define MAX14001_CRCF_FLAG_MASK   NO_OS_BIT(6)
 
#define MAX14001_FET_FLAG_MASK   NO_OS_BIT(7)
 
#define MAX14001_MV_FLAG_MASK   NO_OS_BIT(8)
 
#define MAX14001_DYEN_FLTEN_MASK   NO_OS_BIT(0)
 
#define MAX14001_EADC_FLTEN_MASK   NO_OS_BIT(1)
 
#define MAX14001_EINRD_FLTEN_MASK   NO_OS_BIT(2)
 
#define MAX14001_ESPI_FLTEN_MASK   NO_OS_BIT(3)
 
#define MAX14001_ECOM_FLTEN_MASK   NO_OS_BIT(4)
 
#define MAX14001_ECRCL_FLTEN_MASK   NO_OS_BIT(5)
 
#define MAX14001_ECRCF_FLTEN_MASK   NO_OS_BIT(6)
 
#define MAX14001_EFET_FLTEN_MASK   NO_OS_BIT(7)
 
#define MAX14001_EMV_FLTEN_MASK   NO_OS_BIT(8)
 
#define MAX14001_IINR_INRP_MASK   NO_OS_GENMASK(9, 6)
 
#define MAX14001_IINR_INRP_MODE(a)   ((MAX14001_IINR(a)) << 6)
 
#define MAX14001_TINR_INRP_MASK   NO_OS_GENMASK(5, 2)
 
#define MAX14001_TINR_INRP_MODE(a)   ((MAX14001_TINR(a)) << 2)
 
#define MAX14001_DU_INRP_MASK   NO_OS_GENMASK(1, 0)
 
#define MAX14001_DU_INRP_MODE(a)   (((a) & 0x3) << 0)
 
#define MAX14001_IBIAS_CFG_MASK   NO_OS_GENMASK(9, 6)
 
#define MAX14001_IBIAS_CFG_MODE(a)   ((MAX14001_IBIAS(a)) << 6)
 
#define MAX14001_EXRF_CFG_MASK   NO_OS_BIT(5)
 
#define MAX14001_EXTI_CFG_MASK   NO_OS_BIT(4)
 
#define MAX14001_FT_CFG_MASK   NO_OS_GENMASK(3, 2)
 
#define MAX14001_FT_CFG_MODE(a)   (((a) & 0x3) << 2)
 
#define MAX14001_FAST_CFG_MASK   NO_OS_BIT(1)
 
#define MAX14001_IRAW_CFG_MASK   NO_OS_BIT(0)
 
#define MAX14001_ENA_ENBL_MASK   NO_OS_BIT(4)
 
#define REVERSE_UINT16(x)
 
#define MAX14001_CFG_MIN   0
 
#define MAX14001_CFG_MAX   0xF
 
#define MAX14001_CFG_Q(x, y)
 
#define MAX14001_TINR_INC   8
 
#define MAX14001_TINR(x)   MAX14001_CFG_Q(x, MAX14001_TINR_INC)
 
#define MAX14001_IINR_INC   7
 
#define MAX14001_IINR(x)   MAX14001_CFG_Q(x, MAX14001_IINR_INC)
 
#define MAX14001_MUL   100
 
#define MAX14001_IBIAS_INC   25
 
#define MAX14001_IBIAS(x)
 

Enumerations

enum  max14001_du {
  DUTY_OFF,
  DUTY_1P6,
  DUTY_3P1,
  DUTY_6P3
}
 MAX14001 list of possible duty cycle modes. More...
 
enum  max14001_ft {
  FILTER_OFF,
  AVERAGE_2_READINGS,
  AVERAGE_4_READINGS,
  AVERAGE_8_READINGS
}
 MAX14001 list of possible filtering modes. More...
 

Functions

int max14001_read (struct max14001_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 Read from device. More...
 
int max14001_write (struct max14001_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 Write to device. More...
 
int max14001_reg_update (struct max14001_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
 SPI write to device using a mask. More...
 
int max14001_write_config_verify (struct max14001_dev *dev, uint8_t reg_addr, uint16_t mask, uint16_t data)
 Write to config registers then to corresponding verification register. More...
 
int max14001_init (struct max14001_dev **device, struct max14001_init_param init_param)
 Initialize the device. More...
 
int max14001_init_config (struct max14001_dev *dev)
 Initialize the configurations of device. More...
 
int max14001_wen (struct max14001_dev *dev, bool write_enable)
 Enable write to registers. More...
 
int max14001_full_reset (struct max14001_dev *dev)
 Full reset, same effect as power on reset. More...
 
int max14001_reg_reset (struct max14001_dev *dev)
 Software reset. Restores all registers to their POR value. More...
 
int max14001_inpls_reset (struct max14001_dev *dev)
 Trigger an inrush current pulse. More...
 
int max14001_fast_config (struct max14001_dev *dev, bool fast)
 Enable/Disable fast inrush mode. More...
 
int max14001_iraw_config (struct max14001_dev *dev, bool raw_data)
 Selects Inrush comparator input multiplexer. More...
 
int max14001_emv_config (struct max14001_dev *dev, bool mode)
 Enable MV fault. More...
 
int max14001_efet_config (struct max14001_dev *dev, bool mode)
 Enable FET fault. More...
 
int max14001_ecrcf_config (struct max14001_dev *dev, bool mode)
 Enable CRCF fault. More...
 
int max14001_ecrcl_config (struct max14001_dev *dev, bool mode)
 Enable CRCL fault. More...
 
int max14001_ecom_config (struct max14001_dev *dev, bool mode)
 Enable COM fault. More...
 
int max14001_espi_config (struct max14001_dev *dev, bool mode)
 Enable SPI fault. More...
 
int max14001_einrd_config (struct max14001_dev *dev, bool mode)
 Enable INRD fault. More...
 
int max14001_eadc_config (struct max14001_dev *dev, bool mode)
 Enable ADC fault. More...
 
int max14001_dyen_config (struct max14001_dev *dev, bool mode)
 Enable dynamic FAULT signal. More...
 
int max14001_ena_config (struct max14001_dev *dev, bool enable)
 Enable/Disable field-side current sink. More...
 
int max14001_exrf_config (struct max14001_dev *dev, bool mode)
 Selects the voltage reference source for the ADC. More...
 
int max14001_exti_config (struct max14001_dev *dev, bool mode)
 Current source connection. More...
 
int max14001_tinr_config (struct max14001_dev *dev, int mode)
 Configure 4-bit inrush time. More...
 
int max14001_iinr_config (struct max14001_dev *dev, int mode)
 Configure 4-bit inrush current. More...
 
int max14001_du_config (struct max14001_dev *dev, enum max14001_du mode)
 Set maximum duty cycle for inrush current over the last 10 seconds. More...
 
int max14001_ibias_config (struct max14001_dev *dev, float mode)
 Configure 4-bit bias current. More...
 
int max14001_ft_config (struct max14001_dev *dev, enum max14001_ft mode)
 Set number of readings averaged in the ADC filter. More...
 
int max14001_get_data_raw (struct max14001_dev *dev, uint16_t *data)
 Get adc data. More...
 
int max14001_get_data_filtered (struct max14001_dev *dev, uint16_t *data)
 Get filtered adc data. More...
 
int max14001_remove (struct max14001_dev *dev)
 Free the resources allocated by max14001_init(). More...
 

Detailed Description

Implementation of max14001.h.

Author
NAlteza (natha.nosp@m.niel.nosp@m..alte.nosp@m.za@a.nosp@m.nalog.nosp@m..com)

Copyright 2023(c) Analog Devices, Inc.

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

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 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

◆ MAX14001_ACT_REG

#define MAX14001_ACT_REG   0x0B

◆ MAX14001_ADC_FLAG_MASK

#define MAX14001_ADC_FLAG_MASK   NO_OS_BIT(1)

◆ MAX14001_ADC_REG

#define MAX14001_ADC_REG   0x00

◆ MAX14001_CFG_MAX

#define MAX14001_CFG_MAX   0xF

◆ MAX14001_CFG_MIN

#define MAX14001_CFG_MIN   0

◆ MAX14001_CFG_Q

#define MAX14001_CFG_Q (   x,
 
)

◆ MAX14001_CFG_REG

#define MAX14001_CFG_REG   0x09

◆ MAX14001_CFGV_REG

#define MAX14001_CFGV_REG   0x19

◆ MAX14001_COM_FLAG_MASK

#define MAX14001_COM_FLAG_MASK   NO_OS_BIT(4)

◆ MAX14001_CRCF_FLAG_MASK

#define MAX14001_CRCF_FLAG_MASK   NO_OS_BIT(6)

◆ MAX14001_CRCL_FLAG_MASK

#define MAX14001_CRCL_FLAG_MASK   NO_OS_BIT(5)

◆ MAX14001_DU_INRP_MASK

#define MAX14001_DU_INRP_MASK   NO_OS_GENMASK(1, 0)

◆ MAX14001_DU_INRP_MODE

#define MAX14001_DU_INRP_MODE (   a)    (((a) & 0x3) << 0)

◆ MAX14001_DYEN_FLTEN_MASK

#define MAX14001_DYEN_FLTEN_MASK   NO_OS_BIT(0)

◆ MAX14001_EADC_FLTEN_MASK

#define MAX14001_EADC_FLTEN_MASK   NO_OS_BIT(1)

◆ MAX14001_ECOM_FLTEN_MASK

#define MAX14001_ECOM_FLTEN_MASK   NO_OS_BIT(4)

◆ MAX14001_ECRCF_FLTEN_MASK

#define MAX14001_ECRCF_FLTEN_MASK   NO_OS_BIT(6)

◆ MAX14001_ECRCL_FLTEN_MASK

#define MAX14001_ECRCL_FLTEN_MASK   NO_OS_BIT(5)

◆ MAX14001_EFET_FLTEN_MASK

#define MAX14001_EFET_FLTEN_MASK   NO_OS_BIT(7)

◆ MAX14001_EINRD_FLTEN_MASK

#define MAX14001_EINRD_FLTEN_MASK   NO_OS_BIT(2)

◆ MAX14001_EMV_FLTEN_MASK

#define MAX14001_EMV_FLTEN_MASK   NO_OS_BIT(8)

◆ MAX14001_ENA_ENBL_MASK

#define MAX14001_ENA_ENBL_MASK   NO_OS_BIT(4)

◆ MAX14001_ENBL_REG

#define MAX14001_ENBL_REG   0x0A

◆ MAX14001_ENBLV_REG

#define MAX14001_ENBLV_REG   0x1A

◆ MAX14001_ESPI_FLTEN_MASK

#define MAX14001_ESPI_FLTEN_MASK   NO_OS_BIT(3)

◆ MAX14001_EXRF_CFG_MASK

#define MAX14001_EXRF_CFG_MASK   NO_OS_BIT(5)

◆ MAX14001_EXTI_CFG_MASK

#define MAX14001_EXTI_CFG_MASK   NO_OS_BIT(4)

◆ MAX14001_FADC_REG

#define MAX14001_FADC_REG   0x01

◆ MAX14001_FAST_CFG_MASK

#define MAX14001_FAST_CFG_MASK   NO_OS_BIT(1)

◆ MAX14001_FET_FLAG_MASK

#define MAX14001_FET_FLAG_MASK   NO_OS_BIT(7)

◆ MAX14001_FLAGS_REG

#define MAX14001_FLAGS_REG   0x02

◆ MAX14001_FLTEN_REG

#define MAX14001_FLTEN_REG   0x03

◆ MAX14001_FLTV_REG

#define MAX14001_FLTV_REG   0x13

◆ MAX14001_FT_CFG_MASK

#define MAX14001_FT_CFG_MASK   NO_OS_GENMASK(3, 2)

◆ MAX14001_FT_CFG_MODE

#define MAX14001_FT_CFG_MODE (   a)    (((a) & 0x3) << 2)

◆ MAX14001_IBIAS

#define MAX14001_IBIAS (   x)

◆ MAX14001_IBIAS_CFG_MASK

#define MAX14001_IBIAS_CFG_MASK   NO_OS_GENMASK(9, 6)

◆ MAX14001_IBIAS_CFG_MODE

#define MAX14001_IBIAS_CFG_MODE (   a)    ((MAX14001_IBIAS(a)) << 6)

◆ MAX14001_IBIAS_INC

#define MAX14001_IBIAS_INC   25

◆ MAX14001_IINR

#define MAX14001_IINR (   x)    MAX14001_CFG_Q(x, MAX14001_IINR_INC)

◆ MAX14001_IINR_INC

#define MAX14001_IINR_INC   7

◆ MAX14001_IINR_INRP_MASK

#define MAX14001_IINR_INRP_MASK   NO_OS_GENMASK(9, 6)

◆ MAX14001_IINR_INRP_MODE

#define MAX14001_IINR_INRP_MODE (   a)    ((MAX14001_IINR(a)) << 6)

◆ MAX14001_INPLS_MASK

#define MAX14001_INPLS_MASK   NO_OS_BIT(9)

Trigger an inrush current pulse. Has no effect when ENA = 0.

◆ MAX14001_INRD_FLAG_MASK

#define MAX14001_INRD_FLAG_MASK   NO_OS_BIT(2)

◆ MAX14001_INRP_REG

#define MAX14001_INRP_REG   0x08

◆ MAX14001_INRPV_REG

#define MAX14001_INRPV_REG   0x18

◆ MAX14001_INRR_REG

#define MAX14001_INRR_REG   0x06

◆ MAX14001_INRRV_REG

#define MAX14001_INRRV_REG   0x16

◆ MAX14001_INRT_REG

#define MAX14001_INRT_REG   0x07

◆ MAX14001_INRTV_REG

#define MAX14001_INRTV_REG   0x17

◆ MAX14001_IRAW_CFG_MASK

#define MAX14001_IRAW_CFG_MASK   NO_OS_BIT(0)

◆ MAX14001_MUL

#define MAX14001_MUL   100

◆ MAX14001_MV_FLAG_MASK

#define MAX14001_MV_FLAG_MASK   NO_OS_BIT(8)

◆ MAX14001_REG_DATA_MASK

#define MAX14001_REG_DATA_MASK   NO_OS_GENMASK(9, 0)

◆ MAX14001_REG_READ

#define MAX14001_REG_READ (   x)    (((x) << 11) & NO_OS_GENMASK(15, 11))

◆ MAX14001_REG_WRITE

#define MAX14001_REG_WRITE (   x,
 
)
Value:
NO_OS_BIT(10) | \

◆ MAX14001_RSET_MASK

#define MAX14001_RSET_MASK   NO_OS_BIT(7)

Reset. Has the same effect as a power on reset.

◆ MAX14001_SPI_FLAG_MASK

#define MAX14001_SPI_FLAG_MASK   NO_OS_BIT(3)

◆ MAX14001_SPI_REG_WRITE_DISABLE

#define MAX14001_SPI_REG_WRITE_DISABLE   0x000

◆ MAX14001_SPI_REG_WRITE_ENABLE

#define MAX14001_SPI_REG_WRITE_ENABLE   0x294

◆ MAX14001_SRES_MASK

#define MAX14001_SRES_MASK   NO_OS_BIT(6)

Software reset. Restores all registers to their POR value.

◆ MAX14001_THL_REG

#define MAX14001_THL_REG   0x04

◆ MAX14001_THLV_REG

#define MAX14001_THLV_REG   0x14

◆ MAX14001_THU_REG

#define MAX14001_THU_REG   0x05

◆ MAX14001_THUV_REG

#define MAX14001_THUV_REG   0x15

◆ MAX14001_TINR

#define MAX14001_TINR (   x)    MAX14001_CFG_Q(x, MAX14001_TINR_INC)

◆ MAX14001_TINR_INC

#define MAX14001_TINR_INC   8

◆ MAX14001_TINR_INRP_MASK

#define MAX14001_TINR_INRP_MASK   NO_OS_GENMASK(5, 2)

◆ MAX14001_TINR_INRP_MODE

#define MAX14001_TINR_INRP_MODE (   a)    ((MAX14001_TINR(a)) << 2)

◆ MAX14001_WEN_REG

#define MAX14001_WEN_REG   0x0C

◆ REVERSE_UINT16

#define REVERSE_UINT16 (   x)
Value:
((((x >> 0) & 1) << 15) | \
(((x >> 1) & 1 ) << 14) | \
(((x >> 2) & 1 ) << 13) | \
(((x >> 3) & 1 ) << 12) | \
(((x >> 4) & 1 ) << 11) | \
(((x >> 5) & 1 ) << 10) | \
(((x >> 6) & 1 ) << 9) | \
(((x >> 7) & 1 ) << 8) | \
(((x >> 8) & 1 ) << 7) | \
(((x >> 9) & 1 ) << 6) | \
(((x >> 10) & 1) << 5) | \
(((x >> 11) & 1) << 4) | \
(((x >> 12) & 1) << 3) | \
(((x >> 13) & 1) << 2) | \
(((x >> 14) & 1) << 1) | \
(((x >> 15) & 1) << 0))

◆ VERIFICATION_REG

#define VERIFICATION_REG (   x)    ((x) + 0x10)

Enumeration Type Documentation

◆ max14001_du

MAX14001 list of possible duty cycle modes.

Enumerator
DUTY_OFF 
DUTY_1P6 
DUTY_3P1 
DUTY_6P3 

◆ max14001_ft

MAX14001 list of possible filtering modes.

Enumerator
FILTER_OFF 
AVERAGE_2_READINGS 
AVERAGE_4_READINGS 
AVERAGE_8_READINGS 

Function Documentation

◆ max14001_du_config()

int max14001_du_config ( struct max14001_dev dev,
enum max14001_du  mode 
)

Set maximum duty cycle for inrush current over the last 10 seconds.

Set maximum duty cycle for inrush current over the last 10 seconds.

Parameters
dev- The device structure.
mode- Duty Cycle Accepted values: DUTY_OFF DUTY_1P6 DUTY_3P1 DUTY_6P3
Returns
0 in case of success, fail otherwise.

◆ max14001_dyen_config()

int max14001_dyen_config ( struct max14001_dev dev,
bool  mode 
)

Enable dynamic FAULT signal.

Enable dynamic FAULT signal.

Parameters
dev- The device structure.
mode- true for dynamic FAULT signal false for latched FAULT signal (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_eadc_config()

int max14001_eadc_config ( struct max14001_dev dev,
bool  mode 
)

Enable ADC fault.

Enable ADC fault.

Parameters
dev- The device structure.
mode- true to allow ADC error to assert FAULT false to prevent ADC error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_ecom_config()

int max14001_ecom_config ( struct max14001_dev dev,
bool  mode 
)

Enable COM fault.

Enable COM fault.

Parameters
dev- The device structure.
mode- true to allow COM error to assert FAULT false to prevent COM error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_ecrcf_config()

int max14001_ecrcf_config ( struct max14001_dev dev,
bool  mode 
)

Enable CRCF fault.

Enable CRCF fault.

Parameters
dev- The device structure.
mode- true to allow CRCF error to assert FAULT false to prevent CRCF error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_ecrcl_config()

int max14001_ecrcl_config ( struct max14001_dev dev,
bool  mode 
)

Enable CRCL fault.

Enable CRCL fault.

Parameters
dev- The device structure.
mode- true to allow CRCL error to assert FAULT false to prevent CRCL error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_efet_config()

int max14001_efet_config ( struct max14001_dev dev,
bool  mode 
)

Enable FET fault.

Enable FET fault.

Parameters
dev- The device structure.
mode- true to allow FET error to assert FAULT false to prevent FET error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_einrd_config()

int max14001_einrd_config ( struct max14001_dev dev,
bool  mode 
)

Enable INRD fault.

Enable INRD fault.

Parameters
dev- The device structure.
mode- true to allow INRD error to assert FAULT false to prevent INRD error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_emv_config()

int max14001_emv_config ( struct max14001_dev dev,
bool  mode 
)

Enable MV fault.

Enable MV fault.

Parameters
dev- The device structure.
mode- true to allow MV error to assert FAULT false to prevent MV error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:

◆ max14001_ena_config()

int max14001_ena_config ( struct max14001_dev dev,
bool  enable 
)

Enable/Disable field-side current sink.

Enable/Disable field-side current sink.

Parameters
dev- The device structure.
enable- true to enable field-side current sink false to prevent field-side current sink (default)
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:

◆ max14001_espi_config()

int max14001_espi_config ( struct max14001_dev dev,
bool  mode 
)

Enable SPI fault.

Enable SPI fault.

Parameters
dev- The device structure.
mode- true to allow SPI error to assert FAULT false to prevent SPI error to assert FAULT (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_exrf_config()

int max14001_exrf_config ( struct max14001_dev dev,
bool  mode 
)

Selects the voltage reference source for the ADC.

Selects the voltage reference source for the ADC.

Parameters
dev- The device structure.
mode- 0 for external voltage reference enabled 1 for internal voltage reference enabled (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_exti_config()

int max14001_exti_config ( struct max14001_dev dev,
bool  mode 
)

Current source connection.

Current source connection.

Parameters
dev- The device structure.
mode- 0 for current source on and connected to the REFIN pin 1 for current source off (default)
Returns
0 in case of success, fail otherwise.

◆ max14001_fast_config()

int max14001_fast_config ( struct max14001_dev dev,
bool  fast 
)

Enable/Disable fast inrush mode.

Enable/Disable fast inrush mode.

Parameters
dev- The device structure.
fast- true for FAST inrush mode (default) false for ADC controlled
Returns
0 in case of success, fail otherwise.

◆ max14001_ft_config()

int max14001_ft_config ( struct max14001_dev dev,
enum max14001_ft  mode 
)

Set number of readings averaged in the ADC filter.

Set number of readings averaged in the ADC filter.

Parameters
dev- The device structure.
mode- Average readings Accepted values: FILTER_OFF AVERAGE_2_READINGS AVERAGE_4_READINGS AVERAGE_8_READINGS
Returns
0 in case of success, fail otherwise.

◆ max14001_full_reset()

int max14001_full_reset ( struct max14001_dev dev)

Full reset, same effect as power on reset.

Full reset, same effect as power on reset.

Parameters
dev- The device structure.
Returns
0 in case of success, fail otherwise.

◆ max14001_get_data_filtered()

int max14001_get_data_filtered ( struct max14001_dev dev,
uint16_t *  data 
)

Get filtered adc data.

Get filtered adc data.

Parameters
dev- Device handler.
data- Pointer to filtered adc value.
Returns
0 in case of success, negative error code otherwise.

◆ max14001_get_data_raw()

int max14001_get_data_raw ( struct max14001_dev dev,
uint16_t *  data 
)

Get adc data.

Get adc data.

Parameters
dev- Device handler.
data- Pointer to raw adc value.
Returns
0 in case of success, negative error code otherwise.

◆ max14001_ibias_config()

int max14001_ibias_config ( struct max14001_dev dev,
float  mode 
)

Configure 4-bit bias current.

Configure 4-bit bias current.

Parameters
dev- The device structure.
mode- 50uA to 3.75mA in 0.25mA increments. Inputs are clamped and rounded within limits.
Returns
0 in case of success, fail otherwise.

◆ max14001_iinr_config()

int max14001_iinr_config ( struct max14001_dev dev,
int  mode 
)

Configure 4-bit inrush current.

Configure 4-bit inrush current.

Parameters
dev- The device structure.
mode- 50uA to 105mA in 7mA increments. Inputs are clamped and rounded within limits.
Returns
0 in case of success, fail otherwise.

◆ max14001_init()

int max14001_init ( struct max14001_dev **  device,
struct max14001_init_param  init_param 
)

Initialize the device.

Initialize the device.

Parameters
device- The device structure.
init_param- The structure that contains the device initial parameters.
Returns
0 in case of success, fail otherwise.

◆ max14001_init_config()

int max14001_init_config ( struct max14001_dev dev)

Initialize the configurations of device.

Initialize the configurations of device.

Parameters
dev- The device structure.
Returns
0 in case of success, fail otherwise.

◆ max14001_inpls_reset()

int max14001_inpls_reset ( struct max14001_dev dev)

Trigger an inrush current pulse.

Trigger an inrush current pulse.

Parameters
dev- The device structure.
Returns
0 in case of success, fail otherwise.

◆ max14001_iraw_config()

int max14001_iraw_config ( struct max14001_dev dev,
bool  raw_data 
)

Selects Inrush comparator input multiplexer.

Selects Inrush comparator input multiplexer.

Parameters
dev- The device structure.
raw_data- 0 to connect comparator to ADC register(default) 1 to connect comparator to FADC register
Returns
0 in case of success, fail otherwise.

◆ max14001_read()

int max14001_read ( struct max14001_dev dev,
uint8_t  reg_addr,
uint16_t *  reg_data 
)

Read from device.

Read from device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:

◆ max14001_reg_reset()

int max14001_reg_reset ( struct max14001_dev dev)

Software reset. Restores all registers to their POR value.

Software reset. Restores all registers to their POR value.

Parameters
dev- The device structure.
Returns
0 in case of success, fail otherwise.

◆ max14001_reg_update()

int max14001_reg_update ( struct max14001_dev dev,
uint8_t  reg_addr,
uint16_t  mask,
uint16_t  data 
)

SPI write to device using a mask.

SPI write to device using a mask.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:

◆ max14001_remove()

int max14001_remove ( struct max14001_dev dev)

Free the resources allocated by max14001_init().

Free the resources allocated by max14001_init().

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

◆ max14001_tinr_config()

int max14001_tinr_config ( struct max14001_dev dev,
int  mode 
)

Configure 4-bit inrush time.

Configure 4-bit inrush time.

Parameters
dev- The device structure.
mode- 0 to 120ms in 8ms increments. Inputs are clamped and rounded within limits.
Returns
0 in case of success, fail otherwise.

◆ max14001_wen()

int max14001_wen ( struct max14001_dev dev,
bool  enable 
)

Enable write to registers.

Enable write to registers.

Parameters
dev- The device structure.
enable- true to write enable false to write disable
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:

◆ max14001_write()

int max14001_write ( struct max14001_dev dev,
uint8_t  reg_addr,
uint16_t  reg_data 
)

Write to device.

Write to device.

Parameters
dev- The device structure.
reg_addr- The register address.
reg_data- The register data.
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:

◆ max14001_write_config_verify()

int max14001_write_config_verify ( struct max14001_dev dev,
uint8_t  reg_addr,
uint16_t  mask,
uint16_t  data 
)

Write to config registers then to corresponding verification register.

Write to config registers then to corresponding verification register.

Parameters
dev- The device structure.
reg_addr- The register address.
mask- The mask.
data- The register data.
Returns
0 in case of success, fail otherwise.
Here is the caller graph for this function:
MAX14001_REG_DATA_MASK
#define MAX14001_REG_DATA_MASK
Definition: max14001.h:52
MAX14001_CFG_MAX
#define MAX14001_CFG_MAX
Definition: max14001.h:171
MAX14001_MUL
#define MAX14001_MUL
Definition: max14001.h:190
no_os_clamp
#define no_os_clamp(val, min_val, max_val)
Definition: no_os_util.h:69
MAX14001_CFG_Q
#define MAX14001_CFG_Q(x, y)
Definition: max14001.h:172
MAX14001_REG_READ
#define MAX14001_REG_READ(x)
Definition: max14001.h:48
MAX14001_IBIAS_INC
#define MAX14001_IBIAS_INC
Definition: max14001.h:191
MAX14001_CFG_MIN
#define MAX14001_CFG_MIN
Definition: max14001.h:170
NO_OS_DIV_ROUND_CLOSEST
#define NO_OS_DIV_ROUND_CLOSEST(x, y)
Definition: no_os_util.h:54