no-OS
ad7689.h
Go to the documentation of this file.
1 /***************************************************************************/
33 #ifndef AD7689_H_
34 #define AD7689_H_
35 
36 #include <stdint.h>
37 #include <stdbool.h>
38 #include "no_os_spi.h"
39 
40 #define AD7689_CFG_CFG_MSK NO_OS_BIT(13)
41 #define AD7689_CFG_INCC_MSK NO_OS_GENMASK(12,10)
42 #define AD7689_CFG_INX_MSK NO_OS_GENMASK(9,7)
43 #define AD7689_CFG_BW_MSK NO_OS_BIT(6)
44 #define AD7689_CFG_REF_MSK NO_OS_GENMASK(5,3)
45 #define AD7689_CFG_SEQ_MSK NO_OS_GENMASK(2,1)
46 #define AD7689_CFG_RB_MSK NO_OS_BIT(0)
47 
61 };
62 
80 };
81 
86 enum ad7689_bw {
91 };
92 
97 enum ad7689_ref {
110 };
111 
125 };
126 
135  uint8_t inx;
137  enum ad7689_bw bw;
143  bool rb;
144 };
145 
153 };
154 
155 struct ad7689_dev {
157  const char *name;
164 };
165 
166 int32_t ad7689_init(struct ad7689_dev **dev,
167  struct ad7689_init_param *init_param);
168 int32_t ad7689_write_config(struct ad7689_dev *dev,
169  struct ad7689_config *config);
170 int32_t ad7689_read_config(struct ad7689_dev *dev,
171  struct ad7689_config *config);
172 int32_t ad7689_read(struct ad7689_dev *dev, uint16_t *data,
173  uint32_t nb_samples);
174 int32_t ad7689_remove(struct ad7689_dev *dev);
175 
176 #endif
ad7689_read_config
int32_t ad7689_read_config(struct ad7689_dev *dev, struct ad7689_config *config)
Read the device's CFG register.
Definition: ad7689.c:216
AD7689_UNIPOLAR_GND
@ AD7689_UNIPOLAR_GND
Definition: ad7689.h:79
no_os_alloc.h
AD7689_SEQ_UPDATE_CFG
@ AD7689_SEQ_UPDATE_CFG
Definition: ad7689.h:120
AD7689_CFG_REF_MSK
#define AD7689_CFG_REF_MSK
Definition: ad7689.h:44
ad7689_config::ref
enum ad7689_ref ref
Definition: ad7689.h:139
AD7689_SEQ_SCAN_ALL
@ AD7689_SEQ_SCAN_ALL
Definition: ad7689.h:124
no_os_spi_write_and_read
int32_t no_os_spi_write_and_read(struct no_os_spi_desc *desc, uint8_t *data, uint16_t bytes_number)
Write and read data to/from SPI.
Definition: no_os_spi.c:159
ad7689_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad7689.h:163
no_os_spi.h
Header file of SPI Interface.
ID_AD7689
@ ID_AD7689
Definition: ad7689.h:54
AD7689_CFG_RB_MSK
#define AD7689_CFG_RB_MSK
Definition: ad7689.h:46
ad7689_write_config
int32_t ad7689_write_config(struct ad7689_dev *dev, struct ad7689_config *config)
Write the device's CFG register.
Definition: ad7689.c:193
pr_err
#define pr_err(fmt, args...)
Definition: no_os_print_log.h:88
AD7689_SEQ_DISABLE
@ AD7689_SEQ_DISABLE
Definition: ad7689.h:118
ad7689_read
int32_t ad7689_read(struct ad7689_dev *dev, uint16_t *data, uint32_t nb_samples)
Read ADC samples.
Definition: ad7689.c:250
no_os_delay.h
Header file of Delay functions.
ad7689_write_config
int32_t ad7689_write_config(struct ad7689_dev *dev, struct ad7689_config *config)
Write the device's CFG register.
Definition: ad7689.c:193
ad7689_config::bw
enum ad7689_bw bw
Definition: ad7689.h:137
ad7689_bw
ad7689_bw
Low-pass filter bandwidth selection.
Definition: ad7689.h:86
AD7689_CFG_INCC_MSK
#define AD7689_CFG_INCC_MSK
Definition: ad7689.h:41
no_os_print_log.h
Print messages helpers.
ad7689_config
AD7689 configuration.
Definition: ad7689.h:131
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
bool
bool
Definition: common.h:48
ad7689_config::incc
enum ad7689_incc incc
Definition: ad7689.h:133
ad7689_ref
ad7689_ref
Reference/buffer selection.
Definition: ad7689.h:97
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
AD7689_BW_QUARTER
@ AD7689_BW_QUARTER
Definition: ad7689.h:88
AD7689_SEQ_SCAN_ALL_THEN_TEMP
@ AD7689_SEQ_SCAN_ALL_THEN_TEMP
Definition: ad7689.h:122
no_os_error.h
Error codes definition.
AD7689_TEMPERATURE_SENSOR
@ AD7689_TEMPERATURE_SENSOR
Definition: ad7689.h:73
ad7689_dev::name
const char * name
Definition: ad7689.h:157
AD7689_UNIPOLAR_DIFFERENTIAL_PAIRS
@ AD7689_UNIPOLAR_DIFFERENTIAL_PAIRS
Definition: ad7689.h:75
ad7689_dev
Definition: ad7689.h:155
AD7689_BIPOLAR_DIFFERENTIAL_PAIRS
@ AD7689_BIPOLAR_DIFFERENTIAL_PAIRS
Definition: ad7689.h:69
ad7689_dev::configs
struct ad7689_config configs[2]
Definition: ad7689.h:161
ad7689_config::rb
bool rb
Definition: ad7689.h:143
AD7689_CFG_CFG_MSK
#define AD7689_CFG_CFG_MSK
Definition: ad7689.h:40
ad7689_device_id
ad7689_device_id
Device ID definitions.
Definition: ad7689.h:52
AD7689_BW_FULL
@ AD7689_BW_FULL
Definition: ad7689.h:90
AD7689_UNIPOLAR_COM
@ AD7689_UNIPOLAR_COM
Definition: ad7689.h:77
ID_AD7949
@ ID_AD7949
Definition: ad7689.h:58
ad7689_init_param::config
struct ad7689_config config
Definition: ad7689.h:150
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
AD7689_CFG_INX_MSK
#define AD7689_CFG_INX_MSK
Definition: ad7689.h:42
ad7689_config::seq
enum ad7689_seq seq
Definition: ad7689.h:141
ad7689_remove
int32_t ad7689_remove(struct ad7689_dev *dev)
Remove the driver's descriptor by freeing the associated resources.
Definition: ad7689.c:279
AD7689_CFG_SEQ_MSK
#define AD7689_CFG_SEQ_MSK
Definition: ad7689.h:45
ad7689_seq
ad7689_seq
Channel sequencer configuration.
Definition: ad7689.h:116
ad7689.h
Header file for the ad7689 driver.
ad7689_incc
ad7689_incc
Input channel configuration.
Definition: ad7689.h:67
AD7689_REF_IBUF
@ AD7689_REF_IBUF
Definition: ad7689.h:109
ID_AD7699
@ ID_AD7699
Definition: ad7689.h:60
ad7689_dev::id
enum ad7689_device_id id
Definition: ad7689.h:159
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
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
AD7689_BIPOLAR_COM
@ AD7689_BIPOLAR_COM
Definition: ad7689.h:71
AD7689_REF_EXTERNAL_TEMP_IBUF
@ AD7689_REF_EXTERNAL_TEMP_IBUF
Definition: ad7689.h:105
ad7689_remove
int32_t ad7689_remove(struct ad7689_dev *dev)
Remove the driver's descriptor by freeing the associated resources.
Definition: ad7689.c:279
NULL
#define NULL
Definition: wrapper.h:64
AD7689_REF_INTERNAL_4p096V
@ AD7689_REF_INTERNAL_4p096V
Definition: ad7689.h:101
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ad7689_init
int32_t ad7689_init(struct ad7689_dev **dev, struct ad7689_init_param *init_param)
Initialize the ad7689 driver and create a descriptor.
Definition: ad7689.c:141
no_os_spi_remove
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
ad7689_config::inx
uint8_t inx
Definition: ad7689.h:135
AD7689_REF_EXTERNAL
@ AD7689_REF_EXTERNAL
Definition: ad7689.h:107
ad7689_read
int32_t ad7689_read(struct ad7689_dev *dev, uint16_t *data, uint32_t nb_samples)
Read ADC samples.
Definition: ad7689.c:250
ID_AD7682
@ ID_AD7682
Definition: ad7689.h:56
ad7689_init
int32_t ad7689_init(struct ad7689_dev **dev, struct ad7689_init_param *init_param)
Initialize the ad7689 driver and create a descriptor.
Definition: ad7689.c:141
AD7689_REF_INTERNAL_2p5V
@ AD7689_REF_INTERNAL_2p5V
Definition: ad7689.h:99
no_os_spi_init
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
no_os_util.h
Header file of utility functions.
ad7689_init_param::spi_init
struct no_os_spi_init_param spi_init
Definition: ad7689.h:152
ad7689_init_param
Definition: ad7689.h:146
ad7689_device_name
const char * ad7689_device_name[]
Definition: ad7689.c:41
ad7689_read_config
int32_t ad7689_read_config(struct ad7689_dev *dev, struct ad7689_config *config)
Read the device's CFG register.
Definition: ad7689.c:216
AD7689_CFG_BW_MSK
#define AD7689_CFG_BW_MSK
Definition: ad7689.h:43
AD7689_REF_EXTERNAL_TEMP
@ AD7689_REF_EXTERNAL_TEMP
Definition: ad7689.h:103
ad7689_init_param::id
enum ad7689_device_id id
Definition: ad7689.h:148
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140