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

Header file of MAX22915 Driver. More...

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

Go to the source code of this file.

Classes

struct  max22915_current_config
 
struct  max22915_temp_config
 
struct  max22915_ow_config
 
struct  max22915_desc
 
struct  max22915_init_param
 

Macros

#define MAX22915_MAX_CHANNELS   8
 
#define MAX22915_ADDR_MASK   NO_OS_GENMASK(5, 1)
 
#define MAX22915_RW_MASK   NO_OS_BIT(0)
 
#define MAX22915_CHIP_ADDR_MASK   NO_OS_GENMASK(7, 6)
 
#define MAX22915_REG_SET_OUTPUT   0x00
 
#define MAX22915_REG_SET_FLED   0x01
 
#define MAX22915_REG_SET_SLED   0x02
 
#define MAX22915_REG_INTERRUPT   0x03
 
#define MAX22915_REG_OVL_FLT   0x04
 
#define MAX22915_REG_CL_FLT   0x05
 
#define MAX22915_REG_OWOFF_FLT   0x06
 
#define MAX22915_REG_OWON_FLT   0x07
 
#define MAX22915_REG_SHTVDD_FLT   0x08
 
#define MAX22915_REG_GLOBAL_ERR   0x09
 
#define MAX22915_REG_OWOFF_ENABLE   0x0A
 
#define MAX22915_REG_OWON_ENABLE   0x0B
 
#define MAX22915_REG_SHTVDD_ENABLE   0x0C
 
#define MAX22915_REG_CONFIG1   0x0D
 
#define MAX22915_REG_CONFIG2   0x0E
 
#define MAX22915_REG_MASK   0x0F
 
#define MAX22915_REG_CONFIG3   0x10
 
#define MAX22915_REG_THERM_WARN_THR   0x11
 
#define MAX22915_REG_CURR_MEAS_ENABLE   0x12
 
#define MAX22915_REG_ADC_CONFIG1   0x13
 
#define MAX22915_REG_ADC_CONFIG2   0x14
 
#define MAX22915_REG_ADC_CONFIG3   0x15
 
#define MAX22915_REG_ADC_DATA   0x16
 
#define MAX22915_REG_OWON_FILTER   0x17
 
#define MAX22915_CH_MASK(channel)
 
#define MAX22915_SLED_SET_MASK   NO_OS_BIT(1)
 
#define MAX22915_FLED_SET_MASK   NO_OS_BIT(0)
 
#define MAX22915_CURR_AVG_MASK   NO_OS_GENMASK(6, 4)
 
#define MAX22915_CURR_SINGLE_MASK   NO_OS_BIT(3)
 
#define MAX22915_CURR_CONT_MASK   NO_OS_BIT(2)
 
#define MAX22915_TEMP_AVG_MASK   NO_OS_GENMASK(6, 4)
 
#define MAX22915_THERM_WARN_EN_MASK   NO_OS_BIT(3)
 
#define MAX22915_TEMP_CONT_MASK   NO_OS_BIT(2)
 
#define MAX22915_SPI_FRAME_SIZE   2
 

Enumerations

enum  max22915_sw_state {
  SWITCH_OPEN ,
  SWITCH_CLOSE
}
 
enum  max22915_led_state {
  LED_ON ,
  LED_OFF
}
 

Functions

int max22915_init (struct max22915_desc **desc, struct max22915_init_param *init_param)
 Initialize and configure the MAX22915 device.
 
int max22915_reg_write (struct max22915_desc *desc, uint8_t reg_addr, uint8_t reg_data)
 Write register data to MAX22915.
 
int max22915_reg_read (struct max22915_desc *desc, uint8_t reg_addr, uint8_t *reg_data)
 Read register data from MAX22915.
 
int max22915_reg_write_mask (struct max22915_desc *desc, uint8_t reg_addr, uint8_t mask, uint8_t reg_data)
 Write register data to MAX22915 with mask.
 
int max22915_set_temperature_config (struct max22915_desc *dev, struct max22915_temp_config *config)
 Set the temperature measurement configuration.
 
int max22915_set_current_config (struct max22915_desc *dev, struct max22915_current_config *config)
 Set the current measurement configuration.
 
int max22915_set_shvdd_config (struct max22915_desc *dev, uint8_t channel, bool shtvdd_enable)
 Set the short to VDD detection configuration for a channel.
 
int max22915_set_owoff_config (struct max22915_desc *dev, uint8_t channel, bool owoff_enable)
 Set the open-wire off detection configuration for a channel.
 
int max22915_set_owon_config (struct max22915_desc *dev, uint8_t channel, bool owon_enable)
 Set the open-wire on detection configuration for a channel.
 
int max22915_set_sw_state (struct max22915_desc *dev, uint8_t channel, enum max22915_sw_state state)
 Set the switch state of a channel.
 
int max22915_remove (struct max22915_desc *desc)
 Remove resources allocated for MAX22915.
 

Detailed Description

Header file of MAX22915 Driver.

Author
Janani Sunil (janan.nosp@m.i.su.nosp@m.nil@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2025-2026(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

◆ MAX22915_ADDR_MASK

#define MAX22915_ADDR_MASK   NO_OS_GENMASK(5, 1)

◆ MAX22915_CH_MASK

#define MAX22915_CH_MASK ( channel)
Value:
NO_OS_BIT(channel)
#define NO_OS_BIT(x)
Definition no_os_util.h:46

◆ MAX22915_CHIP_ADDR_MASK

#define MAX22915_CHIP_ADDR_MASK   NO_OS_GENMASK(7, 6)

◆ MAX22915_CURR_AVG_MASK

#define MAX22915_CURR_AVG_MASK   NO_OS_GENMASK(6, 4)

◆ MAX22915_CURR_CONT_MASK

#define MAX22915_CURR_CONT_MASK   NO_OS_BIT(2)

◆ MAX22915_CURR_SINGLE_MASK

#define MAX22915_CURR_SINGLE_MASK   NO_OS_BIT(3)

◆ MAX22915_FLED_SET_MASK

#define MAX22915_FLED_SET_MASK   NO_OS_BIT(0)

◆ MAX22915_MAX_CHANNELS

#define MAX22915_MAX_CHANNELS   8

◆ MAX22915_REG_ADC_CONFIG1

#define MAX22915_REG_ADC_CONFIG1   0x13

◆ MAX22915_REG_ADC_CONFIG2

#define MAX22915_REG_ADC_CONFIG2   0x14

◆ MAX22915_REG_ADC_CONFIG3

#define MAX22915_REG_ADC_CONFIG3   0x15

◆ MAX22915_REG_ADC_DATA

#define MAX22915_REG_ADC_DATA   0x16

◆ MAX22915_REG_CL_FLT

#define MAX22915_REG_CL_FLT   0x05

◆ MAX22915_REG_CONFIG1

#define MAX22915_REG_CONFIG1   0x0D

◆ MAX22915_REG_CONFIG2

#define MAX22915_REG_CONFIG2   0x0E

◆ MAX22915_REG_CONFIG3

#define MAX22915_REG_CONFIG3   0x10

◆ MAX22915_REG_CURR_MEAS_ENABLE

#define MAX22915_REG_CURR_MEAS_ENABLE   0x12

◆ MAX22915_REG_GLOBAL_ERR

#define MAX22915_REG_GLOBAL_ERR   0x09

◆ MAX22915_REG_INTERRUPT

#define MAX22915_REG_INTERRUPT   0x03

◆ MAX22915_REG_MASK

#define MAX22915_REG_MASK   0x0F

◆ MAX22915_REG_OVL_FLT

#define MAX22915_REG_OVL_FLT   0x04

◆ MAX22915_REG_OWOFF_ENABLE

#define MAX22915_REG_OWOFF_ENABLE   0x0A

◆ MAX22915_REG_OWOFF_FLT

#define MAX22915_REG_OWOFF_FLT   0x06

◆ MAX22915_REG_OWON_ENABLE

#define MAX22915_REG_OWON_ENABLE   0x0B

◆ MAX22915_REG_OWON_FILTER

#define MAX22915_REG_OWON_FILTER   0x17

◆ MAX22915_REG_OWON_FLT

#define MAX22915_REG_OWON_FLT   0x07

◆ MAX22915_REG_SET_FLED

#define MAX22915_REG_SET_FLED   0x01

◆ MAX22915_REG_SET_OUTPUT

#define MAX22915_REG_SET_OUTPUT   0x00

◆ MAX22915_REG_SET_SLED

#define MAX22915_REG_SET_SLED   0x02

◆ MAX22915_REG_SHTVDD_ENABLE

#define MAX22915_REG_SHTVDD_ENABLE   0x0C

◆ MAX22915_REG_SHTVDD_FLT

#define MAX22915_REG_SHTVDD_FLT   0x08

◆ MAX22915_REG_THERM_WARN_THR

#define MAX22915_REG_THERM_WARN_THR   0x11

◆ MAX22915_RW_MASK

#define MAX22915_RW_MASK   NO_OS_BIT(0)

◆ MAX22915_SLED_SET_MASK

#define MAX22915_SLED_SET_MASK   NO_OS_BIT(1)

◆ MAX22915_SPI_FRAME_SIZE

#define MAX22915_SPI_FRAME_SIZE   2

◆ MAX22915_TEMP_AVG_MASK

#define MAX22915_TEMP_AVG_MASK   NO_OS_GENMASK(6, 4)

◆ MAX22915_TEMP_CONT_MASK

#define MAX22915_TEMP_CONT_MASK   NO_OS_BIT(2)

◆ MAX22915_THERM_WARN_EN_MASK

#define MAX22915_THERM_WARN_EN_MASK   NO_OS_BIT(3)

Enumeration Type Documentation

◆ max22915_led_state

Enumerator
LED_ON 
LED_OFF 

◆ max22915_sw_state

Enumerator
SWITCH_OPEN 
SWITCH_CLOSE 

Function Documentation

◆ max22915_init()

int max22915_init ( struct max22915_desc ** device,
struct max22915_init_param * init_param )

Initialize and configure the MAX22915 device.

Initialize and configure the MAX22915 device

Parameters
device- Device descriptor for the MAX22915 that will be initialized
init_param- Initialization parameter for the device
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_reg_read()

int max22915_reg_read ( struct max22915_desc * desc,
uint8_t reg_addr,
uint8_t * reg_data )

Read register data from MAX22915.

Read register data from MAX22915

Parameters
desc- Device descriptor for the MAX22915
reg_addr- Register address to read from
reg_data- Pointer to store the read data
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_reg_write()

int max22915_reg_write ( struct max22915_desc * desc,
uint8_t reg_addr,
uint8_t reg_data )

Write register data to MAX22915.

Write register data to MAX22915

Parameters
desc- Device descriptor for the MAX22915
reg_addr- Register address to write to
reg_data- Data to be written
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_reg_write_mask()

int max22915_reg_write_mask ( struct max22915_desc * desc,
uint8_t reg_addr,
uint8_t mask,
uint8_t reg_data )

Write register data to MAX22915 with mask.

Write register data to MAX22915 with bit mask

Parameters
desc- Device descriptor for the MAX22915
reg_addr- Register address to write to
mask- Bit mask for the operation
reg_data- Data to be written
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_remove()

int max22915_remove ( struct max22915_desc * dev)

Remove resources allocated for MAX22915.

Free the resources allocated during init

Parameters
dev- device descriptor for the MAX22915
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_set_current_config()

int max22915_set_current_config ( struct max22915_desc * dev,
struct max22915_current_config * config )

Set the current measurement configuration.

Set the current measurement configuration

Parameters
dev- Device descriptor for the MAX22915
config- Pointer to current configuration structure
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_set_owoff_config()

int max22915_set_owoff_config ( struct max22915_desc * dev,
uint8_t channel,
bool owoff_enable )

Set the open-wire off detection configuration for a channel.

Set the open-wire off detection configuration for a channel

Parameters
dev- Device descriptor for the MAX22915
channel- Channel index
owoff_enable- True to enable, false to disable
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_set_owon_config()

int max22915_set_owon_config ( struct max22915_desc * dev,
uint8_t channel,
bool owon_enable )

Set the open-wire on detection configuration for a channel.

Set the open-wire on detection configuration for a channel

Parameters
dev- Device descriptor for the MAX22915
channel- Channel index
owon_enable- True to enable, false to disable
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_set_shvdd_config()

int max22915_set_shvdd_config ( struct max22915_desc * dev,
uint8_t channel,
bool shtvdd_enable )

Set the short to VDD detection configuration for a channel.

Set the short to VDD detection configuration for a channel

Parameters
dev- Device descriptor for the MAX22915
channel- Channel index
shtvdd_enable- True to enable, false to disable
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_set_sw_state()

int max22915_set_sw_state ( struct max22915_desc * dev,
uint8_t channel,
enum max22915_sw_state state )

Set the switch state of a channel.

Set the switch state of a channel

Parameters
dev- Device descriptor for the MAX22915
channel- Channel index
state- Switch state to be set
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max22915_set_temperature_config()

int max22915_set_temperature_config ( struct max22915_desc * dev,
struct max22915_temp_config * config )

Set the temperature measurement configuration.

Set the temperature measurement configuration

Parameters
dev- Device descriptor for the MAX22915
config- Pointer to temperature configuration structure
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function: