no-OS
|
Header file of MAX22196 Driver. More...
#include <stdint.h>
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_util.h"
Go to the source code of this file.
Classes | |
struct | max22196_init_param |
struct | max22196_desc |
Functions | |
int | max22196_reg_write (struct max22196_desc *, uint32_t, uint32_t) |
MAX22196 register write function. More... | |
int | max22196_reg_read (struct max22196_desc *, uint32_t, uint32_t *) |
MAX22196 register read function. More... | |
int | max22196_reg_update (struct max22196_desc *, uint32_t, uint32_t, uint32_t) |
| |
int | max22196_set_mode (struct max22196_desc *, uint32_t, enum max22196_mode) |
| |
int | max22196_chan_cfg (struct max22196_desc *, uint32_t, uint32_t, enum max22196_curr) |
| |
int | max22196_filter_set (struct max22196_desc *, uint32_t, uint32_t, uint32_t, enum max22196_delay) |
| |
int | max22196_filter_get (struct max22196_desc *, uint32_t, uint32_t *, uint32_t *, enum max22196_delay *) |
| |
int | max22196_fault_mask_set (struct max22196_desc *, enum max22196_fault_mask, bool) |
Set fault mask bits in the fault mask registers. More... | |
int | max22196_fault_mask_get (struct max22196_desc *, enum max22196_fault_mask, bool *) |
Get fault mask bits from the fault mask registers. More... | |
int | max22196_global_cfg (struct max22196_desc *, enum max22196_global_cfg, bool) |
Set global configuration. More... | |
int | max22196_set_chan_cnt (struct max22196_desc *, uint32_t, uint16_t) |
| |
int | max22196_get_chan_cnt (struct max22196_desc *, uint32_t, uint16_t *) |
MAX22196 channel counter get function. More... | |
int | max22196_init (struct max22196_desc **, struct max22196_init_param *) |
Initialize and configure the MAX22196 device. More... | |
int | max22196_remove (struct max22196_desc *) |
Free the resources allocated during init. More... | |
Header file of MAX22196 Driver.
Copyright 2023(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 MAX22194_CHANNELS 4 |
#define MAX22196_ADDR_MASK NO_OS_GENMASK(7, 6) |
#define MAX22196_CFG_MASK (NO_OS_BIT(7) | NO_OS_GENMASK(5, 4)) |
#define MAX22196_CFG_REG | ( | x | ) | (0x03 + (x)) |
#define MAX22196_CHANNELS 8 |
#define MAX22196_CHN_CNT_RESET 0 |
#define MAX22196_CNT_BYTE_MASK NO_OS_GENMASK(7, 0) |
#define MAX22196_CNT_LSB_REG | ( | x | ) | (0x10 + 2 * (x)) |
#define MAX22196_CNT_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22196_CNT_MSB_REG | ( | x | ) | (0x11 + 2 * (x)) |
#define MAX22196_CURR_MASK NO_OS_GENMASK(5, 4) |
#define MAX22196_DELAY_MASK NO_OS_GENMASK(2, 0) |
#define MAX22196_DI_STATE_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22196_DI_STATE_REG 0x00 |
#define MAX22196_F1MASK_REG 0x02 |
#define MAX22196_F2MASK_REG 0x0E |
#define MAX22196_FAULT1_REG 0x01 |
#define MAX22196_FAULT2_MASK NO_OS_GENMASK(4, 0) |
#define MAX22196_FAULT2_REG 0x0D |
#define MAX22196_FAULT_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22196_FILTER_CLRFLT_MASK NO_OS_BIT(3) |
#define MAX22196_FLTEN_MASK NO_OS_BIT(3) |
#define MAX22196_FRAME_SIZE 2 |
#define MAX22196_GLOBAL_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22196_GLOBALCFG_REG 0x0B |
#define MAX22196_HITHR_MASK NO_OS_BIT(7) |
#define MAX22196_LED_REG 0x0C |
#define MAX22196_LSB_MASK NO_OS_GENMASK(7, 0) |
#define MAX22196_MSB_MASK NO_OS_GENMASK(15, 8) |
#define MAX22196_REG_ADDR_MASK NO_OS_GENMASK(5, 1) |
#define MAX22196_RW_MASK NO_OS_BIT(0) |
#define MAX22196_SOURCE_MASK NO_OS_BIT(6) |
#define MAX22196_START_STOP_REG 0x0F |
enum max22196_chip_id |
enum max22196_curr |
enum max22196_delay |
enum max22196_fault_mask |
enum max22196_global_cfg |
enum max22196_mode |
int max22196_chan_cfg | ( | struct max22196_desc * | desc, |
uint32_t | ch, | ||
uint32_t | hi_thr, | ||
enum max22196_curr | curr | ||
) |
Set configuration for a specific channel.
desc | - The device descriptor for MAX22196. |
ch | - Channel for which the configuration is to be changed. |
hi_thr | - Voltage threshold(0 for inactive, 1 for active). |
curr | - Channel current to be set. |
int max22196_fault_mask_get | ( | struct max22196_desc * | desc, |
enum max22196_fault_mask | fault_mask, | ||
bool * | enabled | ||
) |
Get fault mask bits from the fault mask registers.
Get fault masks state for requested fault.
desc | - MAX22196 device descriptor. |
fault_mask | - Requested fault to get mask from. |
enabled | - Mask state to be read. |
int max22196_fault_mask_set | ( | struct max22196_desc * | desc, |
enum max22196_fault_mask | fault_mask, | ||
bool | enabled | ||
) |
Set fault mask bits in the fault mask registers.
Set fault masks for requested fault.
desc | - MAX22196 device descriptor. |
fault_mask | - Requested fault to set mask to. |
enabled | - Mask state to be set. |
int max22196_filter_get | ( | struct max22196_desc * | desc, |
uint32_t | ch, | ||
uint32_t * | flt_en, | ||
uint32_t * | clr_filtr, | ||
enum max22196_delay * | delay | ||
) |
Read filter values for a specific channel.
desc | - MAX22196 device descriptor. |
ch | - Channel from which the filter values are read. |
flt_en | - Variable through which the fillter's state is read. |
clr_filtr | - Clear the filter value and set to mid-scale delay. |
delay | - Filter delay value to be read for the MAX22196's specified channel. |
int max22196_filter_set | ( | struct max22196_desc * | desc, |
uint32_t | ch, | ||
uint32_t | flt_en, | ||
uint32_t | clr_filtr, | ||
enum max22196_delay | delay | ||
) |
Set filter values for a specific channel.
desc | - MAX22196 device descriptor. |
ch | - Channel to which the filter values will be applied to. |
flt_en | - Filter enable value(0 for filter disabled, 1 for filter enable) |
clr_filtr | - Clear filter and set delay value to mid-scale. |
delay | - Filter delay to be set. |
int max22196_get_chan_cnt | ( | struct max22196_desc * | desc, |
uint32_t | ch, | ||
uint16_t * | cnt_msb_lsb_bytes | ||
) |
MAX22196 channel counter get function.
Read channel counter for a specific channel.
desc | - MAX22196 device descriptor. |
ch | - Channel for which the channel counter is read. |
cnt_msb_lsb_bytes | - 8MSBs represent the MSB byte read from the specifc chanel's counter, 8LSBs represent the LSB byte. |
int max22196_global_cfg | ( | struct max22196_desc * | desc, |
enum max22196_global_cfg | global_cfg, | ||
bool | enabled | ||
) |
Set global configuration.
Set global configurations manually if desired.
desc | - MAX22196 device descriptor. |
global_cfg | - Specifc configuration to be set. |
enabled | - State of the specific configuration. |
int max22196_init | ( | struct max22196_desc ** | desc, |
struct max22196_init_param * | param | ||
) |
Initialize and configure the MAX22196 device.
Initialize the MAX22196 descriptor.
desc | - device descriptor for the MAX22196 that will be initialized. |
param | - initialization parameter for the device. |
int max22196_reg_read | ( | struct max22196_desc * | desc, |
uint32_t | reg, | ||
uint32_t * | val | ||
) |
MAX22196 register read function.
Register read function for MAX22196.
desc | - The device descriptor for MAX22196. |
reg | - The register value where the data is read from. |
val | - The value returned from read. |
int max22196_reg_update | ( | struct max22196_desc * | desc, |
uint32_t | reg, | ||
uint32_t | mask, | ||
uint32_t | val | ||
) |
Register update function for MAX22196.
desc | - The device descriptor for MAX22196. |
reg | - The register to be updated. |
mask | - The specific mask where the value will be updated. |
val | - The value that is to be written to the mask. |
int max22196_reg_write | ( | struct max22196_desc * | desc, |
uint32_t | reg, | ||
uint32_t | val | ||
) |
MAX22196 register write function.
Register write function for MAX22196.
desc | - The device descriptor for MAX22196. |
reg | - The register where the information is to be written. |
val | - The value to be written to reg. |
int max22196_remove | ( | struct max22196_desc * | desc | ) |
Free the resources allocated during init.
Remove the resources allocated at init.
desc | - device descriptor for the MAX14916 that will be initialized. |
int max22196_set_chan_cnt | ( | struct max22196_desc * | desc, |
uint32_t | ch, | ||
uint16_t | cnt_msb_lsb_bytes | ||
) |
Set channel counter for a specific channel.
desc | - MAX22196 device descriptor. |
ch | - MAX22196 channel to which the counter is set. |
cnt_msb_lsb_bytes | - 8MSBs represent the MSB byte to be written to the specifc chanel's counter, 8LSBs represent the LSB byte. |
int max22196_set_mode | ( | struct max22196_desc * | desc, |
uint32_t | ch, | ||
enum max22196_mode | mode | ||
) |
Set mode to a specific channel.
desc | - The device descriptor for MAX22196 |
ch | - The channel for which the mode will be set. |
mode | - The mode to be set. |