precision-converters-firmware
app_config.h
Go to the documentation of this file.
1 /*************************************************************************/
13 #ifndef APP_CONFIG_H
14 #define APP_CONFIG_H
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 
20 #include <stdint.h>
21 #include "ad7091r8.h"
22 #include "no_os_pwm.h"
23 #include "no_os_util.h"
24 
25 /******************************************************************************/
26 /********************** Macros and Constants Definition ***********************/
27 /******************************************************************************/
28 
29 /* List of supported platforms */
30 #define STM32_PLATFORM 1
31 
32 /* List of data capture modes for AD7091R device */
33 #define CONTINUOUS_DATA_CAPTURE 0
34 #define BURST_DATA_CAPTURE 1
35 
36 /* List of data capture methods supported by hardware platform */
37 #define SPI_DMA 0
38 #define SPI_INTERRUPT 1
39 
40 /* Macros for stringification */
41 #define XSTR(s) #s
42 #define STR(s) XSTR(s)
43 
44 /* Select the ADC data capture mode (default is CC mode) */
45 #if !defined(DATA_CAPTURE_MODE)
46 #define DATA_CAPTURE_MODE BURST_DATA_CAPTURE
47 #endif
48 
49 /******************************************************************************/
50 
51 /* Select the active platform (default is STM32) */
52 #if !defined(ACTIVE_PLATFORM)
53 #define ACTIVE_PLATFORM STM32_PLATFORM
54 #endif
55 
56 /* Enable the UART port connection */
57 /* Enable the UART/VirtualCOM port connection (default VCOM) */
58 //#define USE_PHY_COM_PORT // Uncomment to select UART
59 
60 #if !defined(USE_PHY_COM_PORT)
61 #define USE_VIRTUAL_COM_PORT
62 #endif
63 
64 /* Note: The STM32 platform supports SPI interrupt and SPI DMA Mode
65  * for data capturing. (Default is SPI DMA mode)
66  * */
67 //#define INTERFACE_MODE SPI_INTERRUPT // Uncomment to select spi interface mode
68 
69 #if !defined(INTERFACE_MODE)
70 #define INTERFACE_MODE SPI_DMA
71 #endif
72 
73 #include "app_config_stm32.h"
74 
75 /* ADC Internal VREF in millivolts */
76 #define ADC_INTERNAL_VREF_MV 2500
77 
78 /* ADC VREF in millivolts (Default is internal reference)
79  * Note: When using the internal reference, the on-chip reference value is fixed at 2.5V.
80  * External reference value can be applied in range of 1.0V to Vdd */
81 //#define ADC_VREF_MV 2500
82 
83 #if !defined(ADC_VREF_MV)
84 #define ADC_VREF_MV ADC_INTERNAL_VREF_MV
85 #endif
86 
87 /* ADC VDD Input in Volts */
88 #define ADC_VDD_V 3.3
89 
90 /* ADC Vref minimum value in Volts */
91 #define ADC_MIN_VREF 1.0
92 
93 /* Active device and resolution */
94 #define ACTIVE_DEVICE_NAME "ad7091r-8"
95 #define DEVICE_NAME "DEV_AD7091R_8"
96 #define ACTIVE_DEVICE_ID AD7091R8
97 #define ADC_RESOLUTION 12
98 
99 /* HW ID of the target EVB */
100 #define HW_MEZZANINE_NAME "EVAL-AD7091R-8ARDZ"
101 
102 /* ADC max count (full scale value) */
103 #define ADC_MAX_COUNT (uint32_t)((1 << ADC_RESOLUTION) - 1)
104 
105 #define HW_CARRIER_NAME TARGET_NAME
106 
107 #define BYTES_PER_SAMPLE sizeof(uint16_t)
108 
109 /****** Macros used to form a VCOM serial number ******/
110 
111 /* Baud rate for IIO application UART interface */
112 #define IIO_UART_BAUD_RATE (230400)
113 
114 /* Used to form a VCOM serial number */
115 #define FIRMWARE_NAME "ad7091r_iio"
116 
117 #if !defined(PLATFORM_NAME)
118 #define PLATFORM_NAME HW_CARRIER_NAME
119 #endif
120 
121 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
122  * If intended to distribute software further, use the VID and PID owned by your
123  * organization */
124 #define VIRTUAL_COM_PORT_VID 0x0456
125 #define VIRTUAL_COM_PORT_PID 0xb66c
126 /* Serial number string is formed as: application name + device (target) name + platform (host) name */
127 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
128 
129 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
130 //#define USE_SDRAM // Uncomment to use SDRAM for data buffer
131 
132 /* PWM period and duty cycle */
133 #define CONV_TRIGGER_PERIOD_NSEC(x) (((float)(1.0 / x) * 1000000) * 1000)
134 #define CONV_TRIGGER_DUTY_CYCLE_NSEC(x) (((float)PWM_DUTY_CYCLE_PERCENT / 100) * CONV_TRIGGER_PERIOD_NSEC(x))
135 
136 /******************************************************************************/
137 /************************ Public Declarations *********************************/
138 /******************************************************************************/
139 
140 extern struct no_os_pwm_desc *pwm_desc;
141 extern struct no_os_uart_desc *uart_iio_com_desc;
142 extern struct no_os_uart_desc *uart_console_stdio_desc;
143 extern struct no_os_eeprom_desc *eeprom_desc;
144 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
145 extern struct no_os_pwm_init_param pwm_init_params;
146 
147 #if (INTERFACE_MODE == SPI_DMA)
148 extern struct no_os_pwm_desc* tx_trigger_desc;
149 extern struct no_os_pwm_init_param cs_init_params;
150 extern struct no_os_dma_init_param ad7091r_dma_init_param;
151 extern struct no_os_gpio_init_param pwm_gpio_params;
152 extern struct no_os_gpio_init_param cs_pwm_gpio_params;
153 extern volatile struct iio_device_data* global_iio_dev_data;
154 extern uint32_t global_nb_of_samples;
155 extern volatile uint32_t* buff_start_addr;
156 extern int32_t data_read;
157 #endif
158 
159 extern void burst_capture_callback(void *context);
160 int init_system(void);
161 int init_pwm_trigger(void);
162 
163 #endif /* APP_CONFIG_H_ */
int32_t init_pwm_trigger(void)
Initialize the PWM trigger contoller.
Definition: app_config.c:161
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_uart_desc * uart_iio_com_desc
Definition: app_config.c:127
struct no_os_pwm_init_param pwm_init_params
Definition: app_config.c:108
struct no_os_eeprom_desc * eeprom_desc
Definition: app_config.c:194
struct no_os_pwm_desc * tx_trigger_desc
Definition: app_config.c:202
struct no_os_pwm_desc * pwm_desc
Definition: app_config.c:106
struct no_os_gpio_init_param cs_pwm_gpio_params
Definition: app_config.h:234
struct no_os_pwm_init_param cs_init_params
Definition: app_config.c:133
volatile uint32_t * buff_start_addr
Definition: ad405x_iio.c:174
int32_t data_read
Definition: ad405x_iio.c:337
struct no_os_gpio_init_param pwm_gpio_params
Definition: app_config.h:235
struct no_os_uart_desc * uart_console_stdio_desc
Definition: app_config.c:100
void burst_capture_callback(void *context)
Interrupt Service Routine to monitor end of conversion event.
Definition: ad469x_iio.c:1033
uint32_t global_nb_of_samples
Definition: ad469x_iio.c:278
volatile struct iio_device_data * global_iio_dev_data
Definition: ad469x_iio.c:275
struct no_os_dma_init_param ad7091r_dma_init_param
Definition: app_config.c:175
Header file for STM32 platform configurations.