no-OS
max9611.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef __MAX9611_H__
35 #define __MAX9611_H__
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 #include <stdint.h>
41 #include <stdlib.h>
42 #include "no_os_i2c.h"
43 #include "no_os_util.h"
44 #include "no_os_error.h"
45 #include "no_os_delay.h"
46 
47 #define MAX9611_MUX_MASK NO_OS_GENMASK(2, 0)
48 #define MAX9611_MODE_MASK NO_OS_GENMASK(7, 5)
49 #define MAX9611_RAW_DATA_MASK NO_OS_GENMASK(15, 4)
50 
51 #define MAX9611_SHDN_MASK NO_OS_BIT(3)
52 #define MAX9611_LR_MASK NO_OS_BIT(4)
53 #define MAX9611_DTIME_MASK NO_OS_BIT(3)
54 #define MAX9611_RTIME_MASK NO_OS_BIT(2)
55 
56 #define MAX9611_CSA_MSB 0x00
57 #define MAX9611_CSA_LSB 0x01
58 #define MAX9611_RSP_MSB 0x02
59 #define MAX9611_RSP_LSB 0x03
60 #define MAX9611_OUT_MSB 0x04
61 #define MAX9611_OUT_LSB 0x05
62 #define MAX9611_SET_MSB 0x06
63 #define MAX9611_SET_LSB 0x07
64 #define MAX9611_TMP_MSB 0x08
65 #define MAX9611_TMP_LSB 0x09
66 #define MAX9611_CTR1 0x0A
67 #define MAX9611_CTR2 0x0B
68 
69 #define MAX9611_OUT_OF_BOUNDS 0x0C
70 
71 /******************************************************************************/
72 /*************************** Types Declarations *******************************/
73 /******************************************************************************/
80 };
81 
87 };
88 
92 };
93 
97 };
98 
108 };
109 
114 };
115 
116 struct max9611_dev {
118  /* ADC Data configuration */
120 };
121 
124 };
125 
126 /* Generate slave address depending on A0 and A1 logic levels */
127 int max9611_addr_gen(struct max9611_init_param *device_ip,
128  enum max9611_addr_lvls a0, enum max9611_addr_lvls a1);
129 
130 /* Initialize device */
131 int max9611_init(struct max9611_dev **device,
133 
134 /* Deallocate resources for device */
135 int max9611_remove(struct max9611_dev *dev);
136 
137 /* Read byte/s from selected starting register */
138 int max9611_read(struct max9611_dev *dev, uint8_t addr,
139  uint8_t bytes, uint8_t *read_data);
140 
141 /* Write byte/s to selected starting register */
142 int max9611_write(struct max9611_dev *dev, uint8_t addr,
143  uint8_t bytes, uint8_t *write_data);
144 
145 /* Update selected register using mask and desired value */
146 int max9611_reg_update(struct max9611_dev *dev, uint8_t addr,
147  int update_mask, int update_val);
148 
149 /* Set MAX9611 operating mode */
150 int max9611_set_mode(struct max9611_dev *dev, enum max9611_mode_conf mode);
151 
152 /* Get MAX9611 operating mode */
153 int max9611_get_mode(struct max9611_dev *dev, enum max9611_mode_conf *mode);
154 
155 /* Set MAX9611 MUX configuration */
156 int max9611_set_mux(struct max9611_dev *dev, enum max9611_mux_conf mux);
157 
158 /* Get MAX9611 MUX configuration */
159 int max9611_get_mux(struct max9611_dev *dev, enum max9611_mux_conf *mux);
160 
161 /* Configure MAX9611 for shutdown or power up */
162 int max9611_shutdown(struct max9611_dev *dev, bool is_shdn);
163 
164 /* Set MAX9611 LR bit */
165 int max9611_set_lr(struct max9611_dev *dev, bool is_normal);
166 
167 /* Get MAX9611 LR bit */
168 int max9611_get_lr(struct max9611_dev *dev, bool *lr);
169 
170 /* Set MAX9611 delay time */
171 int max9611_set_delay(struct max9611_dev *dev, enum max9611_delay_time dtime);
172 
173 /* Get MAX9611 delay time */
174 int max9611_get_delay(struct max9611_dev *dev, enum max9611_delay_time *dtime);
175 
176 /* Set MAX9611 retry time */
177 int max9611_set_retry(struct max9611_dev *dev, enum max9611_retry_time rtime);
178 
179 /* Get MAX9611 retry time */
180 int max9611_get_retry(struct max9611_dev *dev, enum max9611_retry_time *rtime);
181 
182 /* Get MAX9611 raw data */
183 int max9611_get_raw(struct max9611_dev *dev, uint16_t *raw);
184 
185 #endif /* __MAX9611_H__ */
MAX9611_RSP_MSB
#define MAX9611_RSP_MSB
Definition: max9611.h:58
max9611_read
int max9611_read(struct max9611_dev *dev, uint8_t addr, uint8_t bytes, uint8_t *read_data)
Reads data from device register (I2C)
Definition: max9611.c:144
no_os_alloc.h
max9611_get_mux
int max9611_get_mux(struct max9611_dev *dev, enum max9611_mux_conf *mux)
Get the internal MUX settings.
Definition: max9611.c:304
max9611_dev
Definition: max9611.h:116
no_os_i2c_write
int32_t no_os_i2c_write(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Write data to slave device.
Definition: no_os_i2c.c:159
MAX9611_DTIME_MASK
#define MAX9611_DTIME_MASK
Definition: max9611.h:53
no_os_i2c_init
int32_t no_os_i2c_init(struct no_os_i2c_desc **desc, const struct no_os_i2c_init_param *param)
Initialize the I2C communication peripheral.
Definition: no_os_i2c.c:52
max9611_shutdown
int max9611_shutdown(struct max9611_dev *dev, bool is_shdn)
Device shutdown or power up.
Definition: max9611.c:324
max9611_reg_update
int max9611_reg_update(struct max9611_dev *dev, uint8_t addr, int update_mask, int update_val)
Update selected I2C register contents.
Definition: max9611.c:206
no_os_i2c_init_param::slave_address
uint8_t slave_address
Definition: no_os_i2c.h:70
max9611_get_raw
int max9611_get_raw(struct max9611_dev *dev, uint16_t *raw)
Receive data from ADC (single value only).
Definition: max9611.c:448
no_os_i2c_remove
int32_t no_os_i2c_remove(struct no_os_i2c_desc *desc)
Free the resources allocated by no_os_i2c_init().
Definition: no_os_i2c.c:113
max9611_write
int max9611_write(struct max9611_dev *dev, uint8_t addr, uint8_t bytes, uint8_t *write_data)
Writes data to device register (I2C)
Definition: max9611.c:172
max9611_read
int max9611_read(struct max9611_dev *dev, uint8_t addr, uint8_t bytes, uint8_t *read_data)
Reads data from device register (I2C)
Definition: max9611.c:144
max9611_set_mux
int max9611_set_mux(struct max9611_dev *dev, enum max9611_mux_conf mux)
Configures the internal MUX settings.
Definition: max9611.c:264
max9611_get_lr
int max9611_get_lr(struct max9611_dev *dev, bool *lr)
Get LR bit value.
Definition: max9611.c:354
MAX9611_DATA_RSP
@ MAX9611_DATA_RSP
Definition: max9611.h:76
MAX9611_CONF_SENSE_8X
@ MAX9611_CONF_SENSE_8X
Definition: max9611.h:102
MAX9611_OUT_MSB
#define MAX9611_OUT_MSB
Definition: max9611.h:60
max9611_get_raw
int max9611_get_raw(struct max9611_dev *dev, uint16_t *raw)
Receive data from ADC (single value only).
Definition: max9611.c:448
no_os_delay.h
Header file of Delay functions.
MAX9611_COMPARATOR_MODE
@ MAX9611_COMPARATOR_MODE
Definition: max9611.h:113
max9611_addr_gen
int max9611_addr_gen(struct max9611_init_param *device_ip, enum max9611_addr_lvls a0, enum max9611_addr_lvls a1)
Generates slave address based on A1 and A0 pin values.
Definition: max9611.c:54
MAX9611_MODE_MASK
#define MAX9611_MODE_MASK
Definition: max9611.h:48
MAX9611_TMP_MSB
#define MAX9611_TMP_MSB
Definition: max9611.h:64
device
Definition: ad9361_util.h:69
MAX9611_50MS
@ MAX9611_50MS
Definition: max9611.h:95
max9611_set_retry
int max9611_set_retry(struct max9611_dev *dev, enum max9611_retry_time rtime)
Configures MAX9611 retry time.
Definition: max9611.c:411
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
max9611_write
int max9611_write(struct max9611_dev *dev, uint8_t addr, uint8_t bytes, uint8_t *write_data)
Writes data to device register (I2C)
Definition: max9611.c:172
max9611_set_mux
int max9611_set_mux(struct max9611_dev *dev, enum max9611_mux_conf mux)
Configures the internal MUX settings.
Definition: max9611.c:264
max9611_init
int max9611_init(struct max9611_dev **device, struct max9611_init_param init_param)
Initializes the communication peripheral and checks if the device is present.
Definition: max9611.c:97
bool
bool
Definition: common.h:48
max9611_get_mode
int max9611_get_mode(struct max9611_dev *dev, enum max9611_mode_conf *mode)
Get the MAX9611 operating mode.
Definition: max9611.c:244
MAX9611_CTR2
#define MAX9611_CTR2
Definition: max9611.h:67
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
max9611.h
Header file of max9611 Family Driver.
max9611_get_retry
int max9611_get_retry(struct max9611_dev *dev, enum max9611_retry_time *rtime)
Get MAX9611 configured retry time.
Definition: max9611.c:428
MAX9611_DATA_OUT
@ MAX9611_DATA_OUT
Definition: max9611.h:77
no_os_error.h
Error codes definition.
MAX9611_CSA_MSB
#define MAX9611_CSA_MSB
Definition: max9611.h:56
max9611_set_delay
int max9611_set_delay(struct max9611_dev *dev, enum max9611_delay_time dtime)
Configures MAX9611 delay time.
Definition: max9611.c:374
MAX9611_DATA_TMP
@ MAX9611_DATA_TMP
Definition: max9611.h:79
MAX9611_CONF_OUT_ADC
@ MAX9611_CONF_OUT_ADC
Definition: max9611.h:104
MAX9611_DATA_SET
@ MAX9611_DATA_SET
Definition: max9611.h:78
max9611_set_lr
int max9611_set_lr(struct max9611_dev *dev, bool is_normal)
Configure LR bit operation.
Definition: max9611.c:339
MAX9611_SHDN_MASK
#define MAX9611_SHDN_MASK
Definition: max9611.h:51
max9611_init_param
Definition: max9611.h:122
max9611_set_mode
int max9611_set_mode(struct max9611_dev *dev, enum max9611_mode_conf mode)
Configures MAX9611 operating mode.
Definition: max9611.c:228
max9611_mode_conf
max9611_mode_conf
Definition: max9611.h:110
max9611_set_retry
int max9611_set_retry(struct max9611_dev *dev, enum max9611_retry_time rtime)
Configures MAX9611 retry time.
Definition: max9611.c:411
max9611_set_mode
int max9611_set_mode(struct max9611_dev *dev, enum max9611_mode_conf mode)
Configures MAX9611 operating mode.
Definition: max9611.c:228
max9611_shutdown
int max9611_shutdown(struct max9611_dev *dev, bool is_shdn)
Device shutdown or power up.
Definition: max9611.c:324
max9611_init
int max9611_init(struct max9611_dev **device, struct max9611_init_param init_param)
Initializes the communication peripheral and checks if the device is present.
Definition: max9611.c:97
MAX9611_CONF_SENSE_4X
@ MAX9611_CONF_SENSE_4X
Definition: max9611.h:101
MAX9611_NORMAL_MODE
@ MAX9611_NORMAL_MODE
Definition: max9611.h:111
max9611_data
max9611_data
Definition: max9611.h:74
MAX9611_CONF_TEMP
@ MAX9611_CONF_TEMP
Definition: max9611.h:106
max9611_remove
int max9611_remove(struct max9611_dev *dev)
Free the resources allocated by max538x_init().
Definition: max9611.c:126
MAX9611_CONF_IN_COM_MODE
@ MAX9611_CONF_IN_COM_MODE
Definition: max9611.h:103
MAX9611_CONF_SENSE_1X
@ MAX9611_CONF_SENSE_1X
Definition: max9611.h:100
MAX9611_SET_MSB
#define MAX9611_SET_MSB
Definition: max9611.h:62
MAX9611_FAST_MODE
@ MAX9611_FAST_MODE
Definition: max9611.h:107
MAX9611_OPAMP_MODE
@ MAX9611_OPAMP_MODE
Definition: max9611.h:112
no_os_i2c_desc
Structure holding I2C address descriptor.
Definition: no_os_i2c.h:101
no_os_i2c_read
int32_t no_os_i2c_read(struct no_os_i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
I2C Read data from slave device.
Definition: no_os_i2c.c:190
MAX9611_66_VCC
@ MAX9611_66_VCC
Definition: max9611.h:85
no_os_i2c.h
Header file of I2C Interface.
max9611_dev::i2c_desc
struct no_os_i2c_desc * i2c_desc
Definition: max9611.h:117
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
MAX9611_CONF_SET_ADC
@ MAX9611_CONF_SET_ADC
Definition: max9611.h:105
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
MAX9611_RTIME_MASK
#define MAX9611_RTIME_MASK
Definition: max9611.h:54
MAX9611_ZERO_VCC
@ MAX9611_ZERO_VCC
Definition: max9611.h:83
max9611_dev::capture_type
enum max9611_data capture_type
Definition: max9611.h:119
no_os_i2c_init_param
Structure holding the parameters for I2C initialization.
Definition: no_os_i2c.h:64
max9611_get_lr
int max9611_get_lr(struct max9611_dev *dev, bool *lr)
Get LR bit value.
Definition: max9611.c:354
MAX9611_DATA_CSA
@ MAX9611_DATA_CSA
Definition: max9611.h:75
MAX9611_100US
@ MAX9611_100US
Definition: max9611.h:91
MAX9611_RAW_DATA_MASK
#define MAX9611_RAW_DATA_MASK
Definition: max9611.h:49
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
max9611_get_delay
int max9611_get_delay(struct max9611_dev *dev, enum max9611_delay_time *dtime)
Get MAX9611 configured delay time.
Definition: max9611.c:391
max9611_mux_conf
max9611_mux_conf
Definition: max9611.h:99
MAX9611_OUT_OF_BOUNDS
#define MAX9611_OUT_OF_BOUNDS
Definition: max9611.h:69
MAX9611_33_VCC
@ MAX9611_33_VCC
Definition: max9611.h:84
max9611_get_delay
int max9611_get_delay(struct max9611_dev *dev, enum max9611_delay_time *dtime)
Get MAX9611 configured delay time.
Definition: max9611.c:391
MAX9611_10MS
@ MAX9611_10MS
Definition: max9611.h:96
max9611_set_delay
int max9611_set_delay(struct max9611_dev *dev, enum max9611_delay_time dtime)
Configures MAX9611 delay time.
Definition: max9611.c:374
MAX9611_1MS
@ MAX9611_1MS
Definition: max9611.h:90
max9611_set_lr
int max9611_set_lr(struct max9611_dev *dev, bool is_normal)
Configure LR bit operation.
Definition: max9611.c:339
MAX9611_MUX_MASK
#define MAX9611_MUX_MASK
Definition: max9611.h:47
no_os_get_unaligned_be16
uint16_t no_os_get_unaligned_be16(uint8_t *buf)
MAX9611_LR_MASK
#define MAX9611_LR_MASK
Definition: max9611.h:52
max9611_init_param::i2c_init
struct no_os_i2c_init_param i2c_init
Definition: max9611.h:123
max9611_delay_time
max9611_delay_time
Definition: max9611.h:89
no_os_util.h
Header file of utility functions.
max9611_addr_lvls
max9611_addr_lvls
Definition: max9611.h:82
MAX9611_CTR1
#define MAX9611_CTR1
Definition: max9611.h:66
max9611_get_mode
int max9611_get_mode(struct max9611_dev *dev, enum max9611_mode_conf *mode)
Get the MAX9611 operating mode.
Definition: max9611.c:244
max9611_retry_time
max9611_retry_time
Definition: max9611.h:94
max9611_get_retry
int max9611_get_retry(struct max9611_dev *dev, enum max9611_retry_time *rtime)
Get MAX9611 configured retry time.
Definition: max9611.c:428
max9611_remove
int max9611_remove(struct max9611_dev *dev)
Free the resources allocated by max538x_init().
Definition: max9611.c:126
max9611_addr_gen
int max9611_addr_gen(struct max9611_init_param *device_ip, enum max9611_addr_lvls a0, enum max9611_addr_lvls a1)
Generates slave address based on A1 and A0 pin values.
Definition: max9611.c:54
max9611_reg_update
int max9611_reg_update(struct max9611_dev *dev, uint8_t addr, int update_mask, int update_val)
Update selected I2C register contents.
Definition: max9611.c:206
MAX9611_100_VCC
@ MAX9611_100_VCC
Definition: max9611.h:86
max9611_get_mux
int max9611_get_mux(struct max9611_dev *dev, enum max9611_mux_conf *mux)
Get the internal MUX settings.
Definition: max9611.c:304