no-OS
iio_max22200.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef IIO_MAX22200_H
34 #define IIO_MAX22200_H
35 
36 #include <stdint.h>
37 #include <stdbool.h>
38 #include "iio.h"
39 #include "max22200.h"
40 
41 #define MAX22200_HOLD_MAX_VAL 0xFF
42 #define MAX22200_HIT_T_MAX_VAL 0xFF
43 
52 };
53 
64 };
65 
74 };
75 
76 static const char *const max22200_scale_avail[2] = {
77  "fullscale",
78  "half_fullscale"
79 };
80 
81 static const char *const max22200_channel_trig_avail[2] = {
82  "onch_spi",
83  "ext_trig"
84 };
85 
86 static const char *const max22200_ch_drive_avail[2] = {
87  "current_drive",
88  "voltage_dri"
89 };
90 
91 static const char *const max22200_ch_side_avail[2] = {
92  "low_side",
93  "high_side"
94 };
95 
96 static const char *const max22200_ch_op_mode_avail[3] = {
97  "independent_mode",
98  "parallel_mode",
99  "half_bridge_mode",
100 };
101 
102 static const char *const max22200_channel_freq_avail[4] = {
103  "freqmain_div_4",
104  "freqmain_div_3",
105  "freqmain_div_2",
106  "freqmain"
107 };
108 
109 static const char *const max22200_chopping_freq_avail[2] = {
110  "100KHz",
111  "80KHz"
112 };
113 
120 };
121 
128 };
129 
133 
136 
137 #endif
max22200_get_ch_mode
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_IIO_CH_SIDE
@ MAX22200_IIO_CH_SIDE
Definition: iio_max22200.h:61
MAX22200_IIO_CH_OP_MODE
@ MAX22200_IIO_CH_OP_MODE
Definition: iio_max22200.h:62
MAX22200_IIO_CH_DRIVE
@ MAX22200_IIO_CH_DRIVE
Definition: iio_max22200.h:60
MAX22200_HHF_ENABLE
@ MAX22200_HHF_ENABLE
Definition: max22200.h:136
max22200_set_ch_mode
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
MAX22200_M_DPM
@ MAX22200_M_DPM
Definition: max22200.h:90
max22200_get_ch_freq
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
no_os_alloc.h
END_ATTRIBUTES_ARRAY
#define END_ATTRIBUTES_ARRAY
Definition: iio_types.h:116
max22200_get_ch_state
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
IIO_VAL_INT
@ IIO_VAL_INT
Definition: iio_types.h:50
iio_channel
Struct describing the scan type.
Definition: iio_types.h:168
MAX22200_IIO_CH_TRIG
@ MAX22200_IIO_CH_TRIG
Definition: iio_max22200.h:59
MAX22200_CHANNEL
#define MAX22200_CHANNEL(_addr)
Definition: iio_max22200.c:43
MAX22200_IIO_OVT_MASK
@ MAX22200_IIO_OVT_MASK
Definition: iio_max22200.h:51
iio_device::channels
struct iio_channel * channels
Definition: iio_types.h:254
MAX22200_SRC
@ MAX22200_SRC
Definition: max22200.h:139
max22200_iio_desc
MAX22200 specific IIO descriptor.
Definition: iio_max22200.h:117
MAX22200_IIO_CHOP_FREQ_AVAILABLE
@ MAX22200_IIO_CHOP_FREQ_AVAILABLE
Definition: iio_max22200.h:70
max22200_iio_desc::iio_dev
struct iio_device * iio_dev
Definition: iio_max22200.h:119
iio_desc
Definition: iio.c:204
iio_ch_info
Structure holding channel attributess.
Definition: iio_types.h:103
no_os_units.h
Header file of Units.
max22200_set_ch_hit
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
max22200_get_ch_enable
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
MAX22200_IIO_CH_FREQ_AVAILABLE
@ MAX22200_IIO_CH_FREQ_AVAILABLE
Definition: iio_max22200.h:69
max22200_desc
Definition: max22200.h:151
max22200_iio_desc::max22200_desc
struct max22200_desc * max22200_desc
Definition: iio_max22200.h:118
max22200_chopping_freq
max22200_chopping_freq
Definition: max22200.h:97
MAX22200_IIO_HOLD_CURRENT
@ MAX22200_IIO_HOLD_CURRENT
Definition: iio_max22200.h:58
MAX22200_IIO_SCALE_AVAILABLE
@ MAX22200_IIO_SCALE_AVAILABLE
Definition: iio_max22200.h:67
max22200_iio_desc_init_param
Initalization parameter fr the MAX22200 IIO descriptor.
Definition: iio_max22200.h:125
MAX22200_HFS_MASK
#define MAX22200_HFS_MASK
Definition: max22200.h:72
MAX22200_M_OCP
@ MAX22200_M_OCP
Definition: max22200.h:93
max22200_init
int max22200_init(struct max22200_desc **desc, struct max22200_init_param *init_param)
MAX22200 descriptor initialization function.
Definition: max22200.c:724
MAX22200_OL_ENABLE
@ MAX22200_OL_ENABLE
Definition: max22200.h:138
no_os_calloc
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
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
max22200_get_ch_scale
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
@ MAX22200_M_OVT
Definition: max22200.h:94
MAX22200_IIO_HHF_MASK
@ MAX22200_IIO_HHF_MASK
Definition: iio_max22200.h:48
iio_device::debug_reg_read
int32_t(* debug_reg_read)(void *dev, uint32_t reg, uint32_t *readval)
Definition: iio_types.h:283
MAX22200_IIO_CH_FREQ
@ MAX22200_IIO_CH_FREQ
Definition: iio_max22200.h:63
max22200_get_ch_hold
int max22200_get_ch_hold(struct max22200_desc *desc, uint32_t ch, uint8_t *hold_current)
Read channel HOLD configuration.
Definition: max22200.c:530
MAX22200_IIO_CH_DRIVE_AVAILABLE
@ MAX22200_IIO_CH_DRIVE_AVAILABLE
Definition: iio_max22200.h:71
iio_channel::ch_out
bool ch_out
Definition: iio_types.h:188
IIO_SHARED_BY_ALL
@ IIO_SHARED_BY_ALL
Definition: iio_types.h:122
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
max22200_scale
max22200_scale
Definition: max22200.h:108
iio.h
Header file of iio.
no_os_error.h
Error codes definition.
MAX22200_IIO_HIT_CURRENT
@ MAX22200_IIO_HIT_CURRENT
Definition: iio_max22200.h:56
iio_attribute::name
const char * name
Definition: iio_types.h:131
max22200_reg_read
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
max22200_iio_desc_init_param::max22200_init_param
struct max22200_init_param * max22200_init_param
Definition: iio_max22200.h:126
max22200_set_ch_enable
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
max22200_iio_ch_attrs
max22200_iio_ch_attrs
Definition: iio_max22200.h:54
max22200.h
Header file of MAX22200 Driver.
MAX22200_DPM_ENABLE
@ MAX22200_DPM_ENABLE
Definition: max22200.h:137
MAX22200_M_HHF
@ MAX22200_M_HHF
Definition: max22200.h:91
iio_attribute
Structure holding pointers to show and store functions.
Definition: iio_types.h:129
MAX22200_TRIG
@ MAX22200_TRIG
Definition: max22200.h:115
max22200_iio_fault_mask
max22200_iio_fault_mask
Definition: iio_max22200.h:44
max22200_ch_drive
max22200_ch_drive
Definition: max22200.h:118
max22200_iio_desc_init_param::ch_enable
bool ch_enable[MAX22200_CHANNELS]
Definition: iio_max22200.h:127
max22200_iio_remove
int max22200_iio_remove(struct max22200_iio_desc *)
Free resources allocated by the init function.
Definition: iio_max22200.c:1080
max22200_set_chop_freq
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
@ MAX22200_M_OLF
Definition: max22200.h:92
iio_parse_value
int32_t iio_parse_value(char *buf, enum iio_val fmt, int32_t *val, int32_t *val2)
Definition: iio.c:610
MAX22200_IIO_CH_TRIG_AVAILABLE
@ MAX22200_IIO_CH_TRIG_AVAILABLE
Definition: iio_max22200.h:68
MAX22200_HIT_T_MAX_VAL
#define MAX22200_HIT_T_MAX_VAL
Definition: iio_max22200.h:42
max22200_init_param
Definition: max22200.h:142
MAX22200_IIO_OCP_MASK
@ MAX22200_IIO_OCP_MASK
Definition: iio_max22200.h:50
MAX22200_ONCH_SPI
@ MAX22200_ONCH_SPI
Definition: max22200.h:114
max22200_set_ch_scale
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
MAX22200_IIO_CH_SIDE_AVAILABLE
@ MAX22200_IIO_CH_SIDE_AVAILABLE
Definition: iio_max22200.h:72
max22200_set_trig_state
int max22200_set_trig_state(struct max22200_desc *desc, bool trig_state)
Set external trigger's state of the MAX22200.
Definition: max22200.c:164
max22200_iio_remove
int max22200_iio_remove(struct max22200_iio_desc *iio_desc)
Free resources allocated by the init function.
Definition: iio_max22200.c:1080
max22200_ch_freq
max22200_ch_freq
Definition: max22200.h:128
MAX22200_IIO_DPM_MASK
@ MAX22200_IIO_DPM_MASK
Definition: iio_max22200.h:47
max22200_set_ch_trig
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
MAX22200_FULLSCALE
@ MAX22200_FULLSCALE
Definition: max22200.h:109
iio_format_value
int iio_format_value(char *buf, uint32_t len, enum iio_val fmt, int32_t size, int32_t *vals)
Definition: iio.c:661
max22200_set_ch_hold
int max22200_set_ch_hold(struct max22200_desc *desc, uint32_t ch, uint8_t hold_current)
Set channel hold current.
Definition: max22200.c:260
max22200_iio_init
int max22200_iio_init(struct max22200_iio_desc **, struct max22200_iio_desc_init_param *)
Initializes the MAX22200 IIO descriptor.
Definition: iio_max22200.c:1041
iio_ch_info::address
uint32_t address
Definition: iio_types.h:113
MAX22200_IIO_HIT_TIME
@ MAX22200_IIO_HIT_TIME
Definition: iio_max22200.h:57
MAX22200_IIO_SCALE
@ MAX22200_IIO_SCALE
Definition: iio_max22200.h:55
iio_channel::attributes
struct iio_attribute * attributes
Definition: iio_types.h:186
max22200_get_ch_hit
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
iio_device::num_ch
uint16_t num_ch
Definition: iio_types.h:252
MAX22200_M_UVM
@ MAX22200_M_UVM
Definition: max22200.h:88
no_os_free
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
MAX22200_IIO_CH_OP_MODE_AVAILABLE
@ MAX22200_IIO_CH_OP_MODE_AVAILABLE
Definition: iio_max22200.h:73
max22200_ch_side
max22200_ch_side
Definition: max22200.h:123
MAX22200_HALF_FULL_SCALE
@ MAX22200_HALF_FULL_SCALE
Definition: max22200.h:110
max22200_set_ch_freq
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
max22200_remove
int max22200_remove(struct max22200_desc *desc)
Deallocates all the resources used at initialization.
Definition: max22200.c:866
max22200_fault_mask_get
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
MAX22200_CHANNELS
#define MAX22200_CHANNELS
Definition: max22200.h:44
MAX22200_IIO_COMER_MASK
@ MAX22200_IIO_COMER_MASK
Definition: iio_max22200.h:46
max22200_ch_op_mode
max22200_ch_op_mode
Definition: max22200.h:102
NULL
#define NULL
Definition: wrapper.h:64
MAX22200_HOLD_MAX_VAL
#define MAX22200_HOLD_MAX_VAL
Definition: iio_max22200.h:41
MAX22200_IIO_OLF_MASK
@ MAX22200_IIO_OLF_MASK
Definition: iio_max22200.h:49
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
iio_device
Structure holding channels and attributes of a device.
Definition: iio_types.h:247
max22200_iio_setup_channels
int max22200_iio_setup_channels(struct max22200_iio_desc *desc, bool *ch_enable)
Definition: iio_max22200.c:998
MAX22200_HIT_MAX_VAL
#define MAX22200_HIT_MAX_VAL
Definition: max22200.h:47
max22200_get_ch_trig
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
MAX22200_IIO_UVM_MASK
@ MAX22200_IIO_UVM_MASK
Definition: iio_max22200.h:45
MAX22200_TRGNSP_IO_MASK
#define MAX22200_TRGNSP_IO_MASK
Definition: max22200.h:74
max22200_iio_available
max22200_iio_available
Definition: iio_max22200.h:66
max22200_get_chop_freq
int max22200_get_chop_freq(struct max22200_desc *desc, enum max22200_chopping_freq *chopping_freq)
Read chopping frequency.
Definition: max22200.c:481
iio_max22200.h
Header file of IIO MAX22200 Driver.
no_os_util.h
Header file of utility functions.
max22200_trig
max22200_trig
Definition: max22200.h:113
max22200_iio_init
int max22200_iio_init(struct max22200_iio_desc **iio_desc, struct max22200_iio_desc_init_param *init_param)
Initializes the MAX22200 IIO descriptor.
Definition: iio_max22200.c:1041
max22200_reg_write
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
max22200_fault_mask_set
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
MAX22200_M_COMF
@ MAX22200_M_COMF
Definition: max22200.h:89
max22200_set_ch_state
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