APM:Libraries
board.h
Go to the documentation of this file.
1 #ifndef _BOARD_STM32V1F4_H_
2 #define _BOARD_STM32V1F4_H_
3 
4 /*
5  this file included to *ANY* compilation so shouldn't include anything else
6 */
7 
8 
12 #define __CM4_REV 0x0001
13 #define __MPU_PRESENT 1
14 #define __NVIC_PRIO_BITS 4
15 #define __Vendor_SysTickConfig 0
16 #define __FPU_PRESENT 1
18 #define HSE_VALUE (8000000)
19 
20 #define CYCLES_PER_MICROSECOND (SystemCoreClock / 1000000)
21 #define SYSTICK_RELOAD_VAL (CYCLES_PER_MICROSECOND*1000-1)
22 
23 #undef STM32_PCLK1
24 #undef STM32_PCLK2
25 #define STM32_PCLK1 (CYCLES_PER_MICROSECOND*1000000/4)
26 #define STM32_PCLK2 (CYCLES_PER_MICROSECOND*1000000/2)
27 
28 #define BOARD_BUTTON_PIN 254
29 
30 #ifndef LOW
31 # define LOW 0
32 #endif
33 #ifndef HIGH
34 # define HIGH 1
35 #endif
36 
37 
38 //#define BOARD_BUZZER_PIN 5 // PB15, PWM2 - used as PPM2
39 #define HAL_BUZZER_ON 1
40 #define HAL_BUZZER_OFF 0
41 
42 #define BOARD_NR_USARTS 5
43 #define BOARD_USART1_TX_PIN 23
44 #define BOARD_USART1_RX_PIN 24
45 #define BOARD_USART3_TX_PIN 0
46 #define BOARD_USART3_RX_PIN 100
47 #define BOARD_USART6_TX_PIN 12
48 #define BOARD_USART6_RX_PIN 13
49 
50 #define BOARD_USART4_RX_PIN 48
51 #define BOARD_USART4_TX_PIN 47
52 
53 #define BOARD_DSM_USART (_USART1)
54 
55 #define BOARD_NR_SPI 3
56 #define BOARD_SPI1_SCK_PIN 52
57 #define BOARD_SPI1_MISO_PIN 53
58 #define BOARD_SPI1_MOSI_PIN 54
59 #define BOARD_SPI2_SCK_PIN 255
60 #define BOARD_SPI2_MISO_PIN 255
61 #define BOARD_SPI2_MOSI_PIN 255
62 #define BOARD_SPI3_MOSI_PIN 18
63 #define BOARD_SPI3_MISO_PIN 17
64 #define BOARD_SPI3_SCK_PIN 16
65 
66 #define BOARD_DATAFLASH_CS_PIN 104
67 
68 
69 #define BOARD_MPU6000_CS_PIN 51
70 #define BOARD_MPU6000_DRDY_PIN 10 // PC4
71 
72 
73 //#define BOARD_SBUS_INVERTER 6
74 
75 #define BOARD_USB_SENSE 11 // PC5
76 
77 // bus 2 (soft) pins
78 #define BOARD_SOFT_SCL 14
79 #define BOARD_SOFT_SDA 15
80 
81 // SoftSerial pins
82 //#define BOARD_SOFTSERIAL_TX 14
83 //#define BOARD_SOFTSERIAL_RX 15
84 
85 
86 # define BOARD_BLUE_LED_PIN 36 // BLUE
87 # define BOARD_GREEN_LED_PIN 9 // frequency select - resistor to VCC or ground
88 
89 # define HAL_GPIO_A_LED_PIN BOARD_BLUE_LED_PIN
90 # define HAL_GPIO_B_LED_PIN BOARD_GREEN_LED_PIN
91 
92 # define HAL_GPIO_LED_ON LOW
93 # define HAL_GPIO_LED_OFF HIGH
94 
95 
96 #define BOARD_NR_GPIO_PINS 109
97 
98 #define I2C1_SDA PB9
99 #define I2C1_SCL PB8
100 
101 #define I2C2_SDA PB11
102 #define I2C2_SCL PB10
103 
104 // use soft I2C driver instead hardware
105 //#define BOARD_SOFT_I2C2
106 //#define BOARD_I2C_BUS_INT 1 // hardware internal I2C
107 #define BOARD_I2C_BUS_EXT 1 // external I2C
108 #define BOARD_I2C_BUS_SLOW 1 // slow down bus with this number
109 
110 #define HAL_BARO_MS5611_I2C_BUS BOARD_I2C_BUS_EXT
111 #define HAL_BARO_MS5611_I2C_ADDR (0x77)
112 
113 #define HAL_BARO_BMP280_BUS BOARD_I2C_BUS_EXT
114 #define HAL_BARO_BMP280_I2C_ADDR (0x76)
115 
116 #define HAL_BARO_BMP085_BUS BOARD_I2C_BUS_EXT
117 #define HAL_BARO_BMP085_I2C_ADDR (0x77)
118 
119 #define HAL_BARO_MS5607_I2C_BUS BOARD_I2C_BUS_EXT
120 #define HAL_BARO_MS5607_I2C_ADDR (0x77)
121 
122 
123 #define BOARD_COMPASS_DEFAULT HAL_COMPASS_HMC5843
124 //#define BOARD_HMC5883_DRDY_PIN 38 // PB7 - but it not used by driver
125 
126 #define HAL_COMPASS_HMC5843_I2C_BUS BOARD_I2C_BUS_EXT
127 #define HAL_COMPASS_HMC5843_I2C_ADDR (0x1E)
128 #define HAL_COMPASS_HMC5843_ROTATION ROTATION_NONE
129 
130 #define BOARD_INS_DEFAULT HAL_INS_MPU60XX_SPI
131 #define BOARD_INS_ROTATION ROTATION_YAW_180
132 #define BOARD_INS_MPU60x0_NAME "mpu6000"
133 
134 #define BOARD_STORAGE_SIZE 8192 //4096 // EEPROM size
135 
136 
137 #define BOARD_DATAFLASH_NAME "dataflash"
138 #define BOARD_DATAFLASH_PAGES 0x10000
139 #define BOARD_DATAFLASH_ERASE_SIZE (4096)// in bytes
140 
141 // if board's dataflash supports 4k erases then we can use it as FAT and share it via USB
142 #define BOARD_DATAFLASH_FATFS
143 #define BOARD_HAS_SDIO
144 #define USB_MASSSTORAGE
145 #define HAL_BOARD_LOG_DIRECTORY "0:"
146 #define HAL_BOARD_TERRAIN_DIRECTORY "0:/TERRAIN"
147 //#define HAL_PARAM_DEFAULTS_PATH "0:/defaults.parm"
148 
149 #define BOARD_UARTS_LAYOUT 2
150 
151 #define BOARD_OWN_NAME "Airbot"
152 
153 # define BOARD_PUSHBUTTON_PIN 254
154 # define BOARD_USB_MUX_PIN -1
155 # define BOARD_BATTERY_VOLT_PIN 8 // Battery voltage on A0 (PC2) D8
156 # define BOARD_BATTERY_CURR_PIN 7 // Battery current on A1 (PC1) D7
157 # define BOARD_SONAR_SOURCE_ANALOG_PIN 254
158 
159 # define HAL_BATT_VOLT_PIN 8 // ChibiOS compatible defines
160 # define HAL_BATT_CURR_PIN 7
161 # define HAL_BATT_VOLT_SCALE 10.1
162 # define HAL_BATT_CURR_SCALE 17
163 
164 
165 #define BOARD_USB_DMINUS 108
166 
167 
168 
169 #define USE_SERIAL_4WAY_BLHELI_INTERFACE
170 
171 #define BOARD_SBUS_UART 1 // can use some UART as hardware inverted input
172 
173 // motor layouts
174 #define SERVO_PIN_1 46 // PB0
175 #define SERVO_PIN_2 45 // PB1
176 #define SERVO_PIN_3 50 // PA3
177 #define SERVO_PIN_4 49 // PA2
178 #define SERVO_PIN_5 48 // PA1
179 #define SERVO_PIN_6 22 // PA8
180 
181 #define MOTOR_LAYOUT_DEFAULT 0
182 
183 #define HAL_CONSOLE USB_Driver // console on USB
184 //#define HAL_CONSOLE uart1Driver // console on radio
185 #define HAL_CONSOLE_PORT 0
186 
187 
188 
189 /*
190 
191 
192 */
193 
194 #ifdef USB_MASSSTORAGE
195 
196 #define BOARD_HAL_VARINFO \
197  AP_GROUPINFO("USB_STORAGE", 30, AP_Param_Helper, _usb_storage, 0), \
198  AP_GROUPINFO("DBG_WAYBACK", 31, AP_Param_Helper, _dbg_wayback, 0),
199 
200 #else
201 
202 #define BOARD_HAL_VARINFO \
203  AP_GROUPINFO("DBG_WAYBACK", 30, AP_Param_Helper, _dbg_wayback, 0),
204 #endif
205 
206 
207 // parameters
208 #define BOARD_HAL_PARAMS \
209  AP_Int8 _dbg_wayback; \
210  AP_Int8 _usb_storage;
211 
212 #define WAYBACK_DEBUG
213 
214 
215 
216 #endif
217