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