precision-converters-firmware
Loading...
Searching...
No Matches
app_config.h
Go to the documentation of this file.
1/*************************************************************************/
14#ifndef APP_CONFIG_H
15#define APP_CONFIG_H
16
17/******************************************************************************/
18/***************************** Include Files **********************************/
19/******************************************************************************/
20#include <stdint.h>
21#include "no_os_gpio.h"
22#include "no_os_uart.h"
23#include "no_os_irq.h"
24#include "no_os_pwm.h"
25#include "common.h"
26
27/******************************************************************************/
28/********************** Macros and Constants Definition ***********************/
29/******************************************************************************/
30/* List of supported platforms */
31#define MBED_PLATFORM 1
32#define STM32_PLATFORM 2
33
34/* List of data capture modes supported by application*/
35#define CONTINUOUS_DATA_CAPTURE 0
36#define WINDOWED_DATA_CAPTURE 1
37
38/* List of supported data format by device */
39#define STRAIGHT_BINARY 0
40#define TWOS_COMPLEMENT 1
41
42/* Macros for stringification */
43#define XSTR(s) #s
44#define STR(s) XSTR(s)
45
46/******************************************************************************/
47
48/* Select the active platform (default is STM32) */
49#if !defined(ACTIVE_PLATFORM)
50#define ACTIVE_PLATFORM STM32_PLATFORM
51#endif
52
53/* Enable the UART/VirtualCOM port connection (default VCOM) */
54// #define USE_PHY_COM_PORT // Uncomment to select UART
55
56#if !defined(USE_PHY_COM_PORT)
57#define USE_VIRTUAL_COM_PORT
58#endif
59
60/* Select the application data capture mode (default is Windowed mode) */
61#if !defined(APP_CAPTURE_MODE)
62#define APP_CAPTURE_MODE WINDOWED_DATA_CAPTURE
63#endif
64
65/* Select the ADC output data format (default is twos complement mode) */
66#if !defined(ADC_DATA_FORMAT)
67#define ADC_DATA_FORMAT TWOS_COMPLEMENT
68#endif
69
70#define ACTIVE_DEVICE_NAME "ad405x"
71#define DEVICE_NAME "DEV_AD405x"
72
73#if (ACTIVE_PLATFORM == MBED_PLATFORM)
74#include "app_config_mbed.h"
75#define HW_CARRIER_NAME TARGET_NAME
76#define CONSOLE_STDIO_PORT_AVAILABLE
77#elif (ACTIVE_PLATFORM == STM32_PLATFORM)
78#include "app_config_stm32.h"
79#define HW_CARRIER_NAME TARGET_NAME
80#define IIO_TRIGGER_HANDLE_SPI 0 // Unused macro
81#define TRIGGER_INT_ID_SPI_INTR GP1_PIN_NUM
82#define IIO_TRIGGER_HANDLE_I3C CNV_TIMER_HANDLE
83#define TRIGGER_INT_ID_I3C_INTR CNV_PWM_TIMER_IRQ_ID
84#else
85#error "No/Invalid active platform selected"
86#endif
87
88#define DEFAULT_BURST_SAMPLE_RATE 2000000
89
90/* ADC reference voltage (Range: 2.5 to 3.3v) */
91#define ADC_REF_VOLTAGE 2.5
92
93/* Time taken for the application to process the interrupt and
94 * push data into iio buffer. */
95#define MIN_DATA_CAPTURE_TIME_NS 8000
96
97/* Time taken by the MCU to Jump into the ISR after the occurrence of
98 * data ready event */
99#if (APP_CAPTURE_MODE == CONTINUOUS_DATA_CAPTURE)
100#define MIN_INTERRUPT_OVER_HEAD 4500
101#else
102#define MIN_INTERRUPT_OVER_HEAD 3000
103#endif
104
105/* Baud rate for IIO application UART interface */
106#define IIO_UART_BAUD_RATE (230400)
107
108/****** Macros used to form a VCOM serial number ******/
109/* Used to form a VCOM serial number */
110#define FIRMWARE_NAME "ad405x_iio"
111
112#if !defined(PLATFORM_NAME)
113#define PLATFORM_NAME HW_CARRIER_NAME
114#endif
115
116/* Below USB configurations (VID and PID) are owned and assigned by ADI.
117 * If intended to distribute software further, use the VID and PID owned by your
118 * organization */
119#define VIRTUAL_COM_PORT_VID 0x0456
120#define VIRTUAL_COM_PORT_PID 0xb66c
121/* Serial number string is formed as: application name + device (target) name + platform (host) name */
122#define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
123
124/*
125 * Console STDIO on VCOM is supported only if the client is
126 * actively listening to the data on VCOM.
127 *
128 * Comment the below section to enable STDIO on VCOM.
129 */
130#ifdef USE_PHY_COM_PORT
131#ifdef CONSOLE_STDIO_PORT_AVAILABLE
132#undef CONSOLE_STDIO_PORT_AVAILABLE
133#endif
134#endif
135
136/* ADC data buffer size */
137#if defined(SDRAM_SUPPORT_AVAILABLE)
138#define DATA_BUFFER_SIZE SDRAM_SIZE_BYTES
139#else
140#ifdef SPI_SUPPORT_AVAILABLE
141#define DATA_BUFFER_SIZE (131072) // 128kbytes
142#define DUMMY_DATA_COUNT 0
143#else
144#define DATA_BUFFER_SIZE (524288) // 512kbytes
145#define DUMMY_DATA_COUNT 1
146#endif
147#endif
148#define DATA_BUFFER_SIZE_CONT 64000
149
150/******************************************************************************/
151
152#define STORAGE_BITS_SAMPLE 16
153#define AD4050_SAMPLE_RES 12
154#define AD4052_SAMPLE_RES 16
155#define AD4060_SAMPLE_RES 12
156#define AD4062_SAMPLE_RES 16
157
158#define STORAGE_BITS_AVG 32
159#define AD4050_AVG_RES 14
160#define AD4052_AVG_RES 20
161#define AD4060_AVG_RES 14
162#define AD4062_AVG_RES 20
163
164/* Number of storage bytes for each sample */
165#define BYTES_PER_SAMPLE(x) (x/8)
166
167/* Converts pwm period in nanoseconds to sampling frequency in samples per second */
168#define PWM_PERIOD_TO_FREQUENCY(x) (1000000000.0 / x)
169/* Converts sampling frequency in samples per second to pwm period in nanoseconds */
170#define PWM_FREQUENCY_TO_PERIOD(x) PWM_PERIOD_TO_FREQUENCY(x)
171
172/******************************************************************************/
173/********************** Variables and User Defined Data Types *****************/
174/******************************************************************************/
175
176/******************************************************************************/
177/************************ Public Declarations *********************************/
178/******************************************************************************/
179extern struct no_os_eeprom_init_param eeprom_init_params;
180extern struct no_os_pwm_desc *pwm_desc;
181extern struct no_os_irq_ctrl_desc *pwm_irq_desc;
182extern struct no_os_uart_desc *uart_iio_com_desc;
183extern struct no_os_uart_desc *uart_console_stdio_desc;
184extern struct no_os_gpio_desc *trigger_gpio_desc;
185extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
186extern struct no_os_gpio_init_param cs_pwm_gpio_params;
187extern struct no_os_gpio_init_param pwm_gpio_params;
188extern struct no_os_pwm_init_param spi_dma_pwm_init_params;
189extern struct no_os_pwm_init_param spi_intr_pwm_init_params;
190extern struct no_os_dma_xfer_desc dma_tx_desc;
191extern struct no_os_dma_ch dma_chan;
192extern struct no_os_pwm_init_param cs_init_params;
193extern struct no_os_dma_init_param ad405x_dma_init_param;
194extern volatile uint8_t *buff_start_addr;
195extern volatile struct iio_device_data* iio_dev_data_g;
196extern uint32_t nb_of_bytes_g;
197extern uint32_t nb_of_bytes_remaining_g;
198extern uint32_t data_read;
199extern struct no_os_pwm_desc* tx_trigger_desc;
200extern struct no_os_dma_desc *ad405x_dma_desc;
201extern struct no_os_pwm_desc* cs_pwm_desc;
202extern struct no_os_dma_xfer_desc i3c_cr_dma_xfer;
203extern struct no_os_pwm_init_param i3c_dma_pwm_init_params;
204extern struct no_os_pwm_init_param i3c_intr_pwm_init_params;
205extern volatile uint8_t ad405x_i3c_dyn_addr;
206extern uint8_t bytes_per_sample;
207
208int32_t init_pwm(void);
209int32_t deinit_pwm(void);
210int32_t ad405x_gpio_reset(void);
211int32_t init_system(void);
213
214#endif //APP_CONFIG_H
struct no_os_irq_ctrl_desc * trigger_irq_desc
Definition app_config.c:103
int32_t init_system(void)
Initialize the system peripherals.
Definition app_config.c:185
struct no_os_pwm_desc * tx_trigger_desc
Definition app_config.c:149
struct no_os_pwm_desc * pwm_desc
Definition app_config.c:106
struct no_os_gpio_desc * trigger_gpio_desc
Definition app_config.c:170
struct no_os_uart_desc * uart_iio_com_desc
Definition app_config.c:164
struct no_os_gpio_init_param pwm_gpio_params
Definition app_config.c:87
int32_t init_pwm(void)
Initialize the PWM interface.
Definition app_config.c:267
struct no_os_dma_ch dma_chan
volatile struct iio_device_data * iio_dev_data_g
Definition ad405x_iio.c:281
struct no_os_pwm_init_param spi_dma_pwm_init_params
Definition app_config.c:96
struct no_os_pwm_init_param spi_intr_pwm_init_params
Definition app_config.c:109
uint8_t bytes_per_sample
Definition ad405x_iio.c:290
struct no_os_pwm_init_param i3c_intr_pwm_init_params
Definition app_config.c:133
struct no_os_dma_xfer_desc dma_tx_desc
uint32_t data_read
Definition app_support.c:49
int32_t ad405x_gpio_reset(void)
volatile uint8_t ad405x_i3c_dyn_addr
volatile uint8_t * buff_start_addr
Definition ad405x_iio.c:140
struct no_os_pwm_init_param i3c_dma_pwm_init_params
Definition app_config.c:122
int32_t init_system_post_verification(void)
Initializing system peripherals.
Definition app_config.c:575
struct no_os_dma_xfer_desc i3c_cr_dma_xfer
Definition app_config.c:183
struct no_os_gpio_init_param cs_pwm_gpio_params
Definition app_config.c:196
struct no_os_pwm_init_param cs_init_params
Definition app_config.c:123
struct no_os_irq_ctrl_desc * pwm_irq_desc
Definition app_config.c:240
uint32_t nb_of_bytes_g
Definition app_support.c:45
int32_t deinit_pwm(void)
DeInitialize the PWM interface.
Definition app_config.c:420
struct no_os_dma_desc * ad405x_dma_desc
Definition app_config.c:249
struct no_os_dma_init_param ad405x_dma_init_param
Definition app_config.c:254
struct no_os_eeprom_init_param eeprom_init_params
Definition app_config.c:228
struct no_os_pwm_desc * cs_pwm_desc
Definition app_config.c:251
uint32_t nb_of_bytes_remaining_g
Definition app_support.c:46
struct no_os_uart_desc * uart_console_stdio_desc
Definition app_config.c:100
Header file for Mbed platform configurations.