no-OS
Functions | Variables
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. More...
 
int32_t max22017_gpio_remove (struct no_os_gpio_desc *desc)
 Free the resources allocated by no_os_gpio_get(). More...
 
int32_t max22017_gpio_direction_input (struct no_os_gpio_desc *desc)
 Enable the input direction of the specified GPIO. More...
 
int32_t max22017_gpio_direction_output (struct no_os_gpio_desc *desc, uint8_t value)
 Enable the output direction of the specified GPIO. More...
 
int32_t max22017_gpio_get_direction (struct no_os_gpio_desc *desc, uint8_t *direction)
 Get the direction of the specified GPIO. More...
 
int32_t max22017_gpio_set_value (struct no_os_gpio_desc *desc, uint8_t value)
 Set the value of the specified GPIO. More...
 
int32_t max22017_gpio_get_value (struct no_os_gpio_desc *desc, uint8_t *value)
 Get the value of the specified GPIO. More...
 
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. More...
 
int max22017_set_data (struct max22017_desc *desc, enum max22017_channel ch, int32_t data)
 Set data of the selected channel. More...
 
int max22017_get_data (struct max22017_desc *desc, enum max22017_channel ch, int32_t *data)
 Get data from requestec channel. More...
 
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. More...
 
int max22017_offset_calib (struct max22017_desc *desc, enum max22017_channel ch, int16_t offset)
 Set offset value for output calibration. More...
 
int max22017_gain_calib (struct max22017_desc *desc, enum max22017_channel ch, uint16_t gain)
 Set gain value for calibration of requested channel. More...
 
int max22017_op_mode (struct max22017_desc *desc, enum max22017_channel ch, enum max22017_op_mode op_mode)
 Set operation mode for requested channel. More...
 
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. More...
 
int max22017_soft_reset (struct max22017_desc *desc, enum max22017_channel ch, bool coeff_only)
 Soft reset requested channel. More...
 
int max22017_reg_read (struct max22017_desc *desc, uint32_t addr, uint32_t *val)
 Read the value of a device register. More...
 
int max22017_reg_write (struct max22017_desc *desc, uint32_t addr, uint32_t val)
 Write the value of a device register. More...
 
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). More...
 
int max22017_init (struct max22017_desc **desc, struct max22017_init_param *param)
 Initialize and configure the MAX22017 device. More...
 
int max22017_remove (struct max22017_desc *desc)
 Free the resources allocated during init and perform a soft reset. More...
 

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.

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.

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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
Here is the caller graph for this function:

◆ 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
}
max22017_gpio_direction_input
int32_t max22017_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: max22017.c:118
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.
Definition: max22017.c:200
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.
Definition: max22017.c:140
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.
Definition: max22017.c:221
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.
Definition: max22017.c:49
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.
Definition: max22017.c:170
max22017_gpio_remove
int32_t max22017_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: max22017.c:92