no-OS
pulsar_adc.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef SRC_PULSAR_ADC_H_
35 #define SRC_PULSAR_ADC_H_
36 
37 #include <stdbool.h>
38 
39 #if !defined(USE_STANDARD_SPI)
40 #include "spi_engine.h"
41 #include "clk_axi_clkgen.h"
42 #include "no_os_pwm.h"
43 #else
44 #include "no_os_spi.h"
45 #endif
46 #include "no_os_gpio.h"
47 
48 /******************************************************************************/
49 /********************** Macros and Constants Definitions **********************/
50 /******************************************************************************/
51 #define PULSAR_ADC_READ_COMMAND 0x54
52 #define PULSAR_ADC_WRITE_COMMAND 0x14
53 #define PULSAR_ADC_RESERVED_MSK 0xE0
54 
55 #define PULSAR_ADC_TURBO_MODE(x) (((x) & 0x1) << 1)
56 #define PULSAR_ADC_HIGH_Z_MODE(x) (((x) & 0x1) << 2)
57 #define PULSAR_ADC_SPAN_COMPRESSION(x) (((x) & 0x1) << 3)
58 #define PULSAR_ADC_EN_STATUS_BITS(x) (((x) & 0x1) << 4)
59 
88 };
89 
91  uint16_t resolution;
92  char sign;
93  uint16_t max_rate;
94 };
95 
97  /* SPI */
99  /* Clock gen for hdl design structure */
101  /* Trigger conversion PWM generator descriptor */
105  /* Register access speed */
107  /* Device Settings */
114  void (*dcache_invalidate_range)(uint32_t address, uint32_t bytes_count);
115  /* enable offload */
117 };
118 
120  /* SPI */
122  /* PWM generator init structure */
124  /* Clock gen for hdl design init structure */
126  /* Clock generator rate */
127  uint32_t axi_clkgen_rate;
130  /* Register access speed */
132  /* Device Settings */
137  void (*dcache_invalidate_range)(uint32_t address, uint32_t bytes_count);
138  /* buffer to store data samples */
139  uint32_t *buffer;
140  /* buffer size */
141  uint32_t buffer_size;
147 };
148 
149 int32_t pulsar_adc_spi_reg_read(struct pulsar_adc_dev *dev,
150  uint8_t *reg_data);
151 int32_t pulsar_adc_spi_reg_write(struct pulsar_adc_dev *dev,
152  uint8_t reg_data);
153 int32_t pulsar_adc_init(struct pulsar_adc_dev **device,
155 int32_t pulsar_adc_remove(struct pulsar_adc_dev *dev);
156 /* read data samples */
157 int32_t pulsar_adc_read_data(struct pulsar_adc_dev *dev, uint32_t *buf,
158  uint16_t samples);
159 #endif /* SRC_PULSAR_ADC_H_ */
ID_AD4008
@ ID_AD4008
Definition: pulsar_adc.h:69
pulsar_adc_init_param::dev_id
enum pulsar_adc_supported_dev_ids dev_id
Definition: pulsar_adc.h:133
PULSAR_ADC_HIGH_Z_MODE
#define PULSAR_ADC_HIGH_Z_MODE(x)
Definition: pulsar_adc.h:56
pulsar_adc_init_param::spi_init
struct no_os_spi_init_param * spi_init
Definition: pulsar_adc.h:121
ID_AD4006
@ ID_AD4006
Definition: pulsar_adc.h:67
no_os_alloc.h
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
PULSAR_ADC_WRITE_COMMAND
#define PULSAR_ADC_WRITE_COMMAND
Definition: pulsar_adc.h:52
no_os_pwm_init_param
Structure containing the init parameters needed by the PWM generator.
Definition: no_os_pwm.h:66
ID_AD4003
@ ID_AD4003
Definition: pulsar_adc.h:64
ID_AD7693
@ ID_AD7693
Definition: pulsar_adc.h:78
pulsar_adc_init_param::turbo_mode
bool turbo_mode
Definition: pulsar_adc.h:143
NO_OS_GENMASK
#define NO_OS_GENMASK(h, l)
Definition: no_os_util.h:82
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
CS_LOW
#define CS_LOW
Definition: spi_engine.h:73
ID_AD7946
@ ID_AD7946
Definition: pulsar_adc.h:81
pulsar_adc_spi_reg_write
int32_t pulsar_adc_spi_reg_write(struct pulsar_adc_dev *dev, uint8_t reg_data)
Definition: pulsar_adc.c:134
no_os_spi.h
Header file of SPI Interface.
ID_AD4022
@ ID_AD4022
Definition: pulsar_adc.h:74
spi_engine_offload_init
int32_t spi_engine_offload_init(struct no_os_spi_desc *desc, const struct spi_engine_offload_init_param *param)
Initialize the SPI engine's offload module.
Definition: spi_engine.c:763
no_os_pwm_remove
int32_t no_os_pwm_remove(struct no_os_pwm_desc *desc)
Free the resources allocated by no_os_pwm_init().
Definition: no_os_pwm.c:79
ID_AD4010
@ ID_AD4010
Definition: pulsar_adc.h:70
ID_AD7983
@ ID_AD7983
Definition: pulsar_adc.h:84
pulsar_adc_dev::trigger_pwm_desc
struct no_os_pwm_desc * trigger_pwm_desc
Definition: pulsar_adc.h:102
clk_axi_clkgen.h
Driver for the Analog Devices AXI CLKGEN.
pulsar_adc_init_param::span_compression
bool span_compression
Definition: pulsar_adc.h:145
spi_engine_offload_message::commands_data
uint32_t * commands_data
Definition: spi_engine.h:167
ID_AD7985
@ ID_AD7985
Definition: pulsar_adc.h:86
no_os_pwm_init_param::period_ns
uint32_t period_ns
Definition: no_os_pwm.h:70
pulsar_adc_init_param::en_status_bits
bool en_status_bits
Definition: pulsar_adc.h:146
axi_clkgen_init
Definition: clk_axi_clkgen.h:50
axi_clkgen_set_rate
int32_t axi_clkgen_set_rate(struct axi_clkgen *clkgen, uint32_t rate)
axi_clkgen_set_rate
Definition: clk_axi_clkgen.c:414
pulsar_adc_supported_dev_ids
pulsar_adc_supported_dev_ids
Definition: pulsar_adc.h:60
ID_AD7942
@ ID_AD7942
Definition: pulsar_adc.h:79
pulsar_adc_init_param
Definition: pulsar_adc.h:119
spi_engine_offload_message
Structure representing an offload message.
Definition: spi_engine.h:158
ID_AD7691
@ ID_AD7691
Definition: pulsar_adc.h:77
device
Definition: ad9361_util.h:69
pulsar_adc_init_param::offload_enable
bool offload_enable
Definition: pulsar_adc.h:142
pulsar_adc_init_param::reg_access_speed
uint32_t reg_access_speed
Definition: pulsar_adc.h:131
ID_AD7986
@ ID_AD7986
Definition: pulsar_adc.h:87
pulsar_adc_dev::offload_enable
bool offload_enable
Definition: pulsar_adc.h:116
axi_clkgen_init
int32_t axi_clkgen_init(struct axi_clkgen **clk, const struct axi_clkgen_init *init)
axi_clkgen_init
Definition: clk_axi_clkgen.c:520
axi_clkgen
Definition: clk_axi_clkgen.h:44
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
PULSAR_ADC_SPAN_COMPRESSION
#define PULSAR_ADC_SPAN_COMPRESSION(x)
Definition: pulsar_adc.h:57
pulsar_adc_dev_info
Definition: pulsar_adc.h:90
PULSAR_ADC_EN_STATUS_BITS
#define PULSAR_ADC_EN_STATUS_BITS(x)
Definition: pulsar_adc.h:58
ID_AD7690
@ ID_AD7690
Definition: pulsar_adc.h:76
ID_AD4004
@ ID_AD4004
Definition: pulsar_adc.h:65
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
pulsar_adc_spi_reg_write
int32_t pulsar_adc_spi_reg_write(struct pulsar_adc_dev *dev, uint8_t reg_data)
Definition: pulsar_adc.c:134
ID_AD7980
@ ID_AD7980
Definition: pulsar_adc.h:82
ad7616_init_param::reg_access_speed
uint32_t reg_access_speed
Definition: ad7616.h:212
pulsar_adc_dev::clkgen
struct axi_clkgen * clkgen
Definition: pulsar_adc.h:100
pulsar_adc_init_param::offload_init_param
struct spi_engine_offload_init_param * offload_init_param
Definition: pulsar_adc.h:135
pulsar_adc_remove
int32_t pulsar_adc_remove(struct pulsar_adc_dev *dev)
Free the resources allocated by pulsar_adc_init().
Definition: pulsar_adc.c:386
pulsar_adc_init_param::axi_clkgen_rate
uint32_t axi_clkgen_rate
Definition: pulsar_adc.h:127
CS_HIGH
#define CS_HIGH
Definition: spi_engine.h:72
ID_AD4021
@ ID_AD4021
Definition: pulsar_adc.h:73
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:148
ID_AD4000
@ ID_AD4000
Definition: pulsar_adc.h:61
no_os_error.h
Error codes definition.
NO_OS_DIV_ROUND_UP
#define NO_OS_DIV_ROUND_UP(x, y)
Definition: no_os_util.h:52
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:127
ad7616_init_param::offload_init_param
struct spi_engine_offload_init_param * offload_init_param
Definition: ad7616.h:205
pulsar_adc_dev::dcache_invalidate_range
void(* dcache_invalidate_range)(uint32_t address, uint32_t bytes_count)
Definition: pulsar_adc.h:114
ad7616_init_param::trigger_pwm_init
struct no_os_pwm_init_param * trigger_pwm_init
Definition: ad7616.h:207
spi_engine.h
PULSAR_ADC_READ_COMMAND
#define PULSAR_ADC_READ_COMMAND
Definition: pulsar_adc.h:51
pulsar_adc_dev_info::sign
char sign
Definition: pulsar_adc.h:92
pulsar_adc_init_param::dcache_invalidate_range
void(* dcache_invalidate_range)(uint32_t address, uint32_t bytes_count)
Definition: pulsar_adc.h:137
pulsar_adc_init_param::gpio_cnv
struct no_os_gpio_init_param * gpio_cnv
Definition: pulsar_adc.h:129
ID_ADAQ4003
@ ID_ADAQ4003
Definition: pulsar_adc.h:75
pulsar_adc_remove
int32_t pulsar_adc_remove(struct pulsar_adc_dev *dev)
Free the resources allocated by pulsar_adc_init().
Definition: pulsar_adc.c:386
ID_AD4002
@ ID_AD4002
Definition: pulsar_adc.h:63
pulsar_adc_init_param::buffer
uint32_t * buffer
Definition: pulsar_adc.h:139
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
no_os_spi_desc
Structure holding SPI descriptor.
Definition: no_os_spi.h:192
pulsar_adc_dev
Definition: pulsar_adc.h:96
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
ID_AD4007
@ ID_AD4007
Definition: pulsar_adc.h:68
no_os_pwm_desc
Structure representing an PWM generator device.
Definition: no_os_pwm.h:93
no_os_pwm_init_param::duty_cycle_ns
uint32_t duty_cycle_ns
Definition: no_os_pwm.h:72
ID_AD4011
@ ID_AD4011
Definition: pulsar_adc.h:71
no_os_pwm_init
int32_t no_os_pwm_init(struct no_os_pwm_desc **desc, const struct no_os_pwm_init_param *param)
Initialize the PWM peripheral.
Definition: no_os_pwm.c:51
ad7616_init_param::dcache_invalidate_range
void(* dcache_invalidate_range)(uint32_t address, uint32_t bytes_count)
Definition: ad7616.h:230
ad7616_init_param::axi_clkgen_rate
uint32_t axi_clkgen_rate
Definition: ad7616.h:211
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
pulsar_adc_devices
const struct pulsar_adc_dev_info pulsar_adc_devices[]
Definition: pulsar_adc.c:49
no_os_malloc
void * no_os_malloc(size_t size)
Allocate memory and return a pointer to it.
Definition: chibios_alloc.c:43
pulsar_adc_spi_reg_read
int32_t pulsar_adc_spi_reg_read(struct pulsar_adc_dev *dev, uint8_t *reg_data)
Definition: pulsar_adc.c:89
no_os_pwm.h
Header file of PWM Interface.
pulsar_adc_init
int32_t pulsar_adc_init(struct pulsar_adc_dev **device, struct pulsar_adc_init_param *init_param)
Definition: pulsar_adc.c:296
ID_AD4020
@ ID_AD4020
Definition: pulsar_adc.h:72
pulsar_adc_dev::offload_init_param
struct spi_engine_offload_init_param * offload_init_param
Definition: pulsar_adc.h:110
ID_AD7944
@ ID_AD7944
Definition: pulsar_adc.h:80
pulsar_adc_dev_info::max_rate
uint16_t max_rate
Definition: pulsar_adc.h:93
pulsar_adc_init_param::trigger_pwm_init
struct no_os_pwm_init_param * trigger_pwm_init
Definition: pulsar_adc.h:123
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
pulsar_adc_dev_info::resolution
uint16_t resolution
Definition: pulsar_adc.h:91
no_os_get_unaligned_be32
uint32_t no_os_get_unaligned_be32(uint8_t *buf)
no_os_gpio_set_value
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition: no_os_gpio.c:197
init_param
struct ad7616_init_param init_param
Definition: ad7616_sdz.c:113
ad7616_init_param::clkgen_init
struct axi_clkgen_init * clkgen_init
Definition: ad7616.h:209
pulsar_adc_read_data
int32_t pulsar_adc_read_data(struct pulsar_adc_dev *dev, uint32_t *buf, uint16_t samples)
Definition: pulsar_adc.c:267
pulsar_adc_init_param::clkgen_init
struct axi_clkgen_init * clkgen_init
Definition: pulsar_adc.h:125
pulsar_adc_spi_reg_read
int32_t pulsar_adc_spi_reg_read(struct pulsar_adc_dev *dev, uint8_t *reg_data)
Definition: pulsar_adc.c:89
pulsar_adc_init_param::buffer_size
uint32_t buffer_size
Definition: pulsar_adc.h:141
pulsar_adc_dev::dev_info
const struct pulsar_adc_dev_info * dev_info
Definition: pulsar_adc.h:112
spi_engine_offload_transfer
int32_t spi_engine_offload_transfer(struct no_os_spi_desc *desc, struct spi_engine_offload_message msg, uint32_t no_samples)
Initiate a SPI transfer in offload mode.
Definition: spi_engine.c:809
PULSAR_ADC_TURBO_MODE
#define PULSAR_ADC_TURBO_MODE(x)
Definition: pulsar_adc.h:55
ID_AD7982
@ ID_AD7982
Definition: pulsar_adc.h:83
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
spi_engine_offload_init_param
Structure containing the init parameters needed by the offload module.
Definition: spi_engine.h:143
no_os_gpio.h
Header file of GPIO Interface.
pulsar_adc_dev::spi_desc
struct no_os_spi_desc * spi_desc
Definition: pulsar_adc.h:98
pulsar_adc_dev::gpio_cnv
struct no_os_gpio_desc * gpio_cnv
Definition: pulsar_adc.h:104
no_os_spi_desc::max_speed_hz
uint32_t max_speed_hz
Definition: no_os_spi.h:198
ID_AD4005
@ ID_AD4005
Definition: pulsar_adc.h:66
ID_AD7984
@ ID_AD7984
Definition: pulsar_adc.h:85
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
axi_clkgen_remove
int32_t axi_clkgen_remove(struct axi_clkgen *clkgen)
axi_clkgen_remove
Definition: clk_axi_clkgen.c:541
no_os_util.h
Header file of utility functions.
pulsar_adc_dev::dev_id
enum pulsar_adc_supported_dev_ids dev_id
Definition: pulsar_adc.h:108
pulsar_adc_init
int32_t pulsar_adc_init(struct pulsar_adc_dev **device, struct pulsar_adc_init_param *init_param)
Definition: pulsar_adc.c:296
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
PULSAR_ADC_RESERVED_MSK
#define PULSAR_ADC_RESERVED_MSK
Definition: pulsar_adc.h:53
ID_AD4001
@ ID_AD4001
Definition: pulsar_adc.h:62
pulsar_adc_init_param::high_z_mode
bool high_z_mode
Definition: pulsar_adc.h:144
pulsar_adc.h
Header file for pulsar_adc Driver.
READ
#define READ(no_bytes)
Definition: spi_engine.h:62
pulsar_adc_dev::reg_access_speed
uint32_t reg_access_speed
Definition: pulsar_adc.h:106
no_os_spi_init_param
Structure holding the parameters for SPI initialization.
Definition: no_os_spi.h:140
pulsar_adc_read_data
int32_t pulsar_adc_read_data(struct pulsar_adc_dev *dev, uint32_t *buf, uint16_t samples)
Definition: pulsar_adc.c:267