no-OS
|
Source file of MAX22200 Driver. More...
#include <no_os_error.h>
#include <stdlib.h>
#include <string.h>
#include "max22200.h"
#include "no_os_util.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
Functions | |
int | max22200_reg_read (struct max22200_desc *desc, uint32_t reg, uint32_t *val) |
Read data from desired register for MAX22200. More... | |
int | max22200_reg_write (struct max22200_desc *desc, uint32_t reg, uint32_t val) |
Write data to desired register for MAX22200. More... | |
int | max22200_reg_update (struct max22200_desc *desc, uint32_t reg, uint32_t mask, uint32_t val) |
Update data in the desired register. More... | |
int | max22200_set_trig_state (struct max22200_desc *desc, bool trig_state) |
Set external trigger's state of the MAX22200. More... | |
int | max22200_set_ch_state (struct max22200_desc *desc, uint32_t ch, bool ch_state) |
Set channel state for specific channel. More... | |
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. More... | |
int | max22200_set_chop_freq (struct max22200_desc *desc, enum max22200_chopping_freq chopping_freq) |
Set chopping frequency value. More... | |
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. More... | |
int | max22200_set_ch_hold (struct max22200_desc *desc, uint32_t ch, uint8_t hold_current) |
Set channel hold current. More... | |
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. More... | |
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. More... | |
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. More... | |
int | max22200_set_ch_freq (struct max22200_desc *desc, uint32_t ch, enum max22200_ch_freq ch_freq) |
Set channel's frequency. More... | |
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. More... | |
int | max22200_set_cfg_dpm (struct max22200_desc *desc, uint8_t dpm_istart_byte, uint8_t dpm_tdeb_ipth_byte) |
Set configuration DPM. More... | |
int | max22200_fault_mask_get (struct max22200_desc *desc, enum max22200_fault_mask fault_mask, bool *enabled) |
Fault mask bit get function. More... | |
int | max22200_get_ch_state (struct max22200_desc *desc, uint32_t ch, bool *ch_state) |
Read the state of a channel. More... | |
int | max22200_get_chop_freq (struct max22200_desc *desc, enum max22200_chopping_freq *chopping_freq) |
Read chopping frequency. More... | |
int | max22200_get_ch_hit (struct max22200_desc *desc, uint32_t ch, uint8_t *hit_current, uint8_t *hit_time) |
Read channel HIT configuration. More... | |
int | max22200_get_ch_hold (struct max22200_desc *desc, uint32_t ch, uint8_t *hold_current) |
Read channel HOLD configuration. More... | |
int | max22200_get_ch_scale (struct max22200_desc *desc, uint32_t ch, enum max22200_scale *scale) |
Read channel's scale. More... | |
int | max22200_get_ch_trig (struct max22200_desc *desc, uint32_t ch, enum max22200_trig *trig) |
Read channel's selected trigger for specific channel. More... | |
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. More... | |
int | max22200_get_ch_freq (struct max22200_desc *desc, uint32_t ch, enum max22200_ch_freq *ch_freq) |
Read channel's frequency. More... | |
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. More... | |
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. More... | |
int | max22200_init (struct max22200_desc **desc, struct max22200_init_param *init_param) |
MAX22200 descriptor initialization function. More... | |
int | max22200_remove (struct max22200_desc *desc) |
Deallocates all the resources used at initialization. More... | |
Source 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.
int max22200_fault_mask_get | ( | struct max22200_desc * | desc, |
enum max22200_fault_mask | fault_mask, | ||
bool * | enabled | ||
) |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
desc | - MAX22200 device descriptor. |
trig_state | - State to change to. |