no-OS
|
Header file of MAX22017 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 | max22017_gpio_init_param |
Structure holding the GPIO initialization parameter for the MAX22017 GPIO Controller. More... | |
struct | max22017_init_param |
Structure holding the MAX22017 initialization parameter. More... | |
struct | max22017_desc |
Structure holding the MAX22017 device descriptor. More... | |
Functions | |
int32_t | max22017_gpio_get (struct no_os_gpio_desc **, const struct no_os_gpio_init_param *) |
Obtain the GPIO decriptor. More... | |
int32_t | max22017_gpio_remove (struct no_os_gpio_desc *) |
Free the resources allocated by no_os_gpio_get(). More... | |
int32_t | max22017_gpio_direction_input (struct no_os_gpio_desc *) |
Enable the input direction of the specified GPIO. More... | |
int32_t | max22017_gpio_direction_output (struct no_os_gpio_desc *, uint8_t) |
Enable the output direction of the specified GPIO. More... | |
int32_t | max22017_gpio_get_direction (struct no_os_gpio_desc *, uint8_t *) |
Get the direction of the specified GPIO. More... | |
int32_t | max22017_gpio_set_value (struct no_os_gpio_desc *, uint8_t) |
Set the value of the specified GPIO. More... | |
int32_t | max22017_gpio_get_value (struct no_os_gpio_desc *, uint8_t *) |
Get the value of the specified GPIO. More... | |
int | max22017_set_timeout (struct max22017_desc *, bool, bool, enum max22017_timeout_sel) |
Set timeout settings for MAX22017 device. More... | |
int | max22017_set_data (struct max22017_desc *, enum max22017_channel, int32_t) |
Set data of the selected channel. More... | |
int | max22017_get_data (struct max22017_desc *, enum max22017_channel, int32_t *) |
Get data from requestec channel. More... | |
int | max22017_slew_rate (struct max22017_desc *, enum max22017_channel, enum max22017_sr_step_size, enum max22017_sr_update_rate, bool, bool) |
Set slew rate settings for requested channels. More... | |
int | max22017_offset_calib (struct max22017_desc *, enum max22017_channel, int16_t) |
Set offset value for output calibration. More... | |
int | max22017_gain_calib (struct max22017_desc *, enum max22017_channel, uint16_t) |
Set gain value for calibration of requested channel. More... | |
int | max22017_op_mode (struct max22017_desc *, enum max22017_channel, enum max22017_op_mode) |
Set operation mode for requested channel. More... | |
int | max22017_config (struct max22017_desc *, enum max22017_channel, enum max22017_out_mode, enum max22017_cm_sense, bool) |
Set AO configuration. More... | |
int | max22017_soft_reset (struct max22017_desc *, enum max22017_channel, bool) |
Soft reset requested channel. More... | |
int | max22017_reg_read (struct max22017_desc *, uint32_t, uint32_t *) |
Read the value of a device register. More... | |
int | max22017_reg_write (struct max22017_desc *, uint32_t, uint32_t) |
Write the value of a device register. More... | |
int | max22017_reg_update (struct max22017_desc *, uint32_t, uint32_t, uint32_t) |
Update the value of a device register (read/write sequence). More... | |
int | max22017_init (struct max22017_desc **, struct max22017_init_param *) |
Initialize and configure the MAX22017 device. More... | |
int | max22017_remove (struct max22017_desc *) |
Free the resources allocated during init and perform a soft reset. More... | |
Variables | |
const struct no_os_gpio_platform_ops | max22017_gpio_ops |
Header file of MAX22017 Driver.
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:
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.
#define MAX22017_ADRR_MASK NO_OS_GENMASK(7, 1) |
#define MAX22017_AI_EN_MASK | ( | x | ) | NO_OS_BIT(2 + (x)) |
#define MAX22017_AI_EN_MODE_MASK NO_OS_BIT(1) |
#define MAX22017_AO_CMD 0x40 |
#define MAX22017_AO_CNFG 0x42 |
#define MAX22017_AO_DATA_CH1 0x45 |
#define MAX22017_AO_DATA_CH2 0x46 |
#define MAX22017_AO_EN_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22017_AO_EN_MODE_MASK NO_OS_BIT(2) |
#define MAX22017_AO_GAIN_CORR_CH1 0x48 |
#define MAX22017_AO_GAIN_CORR_CH2 0x4A |
#define MAX22017_AO_MODE_MASK | ( | x | ) | NO_OS_BIT(8 + (x)) |
#define MAX22017_AO_MODE_MODE_MASK NO_OS_BIT(0) |
#define MAX22017_AO_OFFSET_CORR_CH1 0x47 |
#define MAX22017_AO_OFFSET_CORR_CH2 0x49 |
#define MAX22017_AO_SLEW_RATE_CH1 0x43 |
#define MAX22017_AO_SLEW_RATE_CH2 0x44 |
#define MAX22017_AO_STA 0x41 |
#define MAX22017_CM_SENSE_MASK | ( | x | ) | NO_OS_BIT(12 + (x)) |
#define MAX22017_CNFG_MASK | ( | x | ) | (NO_OS_BIT(14 + (x)) | NO_OS_BIT(12 + (x)) | NO_OS_BIT(10 + (x)) | NO_OS_BIT(4 + (x))) |
#define MAX22017_COEFF_ONLY_MASK NO_OS_GENMASK(15, 14) |
#define MAX22017_COEFF_ONLY_VAL 0x03 |
#define MAX22017_CRC_MASK NO_OS_BIT(1) |
#define MAX22017_EXT_DAC_REF_MASK NO_OS_BIT(0) |
#define MAX22017_EXTRA_GPIO_NUMBER 2 |
#define MAX22017_FRAME_SIZE 3 |
#define MAX22017_GEN_CNFG 0x03 |
#define MAX22017_GEN_GPI_INT 0x06 |
#define MAX22017_GEN_GPI_INT_STA 0x07 |
#define MAX22017_GEN_GPIO_CTRL 0x04 |
#define MAX22017_GEN_GPIO_DATA 0x05 |
#define MAX22017_GEN_ID 0x00 |
#define MAX22017_GEN_INT 0x08 |
#define MAX22017_GEN_INTEN 0x09 |
#define MAX22017_GEN_RST_CTRL 0x0A |
#define MAX22017_GEN_SERIAL_LSB 0x02 |
#define MAX22017_GEN_SERIAL_MSB 0x01 |
#define MAX22017_GPIO_DIR_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22017_GPIO_IN_VAL_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22017_GPIO_MASK | ( | x | ) | NO_OS_BIT(8 + (x)) |
#define MAX22017_GPIO_NUMBER 4 |
#define MAX22017_GPIO_OUT_VAL_MASK | ( | x | ) | NO_OS_BIT(8 + (x)) |
#define MAX22017_LD_CNFG_MASK | ( | x | ) | NO_OS_BIT(14 + (x)) |
#define MAX22017_OW_MASK | ( | x | ) | NO_OS_BIT(4 + (x)) |
#define MAX22017_PAYLOAD_LSB_MASK NO_OS_GENMASK(7, 0) |
#define MAX22017_PAYLOAD_MSB_MASK NO_OS_GENMASK(15, 8) |
#define MAX22017_RST_MASK | ( | x | ) | NO_OS_BIT(14 + (x)) |
#define MAX22017_RW_MASK NO_OS_BIT(0) |
#define MAX22017_SR_EN_MASK NO_OS_BIT(5) |
#define MAX22017_SR_SEL_MASK NO_OS_BIT(4) |
#define MAX22017_SR_STEP_SIZE_MASK NO_OS_GENMASK(3, 2) |
#define MAX22017_SR_UPDATE_RATE_MASK NO_OS_GENMASK(1, 0) |
#define MAX22017_TIMEOUT_CNFG_MASK NO_OS_BIT(9) |
#define MAX22017_TIMEOUT_EN_MASK NO_OS_BIT(8) |
#define MAX22017_TIMEOUT_MASK NO_OS_GENMASK(13, 8) |
#define MAX22017_TIMEOUT_SEL_MASK NO_OS_GENMASK(13, 10) |
#define MAX22017_UNI_MASK | ( | x | ) | NO_OS_BIT(10 + (x)) |
enum max22017_channel |
enum max22017_cm_sense |
enum max22017_op_mode |
enum max22017_out_mode |
enum max22017_timeout_sel |
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.
Set AO configuration settings for specific channel.
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. |
int max22017_gain_calib | ( | struct max22017_desc * | desc, |
enum max22017_channel | ch, | ||
uint16_t | gain | ||
) |
Set gain value for calibration of requested channel.
Adjust the gain of a specific channel.
desc | - MAX22017 device descriptor |
ch | - Selected channel |
gain | - Gain value |
int max22017_get_data | ( | struct max22017_desc * | desc, |
enum max22017_channel | ch, | ||
int32_t * | data | ||
) |
Get data from requestec channel.
Get data from specific channel.
desc | - MAX22017 device descriptor |
ch | - Selected channel |
data | - Received data from channel |
int32_t max22017_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 max22017_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 max22017_gpio_get | ( | struct no_os_gpio_desc ** | desc, |
const struct no_os_gpio_init_param * | param | ||
) |
Obtain the GPIO decriptor.
Get GPIO descriptor for MAX22017.
desc | - The GPIO descriptor. |
param | - GPIO initialization parameters |
int32_t max22017_gpio_get_direction | ( | struct no_os_gpio_desc * | desc, |
uint8_t * | direction | ||
) |
Get the direction of the specified GPIO.
Get GPIO direction for MAX22017.
desc | - The GPIO descriptor. |
direction | - The direction. Example: NO_OS_GPIO_OUT NO_OS_GPIO_IN |
int32_t max22017_gpio_get_value | ( | struct no_os_gpio_desc * | desc, |
uint8_t * | value | ||
) |
Get the value of the specified GPIO.
Get GPIO value for MAX22017.
desc | - The GPIO descriptor. |
value | - The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW |
int32_t max22017_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 max22017_gpio_set_value | ( | struct no_os_gpio_desc * | desc, |
uint8_t | value | ||
) |
Set the value of the specified GPIO.
Set GPIO value for MAX22017.
desc | - The GPIO descriptor. |
value | - The value. Example: NO_OS_GPIO_HIGH NO_OS_GPIO_LOW |
int max22017_init | ( | struct max22017_desc ** | desc, |
struct max22017_init_param * | param | ||
) |
Initialize and configure the MAX22017 device.
Initialize the MAX22017 device descriptor.
desc | - device descriptor for the MAX22017 that will be initialized. |
param | - initialization parameter for the device. |
int max22017_offset_calib | ( | struct max22017_desc * | desc, |
enum max22017_channel | ch, | ||
int16_t | offset | ||
) |
Set offset value for output calibration.
Calibrate the offset of a specific channel.
desc | - MAX22017 device descriptor |
ch | - Selected channel |
offset | - Offset value |
int max22017_op_mode | ( | struct max22017_desc * | desc, |
enum max22017_channel | ch, | ||
enum max22017_op_mode | op_mode | ||
) |
Set operation mode for requested channel.
Set operation mode for specific channel.
desc | - MAX22017 device descriptor |
ch | - Selected channel |
op_mode | - Operation mode |
int max22017_reg_read | ( | struct max22017_desc * | desc, |
uint32_t | addr, | ||
uint32_t * | val | ||
) |
Read the value of a device register.
Read register value from the MAX22017.
desc | - device descriptor for the MAX22017 |
addr | - address of the register |
val | - value of the 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).
Update the value of a register from the MAX22017.
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) |
int max22017_reg_write | ( | struct max22017_desc * | desc, |
uint32_t | addr, | ||
uint32_t | val | ||
) |
Write the value of a device register.
Write to a register from MAX22017.
desc | - device descriptor for the MAX22017 |
addr | - address of the register |
val | - value of the register |
int max22017_remove | ( | struct max22017_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 MAX22017 that will be initialized. |
int max22017_set_data | ( | struct max22017_desc * | desc, |
enum max22017_channel | ch, | ||
int32_t | data | ||
) |
Set data of the selected channel.
Set data for specific channel.
desc | - MAX22017 device descriptor |
ch | - Selected channel |
data | - Data to be set. |
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.
Set timeout settings.
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 |
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.
Set slew rate settings for specific channel.
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 |
int max22017_soft_reset | ( | struct max22017_desc * | desc, |
enum max22017_channel | ch, | ||
bool | coeff_only | ||
) |
Soft reset requested channel.
Soft-reset the MAX22017.
desc | - MAX22017 device descriptor |
ch | - Selected channel |
coeff_only | - Coefficient only reset enable/disable |
const struct no_os_gpio_platform_ops max22017_gpio_ops |