38 #include "board_hw_defs.c"
43 #include <uavobjectsinit.h>
44 #include "hwomnibusf3.h"
46 #include "manualcontrolsettings.h"
47 #include "modulesettings.h"
50 #if defined(PIOS_INCLUDE_WS2811)
51 #include "rgbledsettings.h"
54 #if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
55 #define PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN 40
62 #ifdef PIOS_INCLUDE_MAX7456
78 #if defined(PIOS_INCLUDE_ANNUNC)
84 #if defined(PIOS_INCLUDE_SPI)
93 #if defined(PIOS_INCLUDE_FLASH)
100 uint32_t num_partitions;
101 flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->
board_rev, &num_partitions);
112 HwOmnibusF3Initialize();
113 ModuleSettingsInitialize();
115 #if defined(PIOS_INCLUDE_RTC)
123 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
139 if (boot_count < 3) {
144 HwOmnibusF3SetDefaults(HwOmnibusF3Handle(), 0);
145 ModuleSettingsSetDefaults(ModuleSettingsHandle(), 0);
146 AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
149 #if defined(PIOS_INCLUDE_USB)
154 bool usb_hid_present =
false;
156 #if defined(PIOS_INCLUDE_USB_CDC)
157 bool usb_cdc_present =
false;
161 usb_hid_present =
true;
162 usb_cdc_present =
true;
167 usb_hid_present =
true;
170 uintptr_t pios_usb_id;
173 #if defined(PIOS_INCLUDE_USB_CDC)
175 uint8_t hw_usb_vcpport;
177 HwOmnibusF3USB_VCPPortGet(&hw_usb_vcpport);
179 if (!usb_cdc_present) {
181 hw_usb_vcpport = HWOMNIBUSF3_USB_VCPPORT_DISABLED;
187 #if defined(PIOS_INCLUDE_USB_HID)
189 uint8_t hw_usb_hidport;
190 HwOmnibusF3USB_HIDPortGet(&hw_usb_hidport);
192 if (!usb_hid_present) {
194 hw_usb_hidport = HWOMNIBUSF3_USB_HIDPORT_DISABLED;
202 #if defined(PIOS_INCLUDE_I2C)
203 if (
PIOS_I2C_Init(&pios_i2c_internal_id, &pios_i2c_internal_cfg))
209 if (
AlarmsGet(SYSTEMALARMS_ALARM_I2C) == SYSTEMALARMS_ALARM_UNINITIALISED)
210 AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_OK);
211 #endif // PIOS_INCLUDE_I2C
214 HwOmnibusF3DSMxModeOptions hw_DSMxMode;
215 HwOmnibusF3DSMxModeGet(&hw_DSMxMode);
218 HwOmnibusF3Uart3Get(&hw_uart3);
219 PIOS_HAL_ConfigurePort(hw_uart3,
227 &pios_uart3_dsm_aux_cfg,
232 HwOmnibusF3Uart2Get(&hw_uart2);
233 PIOS_HAL_ConfigurePort(hw_uart2,
241 &pios_uart2_dsm_aux_cfg,
246 HwOmnibusF3Uart1Get(&hw_uart1);
247 PIOS_HAL_ConfigurePort(hw_uart1,
255 &pios_uart1_dsm_aux_cfg,
259 #ifdef PIOS_INCLUDE_WS2811
262 RGBLEDSettingsInitialize();
264 RGBLEDSettingsNumLedsGet(&num_leds);
270 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
271 #ifdef PIOS_INCLUDE_SERVO
278 #if defined(PIOS_INCLUDE_ADC)
279 uintptr_t unused_adc;
294 HwOmnibusF3GyroRangeOptions hw_gyro_range;
295 HwOmnibusF3GyroRangeGet(&hw_gyro_range);
297 switch(hw_gyro_range) {
298 case HWOMNIBUSF3_GYRORANGE_250:
301 case HWOMNIBUSF3_GYRORANGE_500:
304 case HWOMNIBUSF3_GYRORANGE_1000:
307 case HWOMNIBUSF3_GYRORANGE_2000:
312 HwOmnibusF3AccelRangeOptions hw_accel_range;
313 HwOmnibusF3AccelRangeGet(&hw_accel_range);
314 switch(hw_accel_range) {
315 case HWOMNIBUSF3_ACCELRANGE_2G:
318 case HWOMNIBUSF3_ACCELRANGE_4G:
321 case HWOMNIBUSF3_ACCELRANGE_8G:
324 case HWOMNIBUSF3_ACCELRANGE_16G:
329 HwOmnibusF3MPU9250GyroLPFOptions hw_mpu_dlpf;
330 HwOmnibusF3MPU9250GyroLPFGet(&hw_mpu_dlpf);
331 uint16_t bandwidth = \
332 (hw_mpu_dlpf == HWOMNIBUSF3_MPU9250GYROLPF_184) ? 184 : \
333 (hw_mpu_dlpf == HWOMNIBUSF3_MPU9250GYROLPF_92) ? 92 : \
334 (hw_mpu_dlpf == HWOMNIBUSF3_MPU9250GYROLPF_41) ? 41 : \
335 (hw_mpu_dlpf == HWOMNIBUSF3_MPU9250GYROLPF_20) ? 20 : \
336 (hw_mpu_dlpf == HWOMNIBUSF3_MPU9250GYROLPF_10) ? 10 : \
337 (hw_mpu_dlpf == HWOMNIBUSF3_MPU9250GYROLPF_5) ? 5 : \
344 #ifdef PIOS_INCLUDE_MAX7456
351 #if defined(PIOS_INCLUDE_GPIO)
int32_t PIOS_Flash_Internal_Init(uintptr_t *flash_id, const struct pios_flash_internal_cfg *cfg)
int32_t PIOS_USB_DESC_HID_CDC_Init(void)
void PIOS_HAL_ConfigureCDC(HwSharedUSB_VCPPortOptions port_type, uintptr_t usb_id, const struct pios_usb_cdc_cfg *cdc_cfg)
Main PiOS header to include all the compiled in PiOS options.
int32_t PIOS_INTERNAL_ADC_Init(uintptr_t *internal_adc_id, const struct pios_internal_adc_cfg *cfg)
int32_t PIOS_I2C_CheckClear(pios_i2c_t i2c_id)
uintptr_t pios_com_debug_id
#define PIOS_DEBUG_Assert(test)
int32_t AlarmsSet(SystemAlarmsAlarmElem alarm, SystemAlarmsAlarmOptions severity)
uintptr_t pios_uavo_settings_fs_id
uint16_t PIOS_IAP_ReadBootCount(void)
int32_t PIOS_FLASHFS_Logfs_Init(uintptr_t *fs_id, const struct flashfs_logfs_cfg *cfg, enum pios_flash_partition_labels partition_label)
Initialize the flash object setting FS.
static const struct pios_tim_clock_cfg tim_8_cfg
const struct pios_board_info pios_board_info_blob
struct pios_mpu_dev * pios_mpu_dev_t
struct max7456_dev_s * max7456_dev_t
int PIOS_WS2811_init(ws2811_dev_t *dev_out, const struct pios_ws2811_cfg *cfg, int max_leds)
Allocate and initialise WS2811 device.
uintptr_t pios_com_aux_id
int32_t PIOS_I2C_Init(pios_i2c_t *i2c_id, const char *path)
void PIOS_WDG_Clear(void)
Clear the watchdog timer.
int32_t PIOS_MPU_SPI_Init(pios_mpu_dev_t *dev, pios_spi_t spi_id, uint32_t slave_num, const struct pios_mpu_cfg *cfg)
Initialize the MPU-xxxx 6/9-axis sensor on SPI.
void PIOS_DEBUG_Init(const struct pios_tim_channel *channels, uint8_t num_channels)
uintptr_t pios_com_telem_serial_id
const struct pios_com_driver pios_usart_com_driver
void PIOS_IAP_Init(void)
PIOS_IAP_Init - performs required initializations for iap module.
int32_t PIOS_MPU_SetAccelRange(enum pios_mpu_accel_range range)
const struct pios_adc_driver pios_internal_adc_driver
int32_t PIOS_TIM_InitClock(const struct pios_tim_clock_cfg *cfg)
uintptr_t pios_internal_adc_id
static const struct pios_tim_clock_cfg tim_15_cfg
int32_t PIOS_SPI_Init(pios_spi_t *spi_dev, const struct pios_spi_cfg *cfg)
int32_t PIOS_ANNUNC_Init(const struct pios_annunc_cfg *cfg)
void PIOS_RTC_Init(const struct pios_rtc_cfg *cfg)
int32_t PIOS_USB_DESC_HID_ONLY_Init(void)
void PIOS_HAL_ConfigureHID(HwSharedUSB_HIDPortOptions port_type, uintptr_t usb_id, const struct pios_usb_hid_cfg *hid_cfg)
int32_t PIOS_Servo_Init(const struct pios_servo_cfg *cfg)
void PIOS_MPU_SetGyroBandwidth(uint16_t bandwidth)
Sets the bandwidth desired from the gyro. The driver will automatically select the lowest bandwidth l...
uintptr_t pios_com_openlog_logging_id
uintptr_t pios_com_telem_usb_id
void PIOS_FLASH_register_partition_table(const struct pios_flash_partition partition_table[], uint8_t num_partitions)
Includes PiOS and core architecture components.
int32_t AlarmsClear(SystemAlarmsAlarmElem alarm)
void PIOS_WS2811_trigger_update(ws2811_dev_t dev)
Trigger an update of the LED strand.
int32_t PIOS_USB_Init(uintptr_t *usb_id, const struct pios_usb_cfg *cfg)
uint16_t PIOS_WDG_Init()
Initialize the watchdog timer for a specified timeout.
int32_t PIOS_ADC_Init(uintptr_t *adc_id, const struct pios_adc_driver *driver, uintptr_t lower_id)
void PIOS_IAP_WriteBootCount(uint16_t)
static const struct pios_tim_clock_cfg tim_3_cfg
void PIOS_HAL_CriticalError(uint32_t led_id, enum pios_hal_panic code)
Flash a blink code.
static const struct pios_tim_clock_cfg tim_2_cfg
#define PIOS_Assert(test)
int PIOS_MAX7456_init(max7456_dev_t *dev_out, pios_spi_t spi_handle, uint32_t slave_idx)
Allocate and initialise MAX7456 device.
int32_t PIOS_DELAY_WaitmS(uint32_t mS)
int32_t PIOS_MPU_SetGyroRange(enum pios_mpu_gyro_range range)
int32_t PIOS_USB_BOARD_DATA_Init(void)
SystemAlarmsAlarmOptions AlarmsGet(SystemAlarmsAlarmElem alarm)
void PIOS_RESET_Clear(void)
PIOS_RESET_Clear Does nothing on POSIX systems.