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

Source file of MAX22007 Driver. More...

#include "no_os_print_log.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_crc8.h"
#include "no_os_spi.h"
#include "max22007.h"
#include <string.h>
Include dependency graph for max22007.c:

Macros

#define MAX22007_CRC8_POLYNOMIAL   0x8C
 

Functions

 NO_OS_DECLARE_CRC8_TABLE (max22007_crc8_table)
 
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_get_timeout (struct max22007_dev *dev, bool *timeout_en, enum max22007_timeout_sel *timeout_sel, enum max22007_timeout_cnfg *timeout_cnfg)
 Get 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_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_write_ldac (struct max22007_dev *dev, uint8_t ch_mask)
 Write to LDAC register to update DAC output.
 
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

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

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ MAX22007_CRC8_POLYNOMIAL

#define MAX22007_CRC8_POLYNOMIAL   0x8C

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.

◆ 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_get_timeout()

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

Get timeout configuration.

Parameters
dev- MAX22007 device descriptor.
timeout_en- Timeout Enable.
timeout_sel- Timeout Selection.
timeout_cnfg- Timeout Configuration.
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.

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

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

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

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

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

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

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

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

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

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

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

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( max22007_crc8_table )