precision-converters-firmware
app_config_mbed.h
Go to the documentation of this file.
1 /***************************************************************************/
13 #ifndef APP_CONFIG_MBED_H_
14 #define APP_CONFIG_MBED_H_
15 
16 /******************************************************************************/
17 /***************************** Include Files **********************************/
18 /******************************************************************************/
19 #include <stdint.h>
20 #include <PinNames.h>
21 
22 #include "mbed_i2c.h"
23 #include "mbed_spi.h"
24 #include "mbed_gpio.h"
25 #include "mbed_gpio_irq.h"
26 #include "mbed_pwm.h"
27 #include "mbed_uart.h"
28 
29 /******************************************************************************/
30 /********************** Macros and Constants Definition ***********************/
31 /******************************************************************************/
32 
33 /* Pin mapping for AD405X w.r.t Arduino Headers */
34 #define SPI_CS_PIN_NUM ARDUINO_UNO_D10
35 #define SPI_HOST_SDO ARDUINO_UNO_D11
36 #define SPI_HOST_SDI ARDUINO_UNO_D12
37 #define SPI_SCK ARDUINO_UNO_D13
38 
39 #define CNV_PIN ARDUINO_UNO_D6
40 #define RESET_PIN ARDUINO_UNO_D1
41 #define GP0_PIN ARDUINO_UNO_D9
42 #define GP1_PIN ARDUINO_UNO_D8
43 
44 /* Pins used to trigger a new (periodic) conversion event */
45 #define PWM_TRIGGER ARDUINO_UNO_D6
46 
47 #define trigger_gpio_handle 0 // Unused macro
48 #define TRIGGER_GPIO_PORT 0 // Unused macro
49 #define TRIGGER_GPIO_PIN PWM_TRIGGER
50 #define TIMER1_ID 0 // Unused macro
51 #define TIMER2_ID 0 // Unused macro
52 #define TRIGGER_INT_ID 0 // Unused macro
53 #define I2C_DEV_ID 0 // Unused macro
54 #define UART_MODULE 0 // Unused macro
55 #define UART_IRQ 0 // Unused macro
56 #define SPI_DEVICE_ID 0 // Unused macro
57 #define CNV_PIN_NUM ARDUINO_UNO_D6 // Unused macro
58 #define CNV_PORT_NUM 0 // Unused macro
59 #define GP0_PIN_NUM ARDUINO_UNO_D9 // Unused macro
60 #define GP0_PORT_NUM 0 // Unused macro
61 #define GP1_PIN_NUM ARDUINO_UNO_D8 // Unused macro
62 #define GP1_PORT_NUM 0 // Unused macro
63 
64 /* Console pin mapping on SDP-K1 */
65 #define UART_TX CONSOLE_TX
66 #define UART_RX CONSOLE_RX
67 
68 #define I2C_SCL ARDUINO_UNO_D15
69 #define I2C_SDA ARDUINO_UNO_D14
70 
71 /* Redefine the init params structure mapping w.r.t. platform */
72 #define uart_extra_init_params mbed_uart_extra_init_params
73 #define vcom_extra_init_params mbed_vcom_extra_init_params
74 #define spi_extra_init_params mbed_spi_extra_init_params
75 #define i2c_extra_init_params mbed_i2c_extra_init_params
76 #define pwm_extra_init_params mbed_pwm_extra_init_params
77 #define cnv_extra_init_params mbed_gpio_cnv_extra_init_params
78 #define gp0_extra_init_params mbed_gpio_gp0_extra_init_params
79 #define gp1_extra_init_params mbed_gpio_gp1_extra_init_params
80 #define trigger_gpio_irq_extra_params mbed_trigger_gpio_irq_init_params
81 
82 /* Platform ops */
83 #define gpio_ops mbed_gpio_ops
84 #define spi_ops mbed_spi_ops
85 #define i2c_ops mbed_i2c_ops
86 #define uart_ops mbed_uart_ops
87 #define pwm_ops mbed_pwm_ops
88 #define vcom_ops mbed_virtual_com_ops
89 #define trigger_gpio_irq_ops mbed_gpio_irq_ops
90 
91 #define MAX_SPI_SCLK 22500000
92 
93 /* Define the max possible sampling (or output data) rate for a given platform.
94  * This is also used to find the time period to trigger a periodic conversion event.
95  * Note: Max possible ODR is 62.5KSPS per channel for continuous data capture on
96  * IIO client. This is derived by testing the firmware on SDP-K1 controller board
97  * @22Mhz SPI clock. The max possible ODR can vary from board to board and
98  * data continuity is not guaranteed above this ODR on IIO oscilloscope */
99 #define SAMPLING_RATE (62500)
100 #define CONV_TRIGGER_PERIOD_NSEC(x) (((float)(1.0 / x) * 1000000) * 1000)
101 #define CONV_TRIGGER_DUTY_CYCLE_NSEC(x) (x / 10)
102 
103 /******************************************************************************/
104 /********************** Public/Extern Declarations ****************************/
105 /******************************************************************************/
106 extern struct mbed_spi_init_param mbed_spi_extra_init_params;
107 extern struct mbed_uart_init_param mbed_uart_extra_init_params;
108 extern struct mbed_uart_init_param mbed_vcom_extra_init_params;
109 extern struct mbed_gpio_irq_init_param mbed_trigger_gpio_irq_init_params;
110 extern struct mbed_pwm_init_param mbed_pwm_extra_init_params;
111 extern struct mbed_i2c_init_param mbed_i2c_extra_init_params;
112 extern struct mbed_gpio_init_param mbed_gpio_cnv_extra_init_params;
113 extern struct mbed_gpio_init_param mbed_gpio_gp0_extra_init_params;
114 extern struct mbed_gpio_init_param mbed_gpio_gp1_extra_init_params;
115 
116 #endif /* APP_CONFIG_MBED_H_ */
struct mbed_pwm_init_param mbed_pwm_extra_init_params
Definition: app_config_mbed.c:69
struct mbed_gpio_irq_init_param mbed_trigger_gpio_irq_init_params
Definition: app_config_mbed.c:65
struct mbed_uart_init_param mbed_vcom_extra_init_params
Definition: app_config_mbed.c:42
struct mbed_uart_init_param mbed_uart_extra_init_params
Definition: app_config_mbed.c:31
struct mbed_spi_init_param mbed_spi_extra_init_params
Definition: app_config_mbed.c:54
struct mbed_gpio_init_param mbed_gpio_gp1_extra_init_params
Definition: app_config_mbed.c:85
struct mbed_gpio_init_param mbed_gpio_cnv_extra_init_params
Definition: app_config_mbed.c:75
struct mbed_gpio_init_param mbed_gpio_gp0_extra_init_params
Definition: app_config_mbed.c:80
struct mbed_i2c_init_param mbed_i2c_extra_init_params
Definition: app_config_mbed.c:69