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

Source file of MAX22017 Driver. More...

#include <stdlib.h>
#include <string.h>
#include "max22017.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 max22017.c:

Functions

 NO_OS_DECLARE_CRC8_TABLE (table)
 
int32_t max22017_gpio_get (struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
 Obtain the GPIO decriptor.
 
int32_t max22017_gpio_remove (struct no_os_gpio_desc *desc)
 Free the resources allocated by no_os_gpio_get().
 
int32_t max22017_gpio_direction_input (struct no_os_gpio_desc *desc)
 Enable the input direction of the specified GPIO.
 
int32_t max22017_gpio_direction_output (struct no_os_gpio_desc *desc, uint8_t value)
 Enable the output direction of the specified GPIO.
 
int32_t max22017_gpio_get_direction (struct no_os_gpio_desc *desc, uint8_t *direction)
 Get the direction of the specified GPIO.
 
int32_t max22017_gpio_set_value (struct no_os_gpio_desc *desc, uint8_t value)
 Set the value of the specified GPIO.
 
int32_t max22017_gpio_get_value (struct no_os_gpio_desc *desc, uint8_t *value)
 Get the value of the specified GPIO.
 
int max22017_set_timeout (struct max22017_desc *desc, bool timeout_cnfg, bool timeout_en, enum max22017_timeout_sel timeout)
 Set timeout settings for MAX22017 device.
 
int max22017_set_data (struct max22017_desc *desc, enum max22017_channel ch, int32_t data)
 Set data of the selected channel.
 
int max22017_get_data (struct max22017_desc *desc, enum max22017_channel ch, int32_t *data)
 Get data from requestec channel.
 
int max22017_slew_rate (struct max22017_desc *desc, enum max22017_channel ch, enum max22017_sr_step_size step_size, enum max22017_sr_update_rate update_rate, bool enable, bool hart)
 Set slew rate settings for requested channels.
 
int max22017_offset_calib (struct max22017_desc *desc, enum max22017_channel ch, int16_t offset)
 Set offset value for output calibration.
 
int max22017_gain_calib (struct max22017_desc *desc, enum max22017_channel ch, uint16_t gain)
 Set gain value for calibration of requested channel.
 
int max22017_op_mode (struct max22017_desc *desc, enum max22017_channel ch, enum max22017_op_mode op_mode)
 Set operation mode for requested channel.
 
int max22017_config (struct max22017_desc *desc, enum max22017_channel ch, enum max22017_out_mode uni, enum max22017_cm_sense cm_sense, bool ldac)
 Set AO configuration.
 
int max22017_soft_reset (struct max22017_desc *desc, enum max22017_channel ch, bool coeff_only)
 Soft reset requested channel.
 
int max22017_reg_read (struct max22017_desc *desc, uint32_t addr, uint32_t *val)
 Read the value of a device register.
 
int max22017_reg_write (struct max22017_desc *desc, uint32_t addr, uint32_t val)
 Write the value of a device register.
 
int max22017_reg_update (struct max22017_desc *desc, uint32_t addr, uint32_t mask, uint32_t val)
 Update the value of a device register (read/write sequence).
 
int max22017_init (struct max22017_desc **desc, struct max22017_init_param *param)
 Initialize and configure the MAX22017 device.
 
int max22017_remove (struct max22017_desc *desc)
 Free the resources allocated during init and perform a soft reset.
 

Variables

const struct no_os_gpio_platform_ops max22017_gpio_ops
 

Detailed Description

Source file of MAX22017 Driver.

Author
Radu Sabau (radu..nosp@m.saba.nosp@m.u@ana.nosp@m.log..nosp@m.com)

Copyright 2024(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ max22017_config()

int max22017_config ( struct max22017_desc * desc,
enum max22017_channel ch,
enum max22017_out_mode uni,
enum max22017_cm_sense cm_sense,
bool ldac )

Set AO configuration.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
uni- Polarity type : false - bipolar true - unipolar
cm_sense- CM sense resistor value, affects OW value as well
ldac- Enable/Disable LDAC function, takes effect only if LDAC GPIO is set with load_control API.
Returns
0 in case of succes, negative error code otherwise

◆ max22017_gain_calib()

int max22017_gain_calib ( struct max22017_desc * desc,
enum max22017_channel ch,
uint16_t gain )

Set gain value for calibration of requested channel.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
gain- Gain value
Returns
0 in case of succes, negative error code otherwise

◆ max22017_get_data()

int max22017_get_data ( struct max22017_desc * desc,
enum max22017_channel ch,
int32_t * data )

Get data from requestec channel.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
data- Received data from channel
Returns
0 in case of succes, negative error code otherwise

◆ max22017_gpio_direction_input()

int32_t max22017_gpio_direction_input ( struct no_os_gpio_desc * desc)

Enable the input direction of the specified GPIO.

Parameters
desc- The GPIO descriptor.
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_gpio_direction_output()

int32_t max22017_gpio_direction_output ( struct no_os_gpio_desc * desc,
uint8_t value )

Enable the output direction of the specified GPIO.

Parameters
desc- The GPIO descriptor.
value- The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_gpio_get()

int32_t max22017_gpio_get ( struct no_os_gpio_desc ** desc,
const struct no_os_gpio_init_param * param )

Obtain the GPIO decriptor.

Parameters
desc- The GPIO descriptor.
param- GPIO initialization parameters
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_gpio_get_direction()

int32_t max22017_gpio_get_direction ( struct no_os_gpio_desc * desc,
uint8_t * direction )

Get the direction of the specified GPIO.

Parameters
desc- The GPIO descriptor.
direction- The direction. Example: NO_OS_GPIO_OUT NO_OS_GPIO_IN
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_gpio_get_value()

int32_t max22017_gpio_get_value ( struct no_os_gpio_desc * desc,
uint8_t * value )

Get the value of the specified GPIO.

Parameters
desc- The GPIO descriptor.
value- The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_gpio_remove()

int32_t max22017_gpio_remove ( struct no_os_gpio_desc * desc)

Free the resources allocated by no_os_gpio_get().

Parameters
desc- The GPIO descriptor.
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_gpio_set_value()

int32_t max22017_gpio_set_value ( struct no_os_gpio_desc * desc,
uint8_t value )

Set the value of the specified GPIO.

Parameters
desc- The GPIO descriptor.
value- The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW
Returns
0 in case of success, errno error codes otherwise.

◆ max22017_init()

int max22017_init ( struct max22017_desc ** desc,
struct max22017_init_param * param )

Initialize and configure the MAX22017 device.

Parameters
desc- device descriptor for the MAX22017 that will be initialized.
param- initialization parameter for the device.
Returns
0 in case of success, negative error code otherwise

◆ max22017_offset_calib()

int max22017_offset_calib ( struct max22017_desc * desc,
enum max22017_channel ch,
int16_t offset )

Set offset value for output calibration.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
offset- Offset value
Returns
0 in case of succes, negative error code otherwise

◆ max22017_op_mode()

int max22017_op_mode ( struct max22017_desc * desc,
enum max22017_channel ch,
enum max22017_op_mode op_mode )

Set operation mode for requested channel.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
op_mode- Operation mode
Returns
0 in case of succes, negative error code otherwise

◆ max22017_reg_read()

int max22017_reg_read ( struct max22017_desc * desc,
uint32_t addr,
uint32_t * val )

Read the value of a device register.

Parameters
desc- device descriptor for the MAX22017
addr- address of the register
val- value of the register
Returns
0 in case of success, negative error code otherwise

◆ max22017_reg_update()

int max22017_reg_update ( struct max22017_desc * desc,
uint32_t addr,
uint32_t mask,
uint32_t val )

Update the value of a device register (read/write sequence).

Parameters
desc- device descriptor for the MAX22017
addr- address of the register
mask- bit mask of the field to be updated
val- value of the masked field. Should be bit shifted by using no_os_field_prep(mask, val)
Returns
0 in case of success, negative error code otherwise

◆ max22017_reg_write()

int max22017_reg_write ( struct max22017_desc * desc,
uint32_t addr,
uint32_t val )

Write the value of a device register.

Parameters
desc- device descriptor for the MAX22017
addr- address of the register
val- value of the register
Returns
0 in case of success, negative error code otherwise

◆ max22017_remove()

int max22017_remove ( struct max22017_desc * desc)

Free the resources allocated during init and perform a soft reset.

Parameters
desc- device descriptor for the MAX22017 that will be initialized.
Returns
0 in case of success, negative error code otherwise

◆ max22017_set_data()

int max22017_set_data ( struct max22017_desc * desc,
enum max22017_channel ch,
int32_t data )

Set data of the selected channel.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
data- Data to be set.
Returns
0 in case of succes, negative error code otherwise

◆ max22017_set_timeout()

int max22017_set_timeout ( struct max22017_desc * desc,
bool timeout_cnfg,
bool timeout_en,
enum max22017_timeout_sel timeout )

Set timeout settings for MAX22017 device.

Parameters
desc- MAX22017 device descriptor
timeout_cnfg- Timeout configuration : false - A timeout will only assert TMOUT_INT bit in Interrupts Register true - A timeout will also reset AO_EN, AI_EN and GPIO_EN pair of bits.
timeout_en- Enable/disable timeout
timeout- Timeout time value
Returns
0 in case of succes, negative error code otherwise

◆ max22017_slew_rate()

int max22017_slew_rate ( struct max22017_desc * desc,
enum max22017_channel ch,
enum max22017_sr_step_size step_size,
enum max22017_sr_update_rate update_rate,
bool enable,
bool hart )

Set slew rate settings for requested channels.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
step_size- Step size value
update_rate- Update rate value
enable- Enable/disable slew rate control
hart- true - Slew rate times for HART applications false - Slew rate times for inductive load applications
Returns
0 in case of succes, negative error code otherwise

◆ max22017_soft_reset()

int max22017_soft_reset ( struct max22017_desc * desc,
enum max22017_channel ch,
bool coeff_only )

Soft reset requested channel.

Parameters
desc- MAX22017 device descriptor
ch- Selected channel
coeff_only- Coefficient only reset enable/disable
Returns
0 in case of succes, negative error code otherwise

◆ NO_OS_DECLARE_CRC8_TABLE()

NO_OS_DECLARE_CRC8_TABLE ( table )

Variable Documentation

◆ max22017_gpio_ops

const struct no_os_gpio_platform_ops max22017_gpio_ops
Initial value:
= {
.gpio_ops_get = &max22017_gpio_get,
.gpio_ops_remove = &max22017_gpio_remove,
.gpio_ops_direction_input = &max22017_gpio_direction_input,
.gpio_ops_direction_output = &max22017_gpio_direction_output,
.gpio_ops_get_direction = &max22017_gpio_get_direction,
.gpio_ops_set_value = &max22017_gpio_set_value,
.gpio_ops_get_value = &max22017_gpio_get_value
}
int32_t max22017_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition max22017.c:95
int32_t max22017_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition max22017.c:117
int32_t max22017_gpio_get_direction(struct no_os_gpio_desc *desc, uint8_t *direction)
Get the direction of the specified GPIO.
Definition max22017.c:147
int32_t max22017_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition max22017.c:177
int32_t max22017_gpio_get_value(struct no_os_gpio_desc *desc, uint8_t *value)
Get the value of the specified GPIO.
Definition max22017.c:198
int32_t max22017_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition max22017.c:69
int32_t max22017_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition max22017.c:26