no-OS
Functions | Variables
max2201x.c File Reference

Source file of MAX2201X Driver. More...

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

Functions

 NO_OS_DECLARE_CRC8_TABLE (table)
 
int32_t max2201x_gpio_get (struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
 Obtain the GPIO decriptor. More...
 
int32_t max2201x_gpio_remove (struct no_os_gpio_desc *desc)
 Free the resources allocated by no_os_gpio_get(). More...
 
int32_t max2201x_gpio_direction_input (struct no_os_gpio_desc *desc)
 Enable the input direction of the specified GPIO. More...
 
int32_t max2201x_gpio_direction_output (struct no_os_gpio_desc *desc, uint8_t value)
 Enable the output direction of the specified GPIO. More...
 
int32_t max2201x_gpio_get_direction (struct no_os_gpio_desc *desc, uint8_t *direction)
 Get the direction of the specified GPIO. More...
 
int32_t max2201x_gpio_set_value (struct no_os_gpio_desc *desc, uint8_t value)
 Set the value of the specified GPIO. More...
 
int32_t max2201x_gpio_get_value (struct no_os_gpio_desc *desc, uint8_t *value)
 Get the value of the specified GPIO. More...
 
int max2201x_set_timeout (struct max2201x_desc *desc, bool timeout_cnfg, bool timeout_en, enum max2201x_timeout_sel timeout)
 Set timeout settings for MAX2201X device. More...
 
int max2201x_set_data (struct max2201x_desc *desc, enum max2201x_channel ch, int32_t data)
 Set data of the selected channel. More...
 
int max2201x_get_data (struct max2201x_desc *desc, enum max2201x_channel ch, int32_t *data)
 Get data from requestec channel. More...
 
int max2201x_slew_rate (struct max2201x_desc *desc, enum max2201x_channel ch, enum max2201x_sr_step_size step_size, enum max2201x_sr_update_rate update_rate, bool enable, bool hart)
 Set slew rate settings for requested channels. More...
 
int max2201x_offset_calib (struct max2201x_desc *desc, enum max2201x_channel ch, int16_t offset)
 Set offset value for output calibration. More...
 
int max2201x_gain_calib (struct max2201x_desc *desc, enum max2201x_channel ch, uint16_t gain)
 Set gain value for calibration of requested channel. More...
 
int max2201x_op_mode (struct max2201x_desc *desc, enum max2201x_channel ch, enum max2201x_op_mode op_mode)
 Set operation mode for requested channel. More...
 
int max2201x_config (struct max2201x_desc *desc, enum max2201x_channel ch, enum max2201x_out_mode uni, enum max2201x_cm_sense cm_sense, bool ldac)
 Set AO configuration. More...
 
int max2201x_soft_reset (struct max2201x_desc *desc, enum max2201x_channel ch, bool coeff_only)
 Soft reset requested channel. More...
 
int max2201x_reg_read (struct max2201x_desc *desc, uint32_t addr, uint32_t *val)
 Read the value of a device register. More...
 
int max2201x_reg_write (struct max2201x_desc *desc, uint32_t addr, uint32_t val)
 Write the value of a device register. More...
 
int max2201x_reg_update (struct max2201x_desc *desc, uint32_t addr, uint32_t mask, uint32_t val)
 Update the value of a device register (read/write sequence). More...
 
int max2201x_init (struct max2201x_desc **desc, struct max2201x_init_param *param)
 Initialize and configure the MAX2201X device. More...
 
int max2201x_remove (struct max2201x_desc *desc)
 Free the resources allocated during init and perform a soft reset. More...
 

Variables

const struct no_os_gpio_platform_ops max2201x_gpio_ops
 

Detailed Description

Source file of MAX2201X Driver.

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

Copyright 2024(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, 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

◆ max2201x_config()

int max2201x_config ( struct max2201x_desc desc,
enum max2201x_channel  ch,
enum max2201x_out_mode  uni,
enum max2201x_cm_sense  cm_sense,
bool  ldac 
)

Set AO configuration.

Parameters
desc- MAX2201X 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:

◆ max2201x_gain_calib()

int max2201x_gain_calib ( struct max2201x_desc desc,
enum max2201x_channel  ch,
uint16_t  gain 
)

Set gain value for calibration of requested channel.

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

◆ max2201x_get_data()

int max2201x_get_data ( struct max2201x_desc desc,
enum max2201x_channel  ch,
int32_t *  data 
)

Get data from requestec channel.

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

◆ max2201x_gpio_direction_input()

int32_t max2201x_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.

◆ max2201x_gpio_direction_output()

int32_t max2201x_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.

◆ max2201x_gpio_get()

int32_t max2201x_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.

◆ max2201x_gpio_get_direction()

int32_t max2201x_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.

◆ max2201x_gpio_get_value()

int32_t max2201x_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.

◆ max2201x_gpio_remove()

int32_t max2201x_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.

◆ max2201x_gpio_set_value()

int32_t max2201x_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.

◆ max2201x_init()

int max2201x_init ( struct max2201x_desc **  desc,
struct max2201x_init_param param 
)

Initialize and configure the MAX2201X device.

Parameters
desc- device descriptor for the MAX2201X 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:

◆ max2201x_offset_calib()

int max2201x_offset_calib ( struct max2201x_desc desc,
enum max2201x_channel  ch,
int16_t  offset 
)

Set offset value for output calibration.

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

◆ max2201x_op_mode()

int max2201x_op_mode ( struct max2201x_desc desc,
enum max2201x_channel  ch,
enum max2201x_op_mode  op_mode 
)

Set operation mode for requested channel.

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

◆ max2201x_reg_read()

int max2201x_reg_read ( struct max2201x_desc desc,
uint32_t  addr,
uint32_t *  val 
)

Read the value of a device register.

Parameters
desc- device descriptor for the MAX2201X
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:

◆ max2201x_reg_update()

int max2201x_reg_update ( struct max2201x_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 MAX2201X
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:

◆ max2201x_reg_write()

int max2201x_reg_write ( struct max2201x_desc desc,
uint32_t  addr,
uint32_t  val 
)

Write the value of a device register.

Parameters
desc- device descriptor for the MAX2201X
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:

◆ max2201x_remove()

int max2201x_remove ( struct max2201x_desc desc)

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

Parameters
desc- device descriptor for the MAX2201X that will be initialized.
Returns
0 in case of success, negative error code otherwise
Here is the caller graph for this function:

◆ max2201x_set_data()

int max2201x_set_data ( struct max2201x_desc desc,
enum max2201x_channel  ch,
int32_t  data 
)

Set data of the selected channel.

Parameters
desc- MAX2201X 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:

◆ max2201x_set_timeout()

int max2201x_set_timeout ( struct max2201x_desc desc,
bool  timeout_cnfg,
bool  timeout_en,
enum max2201x_timeout_sel  timeout 
)

Set timeout settings for MAX2201X device.

Parameters
desc- MAX2201X 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

◆ max2201x_slew_rate()

int max2201x_slew_rate ( struct max2201x_desc desc,
enum max2201x_channel  ch,
enum max2201x_sr_step_size  step_size,
enum max2201x_sr_update_rate  update_rate,
bool  enable,
bool  hart 
)

Set slew rate settings for requested channels.

Parameters
desc- MAX2201X 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:

◆ max2201x_soft_reset()

int max2201x_soft_reset ( struct max2201x_desc desc,
enum max2201x_channel  ch,
bool  coeff_only 
)

Soft reset requested channel.

Parameters
desc- MAX2201X 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

◆ max2201x_gpio_ops

const struct no_os_gpio_platform_ops max2201x_gpio_ops
Initial value:
= {
.gpio_ops_get = &max2201x_gpio_get,
.gpio_ops_remove = &max2201x_gpio_remove,
.gpio_ops_direction_input = &max2201x_gpio_direction_input,
.gpio_ops_direction_output = &max2201x_gpio_direction_output,
.gpio_ops_get_direction = &max2201x_gpio_get_direction,
.gpio_ops_set_value = &max2201x_gpio_set_value,
.gpio_ops_get_value = &max2201x_gpio_get_value
}
max2201x_gpio_remove
int32_t max2201x_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: max2201x.c:98
max2201x_gpio_direction_output
int32_t max2201x_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: max2201x.c:146
max2201x_gpio_get_value
int32_t max2201x_gpio_get_value(struct no_os_gpio_desc *desc, uint8_t *value)
Get the value of the specified GPIO.
Definition: max2201x.c:227
max2201x_gpio_set_value
int32_t max2201x_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: max2201x.c:206
max2201x_gpio_get_direction
int32_t max2201x_gpio_get_direction(struct no_os_gpio_desc *desc, uint8_t *direction)
Get the direction of the specified GPIO.
Definition: max2201x.c:176
max2201x_gpio_direction_input
int32_t max2201x_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: max2201x.c:124
max2201x_gpio_get
int32_t max2201x_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: max2201x.c:55