no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
max22017.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef _MAX22017_H
34#define _MAX22017_H
35
36#include <stdint.h>
37#include <stdbool.h>
38#include "no_os_gpio.h"
39#include "no_os_spi.h"
40#include "no_os_util.h"
41
42/* GEN Registers */
43#define MAX22017_GEN_ID 0x00
44#define MAX22017_GEN_SERIAL_MSB 0x01
45#define MAX22017_GEN_SERIAL_LSB 0x02
46#define MAX22017_GEN_CNFG 0x03
47#define MAX22017_GEN_GPIO_CTRL 0x04
48#define MAX22017_GEN_GPIO_DATA 0x05
49#define MAX22017_GEN_GPI_INT 0x06
50#define MAX22017_GEN_GPI_INT_STA 0x07
51#define MAX22017_GEN_INT 0x08
52#define MAX22017_GEN_INTEN 0x09
53#define MAX22017_GEN_RST_CTRL 0x0A
54
55/* AO Registers */
56#define MAX22017_AO_CMD 0x40
57#define MAX22017_AO_STA 0x41
58#define MAX22017_AO_CNFG 0x42
59#define MAX22017_AO_SLEW_RATE_CH1 0x43
60#define MAX22017_AO_SLEW_RATE_CH2 0x44
61#define MAX22017_AO_DATA_CH1 0x45
62#define MAX22017_AO_DATA_CH2 0x46
63#define MAX22017_AO_OFFSET_CORR_CH1 0x47
64#define MAX22017_AO_GAIN_CORR_CH1 0x48
65#define MAX22017_AO_OFFSET_CORR_CH2 0x49
66#define MAX22017_AO_GAIN_CORR_CH2 0x4A
67
68#define MAX22017_FRAME_SIZE 3
69
70#define MAX22017_ADRR_MASK NO_OS_GENMASK(7, 1)
71#define MAX22017_RW_MASK NO_OS_BIT(0)
72#define MAX22017_PAYLOAD_LSB_MASK NO_OS_GENMASK(7, 0)
73#define MAX22017_PAYLOAD_MSB_MASK NO_OS_GENMASK(15, 8)
74#define MAX22017_CRC_MASK NO_OS_BIT(1)
75#define MAX22017_EXT_DAC_REF_MASK NO_OS_BIT(0)
76#define MAX22017_GPIO_MASK(x) NO_OS_BIT(8 + (x))
77#define MAX22017_GPIO_DIR_MASK(x) NO_OS_BIT(x)
78#define MAX22017_GPIO_OUT_VAL_MASK(x) NO_OS_BIT(8 + (x))
79#define MAX22017_GPIO_IN_VAL_MASK(x) NO_OS_BIT(x)
80#define MAX22017_SR_EN_MASK NO_OS_BIT(5)
81#define MAX22017_SR_SEL_MASK NO_OS_BIT(4)
82#define MAX22017_SR_STEP_SIZE_MASK NO_OS_GENMASK(3, 2)
83#define MAX22017_SR_UPDATE_RATE_MASK NO_OS_GENMASK(1, 0)
84#define MAX22017_AO_EN_MASK(x) NO_OS_BIT(x)
85#define MAX22017_AO_EN_MODE_MASK NO_OS_BIT(2)
86#define MAX22017_AI_EN_MASK(x) NO_OS_BIT(2 + (x))
87#define MAX22017_AI_EN_MODE_MASK NO_OS_BIT(1)
88#define MAX22017_AO_MODE_MASK(x) NO_OS_BIT(8 + (x))
89#define MAX22017_AO_MODE_MODE_MASK NO_OS_BIT(0)
90#define MAX22017_OP_MODE_MASK(x) (NO_OS_BIT(x) | NO_OS_BIT(2 + (x)) | NO_OS_BIT(8 + (x)))
91#define MAX22017_LD_CNFG_MASK(x) NO_OS_BIT(14 + (x))
92#define MAX22017_CM_SENSE_MASK(x) NO_OS_BIT(12 + (x))
93#define MAX22017_UNI_MASK(x) NO_OS_BIT(10 + (x))
94#define MAX22017_OW_MASK(x) NO_OS_BIT(4 + (x))
95#define MAX22017_CNFG_MASK(x) (NO_OS_BIT(14 + (x)) | NO_OS_BIT(12 + (x)) | NO_OS_BIT(10 + (x)) | NO_OS_BIT(4 + (x)))
96#define MAX22017_COEFF_ONLY_MASK NO_OS_GENMASK(15, 14)
97#define MAX22017_RST_MASK(x) NO_OS_BIT(14 + (x))
98#define MAX22017_TIMEOUT_SEL_MASK NO_OS_GENMASK(13, 10)
99#define MAX22017_TIMEOUT_CNFG_MASK NO_OS_BIT(9)
100#define MAX22017_TIMEOUT_EN_MASK NO_OS_BIT(8)
101#define MAX22017_TIMEOUT_MASK NO_OS_GENMASK(13, 8)
102
103#define MAX22017_COEFF_ONLY_VAL 0x03
104
105#define MAX22017_GPIO_NUMBER 4
106#define MAX22017_EXTRA_GPIO_NUMBER 2
107
109
119
124
129
148
159
170
175
183
196
210
212int32_t max22017_gpio_get(struct no_os_gpio_desc **,
213 const struct no_os_gpio_init_param *);
214
216int32_t max22017_gpio_remove(struct no_os_gpio_desc *);
217
220
222int32_t max22017_gpio_direction_output(struct no_os_gpio_desc *, uint8_t);
223
225int32_t max22017_gpio_get_direction(struct no_os_gpio_desc *, uint8_t *);
226
228int32_t max22017_gpio_set_value(struct no_os_gpio_desc *, uint8_t);
229
231int32_t max22017_gpio_get_value(struct no_os_gpio_desc *, uint8_t *);
232
234int max22017_set_timeout(struct max22017_desc *, bool, bool,
236
238int max22017_set_data(struct max22017_desc *, enum max22017_channel, int32_t);
239
241int max22017_get_data(struct max22017_desc *, enum max22017_channel, int32_t *);
242
246 bool, bool);
247
250 int16_t);
251
254 uint16_t);
255
258 enum max22017_op_mode);
259
262 enum max22017_out_mode, enum max22017_cm_sense, bool);
263
265int max22017_soft_reset(struct max22017_desc *, enum max22017_channel, bool);
266
268int max22017_reg_read(struct max22017_desc *, uint32_t, uint32_t *);
269
271int max22017_reg_write(struct max22017_desc *, uint32_t, uint32_t);
272
274int max22017_reg_update(struct max22017_desc *, uint32_t, uint32_t, uint32_t);
275
277int max22017_init(struct max22017_desc **, struct max22017_init_param *);
278
280int max22017_remove(struct max22017_desc *);
281
282#endif /* _MAX22017_H */
const struct no_os_gpio_platform_ops max22017_gpio_ops
Definition max22017.c:674
int32_t max22017_gpio_remove(struct no_os_gpio_desc *)
Free the resources allocated by no_os_gpio_get().
Definition max22017.c:92
int max22017_set_timeout(struct max22017_desc *, bool, bool, enum max22017_timeout_sel)
Set timeout settings for MAX22017 device.
Definition max22017.c:254
max22017_cm_sense
Definition max22017.h:125
@ MAX22017_250_OHM_RESISTOR
Definition max22017.h:127
@ MAX22017_50_OHM_RESISTOR
Definition max22017.h:126
max22017_op_mode
Definition max22017.h:110
@ MAX22017_OUTPUT_VOLTAGE_NO_MONITORRING
Definition max22017.h:114
@ MAX22017_OUTPUT_CURRENT_MONITORRING
Definition max22017.h:117
@ MAX22017_INPUT_VOLTAGE_MODE
Definition max22017.h:112
@ MAX22017_HIGH_Z
Definition max22017.h:111
@ MAX22017_OUTPUT_CURRENT_NO_MONITORRING
Definition max22017.h:115
@ MAX22017_OUTPUT_VOLTAGE_MONITORRING
Definition max22017.h:116
@ MAX22017_INPUT_CURRENT_MODE
Definition max22017.h:113
max22017_sr_update_rate
Definition max22017.h:160
@ MAX22017_UPDATE_RATE_32KHZ_16KHZ
Definition max22017.h:168
@ MAX22017_UPDATE_RATE_160KHZ_80KHZ
Definition max22017.h:163
@ MAX22017_UPDATE_RATE_64KHZ_32KHZ
Definition max22017.h:162
@ MAX22017_UPDATE_RATE_20KHZ_10KHZ
Definition max22017.h:167
@ MAX22017_UPDATE_RATE_4KHZ_2KHZ
Definition max22017.h:161
@ MAX22017_UPDATE_RATE_200KHZ_100KHZ
Definition max22017.h:164
@ MAX22017_UPDATE_RATE_12KHZ_6KHZ
Definition max22017.h:165
@ MAX22017_UPDATE_RATE_15KHZ_7KHZ
Definition max22017.h:166
int max22017_init(struct max22017_desc **, struct max22017_init_param *)
Initialize and configure the MAX22017 device.
Definition max22017.c:566
int max22017_reg_write(struct max22017_desc *, uint32_t, uint32_t)
Write the value of a device register.
Definition max22017.c:513
int max22017_get_data(struct max22017_desc *, enum max22017_channel, int32_t *)
Get data from requestec channel.
Definition max22017.c:294
int max22017_gain_calib(struct max22017_desc *, enum max22017_channel, uint16_t)
Set gain value for calibration of requested channel.
Definition max22017.c:362
int32_t max22017_gpio_get(struct no_os_gpio_desc **, const struct no_os_gpio_init_param *)
Obtain the GPIO decriptor.
Definition max22017.c:49
int32_t max22017_gpio_direction_output(struct no_os_gpio_desc *, uint8_t)
Enable the output direction of the specified GPIO.
Definition max22017.c:140
int32_t max22017_gpio_get_direction(struct no_os_gpio_desc *, uint8_t *)
Get the direction of the specified GPIO.
Definition max22017.c:170
int32_t max22017_gpio_get_value(struct no_os_gpio_desc *, uint8_t *)
Get the value of the specified GPIO.
Definition max22017.c:221
max22017_out_mode
Definition max22017.h:120
@ MAX22017_BIPOLAR
Definition max22017.h:121
@ MAX22017_UNIPOLAR
Definition max22017.h:122
max22017_channel
Definition max22017.h:171
@ MAX22017_CH2
Definition max22017.h:173
@ MAX22017_CH1
Definition max22017.h:172
#define MAX22017_FRAME_SIZE
Definition max22017.h:68
int32_t max22017_gpio_direction_input(struct no_os_gpio_desc *)
Enable the input direction of the specified GPIO.
Definition max22017.c:118
max22017_timeout_sel
Definition max22017.h:130
@ MAX22017_TIMEOUT_200MS
Definition max22017.h:132
@ MAX22017_TIMEOUT_1000MS
Definition max22017.h:140
@ MAX22017_TIMEOUT_400MS
Definition max22017.h:134
@ MAX22017_TIMEOUT_1500MS
Definition max22017.h:145
@ MAX22017_TIMEOUT_1300MS
Definition max22017.h:143
@ MAX22017_TIMEOUT_900MS
Definition max22017.h:139
@ MAX22017_TIMEOUT_1200MS
Definition max22017.h:142
@ MAX22017_TIMEOUT_1100MS
Definition max22017.h:141
@ MAX22017_TIMEOUT_600MS
Definition max22017.h:136
@ MAX22017_TIMEOUT_1400MS
Definition max22017.h:144
@ MAX22017_TIMEOUT_1600MS
Definition max22017.h:146
@ MAX22017_TIMEOUT_700MS
Definition max22017.h:137
@ MAX22017_TIMEOUT_500MS
Definition max22017.h:135
@ MAX22017_TIMEOUT_100MS
Definition max22017.h:131
@ MAX22017_TIMEOUT_300MS
Definition max22017.h:133
@ MAX22017_TIMEOUT_800MS
Definition max22017.h:138
int max22017_offset_calib(struct max22017_desc *, enum max22017_channel, int16_t)
Set offset value for output calibration.
Definition max22017.c:344
int max22017_reg_update(struct max22017_desc *, uint32_t, uint32_t, uint32_t)
Update the value of a device register (read/write sequence).
Definition max22017.c:544
int max22017_remove(struct max22017_desc *)
Free the resources allocated during init and perform a soft reset.
Definition max22017.c:652
int max22017_slew_rate(struct max22017_desc *, enum max22017_channel, enum max22017_sr_step_size, enum max22017_sr_update_rate, bool, bool)
Set slew rate settings for requested channels.
Definition max22017.c:321
max22017_sr_step_size
Definition max22017.h:149
@ MAX22017_STEP_SIZE_4096BITS
Definition max22017.h:152
@ MAX22017_STEP_SIZE_31BITS
Definition max22017.h:156
@ MAX22017_STEP_SIZE_28BITS
Definition max22017.h:155
@ MAX22017_STEP_SIZE_26BITS
Definition max22017.h:154
@ MAX22017_STEP_SIZE_1024BITS
Definition max22017.h:151
@ MAX22017_STEP_SIZE_16384BITS
Definition max22017.h:153
@ MAX22017_STEP_SIZE_35BITS
Definition max22017.h:157
@ MAX22017_STEP_SIZE_512BITS
Definition max22017.h:150
int32_t max22017_gpio_set_value(struct no_os_gpio_desc *, uint8_t)
Set the value of the specified GPIO.
Definition max22017.c:200
int max22017_config(struct max22017_desc *, enum max22017_channel, enum max22017_out_mode, enum max22017_cm_sense, bool)
Set AO configuration.
Definition max22017.c:404
int max22017_set_data(struct max22017_desc *, enum max22017_channel, int32_t)
Set data of the selected channel.
Definition max22017.c:274
int max22017_reg_read(struct max22017_desc *, uint32_t, uint32_t *)
Read the value of a device register.
Definition max22017.c:468
int max22017_soft_reset(struct max22017_desc *, enum max22017_channel, bool)
Soft reset requested channel.
Definition max22017.c:442
Header file of GPIO Interface.
Header file of SPI Interface.
Header file of utility functions.
Structure holding the MAX22017 device descriptor.
Definition max22017.h:200
bool crc_en
Definition max22017.h:207
struct no_os_spi_desc * comm_desc
Definition max22017.h:205
struct no_os_gpio_desc * ldac_desc
Definition max22017.h:201
uint8_t buff[MAX22017_FRAME_SIZE+1]
Definition max22017.h:206
struct no_os_gpio_desc * fault_desc
Definition max22017.h:204
struct no_os_gpio_desc * busy_desc
Definition max22017.h:203
struct no_os_gpio_desc * rstb_desc
Definition max22017.h:202
bool uni
Definition max22017.h:208
Structure holding the GPIO initialization parameter for the MAX22017 GPIO Controller.
Definition max22017.h:180
struct max22017_desc * max22017_desc
Definition max22017.h:181
Structure holding the MAX22017 initialization parameter.
Definition max22017.h:187
struct no_os_spi_init_param * comm_param
Definition max22017.h:192
struct no_os_gpio_init_param * rstb_param
Definition max22017.h:189
struct no_os_gpio_init_param * busy_param
Definition max22017.h:190
struct no_os_gpio_init_param * fault_param
Definition max22017.h:191
bool crc_en
Definition max22017.h:193
bool ext_dac_ref
Definition max22017.h:194
struct no_os_gpio_init_param * ldac_param
Definition max22017.h:188
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding gpio function pointers that point to the platform specific function.
Definition no_os_gpio.h:115
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128