Go to the documentation of this file.
42 #define MAX22200_FRAME_SIZE 4
44 #define MAX22200_CHANNELS 8
45 #define MAX22200_CHANNELS_CONFIG 4
46 #define MAX22200_MAX_CHN_IDX 7
47 #define MAX22200_HIT_MAX_VAL 0x7F
48 #define MAX22200_HIT_NO_TIME 0x00
50 #define MAX22200_R1B NO_OS_BIT(0)
52 #define MAX22200_STATUS_REG 0x00
53 #define MAX22200_CFG_CH(x) (0x02 + (0x02 * (x)))
54 #define MAX22200_FAULT_REG 0x0C
55 #define MAX22200_CFG_DPM_REG 0x0E
58 #define MAX22200_RW_MASK NO_OS_BIT(7)
59 #define MAX22200_ADDR_MASK NO_OS_GENMASK(6, 0)
62 #define MAX22200_ONCH_MASK(x) NO_OS_BIT((x) + 24)
63 #define MAX22200_STATUS_ONCH_MASK NO_OS_GENMASK(31, 24)
64 #define MAX22200_STATUS_FREQ_MASK NO_OS_BIT(16)
65 #define MAX22200_STATUS_FAULT_MASK(x) NO_OS_BIT(x)
66 #define MAX22200_STATUS_MODE_MASK NO_OS_GENMASK(15, 8)
67 #define MAX22200_CH_MODE_MASK(x) NO_OS_GENMASK(8 + (2 * (x)), 9 + (2 * (x)))
68 #define MAX22200_STATUS_FLAG_MASK NO_OS_GENMASK(7, 0)
69 #define MAX22200_ACTIVE_MASK NO_OS_BIT(0)
72 #define MAX22200_HFS_MASK NO_OS_BIT(31)
73 #define MAX22200_HOLD_MASK NO_OS_GENMASK(30, 24)
74 #define MAX22200_TRGNSP_IO_MASK NO_OS_BIT(23)
75 #define MAX22200_HIT_MASK NO_OS_GENMASK(22, 16)
76 #define MAX22200_HIT_T_MASK NO_OS_GENMASK(15, 8)
77 #define MAX22200_VDRNCDR_MASK NO_OS_BIT(7)
78 #define MAX22200_HSNLS_MASK NO_OS_BIT(6)
79 #define MAX22200_FREQ_CFG_MASK NO_OS_GENMASK(5, 4)
80 #define MAX22200_CH_ENABLE_MASK(x) NO_OS_BIT(x)
83 #define MAX22200_DPM_ISTART_MASK NO_OS_GENMASK(14, 8)
84 #define MAX22200_DPM_TDEB_MASK NO_OS_GENMASK(7, 4)
85 #define MAX22200_DPM_IPTH_MASK NO_OS_GENMASK(3, 0)
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.
Definition: max22200.c:609
@ MAX22200_HHF_ENABLE
Definition: max22200.h:136
struct no_os_spi_init_param * comm_param
Definition: max22200.h:143
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.
Definition: max22200.c:324
int max22200_fault_mask_get(struct max22200_desc *, enum max22200_fault_mask, bool *)
Fault mask bit get function.
Definition: max22200.c:433
@ MAX22200_M_DPM
Definition: max22200.h:90
int max22200_get_ch_freq(struct max22200_desc *desc, uint32_t ch, enum max22200_ch_freq *ch_freq)
Read channel's frequency.
Definition: max22200.c:644
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
@ MAX22200_FREQMAIN_DIV_2
Definition: max22200.h:131
@ MAX22200_FREQ_80KHZ
Definition: max22200.h:99
int max22200_get_ch_state(struct max22200_desc *desc, uint32_t ch, bool *ch_state)
Read the state of a channel.
Definition: max22200.c:456
struct no_os_gpio_desc * cmd_desc
Definition: max22200.h:155
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.
Definition: max22200.c:609
int max22200_set_ch_hit(struct max22200_desc *, uint32_t, uint8_t, uint8_t)
Set channel HIT time and HIT current.
Definition: max22200.c:231
int max22200_get_ch_hold(struct max22200_desc *, uint32_t, uint8_t *)
Read channel HOLD configuration.
Definition: max22200.c:530
#define MAX22200_FREQ_CFG_MASK
Definition: max22200.h:79
struct no_os_gpio_init_param * fault_param
Definition: max22200.h:144
@ MAX22200_SRC
Definition: max22200.h:139
int max22200_set_cfg_dpm(struct max22200_desc *, uint8_t, uint8_t)
Set configuration DPM.
Definition: max22200.c:409
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.
Definition: max22200.c:324
enum max22200_ch_side chan_side
Definition: max22200.h:159
@ MAX22200_FREQMAIN_DIV_3
Definition: max22200.h:130
Header file of SPI Interface.
int max22200_fault_mask_set(struct max22200_desc *, enum max22200_fault_mask, bool)
Set fault mask bits in the status register.
Definition: max22200.c:197
@ MAX22200_FREQMAIN
Definition: max22200.h:132
@ MAX22200_INDEPENDENT_MODE
Definition: max22200.h:103
int max22200_init(struct max22200_desc **, struct max22200_init_param *)
MAX22200 descriptor initialization function.
Definition: max22200.c:724
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.
Definition: max22200.c:231
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.
Definition: max22200.c:670
Definition: no_os_spi.h:100
Header file of Delay functions.
Definition: max22200.h:151
max22200_chopping_freq
Definition: max22200.h:97
int max22200_get_ch_scale(struct max22200_desc *, uint32_t, enum max22200_scale *)
Read channel's scale.
Definition: max22200.c:555
#define MAX22200_STATUS_REG
Definition: max22200.h:52
#define MAX22200_ADDR_MASK
Definition: max22200.h:59
max22200_ch_enable
Definition: max22200.h:135
#define MAX22200_HFS_MASK
Definition: max22200.h:72
@ MAX22200_M_OCP
Definition: max22200.h:93
int max22200_init(struct max22200_desc **desc, struct max22200_init_param *init_param)
MAX22200 descriptor initialization function.
Definition: max22200.c:724
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
#define MAX22200_DPM_IPTH_MASK
Definition: max22200.h:85
enum max22200_ch_drive chan_drive
Definition: max22200.h:160
#define MAX22200_STATUS_FAULT_MASK(x)
Definition: max22200.h:65
@ MAX22200_OL_ENABLE
Definition: max22200.h:138
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition: no_os_gpio.c:124
#define MAX22200_VDRNCDR_MASK
Definition: max22200.h:77
int max22200_get_ch_scale(struct max22200_desc *desc, uint32_t ch, enum max22200_scale *scale)
Read channel's scale.
Definition: max22200.c:555
@ MAX22200_M_OVT
Definition: max22200.h:94
@ MAX22200_CURRENT_DRIVE
Definition: max22200.h:119
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
uint8_t * tx_buff
Definition: no_os_spi.h:102
int max22200_set_chop_freq(struct max22200_desc *, enum max22200_chopping_freq)
Set chopping frequency value.
Definition: max22200.c:214
int max22200_get_ch_hold(struct max22200_desc *desc, uint32_t ch, uint8_t *hold_current)
Read channel HOLD configuration.
Definition: max22200.c:530
#define MAX22200_CFG_CH(x)
Definition: max22200.h:53
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
max22200_scale
Definition: max22200.h:108
struct no_os_gpio_desc * trig_desc
Definition: max22200.h:156
int max22200_get_ch_hit(struct max22200_desc *, uint32_t, uint8_t *, uint8_t *)
Read channel HIT configuration.
Definition: max22200.c:504
@ MAX22200_FREQMAIN_DIV_4
Definition: max22200.h:129
int max22200_set_ch_scale(struct max22200_desc *, uint32_t, enum max22200_scale)
Set channel's scale to fullscale or half fullscale.
Definition: max22200.c:280
@ MAX22200_HIGH_SIDE
Definition: max22200.h:125
int max22200_reg_write(struct max22200_desc *, uint32_t, uint32_t)
Write data to desired register for MAX22200.
Definition: max22200.c:95
int max22200_reg_read(struct max22200_desc *desc, uint32_t reg, uint32_t *val)
Read data from desired register for MAX22200.
Definition: max22200.c:48
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.
Definition: max22200.c:391
#define MAX22200_HSNLS_MASK
Definition: max22200.h:78
max22200_fault_mask
Definition: max22200.h:87
int max22200_set_cfg_dpm(struct max22200_desc *desc, uint8_t dpm_istart_byte, uint8_t dpm_tdeb_ipth_byte)
Set configuration DPM.
Definition: max22200.c:409
Header file of MAX22200 Driver.
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.
Definition: max22200.c:391
@ MAX22200_LOW_SIDE
Definition: max22200.h:124
@ MAX22200_DPM_ENABLE
Definition: max22200.h:137
@ MAX22200_M_HHF
Definition: max22200.h:91
@ MAX22200_TRIG
Definition: max22200.h:115
int max22200_get_ch_state(struct max22200_desc *, uint32_t, bool *)
Read the state of a channel.
Definition: max22200.c:456
max22200_ch_drive
Definition: max22200.h:118
int max22200_get_chop_freq(struct max22200_desc *, enum max22200_chopping_freq *)
Read chopping frequency.
Definition: max22200.c:481
enum max22200_ch_op_mode ch_config[MAX22200_CHANNELS_CONFIG]
Definition: max22200.h:148
#define MAX22200_MAX_CHN_IDX
Definition: max22200.h:46
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
int max22200_set_chop_freq(struct max22200_desc *desc, enum max22200_chopping_freq chopping_freq)
Set chopping frequency value.
Definition: max22200.c:214
@ MAX22200_M_OLF
Definition: max22200.h:92
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
struct no_os_gpio_desc * enable_desc
Definition: max22200.h:154
Definition: max22200.h:142
@ MAX22200_FREQ_100KHZ
Definition: max22200.h:98
int max22200_set_ch_hold(struct max22200_desc *, uint32_t, uint8_t)
Set channel hold current.
Definition: max22200.c:260
@ MAX22200_ONCH_SPI
Definition: max22200.h:114
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.
Definition: max22200.c:280
int max22200_set_trig_state(struct max22200_desc *desc, bool trig_state)
Set external trigger's state of the MAX22200.
Definition: max22200.c:164
#define MAX22200_STATUS_FREQ_MASK
Definition: max22200.h:64
uint32_t bytes_number
Definition: no_os_spi.h:106
int32_t no_os_spi_transfer(struct no_os_spi_desc *desc, struct no_os_spi_msg *msgs, uint32_t len)
Iterate over head list and send all spi messages.
Definition: no_os_spi.c:185
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.
Definition: max22200.c:700
struct no_os_gpio_desc * fault_desc
Definition: max22200.h:153
#define MAX22200_R1B
Definition: max22200.h:50
max22200_ch_freq
Definition: max22200.h:128
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
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.
Definition: max22200.c:302
#define MAX22200_HIT_NO_TIME
Definition: max22200.h:48
@ MAX22200_FULLSCALE
Definition: max22200.h:109
int max22200_set_ch_hold(struct max22200_desc *desc, uint32_t ch, uint8_t hold_current)
Set channel hold current.
Definition: max22200.c:260
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
uint8_t buff[MAX22200_FRAME_SIZE]
Definition: max22200.h:157
int max22200_get_ch_hit(struct max22200_desc *desc, uint32_t ch, uint8_t *hit_current, uint8_t *hit_time)
Read channel HIT configuration.
Definition: max22200.c:504
@ MAX22200_M_UVM
Definition: max22200.h:88
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
#define MAX22200_FRAME_SIZE
Definition: max22200.h:42
max22200_ch_side
Definition: max22200.h:123
@ MAX22200_HALF_FULL_SCALE
Definition: max22200.h:110
int max22200_set_ch_freq(struct max22200_desc *desc, uint32_t ch, enum max22200_ch_freq ch_freq)
Set channel's frequency.
Definition: max22200.c:372
int max22200_remove(struct max22200_desc *desc)
Deallocates all the resources used at initialization.
Definition: max22200.c:866
struct no_os_gpio_init_param * enable_param
Definition: max22200.h:145
#define MAX22200_RW_MASK
Definition: max22200.h:58
@ MAX22200_HALF_BRIDGE_MODE
Definition: max22200.h:105
int max22200_fault_mask_get(struct max22200_desc *desc, enum max22200_fault_mask fault_mask, bool *enabled)
Fault mask bit get function.
Definition: max22200.c:433
#define MAX22200_CHANNELS
Definition: max22200.h:44
@ MAX22200_PARALLEL_MODE
Definition: max22200.h:104
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
max22200_ch_op_mode
Definition: max22200.h:102
int max22200_reg_read(struct max22200_desc *, uint32_t, uint32_t *)
Read data from desired register for MAX22200.
Definition: max22200.c:48
enum max22200_ch_op_mode ch_config[MAX22200_CHANNELS_CONFIG]
Definition: max22200.h:158
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
int max22200_set_ch_freq(struct max22200_desc *, uint32_t, enum max22200_ch_freq)
Set channel's frequency.
Definition: max22200.c:372
#define MAX22200_HIT_MASK
Definition: max22200.h:75
#define MAX22200_HIT_MAX_VAL
Definition: max22200.h:47
int max22200_set_ch_state(struct max22200_desc *, uint32_t, bool)
Set channel state for specific channel.
Definition: max22200.c:180
#define MAX22200_DPM_ISTART_MASK
Definition: max22200.h:83
int max22200_get_ch_trig(struct max22200_desc *desc, uint32_t ch, enum max22200_trig *trig)
Read channel's selected trigger for specific channel.
Definition: max22200.c:581
int max22200_get_ch_enable(struct max22200_desc *, uint32_t, enum max22200_ch_enable, bool *)
Read channel's enable bits state.
Definition: max22200.c:670
int max22200_reg_update(struct max22200_desc *desc, uint32_t reg, uint32_t mask, uint32_t val)
Update data in the desired register.
Definition: max22200.c:142
#define MAX22200_TRGNSP_IO_MASK
Definition: max22200.h:74
int max22200_get_ch_trig(struct max22200_desc *, uint32_t, enum max22200_trig *)
Read channel's selected trigger for specific channel.
Definition: max22200.c:581
#define MAX22200_HIT_T_MASK
Definition: max22200.h:76
int32_t no_os_spi_remove(struct no_os_spi_desc *desc)
Free the resources allocated by no_os_spi_init().
Definition: no_os_spi.c:116
struct no_os_gpio_init_param * cmd_param
Definition: max22200.h:146
int max22200_set_trig_state(struct max22200_desc *, bool)
Set external trigger's state of the MAX22200.
Definition: max22200.c:164
@ MAX22200_VOLTAGE_DRIVE
Definition: max22200.h:120
Header file of GPIO Interface.
#define MAX22200_ACTIVE_MASK
Definition: max22200.h:69
#define MAX22200_CH_MODE_MASK(x)
Definition: max22200.h:67
int max22200_get_chop_freq(struct max22200_desc *desc, enum max22200_chopping_freq *chopping_freq)
Read chopping frequency.
Definition: max22200.c:481
int max22200_reg_update(struct max22200_desc *, uint32_t, uint32_t, uint32_t)
Update data in the desired register.
Definition: max22200.c:142
#define MAX22200_DPM_TDEB_MASK
Definition: max22200.h:84
#define MAX22200_CHANNELS_CONFIG
Definition: max22200.h:45
int32_t no_os_spi_init(struct no_os_spi_desc **desc, const struct no_os_spi_init_param *param)
Initialize the SPI communication peripheral.
Definition: no_os_spi.c:52
struct no_os_spi_desc * comm_desc
Definition: max22200.h:152
#define MAX22200_ONCH_MASK(x)
Definition: max22200.h:62
Header file of utility functions.
int max22200_get_cfg_dpm(struct max22200_desc *, uint8_t *, uint8_t *)
Read configuration for the detection of the plunger movement of the device.
Definition: max22200.c:700
#define MAX22200_CFG_DPM_REG
Definition: max22200.h:55
struct no_os_gpio_init_param * trig_param
Definition: max22200.h:147
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
max22200_trig
Definition: max22200.h:113
int max22200_reg_write(struct max22200_desc *desc, uint32_t reg, uint32_t val)
Write data to desired register for MAX22200.
Definition: max22200.c:95
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.
Definition: max22200.c:197
int max22200_remove(struct max22200_desc *)
Deallocates all the resources used at initialization.
Definition: max22200.c:866
int max22200_set_ch_trig(struct max22200_desc *, uint32_t, enum max22200_trig)
Set channel's trigger to be either SPI or external trigger.
Definition: max22200.c:302
void no_os_put_unaligned_le32(uint32_t val, uint8_t *buf)
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
@ MAX22200_M_COMF
Definition: max22200.h:89
int max22200_get_ch_freq(struct max22200_desc *, uint32_t, enum max22200_ch_freq *)
Read channel's frequency.
Definition: max22200.c:644
int max22200_set_ch_state(struct max22200_desc *desc, uint32_t ch, bool ch_state)
Set channel state for specific channel.
Definition: max22200.c:180
#define MAX22200_HOLD_MASK
Definition: max22200.h:73
#define MAX22200_CH_ENABLE_MASK(x)
Definition: max22200.h:80
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition: no_os_gpio.c:75