no-OS
ad7689.h
Go to the documentation of this file.
1 /***************************************************************************/
39 #ifndef AD7689_H_
40 #define AD7689_H_
41 
42 #include <stdint.h>
43 #include <stdbool.h>
44 #include "no_os_spi.h"
45 
46 #define AD7689_CFG_CFG_MSK NO_OS_BIT(13)
47 #define AD7689_CFG_INCC_MSK NO_OS_GENMASK(12,10)
48 #define AD7689_CFG_INX_MSK NO_OS_GENMASK(9,7)
49 #define AD7689_CFG_BW_MSK NO_OS_BIT(6)
50 #define AD7689_CFG_REF_MSK NO_OS_GENMASK(5,3)
51 #define AD7689_CFG_SEQ_MSK NO_OS_GENMASK(2,1)
52 #define AD7689_CFG_RB_MSK NO_OS_BIT(0)
53 
67 };
68 
86 };
87 
92 enum ad7689_bw {
97 };
98 
116 };
117 
131 };
132 
141  uint8_t inx;
143  enum ad7689_bw bw;
149  bool rb;
150 };
151 
159 };
160 
161 struct ad7689_dev {
163  const char *name;
170 };
171 
172 int32_t ad7689_init(struct ad7689_dev **dev,
173  struct ad7689_init_param *init_param);
174 int32_t ad7689_write_config(struct ad7689_dev *dev,
175  struct ad7689_config *config);
176 int32_t ad7689_read_config(struct ad7689_dev *dev,
177  struct ad7689_config *config);
178 int32_t ad7689_read(struct ad7689_dev *dev, uint16_t *data,
179  uint32_t nb_samples);
180 int32_t ad7689_remove(struct ad7689_dev *dev);
181 
182 #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:222
AD7689_UNIPOLAR_GND
@ AD7689_UNIPOLAR_GND
Definition: ad7689.h:85
no_os_alloc.h
AD7689_SEQ_UPDATE_CFG
@ AD7689_SEQ_UPDATE_CFG
Definition: ad7689.h:126
AD7689_CFG_REF_MSK
#define AD7689_CFG_REF_MSK
Definition: ad7689.h:50
ad7689_config::ref
enum ad7689_ref ref
Definition: ad7689.h:145
AD7689_SEQ_SCAN_ALL
@ AD7689_SEQ_SCAN_ALL
Definition: ad7689.h:130
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:165
ad7689_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: ad7689.h:169
no_os_spi.h
Header file of SPI Interface.
ID_AD7689
@ ID_AD7689
Definition: ad7689.h:60
AD7689_CFG_RB_MSK
#define AD7689_CFG_RB_MSK
Definition: ad7689.h:52
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:199
pr_err
#define pr_err(fmt, args...)
Definition: no_os_print_log.h:94
AD7689_SEQ_DISABLE
@ AD7689_SEQ_DISABLE
Definition: ad7689.h:124
ad7689_read
int32_t ad7689_read(struct ad7689_dev *dev, uint16_t *data, uint32_t nb_samples)
Read ADC samples.
Definition: ad7689.c:256
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:199
ad7689_config::bw
enum ad7689_bw bw
Definition: ad7689.h:143
ad7689_bw
ad7689_bw
Low-pass filter bandwidth selection.
Definition: ad7689.h:92
AD7689_CFG_INCC_MSK
#define AD7689_CFG_INCC_MSK
Definition: ad7689.h:47
no_os_print_log.h
Print messages helpers.
ad7689_config
AD7689 configuration.
Definition: ad7689.h:137
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:60
bool
bool
Definition: common.h:54
ad7689_config::incc
enum ad7689_incc incc
Definition: ad7689.h:139
ad7689_ref
ad7689_ref
Reference/buffer selection.
Definition: ad7689.h:103
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:94
AD7689_SEQ_SCAN_ALL_THEN_TEMP
@ AD7689_SEQ_SCAN_ALL_THEN_TEMP
Definition: ad7689.h:128
no_os_error.h
Error codes definition.
AD7689_TEMPERATURE_SENSOR
@ AD7689_TEMPERATURE_SENSOR
Definition: ad7689.h:79
ad7689_dev::name
const char * name
Definition: ad7689.h:163
AD7689_UNIPOLAR_DIFFERENTIAL_PAIRS
@ AD7689_UNIPOLAR_DIFFERENTIAL_PAIRS
Definition: ad7689.h:81
ad7689_dev
Definition: ad7689.h:161
AD7689_BIPOLAR_DIFFERENTIAL_PAIRS
@ AD7689_BIPOLAR_DIFFERENTIAL_PAIRS
Definition: ad7689.h:75
ad7689_dev::configs
struct ad7689_config configs[2]
Definition: ad7689.h:167
ad7689_config::rb
bool rb
Definition: ad7689.h:149
AD7689_CFG_CFG_MSK
#define AD7689_CFG_CFG_MSK
Definition: ad7689.h:46
ad7689_device_id
ad7689_device_id
Device ID definitions.
Definition: ad7689.h:58
AD7689_BW_FULL
@ AD7689_BW_FULL
Definition: ad7689.h:96
AD7689_UNIPOLAR_COM
@ AD7689_UNIPOLAR_COM
Definition: ad7689.h:83
ID_AD7949
@ ID_AD7949
Definition: ad7689.h:64
ad7689_init_param::config
struct ad7689_config config
Definition: ad7689.h:156
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:177
AD7689_CFG_INX_MSK
#define AD7689_CFG_INX_MSK
Definition: ad7689.h:48
ad7689_config::seq
enum ad7689_seq seq
Definition: ad7689.h:147
ad7689_remove
int32_t ad7689_remove(struct ad7689_dev *dev)
Remove the driver's descriptor by freeing the associated resources.
Definition: ad7689.c:285
AD7689_CFG_SEQ_MSK
#define AD7689_CFG_SEQ_MSK
Definition: ad7689.h:51
ad7689_seq
ad7689_seq
Channel sequencer configuration.
Definition: ad7689.h:122
ad7689.h
Header file for the ad7689 driver.
ad7689_incc
ad7689_incc
Input channel configuration.
Definition: ad7689.h:73
AD7689_REF_IBUF
@ AD7689_REF_IBUF
Definition: ad7689.h:115
ID_AD7699
@ ID_AD7699
Definition: ad7689.h:66
ad7689_dev::id
enum ad7689_device_id id
Definition: ad7689.h:165
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:75
AD7689_BIPOLAR_COM
@ AD7689_BIPOLAR_COM
Definition: ad7689.h:77
AD7689_REF_EXTERNAL_TEMP_IBUF
@ AD7689_REF_EXTERNAL_TEMP_IBUF
Definition: ad7689.h:111
ad7689_remove
int32_t ad7689_remove(struct ad7689_dev *dev)
Remove the driver's descriptor by freeing the associated resources.
Definition: ad7689.c:285
NULL
#define NULL
Definition: wrapper.h:64
AD7689_REF_INTERNAL_4p096V
@ AD7689_REF_INTERNAL_4p096V
Definition: ad7689.h:107
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:119
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:147
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:122
ad7689_config::inx
uint8_t inx
Definition: ad7689.h:141
AD7689_REF_EXTERNAL
@ AD7689_REF_EXTERNAL
Definition: ad7689.h:113
ad7689_read
int32_t ad7689_read(struct ad7689_dev *dev, uint16_t *data, uint32_t nb_samples)
Read ADC samples.
Definition: ad7689.c:256
ID_AD7682
@ ID_AD7682
Definition: ad7689.h:62
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:147
AD7689_REF_INTERNAL_2p5V
@ AD7689_REF_INTERNAL_2p5V
Definition: ad7689.h:105
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:58
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:158
ad7689_init_param
Definition: ad7689.h:152
ad7689_device_name
const char * ad7689_device_name[]
Definition: ad7689.c:47
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:222
AD7689_CFG_BW_MSK
#define AD7689_CFG_BW_MSK
Definition: ad7689.h:49
AD7689_REF_EXTERNAL_TEMP
@ AD7689_REF_EXTERNAL_TEMP
Definition: ad7689.h:109
ad7689_init_param::id
enum ad7689_device_id id
Definition: ad7689.h:154
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:131