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 
22 /******************************************************************************/
23 /********************** Macros and Constants Definition ***********************/
24 /******************************************************************************/
25 
26 /* List of supported platforms*/
27 #define MBED_PLATFORM 1
28 
29 /* List of data capture modes */
30 #define BURST_DATA_CAPTURE 0
31 #define CONTINUOUS_DATA_CAPTURE 1
32 
33 /* Macros for stringification */
34 #define XSTR(s) #s
35 #define STR(s) XSTR(s)
36 
37 /* Select the active platform (default is Mbed) */
38 #if !defined(ACTIVE_PLATFORM)
39 #define ACTIVE_PLATFORM MBED_PLATFORM
40 #endif
41 
42 /* Select the ADC data capture mode (default is CC mode) */
43 #if !defined(DATA_CAPTURE_MODE)
44 #define DATA_CAPTURE_MODE CONTINUOUS_DATA_CAPTURE
45 #endif
46 
47 /* Enable the UART/VirtualCOM port connection (default VCOM) */
48 //#define USE_PHY_COM_PORT // Uncomment to select UART
49 
50 #if !defined(USE_PHY_COM_PORT)
51 #define USE_VIRTUAL_COM_PORT
52 #endif
53 
54 // **** Note for User: ACTIVE_DEVICE selection ****//
55 /* Define the device type here from the list of below device type defines
56  * (one at a time. Defining more than one device can result into compile error).
57  * e.g. #define DEV_AD7606B -> This will make AD7606B as an ACTIVE_DEVICE.
58  * The ACTIVE_DEVICE is default set to AD7606B if device type is not defined.
59  * */
60 
61 //#define DEV_AD7606B
62 
63 #if defined(DEV_AD7605_4)
64 #define ACTIVE_DEVICE ID_AD7605_4
65 #define ACTIVE_DEVICE_NAME "ad7605-4"
66 #define DEVICE_NAME "DEV_AD7605_4"
67 #elif defined(DEV_AD7606_4)
68 #define ACTIVE_DEVICE ID_AD7606_4
69 #define ACTIVE_DEVICE_NAME "ad7606-4"
70 #define DEVICE_NAME "DEV_AD7606_4"
71 #elif defined(DEV_AD7606_6)
72 #define ACTIVE_DEVICE ID_AD7606_6
73 #define ACTIVE_DEVICE_NAME "ad7606-6"
74 #define DEVICE_NAME "DEV_AD7606_6"
75 #elif defined(DEV_AD7606_8)
76 #define ACTIVE_DEVICE ID_AD7606_8
77 #define ACTIVE_DEVICE_NAME "ad7606-8"
78 #define DEVICE_NAME "DEV_AD7606_8"
79 #elif defined(DEV_AD7606B)
80 #define ACTIVE_DEVICE ID_AD7606B
81 #define ACTIVE_DEVICE_NAME "ad7606b"
82 #define DEVICE_NAME "DEV_AD7606B"
83 #elif defined(DEV_AD7606C_16)
84 #define ACTIVE_DEVICE ID_AD7606C_16
85 #define ACTIVE_DEVICE_NAME "ad7606c-16"
86 #define DEVICE_NAME "DEV_AD7606C_16"
87 #elif defined(DEV_AD7606C_18)
88 #define ACTIVE_DEVICE ID_AD7606C_18
89 #define ACTIVE_DEVICE_NAME "ad7606c-18"
90 #define DEVICE_NAME "DEV_AD7606C_18"
91 #elif defined(DEV_AD7608)
92 #define ACTIVE_DEVICE ID_AD7608
93 #define ACTIVE_DEVICE_NAME "ad7608"
94 #define DEVICE_NAME "DEV_AD7608"
95 #elif defined(DEV_AD7609)
96 #define ACTIVE_DEVICE ID_AD7609
97 #define ACTIVE_DEVICE_NAME "ad7609"
98 #define DEVICE_NAME "DEV_AD7609"
99 #else
100 #warning No/Unsupported ADxxxxy symbol defined. AD7606B defined
101 #define DEV_AD7606B
102 #define ACTIVE_DEVICE ID_AD7606B
103 #define ACTIVE_DEVICE_NAME "ad7606b"
104 #define DEVICE_NAME "DEV_AD7606B"
105 #endif
106 
107 #if defined(DEV_AD7605_4)
108 #define AD7606X_ADC_CHANNELS 4
109 #define AD7606X_ADC_RESOLUTION 16
110 #elif defined(DEV_AD7606_4)
111 #define AD7606X_ADC_CHANNELS 4
112 #define AD7606X_ADC_RESOLUTION 16
113 #elif defined(DEV_AD7606_6)
114 #define AD7606X_ADC_CHANNELS 6
115 #define AD7606X_ADC_RESOLUTION 16
116 #elif defined(DEV_AD7606_8)
117 #define AD7606X_ADC_CHANNELS 8
118 #define AD7606X_ADC_RESOLUTION 16
119 #elif defined(DEV_AD7606B)
120 #define AD7606X_ADC_CHANNELS 8
121 #define AD7606X_ADC_RESOLUTION 16
122 #elif defined(DEV_AD7606C_16)
123 #define AD7606X_ADC_CHANNELS 8
124 #define AD7606X_ADC_RESOLUTION 16
125 #elif defined(DEV_AD7606C_18)
126 #define AD7606X_ADC_CHANNELS 8
127 #define AD7606X_ADC_RESOLUTION 18
128 #elif defined(DEV_AD7608)
129 #define AD7606X_ADC_CHANNELS 8
130 #define AD7606X_ADC_RESOLUTION 18
131 #elif defined(DEV_AD7609)
132 #define AD7606X_ADC_CHANNELS 8
133 #define AD7606X_ADC_RESOLUTION 18
134 #else
135 /* Default config for AD7606B */
136 #define AD7606X_ADC_CHANNELS 8
137 #define AD7606X_ADC_RESOLUTION 16
138 #endif
139 
140 #if (ACTIVE_PLATFORM == MBED_PLATFORM)
141 #include "app_config_mbed.h"
142 
143 #define HW_CARRIER_NAME TARGET_NAME
144 
145 /* Redefine the init params structure mapping w.r.t. platform */
146 #define pwm_extra_init_params mbed_pwm_extra_init_params
147 #if defined(USE_VIRTUAL_COM_PORT)
148 #define uart_extra_init_params mbed_vcom_extra_init_params
149 #define uart_ops mbed_virtual_com_ops
150 #else
151 #define uart_extra_init_params mbed_uart_extra_init_params
152 #define uart_ops mbed_uart_ops
153 #endif
154 #define spi_extra_init_params mbed_spi_extra_init_params
155 #define i2c_extra_init_params mbed_i2c_extra_init_params
156 #define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
157 #define trigger_gpio_extra_init_params mbed_trigger_gpio_extra_init_params
158 #define reset_gpio_extra_init_params mbed_reset_gpio_extra_init_params
159 #define convst_gpio_extra_init_params mbed_convst_gpio_extra_init_params
160 #define busy_gpio_extra_init_params mbed_busy_gpio_extra_init_params
161 #define osr0_gpio_extra_init_params mbed_osr0_gpio_extra_init_params
162 #define osr1_gpio_extra_init_params mbed_osr1_gpio_extra_init_params
163 #define osr2_gpio_extra_init_params mbed_osr2_gpio_extra_init_params
164 #define range_gpio_extra_init_params mbed_range_gpio_extra_init_params
165 #define stdby_gpio_extra_init_params mbed_stdby_gpio_extra_init_params
166 #define trigger_gpio_ops mbed_gpio_ops
167 #define irq_ops mbed_gpio_irq_ops
168 #define gpio_ops mbed_gpio_ops
169 #define spi_ops mbed_spi_ops
170 #define i2c_ops mbed_i2c_ops
171 #define trigger_gpio_irq_ops mbed_gpio_irq_ops
172 #define trigger_gpio_handle 0 // Unused macro
173 #define IRQ_INT_ID GPIO_IRQ_ID1
174 #define TRIGGER_GPIO_PORT 0 // Unused macro
175 #define TRIGGER_GPIO_PIN PWM_TRIGGER
176 #define TRIGGER_INT_ID GPIO_IRQ_ID1
177 #else
178 #error "No/Invalid active platform selected"
179 #endif
180 
181 /* ADC max count (full scale value) for unipolar inputs */
182 #define ADC_MAX_COUNT_UNIPOLAR (uint32_t)((1 << AD7606X_ADC_RESOLUTION) - 1)
183 
184 /* ADC max count (full scale value) for bipolar inputs */
185 #define ADC_MAX_COUNT_BIPOLAR (uint32_t)(1 << (AD7606X_ADC_RESOLUTION-1))
186 
187 /* Bytes per sample. This count should divide the total 256 bytes into 'n' equivalent
188  * ADC samples as IIO library requests only 256bytes of data at a time in a given
189  * data read query.
190  * For 1 to 8-bit ADC, bytes per sample = 1 (2^0)
191  * For 9 to 16-bit ADC, bytes per sample = 2 (2^1)
192  * For 17 to 32-bit ADC, bytes per sample = 4 (2^2)
193  **/
194 #if (AD7606X_ADC_RESOLUTION == 18)
195 #define BYTES_PER_SAMPLE sizeof(uint32_t) // For ADC resolution of 18-bits
196 #else
197 #define BYTES_PER_SAMPLE sizeof(uint16_t) // For ADC resolution of 16-bits
198 #endif
199 
200 /****** Macros used to form a VCOM serial number ******/
201 #define FIRMWARE_NAME "ad7606_iio"
202 
203 #if !defined(PLATFORM_NAME)
204 #define PLATFORM_NAME HW_CARRIER_NAME
205 #endif
206 
207 /* Below USB configurations (VID and PID) are owned and assigned by ADI.
208  * If intended to distribute software further, use the VID and PID owned by your
209  * organization */
210 #define VIRTUAL_COM_PORT_VID 0x0456
211 #define VIRTUAL_COM_PORT_PID 0xb66c
212 /* Serial number string is formed as: application name + device (target) name + platform (host) name */
213 #define VIRTUAL_COM_SERIAL_NUM (FIRMWARE_NAME "_" DEVICE_NAME "_" STR(PLATFORM_NAME))
214 
215 /* Baud rate for IIO application UART interface */
216 #define IIO_UART_BAUD_RATE (230400)
217 
218 /* Enable/Disable the use of SDRAM for ADC data capture buffer */
219 //#define USE_SDRAM // Uncomment to use SDRAM for data buffer
220 
221 /******************************************************************************/
222 /********************** Public/Extern Declarations ****************************/
223 /******************************************************************************/
224 
225 extern struct no_os_uart_desc *uart_desc;
226 extern struct no_os_gpio_desc *led_gpio_desc;
227 extern struct no_os_irq_ctrl_desc *trigger_irq_desc;
228 
229 int32_t init_system(void);
230 int32_t init_pwm_trigger(void);
231 
232 #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_desc
Definition: app_config.c:97
struct no_os_gpio_desc * led_gpio_desc
Definition: app_config.c:208
Header file for Mbed platform configurations.