no-OS
|
Header file of MAX22200 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 | max22200_init_param |
struct | max22200_desc |
Functions | |
int | max22200_reg_read (struct max22200_desc *, uint32_t, uint32_t *) |
Read data from desired register for MAX22200. More... | |
int | max22200_reg_write (struct max22200_desc *, uint32_t, uint32_t) |
Write data to desired register for MAX22200. More... | |
int | max22200_reg_update (struct max22200_desc *, uint32_t, uint32_t, uint32_t) |
Update data in the desired register. More... | |
int | max22200_set_trig_state (struct max22200_desc *, bool) |
Set external trigger's state of the MAX22200. More... | |
int | max22200_set_ch_state (struct max22200_desc *, uint32_t, bool) |
Set channel state for specific channel. More... | |
int | max22200_fault_mask_set (struct max22200_desc *, enum max22200_fault_mask, bool) |
Set fault mask bits in the status register. More... | |
int | max22200_set_chop_freq (struct max22200_desc *, enum max22200_chopping_freq) |
Set chopping frequency value. More... | |
int | max22200_set_ch_hit (struct max22200_desc *, uint32_t, uint8_t, uint8_t) |
Set channel HIT time and HIT current. More... | |
int | max22200_set_ch_hold (struct max22200_desc *, uint32_t, uint8_t) |
Set channel hold current. More... | |
int | max22200_set_ch_scale (struct max22200_desc *, uint32_t, enum max22200_scale) |
Set channel's scale to fullscale or half fullscale. More... | |
int | max22200_set_ch_trig (struct max22200_desc *, uint32_t, enum max22200_trig) |
Set channel's trigger to be either SPI or external trigger. More... | |
int | max22200_set_ch_mode (struct max22200_desc *, uint32_t, enum max22200_ch_drive, enum max22200_ch_side, enum max22200_ch_op_mode) |
Set chanmel operation mode, high-side/low-side and drive. More... | |
int | max22200_set_ch_freq (struct max22200_desc *, uint32_t, enum max22200_ch_freq) |
Set channel's frequency. More... | |
int | max22200_set_ch_enable (struct max22200_desc *, uint32_t, enum max22200_ch_enable, bool) |
Set channel's enables for different checks, detection and functions. More... | |
int | max22200_set_cfg_dpm (struct max22200_desc *, uint8_t, uint8_t) |
Set configuration DPM. More... | |
int | max22200_fault_mask_get (struct max22200_desc *, enum max22200_fault_mask, bool *) |
Fault mask bit get function. More... | |
int | max22200_get_ch_state (struct max22200_desc *, uint32_t, bool *) |
Read the state of a channel. More... | |
int | max22200_get_chop_freq (struct max22200_desc *, enum max22200_chopping_freq *) |
Read chopping frequency. More... | |
int | max22200_get_ch_hit (struct max22200_desc *, uint32_t, uint8_t *, uint8_t *) |
Read channel HIT configuration. More... | |
int | max22200_get_ch_hold (struct max22200_desc *, uint32_t, uint8_t *) |
Read channel HOLD configuration. More... | |
int | max22200_get_ch_scale (struct max22200_desc *, uint32_t, enum max22200_scale *) |
Read channel's scale. More... | |
int | max22200_get_ch_trig (struct max22200_desc *, uint32_t, enum max22200_trig *) |
Read channel's selected trigger for specific channel. More... | |
int | max22200_get_ch_mode (struct max22200_desc *, uint32_t, enum max22200_ch_drive *, enum max22200_ch_side *, enum max22200_ch_op_mode *) |
Read channel's mode configuration. More... | |
int | max22200_get_ch_freq (struct max22200_desc *, uint32_t, enum max22200_ch_freq *) |
Read channel's frequency. More... | |
int | max22200_get_ch_enable (struct max22200_desc *, uint32_t, enum max22200_ch_enable, bool *) |
Read channel's enable bits state. More... | |
int | max22200_get_cfg_dpm (struct max22200_desc *, uint8_t *, uint8_t *) |
Read configuration for the detection of the plunger movement of the device. More... | |
int | max22200_init (struct max22200_desc **, struct max22200_init_param *) |
MAX22200 descriptor initialization function. More... | |
int | max22200_remove (struct max22200_desc *) |
Deallocates all the resources used at initialization. More... | |
Header file of MAX22200 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 MAX22200_ACTIVE_MASK NO_OS_BIT(0) |
#define MAX22200_ADDR_MASK NO_OS_GENMASK(6, 0) |
#define MAX22200_CFG_CH | ( | x | ) | (0x02 + (0x02 * (x))) |
#define MAX22200_CFG_DPM_REG 0x0E |
#define MAX22200_CH_ENABLE_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22200_CH_MODE_MASK | ( | x | ) | NO_OS_GENMASK(8 + (2 * (x)), 9 + (2 * (x))) |
#define MAX22200_CHANNELS 8 |
#define MAX22200_CHANNELS_CONFIG 4 |
#define MAX22200_DPM_IPTH_MASK NO_OS_GENMASK(3, 0) |
#define MAX22200_DPM_ISTART_MASK NO_OS_GENMASK(14, 8) |
#define MAX22200_DPM_TDEB_MASK NO_OS_GENMASK(7, 4) |
#define MAX22200_FAULT_REG 0x0C |
#define MAX22200_FRAME_SIZE 4 |
#define MAX22200_FREQ_CFG_MASK NO_OS_GENMASK(5, 4) |
#define MAX22200_HFS_MASK NO_OS_BIT(31) |
#define MAX22200_HIT_MASK NO_OS_GENMASK(22, 16) |
#define MAX22200_HIT_MAX_VAL 0x7F |
#define MAX22200_HIT_NO_TIME 0x00 |
#define MAX22200_HIT_T_MASK NO_OS_GENMASK(15, 8) |
#define MAX22200_HOLD_MASK NO_OS_GENMASK(30, 24) |
#define MAX22200_HSNLS_MASK NO_OS_BIT(6) |
#define MAX22200_MAX_CHN_IDX 7 |
#define MAX22200_ONCH_MASK | ( | x | ) | NO_OS_BIT((x) + 24) |
#define MAX22200_R1B NO_OS_BIT(0) |
#define MAX22200_RW_MASK NO_OS_BIT(7) |
#define MAX22200_STATUS_FAULT_MASK | ( | x | ) | NO_OS_BIT(x) |
#define MAX22200_STATUS_FLAG_MASK NO_OS_GENMASK(7, 0) |
#define MAX22200_STATUS_FREQ_MASK NO_OS_BIT(16) |
#define MAX22200_STATUS_MODE_MASK NO_OS_GENMASK(15, 8) |
#define MAX22200_STATUS_ONCH_MASK NO_OS_GENMASK(31, 24) |
#define MAX22200_STATUS_REG 0x00 |
#define MAX22200_TRGNSP_IO_MASK NO_OS_BIT(23) |
#define MAX22200_VDRNCDR_MASK NO_OS_BIT(7) |
enum max22200_ch_drive |
enum max22200_ch_enable |
enum max22200_ch_freq |
enum max22200_ch_op_mode |
enum max22200_ch_side |
enum max22200_fault_mask |
enum max22200_scale |
enum max22200_trig |
int max22200_fault_mask_get | ( | struct max22200_desc * | desc, |
enum max22200_fault_mask | fault_mask, | ||
bool * | enabled | ||
) |
Fault mask bit get function.
Fault mask bit get function
desc | - MAX22200 device descriptor. |
fault_mask | - Fault mask specific bit to read the state for. |
enabled | - State of the bit. |
int max22200_fault_mask_set | ( | struct max22200_desc * | desc, |
enum max22200_fault_mask | fault_mask, | ||
bool | enabled | ||
) |
Set fault mask bits in the status register.
Set fault mask bits in the status register.
desc | - MAX22200 device descriptor. |
fault_mask | - Desired fault mask bit to set. |
enabled | - enabled/disabled state of the mask. |
int max22200_get_cfg_dpm | ( | struct max22200_desc * | desc, |
uint8_t * | dpm_istart_byte, | ||
uint8_t * | dpm_tdeb_ipth_byte | ||
) |
Read configuration for the detection of the plunger movement of the device.
Read configuration for the detection of the plunger movement of the device.
desc | - MAX22200 device descriptor. |
dpm_istart_byte | - Detection of plunger movement starting current value. |
dpm_tdeb_ipth_byte | - Detection of plunger movement debounce time value. |
int max22200_get_ch_enable | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_ch_enable | ch_enable, | ||
bool * | enabled | ||
) |
Read channel's enable bits state.
Read channel's enable bits state.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
ch_enable | - Requested channel enable bit to read the state for. |
enabled | - Requested enabled bit state. |
int max22200_get_ch_freq | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_ch_freq * | ch_freq | ||
) |
Read channel's frequency.
Read channel's frequency.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
ch_freq | - Channel's frequency value read from the device. |
int max22200_get_ch_hit | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
uint8_t * | hit_current, | ||
uint8_t * | hit_time | ||
) |
Read channel HIT configuration.
Read channel HIT configuration.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
hit_current | - HIT current value read from the device. |
hit_time | - HIT time value read from the device. |
int max22200_get_ch_hold | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
uint8_t * | hold_current | ||
) |
Read channel HOLD configuration.
Read channel HOLD configuration.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
hold_current | - HOLD current value read from the device. |
int max22200_get_ch_mode | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_ch_drive * | ch_drive, | ||
enum max22200_ch_side * | ch_side, | ||
enum max22200_ch_op_mode * | ch_op_mode | ||
) |
Read channel's mode configuration.
Read channel's mode configuration.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
ch_drive | - Channel's drive read from the device. |
ch_side | - Channel's high-side/low-side configuraton read from the device. |
ch_op_mode | - Channel's operation mode read from the device. |
int max22200_get_ch_scale | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_scale * | scale | ||
) |
Read channel's scale.
Read channel's scale.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
scale | - Scale read from device's channel. |
int max22200_get_ch_state | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
bool * | ch_state | ||
) |
Read the state of a channel.
Get the state of a specific channel.
desc | - MAX22200 device descriptor |
ch | - Channel number (0 based). |
ch_state | - State of the channel. |
int max22200_get_ch_trig | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_trig * | trig | ||
) |
Read channel's selected trigger for specific channel.
Read channel's selected trigger for specific channel.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
trig | - Selected trigger for the channel requested read from the device. |
int max22200_get_chop_freq | ( | struct max22200_desc * | desc, |
enum max22200_chopping_freq * | chopping_freq | ||
) |
Read chopping frequency.
Read device frequency
desc | - MAX22200 device descriptor. |
chopping_freq | - Pointer of the variable holding the value of the chopping frequency. |
int max22200_init | ( | struct max22200_desc ** | desc, |
struct max22200_init_param * | init_param | ||
) |
MAX22200 descriptor initialization function.
MAX22200 device initialization function.
desc | - MAX22200 device descriptor. |
init_param | - Initialization parameter containing data about the device descriptor to be initialized. |
int max22200_reg_read | ( | struct max22200_desc * | desc, |
uint32_t | reg, | ||
uint32_t * | val | ||
) |
Read data from desired register for MAX22200.
Read data from desired register for MAX22200.
desc | - MAX22200 device descriptor. |
reg | - Register address to read data from. |
val | - Value read from the register. |
int max22200_reg_update | ( | struct max22200_desc * | desc, |
uint32_t | reg, | ||
uint32_t | mask, | ||
uint32_t | val | ||
) |
Update data in the desired register.
Update data in the desired register.
desc | - MAX22200 device descriptor. |
reg | - Register address to update data to. |
mask | - Bit mask of the field to be updated. |
val | - Value to be updated in the desired register. Should be bit shifted by using no_os_field_prep(mask, val) |
int max22200_reg_write | ( | struct max22200_desc * | desc, |
uint32_t | reg, | ||
uint32_t | val | ||
) |
Write data to desired register for MAX22200.
Write data to desired register for MAX22200
desc | - MAXX22200 device descriptor. |
reg | - Register address to write data to. |
val | - Value to be written to the register. |
int max22200_remove | ( | struct max22200_desc * | desc | ) |
Deallocates all the resources used at initialization.
Deallocates all the resources used at initialization.
desc | - MAX22200 device descriptor. |
int max22200_set_cfg_dpm | ( | struct max22200_desc * | desc, |
uint8_t | dpm_istart_byte, | ||
uint8_t | dpm_tdeb_ipth_byte | ||
) |
Set configuration DPM.
Set configuration DPM.
desc | - MAX22200 device descriptor. |
dpm_istart_byte | - Detection of plunger movement starting current |
dpm_tdeb_ipth_byte | - Detection of plunger movement debounce time. |
int max22200_set_ch_enable | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_ch_enable | ch_enable, | ||
bool | enabled | ||
) |
Set channel's enables for different checks, detection and functions.
Set channel's enables for different checks, detection and functions.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
ch_enable | - Channel enable to be set. |
enabled | - Disabled/Enabled state. |
int max22200_set_ch_freq | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_ch_freq | ch_freq | ||
) |
Set channel's frequency.
Set channel's frequency.
desc | - MAX22200 device descriptor |
ch | - Channel's number (0 based). |
ch_freq | - 80KHz/100KHz frequency. |
int max22200_set_ch_hit | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
uint8_t | hit_current, | ||
uint8_t | hit_time | ||
) |
Set channel HIT time and HIT current.
Set channel HIT time and HIT current.
desc | - MAX22200 device descriptor. |
ch | - Channel for which HIT time is to be set.(0 based) |
hit_current | - HIT current value, it shall not be greater than 127 since the value is stored only on 7 bits in the channel's configuration register. |
hit_time | - HIT time value to be set. |
int max22200_set_ch_hold | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
uint8_t | hold_current | ||
) |
Set channel hold current.
Set channel hold current.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
hold_current | - Hold current value to be set. It shall not be greater than 127 since the value it's stored on 7 bits in the channel's configuration register. |
int max22200_set_ch_mode | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_ch_drive | ch_drive, | ||
enum max22200_ch_side | ch_side, | ||
enum max22200_ch_op_mode | ch_op_mode | ||
) |
Set chanmel operation mode, high-side/low-side and drive.
Set chanmel operation mode, high-side/low-side and drive.
desc | - MAX22200 device descriptor. |
ch | - Channel number (0 based). |
ch_drive | - Voltage/Current drive. |
ch_side | - High-Side/Low-Side. |
ch_op_mode | - Independent/Half-Bridge/Full-Bridge mode. |
int max22200_set_ch_scale | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_scale | scale | ||
) |
Set channel's scale to fullscale or half fullscale.
Set channel's scale to fullscale or half fullscale.
desc | - MAX22200 device dscriptor. |
ch | - Channel's number (0 based). |
scale | - Scale value. |
int max22200_set_ch_state | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
bool | ch_state | ||
) |
Set channel state for specific channel.
Set channel state for specific channel.
desc | - MAX22200 device descriptor. |
ch | - Channel number. |
ch_state | - Channel's state to be changed into. |
int max22200_set_ch_trig | ( | struct max22200_desc * | desc, |
uint32_t | ch, | ||
enum max22200_trig | trig | ||
) |
Set channel's trigger to be either SPI or external trigger.
Set channel's trigger to be either SPI or external trigger.
desc | - MAX22200 device descriptor. |
ch | - Channel's number (0 based). |
trig | - Trigger to be set. If external trigger is requested but no external's trigger descriptor was initialized, will return negative error code. |
int max22200_set_chop_freq | ( | struct max22200_desc * | desc, |
enum max22200_chopping_freq | chopping_freq | ||
) |
Set chopping frequency value.
Set device frequency value.
desc | - MAX22200 device descriptor. |
chopping_freq | - Chopping frequency value. |
int max22200_set_trig_state | ( | struct max22200_desc * | desc, |
bool | trig_state | ||
) |
Set external trigger's state of the MAX22200.
Set external trigger's state of the MAX22200.
desc | - MAX22200 device descriptor. |
trig_state | - State to change to. |