38 #include "board_hw_defs.c"
43 #include <uavobjectsinit.h>
45 #include "manualcontrolsettings.h"
46 #include "modulesettings.h"
47 #include "rgbledsettings.h"
53 #ifdef PIOS_INCLUDE_MAX7456
68 #if defined(PIOS_INCLUDE_ANNUNC)
74 #if defined(PIOS_INCLUDE_SPI)
75 if (
PIOS_SPI_Init(&pios_spi_internal_id, &pios_spi_internal_cfg)) {
80 #if defined(PIOS_INCLUDE_FLASH)
87 uint32_t num_partitions;
88 flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->
board_rev, &num_partitions);
97 ModuleSettingsInitialize();
99 #if defined(PIOS_INCLUDE_RTC)
107 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
122 #ifdef PIOS_INCLUDE_SPI
125 HwAQ32OSDPortGet(&hw_osdport);
127 if (hw_osdport != HWAQ32_OSDPORT_DISABLED) {
128 if (
PIOS_SPI_Init(&pios_spi_external_id, &pios_spi_external_cfg)) {
132 switch (hw_osdport) {
133 #ifdef PIOS_INCLUDE_MAX7456
134 case HWAQ32_OSDPORT_MAX7456OSD:
136 pios_spi_external_id, 0)) {
151 if (boot_count < 3) {
156 HwAQ32SetDefaults(HwAQ32Handle(), 0);
157 ModuleSettingsSetDefaults(ModuleSettingsHandle(),0);
158 AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
161 #if defined(PIOS_INCLUDE_USB)
163 GPIO_Init(pios_usb_main_cfg.disconnect.gpio, (GPIO_InitTypeDef*)&pios_usb_main_cfg.disconnect.init);
164 GPIO_SetBits(pios_usb_main_cfg.disconnect.gpio, pios_usb_main_cfg.disconnect.init.GPIO_Pin);
170 bool usb_hid_present =
false;
171 bool usb_cdc_present =
false;
173 #if defined(PIOS_INCLUDE_USB_CDC)
177 usb_hid_present =
true;
178 usb_cdc_present =
true;
183 usb_hid_present =
true;
186 uintptr_t pios_usb_id;
189 #if defined(PIOS_INCLUDE_USB_CDC)
191 uint8_t hw_usb_vcpport;
193 HwAQ32USB_VCPPortGet(&hw_usb_vcpport);
195 if (!usb_cdc_present) {
197 hw_usb_vcpport = HWAQ32_USB_VCPPORT_DISABLED;
204 #if defined(PIOS_INCLUDE_USB_HID)
206 uint8_t hw_usb_hidport;
207 HwAQ32USB_HIDPortGet(&hw_usb_hidport);
209 if (!usb_hid_present) {
211 hw_usb_hidport = HWAQ32_USB_HIDPORT_DISABLED;
218 if (usb_hid_present || usb_cdc_present) {
225 GPIO_ResetBits(pios_usb_main_cfg.disconnect.gpio, pios_usb_main_cfg.disconnect.init.GPIO_Pin);
229 GPIO_SetBits(pios_usb_main_cfg.disconnect.gpio, pios_usb_main_cfg.disconnect.init.GPIO_Pin);
236 #if defined(PIOS_INCLUDE_I2C)
237 if (
PIOS_I2C_Init(&pios_i2c_internal_id, &pios_i2c_internal_cfg))
243 if (
AlarmsGet(SYSTEMALARMS_ALARM_I2C) == SYSTEMALARMS_ALARM_UNINITIALISED)
244 AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_OK);
245 #endif // PIOS_INCLUDE_I2C
247 HwAQ32DSMxModeOptions hw_DSMxMode;
248 HwAQ32DSMxModeGet(&hw_DSMxMode);
252 HwAQ32Uart1Get(&hw_uart1);
254 PIOS_HAL_ConfigurePort(hw_uart1,
268 HwAQ32Uart2Get(&hw_uart2);
270 PIOS_HAL_ConfigurePort(hw_uart2,
284 HwAQ32Uart3Get(&hw_uart3);
286 PIOS_HAL_ConfigurePort(hw_uart3,
296 &pios_usart3_sbus_aux_cfg);
298 if (hw_uart3 == HWAQ32_UART3_FRSKYSENSORHUB)
300 GPIO_Init(pios_usart3_sbus_aux_cfg.inv.gpio, (GPIO_InitTypeDef*)&pios_usart3_sbus_aux_cfg.inv.init);
301 GPIO_WriteBit(pios_usart3_sbus_aux_cfg.inv.gpio, pios_usart3_sbus_aux_cfg.inv.init.GPIO_Pin, pios_usart3_sbus_aux_cfg.gpio_inv_enable);
306 HwAQ32Uart4Get(&hw_uart4);
308 PIOS_HAL_ConfigurePort(hw_uart4,
316 &pios_usart4_dsm_aux_cfg,
322 HwAQ32Uart6Get(&hw_uart6);
324 PIOS_HAL_ConfigurePort(hw_uart6,
332 &pios_usart6_dsm_aux_cfg,
337 HwAQ32RcvrPortGet(&hw_rcvrport);
340 PIOS_HAL_ConfigurePort(hw_rcvrport,
352 #if defined(PIOS_INCLUDE_SERVO) & defined(PIOS_INCLUDE_DMASHOT)
356 #if defined(PIOS_INCLUDE_TIM) && defined(PIOS_INCLUDE_SERVO)
357 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
364 #ifdef PIOS_INCLUDE_WS2811
365 RGBLEDSettingsInitialize();
369 RGBLEDSettingsNumLedsGet(&temp);
379 #ifdef PIOS_INCLUDE_DAC
382 PIOS_HAL_ConfigureDAC(pios_dac);
392 #if defined(PIOS_INCLUDE_MPU)
397 HwAQ32GyroRangeOptions hw_gyro_range;
398 HwAQ32GyroRangeGet(&hw_gyro_range);
399 switch(hw_gyro_range) {
400 case HWAQ32_GYRORANGE_250:
403 case HWAQ32_GYRORANGE_500:
406 case HWAQ32_GYRORANGE_1000:
409 case HWAQ32_GYRORANGE_2000:
414 HwAQ32AccelRangeOptions hw_accel_range;
415 HwAQ32AccelRangeGet(&hw_accel_range);
416 switch(hw_accel_range) {
417 case HWAQ32_ACCELRANGE_2G:
420 case HWAQ32_ACCELRANGE_4G:
423 case HWAQ32_ACCELRANGE_8G:
426 case HWAQ32_ACCELRANGE_16G:
432 HwAQ32MPU6000DLPFOptions hw_mpu_dlpf;
433 HwAQ32MPU6000DLPFGet(&hw_mpu_dlpf);
434 uint16_t bandwidth = \
435 (hw_mpu_dlpf == HWAQ32_MPU6000DLPF_188) ? 188 : \
436 (hw_mpu_dlpf == HWAQ32_MPU6000DLPF_98) ? 98 : \
437 (hw_mpu_dlpf == HWAQ32_MPU6000DLPF_42) ? 42 : \
438 (hw_mpu_dlpf == HWAQ32_MPU6000DLPF_20) ? 20 : \
439 (hw_mpu_dlpf == HWAQ32_MPU6000DLPF_10) ? 10 : \
440 (hw_mpu_dlpf == HWAQ32_MPU6000DLPF_5) ? 5 : \
445 #if defined(PIOS_INCLUDE_I2C)
448 uint8_t hw_magnetometer;
449 HwAQ32MagnetometerGet(&hw_magnetometer);
451 switch (hw_magnetometer) {
452 case HWAQ32_MAGNETOMETER_NONE:
455 case HWAQ32_MAGNETOMETER_INTERNAL:
456 #if defined(PIOS_INCLUDE_HMC5883)
457 if ((
PIOS_HMC5883_Init(pios_i2c_internal_id, &pios_hmc5883_internal_cfg) != 0) ||
466 PIOS_HAL_ConfigurePort(HWSHARED_PORTTYPES_I2C,
469 &pios_i2c_external_id,
470 &pios_i2c_external_cfg,
478 uint8_t hw_orientation;
479 HwAQ32ExtMagOrientationGet(&hw_orientation);
482 &pios_i2c_external_id, &pios_i2c_external_cfg);
491 #if defined(PIOS_INCLUDE_MS5611)
493 || (PIOS_MS5611_Test() != 0))
502 #if defined(PIOS_INCLUDE_ADC)
506 HwAQ32ADCInputsGet(&hw_adcport);
508 switch (hw_adcport) {
509 case HWAQ32_ADCINPUTS_DISABLED:
511 case HWAQ32_ADCINPUTS_ENABLED:
513 uintptr_t internal_adc_id;
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)
int32_t PIOS_HMC5883_Test(void)
#define PIOS_DEBUG_Assert(test)
int PIOS_HAL_ConfigureExternalMag(HwSharedMagOptions mag, HwSharedMagOrientationOptions orientation, pios_i2c_t *i2c_id, const struct pios_i2c_adapter_cfg *i2c_cfg)
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.
Configuration structure for the MS5611 driver.
int32_t PIOS_I2C_Init(pios_i2c_t *i2c_id, const char *path)
void PIOS_WDG_Clear(void)
Clear the watchdog timer.
int PIOS_DAC_init(dac_dev_t *dev_out, const struct pios_dac_cfg *cfg)
Allocate and initialise DAC device.
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)
static const struct pios_tim_clock_cfg tim_4_cfg
uintptr_t pios_com_telem_serial_id
const struct pios_com_driver pios_usart_com_driver
static const struct pios_tim_clock_cfg tim_5_cfg
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
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)
int32_t PIOS_SENSORS_Init()
Initialize the PIOS_SENSORS interface.
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_USBHOOK_Activate(void)
void PIOS_FLASH_register_partition_table(const struct pios_flash_partition partition_table[], uint8_t num_partitions)
int32_t PIOS_HMC5883_Init(pios_i2c_t i2c_id, const struct pios_hmc5883_cfg *cfg)
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)
int32_t PIOS_MS5611_Init(const struct pios_ms5611_cfg *cfg, pios_i2c_t i2c_device)
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
void PIOS_DMAShot_Init(const struct pios_dmashot_cfg *config)
Initializes the DMAShot driver by loading the configuration.
#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)