no-OS
ad400x.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef SRC_AD400X_H_
41 #define SRC_AD400X_H_
42 
43 #include "spi_engine.h"
44 
45 /******************************************************************************/
46 /********************** Macros and Constants Definitions **********************/
47 /******************************************************************************/
48 #define AD400X_READ_COMMAND 0x54
49 #define AD400X_WRITE_COMMAND 0x14
50 #define AD400X_RESERVED_MSK 0xE0
51 
52 #define AD400X_TURBO_MODE(x) (((x) & 0x1) << 1)
53 #define AD400X_HIGH_Z_MODE(x) (((x) & 0x1) << 2)
54 #define AD400X_SPAN_COMPRESSION(x) (((x) & 0x1) << 3)
55 #define AD400X_EN_STATUS_BITS(x) (((x) & 0x1) << 4)
56 
62 };
63 
64 extern const uint16_t ad400x_device_resol[];
65 
66 struct ad400x_dev {
67  /* SPI */
69  /* Register access speed */
70  uint32_t reg_access_speed;
71  /* Device Settings */
73 };
74 
76  /* SPI */
78  /* Register access speed */
79  uint32_t reg_access_speed;
80  /* Device Settings */
82  bool turbo_mode;
86 };
87 
88 int32_t ad400x_spi_reg_read(struct ad400x_dev *dev,
89  uint8_t *reg_data);
90 int32_t ad400x_spi_reg_write(struct ad400x_dev *dev,
91  uint8_t reg_data);
92 int32_t ad400x_init(struct ad400x_dev **device,
94 int32_t ad400x_remove(struct ad400x_dev *dev);
95 /* Execute a single conversion */
96 int32_t ad400x_spi_single_conversion(struct ad400x_dev *dev,
97  uint32_t *adc_data);
98 
99 #endif /* SRC_AD400X_H_ */
ad400x_spi_reg_write
int32_t ad400x_spi_reg_write(struct ad400x_dev *dev, uint8_t reg_data)
Definition: ad400x.c:96
adc_data
Definition: ad77681.h:496
ad400x_spi_reg_read
int32_t ad400x_spi_reg_read(struct ad400x_dev *dev, uint8_t *reg_data)
Definition: ad400x.c:70
ad400x_init_param
Definition: ad400x.h:75
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:82
ad400x_dev::spi_desc
no_os_spi_desc * spi_desc
Definition: ad400x.h:68
ad400x_supported_dev_ids
ad400x_supported_dev_ids
Definition: ad400x.h:57
spi_engine_init_param::data_width
uint8_t data_width
Definition: spi_engine.h:99
AD400X_READ_COMMAND
#define AD400X_READ_COMMAND
Definition: ad400x.h:48
ad400x_device_resol
const uint16_t ad400x_device_resol[]
Device resolution.
Definition: ad400x.c:53
device
Definition: ad9361_util.h:75
ad400x_spi_reg_read
int32_t ad400x_spi_reg_read(struct ad400x_dev *dev, uint8_t *reg_data)
Definition: ad400x.c:70
AD400X_EN_STATUS_BITS
#define AD400X_EN_STATUS_BITS(x)
Definition: ad400x.h:55
ad400x_spi_single_conversion
int32_t ad400x_spi_single_conversion(struct ad400x_dev *dev, uint32_t *adc_data)
Definition: ad400x.c:121
AD400X_RESERVED_MSK
#define AD400X_RESERVED_MSK
Definition: ad400x.h:50
ad400x_spi_reg_write
int32_t ad400x_spi_reg_write(struct ad400x_dev *dev, uint8_t reg_data)
Definition: ad400x.c:96
ad7616_init_param::reg_access_speed
uint32_t reg_access_speed
Definition: ad7616.h:169
ad400x_dev
Definition: ad400x.h:66
ad400x_remove
int32_t ad400x_remove(struct ad400x_dev *dev)
Free the resources allocated by ad400x_init().
Definition: ad400x.c:192
AD400X_TURBO_MODE
#define AD400X_TURBO_MODE(x)
Definition: ad400x.h:52
spi_engine_set_speed
void spi_engine_set_speed(struct no_os_spi_desc *desc, uint32_t speed_hz)
Set SPI engine clock frequency.
Definition: spi_engine.c:150
no_os_error.h
Error codes definition.
ad400x_dev::dev_id
enum ad400x_supported_dev_ids dev_id
Definition: ad400x.h:72
ad400x_dev::reg_access_speed
uint32_t reg_access_speed
Definition: ad400x.h:70
spi_engine_set_transfer_width
int32_t spi_engine_set_transfer_width(struct no_os_spi_desc *desc, uint8_t data_wdith)
Set width of the transfered word over SPI.
Definition: spi_engine.c:129
ad400x_init_param::high_z_mode
bool high_z_mode
Definition: ad400x.h:83
AD400X_SPAN_COMPRESSION
#define AD400X_SPAN_COMPRESSION(x)
Definition: ad400x.h:54
spi_engine.h
ad400x_device_resol
const uint16_t ad400x_device_resol[]
Device resolution.
Definition: ad400x.c:53
ID_AD4003
@ ID_AD4003
Definition: ad400x.h:58
ad400x_init_param::turbo_mode
bool turbo_mode
Definition: ad400x.h:82
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:132
ID_AD4020
@ ID_AD4020
Definition: ad400x.h:61
spi_eng_init_param
struct spi_engine_init_param spi_eng_init_param
Definition: ad7616_sdz.c:70
ad400x_init_param::en_status_bits
bool en_status_bits
Definition: ad400x.h:85
ad400x_init
int32_t ad400x_init(struct ad400x_dev **device, struct ad400x_init_param *init_param)
Definition: ad400x.c:141
ad400x.h
Header file for ad400x Driver.
ad400x_remove
int32_t ad400x_remove(struct ad400x_dev *dev)
Free the resources allocated by ad400x_init().
Definition: ad400x.c:192
ID_AD4007
@ ID_AD4007
Definition: ad400x.h:59
AD400X_HIGH_Z_MODE
#define AD400X_HIGH_Z_MODE(x)
Definition: ad400x.h:53
spi_engine_init_param
Structure containing the init parameters needed by the SPI engine.
Definition: spi_engine.h:89
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:96
ad400x_init_param::reg_access_speed
uint32_t reg_access_speed
Definition: ad400x.h:79
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:70
no_os_spi_desc::max_speed_hz
uint32_t max_speed_hz
Definition: no_os_spi.h:136
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:51
ad400x_init
int32_t ad400x_init(struct ad400x_dev **device, struct ad400x_init_param *init_param)
Definition: ad400x.c:141
AD400X_WRITE_COMMAND
#define AD400X_WRITE_COMMAND
Definition: ad400x.h:49
ad400x_init_param::spi_init
no_os_spi_init_param spi_init
Definition: ad400x.h:77
ad400x_init_param::span_compression
bool span_compression
Definition: ad400x.h:84
ID_AD4011
@ ID_AD4011
Definition: ad400x.h:60
ad400x_spi_single_conversion
int32_t ad400x_spi_single_conversion(struct ad400x_dev *dev, uint32_t *adc_data)
Definition: ad400x.c:121
ad400x_init_param::dev_id
enum ad400x_supported_dev_ids dev_id
Definition: ad400x.h:81
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:112