no-OS
|
Header file of MAX2201X Driver. More...
#include <stdint.h>
#include <stdbool.h>
#include "no_os_gpio.h"
#include "no_os_spi.h"
#include "no_os_util.h"
Go to the source code of this file.
Classes | |
struct | max2201x_gpio_init_param |
Structure holding the GPIO initialization parameter for the MAX2201X GPIO Controller. More... | |
struct | max2201x_init_param |
Structure holding the MAX2201X initialization parameter. More... | |
struct | max2201x_desc |
Structure holding the MAX2201X device descriptor. More... | |
Functions | |
int32_t | max2201x_gpio_get (struct no_os_gpio_desc **, const struct no_os_gpio_init_param *) |
Obtain the GPIO decriptor. More... | |
int32_t | max2201x_gpio_remove (struct no_os_gpio_desc *) |
Free the resources allocated by no_os_gpio_get(). More... | |
int32_t | max2201x_gpio_direction_input (struct no_os_gpio_desc *) |
Enable the input direction of the specified GPIO. More... | |
int32_t | max2201x_gpio_direction_output (struct no_os_gpio_desc *, uint8_t) |
Enable the output direction of the specified GPIO. More... | |
int32_t | max2201x_gpio_get_direction (struct no_os_gpio_desc *, uint8_t *) |
Get the direction of the specified GPIO. More... | |
int32_t | max2201x_gpio_set_value (struct no_os_gpio_desc *, uint8_t) |
Set the value of the specified GPIO. More... | |
int32_t | max2201x_gpio_get_value (struct no_os_gpio_desc *, uint8_t *) |
Get the value of the specified GPIO. More... | |
int | max2201x_set_timeout (struct max2201x_desc *, bool, bool, enum max2201x_timeout_sel) |
Set timeout settings for MAX2201X device. More... | |
int | max2201x_set_data (struct max2201x_desc *, enum max2201x_channel, int32_t) |
Set data of the selected channel. More... | |
int | max2201x_get_data (struct max2201x_desc *, enum max2201x_channel, int32_t *) |
Get data from requestec channel. More... | |
int | max2201x_slew_rate (struct max2201x_desc *, enum max2201x_channel, enum max2201x_sr_step_size, enum max2201x_sr_update_rate, bool, bool) |
Set slew rate settings for requested channels. More... | |
int | max2201x_offset_calib (struct max2201x_desc *, enum max2201x_channel, int16_t) |
Set offset value for output calibration. More... | |
int | max2201x_gain_calib (struct max2201x_desc *, enum max2201x_channel, uint16_t) |
Set gain value for calibration of requested channel. More... | |
int | max2201x_op_mode (struct max2201x_desc *, enum max2201x_channel, enum max2201x_op_mode) |
Set operation mode for requested channel. More... | |
int | max2201x_config (struct max2201x_desc *, enum max2201x_channel, enum max2201x_out_mode, enum max2201x_cm_sense, bool) |
Set AO configuration. More... | |
int | max2201x_soft_reset (struct max2201x_desc *, enum max2201x_channel, bool) |
Soft reset requested channel. More... | |
int | max2201x_reg_read (struct max2201x_desc *, uint32_t, uint32_t *) |
Read the value of a device register. More... | |
int | max2201x_reg_write (struct max2201x_desc *, uint32_t, uint32_t) |
Write the value of a device register. More... | |
int | max2201x_reg_update (struct max2201x_desc *, uint32_t, uint32_t, uint32_t) |
Update the value of a device register (read/write sequence). More... | |
int | max2201x_init (struct max2201x_desc **, struct max2201x_init_param *) |
Initialize and configure the MAX2201X device. More... | |
int | max2201x_remove (struct max2201x_desc *) |
Free the resources allocated during init and perform a soft reset. More... | |
Variables | |
const struct no_os_gpio_platform_ops | max2201x_gpio_ops |
Header file of MAX2201X Driver.
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.
#define MAX2201X_ADRR_MASK NO_OS_GENMASK(7, 1) |
#define MAX2201X_AI_EN_MASK | ( | x | ) | NO_OS_BIT(2 + (x)) |
#define MAX2201X_AI_EN_MODE_MASK NO_OS_BIT(1) |
#define MAX2201X_AO_CMD 0x40 |
#define MAX2201X_AO_CNFG 0x42 |
#define MAX2201X_AO_DATA_CH1 0x45 |
#define MAX2201X_AO_DATA_CH2 0x46 |
#define MAX2201X_AO_EN_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX2201X_AO_EN_MODE_MASK NO_OS_BIT(2) |
#define MAX2201X_AO_GAIN_CORR_CH1 0x48 |
#define MAX2201X_AO_GAIN_CORR_CH2 0x4A |
#define MAX2201X_AO_MODE_MASK | ( | x | ) | NO_OS_BIT(8 + (x)) |
#define MAX2201X_AO_MODE_MODE_MASK NO_OS_BIT(0) |
#define MAX2201X_AO_OFFSET_CORR_CH1 0x47 |
#define MAX2201X_AO_OFFSET_CORR_CH2 0x49 |
#define MAX2201X_AO_SLEW_RATE_CH1 0x43 |
#define MAX2201X_AO_SLEW_RATE_CH2 0x44 |
#define MAX2201X_AO_STA 0x41 |
#define MAX2201X_CM_SENSE_MASK | ( | x | ) | NO_OS_BIT(12 + (x)) |
#define MAX2201X_CNFG_MASK | ( | x | ) | (NO_OS_BIT(14 + (x)) | NO_OS_BIT(12 + (x)) | NO_OS_BIT(10 + (x)) | NO_OS_BIT(4 + (x))) |
#define MAX2201X_COEFF_ONLY_MASK NO_OS_GENMASK(15, 14) |
#define MAX2201X_COEFF_ONLY_VAL 0x03 |
#define MAX2201X_CRC_MASK NO_OS_BIT(1) |
#define MAX2201X_EXT_DAC_REF_MASK NO_OS_BIT(0) |
#define MAX2201X_EXTRA_GPIO_NUMBER 2 |
#define MAX2201X_FRAME_SIZE 3 |
#define MAX2201X_GEN_CNFG 0x03 |
#define MAX2201X_GEN_GPI_INT 0x06 |
#define MAX2201X_GEN_GPI_INT_STA 0x07 |
#define MAX2201X_GEN_GPIO_CTRL 0x04 |
#define MAX2201X_GEN_GPIO_DATA 0x05 |
#define MAX2201X_GEN_ID 0x00 |
#define MAX2201X_GEN_INT 0x08 |
#define MAX2201X_GEN_INTEN 0x09 |
#define MAX2201X_GEN_RST_CTRL 0x0A |
#define MAX2201X_GEN_SERIAL_LSB 0x02 |
#define MAX2201X_GEN_SERIAL_MSB 0x01 |
#define MAX2201X_GPIO_DIR_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX2201X_GPIO_IN_VAL_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX2201X_GPIO_MASK | ( | x | ) | NO_OS_BIT(8 + (x)) |
#define MAX2201X_GPIO_NUMBER 4 |
#define MAX2201X_GPIO_OUT_VAL_MASK | ( | x | ) | NO_OS_BIT(8 + (x)) |
#define MAX2201X_LD_CNFG_MASK | ( | x | ) | NO_OS_BIT(14 + (x)) |
#define MAX2201X_OW_MASK | ( | x | ) | NO_OS_BIT(4 + (x)) |
#define MAX2201X_PAYLOAD_LSB_MASK NO_OS_GENMASK(7, 0) |
#define MAX2201X_PAYLOAD_MSB_MASK NO_OS_GENMASK(15, 8) |
#define MAX2201X_RST_MASK | ( | x | ) | NO_OS_BIT(14 + (x)) |
#define MAX2201X_RW_MASK NO_OS_BIT(0) |
#define MAX2201X_SR_EN_MASK NO_OS_BIT(5) |
#define MAX2201X_SR_SEL_MASK NO_OS_BIT(4) |
#define MAX2201X_SR_STEP_SIZE_MASK NO_OS_GENMASK(3, 2) |
#define MAX2201X_SR_UPDATE_RATE_MASK NO_OS_GENMASK(1, 0) |
#define MAX2201X_TIMEOUT_CNFG_MASK NO_OS_BIT(9) |
#define MAX2201X_TIMEOUT_EN_MASK NO_OS_BIT(8) |
#define MAX2201X_TIMEOUT_MASK NO_OS_GENMASK(13, 8) |
#define MAX2201X_TIMEOUT_SEL_MASK NO_OS_GENMASK(13, 10) |
#define MAX2201X_UNI_MASK | ( | x | ) | NO_OS_BIT(10 + (x)) |
enum max2201x_channel |
enum max2201x_cm_sense |
enum max2201x_op_mode |
enum max2201x_out_mode |
enum max2201x_timeout_sel |
enum max2201x_type |
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.
Set AO configuration settings for specific channel.
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. |
int max2201x_gain_calib | ( | struct max2201x_desc * | desc, |
enum max2201x_channel | ch, | ||
uint16_t | gain | ||
) |
Set gain value for calibration of requested channel.
Adjust the gain of a specific channel.
desc | - MAX2201X device descriptor |
ch | - Selected channel |
gain | - Gain value |
int max2201x_get_data | ( | struct max2201x_desc * | desc, |
enum max2201x_channel | ch, | ||
int32_t * | data | ||
) |
Get data from requestec channel.
Get data from specific channel.
desc | - MAX2201X device descriptor |
ch | - Selected channel |
data | - Received data from channel |
int32_t max2201x_gpio_direction_input | ( | struct no_os_gpio_desc * | desc | ) |
Enable the input direction of the specified GPIO.
Set GPIO direction as input.
desc | - The GPIO descriptor. |
int32_t max2201x_gpio_direction_output | ( | struct no_os_gpio_desc * | desc, |
uint8_t | value | ||
) |
Enable the output direction of the specified GPIO.
Set GPIO direction as output.
desc | - The GPIO descriptor. |
value | - The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW |
int32_t max2201x_gpio_get | ( | struct no_os_gpio_desc ** | desc, |
const struct no_os_gpio_init_param * | param | ||
) |
Obtain the GPIO decriptor.
Get GPIO descriptor for MAX2201X.
desc | - The GPIO descriptor. |
param | - GPIO initialization parameters |
int32_t max2201x_gpio_get_direction | ( | struct no_os_gpio_desc * | desc, |
uint8_t * | direction | ||
) |
Get the direction of the specified GPIO.
Get GPIO direction for MAX2201X.
desc | - The GPIO descriptor. |
direction | - The direction. Example: NO_OS_GPIO_OUT NO_OS_GPIO_IN |
int32_t max2201x_gpio_get_value | ( | struct no_os_gpio_desc * | desc, |
uint8_t * | value | ||
) |
Get the value of the specified GPIO.
Get GPIO value for MAX2201x.
desc | - The GPIO descriptor. |
value | - The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW |
int32_t max2201x_gpio_remove | ( | struct no_os_gpio_desc * | desc | ) |
Free the resources allocated by no_os_gpio_get().
Free the resources allocated by no_os_gpio_get().
desc | - The GPIO descriptor. |
int32_t max2201x_gpio_set_value | ( | struct no_os_gpio_desc * | desc, |
uint8_t | value | ||
) |
Set the value of the specified GPIO.
Set GPIO value for MAX2201X.
desc | - The GPIO descriptor. |
value | - The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW |
int max2201x_init | ( | struct max2201x_desc ** | desc, |
struct max2201x_init_param * | param | ||
) |
Initialize and configure the MAX2201X device.
Initialize the MAX2201X device descriptor.
desc | - device descriptor for the MAX2201X that will be initialized. |
param | - initialization parameter for the device. |
int max2201x_offset_calib | ( | struct max2201x_desc * | desc, |
enum max2201x_channel | ch, | ||
int16_t | offset | ||
) |
Set offset value for output calibration.
Calibrate the offset of a specific channel.
desc | - MAX2201X device descriptor |
ch | - Selected channel |
offset | - Offset value |
int max2201x_op_mode | ( | struct max2201x_desc * | desc, |
enum max2201x_channel | ch, | ||
enum max2201x_op_mode | op_mode | ||
) |
Set operation mode for requested channel.
Set operation mode for specific channel.
desc | - MAX2201X device descriptor |
ch | - Selected channel |
op_mode | - Operation mode |
int max2201x_reg_read | ( | struct max2201x_desc * | desc, |
uint32_t | addr, | ||
uint32_t * | val | ||
) |
Read the value of a device register.
Read register value from the MAX2201X.
desc | - device descriptor for the MAX2201X |
addr | - address of the register |
val | - value of the register |
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).
Update the value of a register from the MAX2201X.
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) |
int max2201x_reg_write | ( | struct max2201x_desc * | desc, |
uint32_t | addr, | ||
uint32_t | val | ||
) |
Write the value of a device register.
Write to a register from MAX2201X.
desc | - device descriptor for the MAX2201X |
addr | - address of the register |
val | - value of the register |
int max2201x_remove | ( | struct max2201x_desc * | desc | ) |
Free the resources allocated during init and perform a soft reset.
Free resources allocated by the init() function.
desc | - device descriptor for the MAX2201X that will be initialized. |
int max2201x_set_data | ( | struct max2201x_desc * | desc, |
enum max2201x_channel | ch, | ||
int32_t | data | ||
) |
Set data of the selected channel.
Set data for specific channel.
desc | - MAX2201X device descriptor |
ch | - Selected channel |
data | - Data to be set. |
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.
Set timeout settings.
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 |
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.
Set slew rate settings for specific channel.
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 |
int max2201x_soft_reset | ( | struct max2201x_desc * | desc, |
enum max2201x_channel | ch, | ||
bool | coeff_only | ||
) |
Soft reset requested channel.
Soft-reset the MAX2201X.
desc | - MAX2201X device descriptor |
ch | - Selected channel |
coeff_only | - Coefficient only reset enable/disable |
const struct no_os_gpio_platform_ops max2201x_gpio_ops |