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

Header file of MAX22007 Driver. More...

#include "no_os_spi.h"
#include "no_os_util.h"
Include dependency graph for max22007.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  max22007_spi_timeout_config
 
struct  max22007_channel_config
 
struct  max22007_init_param
 
struct  max22007_dev
 

Macros

#define MAX22007_REV_ID_REG   0x00
 
#define MAX22007_STAT_AND_INTR_REG   0x01
 
#define MAX22007_INR_ENABLE_REG   0x02
 
#define MAX22007_CONFIG_REG   0x03
 
#define MAX22007_CTRL_REG   0x04
 
#define MAX22007_CHANNEL_MODE_REG   0x05
 
#define MAX22007_SOFT_RESET_REG   0x06
 
#define MAX22007_CHANNEL_DATA_REG(channel)
 
#define MAX22007_GPIO_CTRL_REG   0x0B
 
#define MAX22007_GPIO_DATA_REG   0x0C
 
#define MAX22007_GPIO_EDGE_CTRL_REG   0x0D
 
#define MAX22007_GPIO_EDGE_DETECTION_STAT_REG   0x0E
 
#define MAX22007_REV_ID_MASK   NO_OS_GENMASK(7, 0)
 
#define MAX22007_PART_ID_MASK   NO_OS_GENMASK(15, 8)
 
#define MAX22007_CONFIG_LD_CNFG_MASK   NO_OS_GENMASK(15, 12)
 
#define MAX22007_CONFIG_COMP_EDGE_MASK   NO_OS_GENMASK(11, 10)
 
#define MAX22007_CONFIG_REF_SEL_MASK   NO_OS_BIT(8)
 
#define MAX22007_TIMEOUT_SEL_MASK   NO_OS_GENMASK(7, 4)
 
#define MAX22007_TIMEOUT_CNFG_MASK   NO_OS_BIT(3)
 
#define MAX22007_TIMEOUT_EN_MASK   NO_OS_BIT(2)
 
#define MAX22007_OVERCURRENT_CTRL_MASK   NO_OS_BIT(1)
 
#define MAX22007_CRC_EN_MASK   NO_OS_BIT(0)
 
#define MAX22007_LD_CTRL_MASK   NO_OS_GENMASK(15, 12)
 
#define LD_CTRL_CH_MASK(channel)
 
#define MAX22007_CH_MODE_MASK   NO_OS_GENMASK(15, 12)
 
#define MAX22007_CH_MODE_CH_MASK(channel)
 
#define MAX22007_CH_PWR_MASK   NO_OS_GENMASK(11, 8)
 
#define MAX22007_CH_PWR_CH_MASK(channel)
 
#define MAX22007_SW_CLR_MASK   NO_OS_BIT(12)
 
#define MAX22007_SW_RST_MASK   NO_OS_BIT(8)
 
#define MAX22007_GPIO_CTRL_MASK   NO_OS_GENMASK(15, 8)
 
#define MAX22007_GPIO_DIR_MASK   NO_OS_GENMASK(7, 0)
 
#define DAC_CH_DATA_MASK   NO_OS_GENMASK(15, 4)
 
#define MAX22007_GPO_DATA_MASK   NO_OS_GENMASK(15, 8)
 
#define MAX22007_GPI_DATA_MASK   NO_OS_GENMASK(7, 0)
 
#define MAX22007_SPI_READ   0x80
 
#define MAX22007_NUM_CHANNELS   4
 
#define MAX22007_REV_ID_REV0   0xBB45
 
#define MAX22007_REV_ID_REV1   0xBB47
 
#define MAX22007_ADRR_MASK   NO_OS_GENMASK(7, 1)
 
#define MAX22007_RW_MASK   NO_OS_BIT(0)
 
#define MAX22007_FRAME_SIZE   3
 
#define MAX22007_PAYLOAD_LSB_MASK   NO_OS_GENMASK(7, 0)
 
#define MAX22007_PAYLOAD_MSB_MASK   NO_OS_GENMASK(15, 8)
 

Enumerations

enum  max22007_dac_latch_mode {
  LDAC_CONTROL ,
  TRANSPARENT_LATCH
}
 
enum  max22007_ref_mode {
  INTERNAL_REF ,
  EXTERNAL_REF
}
 
enum  max22007_timeout_sel {
  MAX22007_TIMEOUT_100MS ,
  MAX22007_TIMEOUT_200MS ,
  MAX22007_TIMEOUT_300MS ,
  MAX22007_TIMEOUT_400MS ,
  MAX22007_TIMEOUT_500MS ,
  MAX22007_TIMEOUT_600MS ,
  MAX22007_TIMEOUT_700MS ,
  MAX22007_TIMEOUT_800MS ,
  MAX22007_TIMEOUT_900MS ,
  MAX22007_TIMEOUT_1000MS ,
  MAX22007_TIMEOUT_1100MS ,
  MAX22007_TIMEOUT_1200MS ,
  MAX22007_TIMEOUT_1300MS ,
  MAX22007_TIMEOUT_1400MS ,
  MAX22007_TIMEOUT_1500MS ,
  MAX22007_TIMEOUT_1600MS
}
 
enum  max22007_timeout_cnfg {
  TIMEOUT_EVENT_ONLY ,
  TIMEOUT_RESET
}
 
enum  max22007_channel_mode {
  MAX22007_VOLTAGE_MODE ,
  MAX22007_CURRENT_MODE
}
 
enum  max22007_channel_power {
  MAX22007_CH_POWER_OFF ,
  MAX22007_CH_POWER_ON
}
 

Functions

int max22007_reg_read (struct max22007_dev *dev, uint8_t reg_addr, uint16_t *reg_data)
 Read from a register.
 
int max22007_reg_write (struct max22007_dev *dev, uint8_t reg_addr, uint16_t reg_data)
 Write to a register.
 
int max22007_reg_write_msk (struct max22007_dev *dev, uint8_t reg_addr, uint16_t data, uint16_t mask)
 Register write with mask.
 
int max22007_set_latch_mode (struct max22007_dev *dev, uint8_t ch, enum max22007_dac_latch_mode mode)
 Set DAC latch mode.
 
int max22007_get_latch_mode (struct max22007_dev *dev, uint8_t ch, enum max22007_dac_latch_mode *mode)
 Get DAC latch mode.
 
int max22007_set_reference (struct max22007_dev *dev, enum max22007_ref_mode mode)
 Set reference source.
 
int max22007_get_reference (struct max22007_dev *dev, enum max22007_ref_mode *mode)
 Get reference source.
 
int max22007_set_timeout (struct max22007_dev *dev, bool timeout_en, enum max22007_timeout_sel timeout_sel, enum max22007_timeout_cnfg timeout_cnfg)
 Set timeout configuration.
 
int max22007_set_channel_mode (struct max22007_dev *dev, uint8_t ch, enum max22007_channel_mode mode)
 Set channel mode.
 
int max22007_get_channel_mode (struct max22007_dev *dev, uint8_t ch, enum max22007_channel_mode *mode)
 Get channel mode.
 
int max22007_set_channel_power (struct max22007_dev *dev, uint8_t ch, enum max22007_channel_power mode)
 Set channel power.
 
int max22007_get_channel_power (struct max22007_dev *dev, uint8_t ch, enum max22007_channel_power *mode)
 Get channel power.
 
int max22007_configure_crc (struct max22007_dev *dev, bool crc_en)
 Configure CRC.
 
int max22007_write_ldac (struct max22007_dev *dev, uint8_t ch_mask)
 Write to LDAC register to update DAC output.
 
int max22007_write_channel_data (struct max22007_dev *dev, uint8_t ch, uint16_t data)
 Write data to a DAC channel data register.
 
int max22007_read_channel_data (struct max22007_dev *dev, uint8_t ch, uint16_t *data)
 Read data from a DAC channel data register.
 
int max22007_init (struct max22007_dev **device, struct max22007_init_param init_param)
 MAX22007 descriptor initialization function.
 
int max22007_remove (struct max22007_dev *dev)
 Deallocates all the resources used at initialization.
 

Detailed Description

Header file of MAX22007 Driver.

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

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

◆ DAC_CH_DATA_MASK

#define DAC_CH_DATA_MASK   NO_OS_GENMASK(15, 4)

◆ LD_CTRL_CH_MASK

#define LD_CTRL_CH_MASK ( channel)
Value:
NO_OS_BIT(12 + channel)
#define NO_OS_BIT(x)
Definition no_os_util.h:46

◆ MAX22007_ADRR_MASK

#define MAX22007_ADRR_MASK   NO_OS_GENMASK(7, 1)

◆ MAX22007_CH_MODE_CH_MASK

#define MAX22007_CH_MODE_CH_MASK ( channel)
Value:
NO_OS_BIT(12 + channel)

◆ MAX22007_CH_MODE_MASK

#define MAX22007_CH_MODE_MASK   NO_OS_GENMASK(15, 12)

◆ MAX22007_CH_PWR_CH_MASK

#define MAX22007_CH_PWR_CH_MASK ( channel)
Value:
NO_OS_BIT(8 + channel)

◆ MAX22007_CH_PWR_MASK

#define MAX22007_CH_PWR_MASK   NO_OS_GENMASK(11, 8)

◆ MAX22007_CHANNEL_DATA_REG

#define MAX22007_CHANNEL_DATA_REG ( channel)
Value:
(0x07 + (channel))

◆ MAX22007_CHANNEL_MODE_REG

#define MAX22007_CHANNEL_MODE_REG   0x05

◆ MAX22007_CONFIG_COMP_EDGE_MASK

#define MAX22007_CONFIG_COMP_EDGE_MASK   NO_OS_GENMASK(11, 10)

◆ MAX22007_CONFIG_LD_CNFG_MASK

#define MAX22007_CONFIG_LD_CNFG_MASK   NO_OS_GENMASK(15, 12)

◆ MAX22007_CONFIG_REF_SEL_MASK

#define MAX22007_CONFIG_REF_SEL_MASK   NO_OS_BIT(8)

◆ MAX22007_CONFIG_REG

#define MAX22007_CONFIG_REG   0x03

◆ MAX22007_CRC_EN_MASK

#define MAX22007_CRC_EN_MASK   NO_OS_BIT(0)

◆ MAX22007_CTRL_REG

#define MAX22007_CTRL_REG   0x04

◆ MAX22007_FRAME_SIZE

#define MAX22007_FRAME_SIZE   3

◆ MAX22007_GPI_DATA_MASK

#define MAX22007_GPI_DATA_MASK   NO_OS_GENMASK(7, 0)

◆ MAX22007_GPIO_CTRL_MASK

#define MAX22007_GPIO_CTRL_MASK   NO_OS_GENMASK(15, 8)

◆ MAX22007_GPIO_CTRL_REG

#define MAX22007_GPIO_CTRL_REG   0x0B

◆ MAX22007_GPIO_DATA_REG

#define MAX22007_GPIO_DATA_REG   0x0C

◆ MAX22007_GPIO_DIR_MASK

#define MAX22007_GPIO_DIR_MASK   NO_OS_GENMASK(7, 0)

◆ MAX22007_GPIO_EDGE_CTRL_REG

#define MAX22007_GPIO_EDGE_CTRL_REG   0x0D

◆ MAX22007_GPIO_EDGE_DETECTION_STAT_REG

#define MAX22007_GPIO_EDGE_DETECTION_STAT_REG   0x0E

◆ MAX22007_GPO_DATA_MASK

#define MAX22007_GPO_DATA_MASK   NO_OS_GENMASK(15, 8)

◆ MAX22007_INR_ENABLE_REG

#define MAX22007_INR_ENABLE_REG   0x02

◆ MAX22007_LD_CTRL_MASK

#define MAX22007_LD_CTRL_MASK   NO_OS_GENMASK(15, 12)

◆ MAX22007_NUM_CHANNELS

#define MAX22007_NUM_CHANNELS   4

◆ MAX22007_OVERCURRENT_CTRL_MASK

#define MAX22007_OVERCURRENT_CTRL_MASK   NO_OS_BIT(1)

◆ MAX22007_PART_ID_MASK

#define MAX22007_PART_ID_MASK   NO_OS_GENMASK(15, 8)

◆ MAX22007_PAYLOAD_LSB_MASK

#define MAX22007_PAYLOAD_LSB_MASK   NO_OS_GENMASK(7, 0)

◆ MAX22007_PAYLOAD_MSB_MASK

#define MAX22007_PAYLOAD_MSB_MASK   NO_OS_GENMASK(15, 8)

◆ MAX22007_REV_ID_MASK

#define MAX22007_REV_ID_MASK   NO_OS_GENMASK(7, 0)

◆ MAX22007_REV_ID_REG

#define MAX22007_REV_ID_REG   0x00

◆ MAX22007_REV_ID_REV0

#define MAX22007_REV_ID_REV0   0xBB45

◆ MAX22007_REV_ID_REV1

#define MAX22007_REV_ID_REV1   0xBB47

◆ MAX22007_RW_MASK

#define MAX22007_RW_MASK   NO_OS_BIT(0)

◆ MAX22007_SOFT_RESET_REG

#define MAX22007_SOFT_RESET_REG   0x06

◆ MAX22007_SPI_READ

#define MAX22007_SPI_READ   0x80

◆ MAX22007_STAT_AND_INTR_REG

#define MAX22007_STAT_AND_INTR_REG   0x01

◆ MAX22007_SW_CLR_MASK

#define MAX22007_SW_CLR_MASK   NO_OS_BIT(12)

◆ MAX22007_SW_RST_MASK

#define MAX22007_SW_RST_MASK   NO_OS_BIT(8)

◆ MAX22007_TIMEOUT_CNFG_MASK

#define MAX22007_TIMEOUT_CNFG_MASK   NO_OS_BIT(3)

◆ MAX22007_TIMEOUT_EN_MASK

#define MAX22007_TIMEOUT_EN_MASK   NO_OS_BIT(2)

◆ MAX22007_TIMEOUT_SEL_MASK

#define MAX22007_TIMEOUT_SEL_MASK   NO_OS_GENMASK(7, 4)

Enumeration Type Documentation

◆ max22007_channel_mode

Enumerator
MAX22007_VOLTAGE_MODE 
MAX22007_CURRENT_MODE 

◆ max22007_channel_power

Enumerator
MAX22007_CH_POWER_OFF 
MAX22007_CH_POWER_ON 

◆ max22007_dac_latch_mode

Enumerator
LDAC_CONTROL 
TRANSPARENT_LATCH 

◆ max22007_ref_mode

Enumerator
INTERNAL_REF 
EXTERNAL_REF 

◆ max22007_timeout_cnfg

Enumerator
TIMEOUT_EVENT_ONLY 
TIMEOUT_RESET 

◆ max22007_timeout_sel

Enumerator
MAX22007_TIMEOUT_100MS 
MAX22007_TIMEOUT_200MS 
MAX22007_TIMEOUT_300MS 
MAX22007_TIMEOUT_400MS 
MAX22007_TIMEOUT_500MS 
MAX22007_TIMEOUT_600MS 
MAX22007_TIMEOUT_700MS 
MAX22007_TIMEOUT_800MS 
MAX22007_TIMEOUT_900MS 
MAX22007_TIMEOUT_1000MS 
MAX22007_TIMEOUT_1100MS 
MAX22007_TIMEOUT_1200MS 
MAX22007_TIMEOUT_1300MS 
MAX22007_TIMEOUT_1400MS 
MAX22007_TIMEOUT_1500MS 
MAX22007_TIMEOUT_1600MS 

Function Documentation

◆ max22007_configure_crc()

int max22007_configure_crc ( struct max22007_dev * dev,
bool crc_en )

Configure CRC.

Parameters
dev- MAX22007 device descriptor.
crc_en- CRC enable/disable.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_get_channel_mode()

int max22007_get_channel_mode ( struct max22007_dev * dev,
uint8_t ch,
enum max22007_channel_mode * mode )

Get channel mode.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number.
mode- Channel mode.
Returns
0 in case of success, negative error code otherwise.

◆ max22007_get_channel_power()

int max22007_get_channel_power ( struct max22007_dev * dev,
uint8_t ch,
enum max22007_channel_power * mode )

Get channel power.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number.
mode- Power mode.
Returns
0 in case of success, negative error code otherwise.

◆ max22007_get_latch_mode()

int max22007_get_latch_mode ( struct max22007_dev * dev,
uint8_t ch,
enum max22007_dac_latch_mode * mode )

Get DAC latch mode.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number.
mode- Latch mode.
Returns
0 in case of success, negative error code otherwise.

◆ max22007_get_reference()

int max22007_get_reference ( struct max22007_dev * dev,
enum max22007_ref_mode * mode )

Get reference source.

Parameters
dev- MAX22007 device descriptor.
mode- Reference mode.
Returns
0 in case of success, negative error code otherwise.

◆ max22007_init()

int max22007_init ( struct max22007_dev ** device,
struct max22007_init_param init_param )

MAX22007 descriptor initialization function.

Parameters
device- MAX22007 device descriptor.
init_param- Initialization parameter containing data about the device descriptor to be initialized.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_read_channel_data()

int max22007_read_channel_data ( struct max22007_dev * dev,
uint8_t ch,
uint16_t * data )

Read data from a DAC channel data register.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number (0-3).
data- Pointer to store the 16-bit data read from the channel.
Returns
0 in case of success, negative error code otherwise.

◆ max22007_reg_read()

int max22007_reg_read ( struct max22007_dev * dev,
uint8_t reg_addr,
uint16_t * reg_data )

Read from a register.

Parameters
dev- MAX22007 device descriptor.
reg_addr- Register address.
reg_data- Register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_reg_write()

int max22007_reg_write ( struct max22007_dev * dev,
uint8_t reg_addr,
uint16_t reg_data )

Write to a register.

Parameters
dev- MAX22007 device descriptor.
reg_addr- Register address.
reg_data- Register data.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_reg_write_msk()

int max22007_reg_write_msk ( struct max22007_dev * dev,
uint8_t reg_addr,
uint16_t data,
uint16_t mask )

Register write with mask.

Parameters
dev- MAX22007 device descriptor.
reg_addr- Register address.
data- Register data.
mask- Register mask.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_remove()

int max22007_remove ( struct max22007_dev * dev)

Deallocates all the resources used at initialization.

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

◆ max22007_set_channel_mode()

int max22007_set_channel_mode ( struct max22007_dev * dev,
uint8_t ch,
enum max22007_channel_mode mode )

Set channel mode.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number.
mode- Channel mode.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_set_channel_power()

int max22007_set_channel_power ( struct max22007_dev * dev,
uint8_t ch,
enum max22007_channel_power mode )

Set channel power.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number.
mode- Power mode.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_set_latch_mode()

int max22007_set_latch_mode ( struct max22007_dev * dev,
uint8_t ch,
enum max22007_dac_latch_mode mode )

Set DAC latch mode.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number.
mode- Latch mode.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_set_reference()

int max22007_set_reference ( struct max22007_dev * dev,
enum max22007_ref_mode mode )

Set reference source.

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

◆ max22007_set_timeout()

int max22007_set_timeout ( struct max22007_dev * dev,
bool timeout_en,
enum max22007_timeout_sel timeout_sel,
enum max22007_timeout_cnfg timeout_cnfg )

Set timeout configuration.

Parameters
dev- MAX22007 device descriptor.
timeout_en- Timeout enable/disable.
timeout_sel- Timeout selection.
timeout_cnfg- Timeout configuration.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_write_channel_data()

int max22007_write_channel_data ( struct max22007_dev * dev,
uint8_t ch,
uint16_t data )

Write data to a DAC channel data register.

Parameters
dev- MAX22007 device descriptor.
ch- Channel number (0-3).
data- 16-bit data to write to the channel.
Returns
0 in case of success, negative error code otherwise.
Here is the caller graph for this function:

◆ max22007_write_ldac()

int max22007_write_ldac ( struct max22007_dev * dev,
uint8_t ch_mask )

Write to LDAC register to update DAC output.

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