38 #include "board_hw_defs.c"
43 #include <uavobjectsinit.h>
46 #include "manualcontrolsettings.h"
47 #include "modulesettings.h"
49 #if defined(PIOS_INCLUDE_WS2811)
50 #include "rgbledsettings.h"
53 #if defined(PIOS_INCLUDE_DEBUG_CONSOLE)
54 #define PIOS_COM_DEBUGCONSOLE_TX_BUF_LEN 40
74 #if defined(PIOS_INCLUDE_ANNUNC)
80 #if defined(PIOS_INCLUDE_SPI)
89 #if defined(PIOS_INCLUDE_FLASH)
96 uint32_t num_partitions;
97 flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->
board_rev, &num_partitions);
108 HwSprf3eInitialize();
109 ModuleSettingsInitialize();
111 #if defined(PIOS_INCLUDE_RTC)
119 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
137 if (boot_count < 3) {
142 HwSprf3eSetDefaults(HwSprf3eHandle(), 0);
143 ModuleSettingsSetDefaults(ModuleSettingsHandle(), 0);
144 AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
147 #if defined(PIOS_INCLUDE_USB)
152 bool usb_hid_present =
false;
154 #if defined(PIOS_INCLUDE_USB_CDC)
155 bool usb_cdc_present =
false;
159 usb_hid_present =
true;
160 usb_cdc_present =
true;
165 usb_hid_present =
true;
168 uintptr_t pios_usb_id;
171 #if defined(PIOS_INCLUDE_USB_CDC)
173 uint8_t hw_usb_vcpport;
175 HwSprf3eUSB_VCPPortGet(&hw_usb_vcpport);
177 if (!usb_cdc_present) {
179 hw_usb_vcpport = HWSPRF3E_USB_VCPPORT_DISABLED;
185 #if defined(PIOS_INCLUDE_USB_HID)
187 uint8_t hw_usb_hidport;
188 HwSprf3eUSB_HIDPortGet(&hw_usb_hidport);
190 if (!usb_hid_present) {
192 hw_usb_hidport = HWSPRF3E_USB_HIDPORT_DISABLED;
200 #if defined(PIOS_INCLUDE_I2C)
201 if (
PIOS_I2C_Init(&pios_i2c_internal_id, &pios_i2c_internal_cfg))
207 if (
AlarmsGet(SYSTEMALARMS_ALARM_I2C) == SYSTEMALARMS_ALARM_UNINITIALISED)
208 AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_OK);
209 #endif // PIOS_INCLUDE_I2C
212 HwSprf3eDSMxModeOptions hw_DSMxMode;
213 HwSprf3eDSMxModeGet(&hw_DSMxMode);
216 HwSprf3eUart3Get(&hw_uart3);
217 PIOS_HAL_ConfigurePort(hw_uart3,
225 &pios_uart3_dsm_aux_cfg,
230 HwSprf3eUart2Get(&hw_uart2);
231 PIOS_HAL_ConfigurePort(hw_uart2,
239 &pios_uart2_dsm_aux_cfg,
244 HwSprf3eUart1Get(&hw_uart1);
245 PIOS_HAL_ConfigurePort(hw_uart1,
253 &pios_uart1_dsm_aux_cfg,
257 #ifdef PIOS_INCLUDE_WS2811
260 RGBLEDSettingsInitialize();
262 RGBLEDSettingsNumLedsGet(&num_leds);
268 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
269 #ifdef PIOS_INCLUDE_SERVO
276 #if defined(PIOS_INCLUDE_ADC)
280 uintptr_t unused_adc;
289 #if defined(PIOS_INCLUDE_BMP280)
293 HwSprf3eBarometerGet(&hw_baro);
295 case HWSPRF3E_BAROMETER_BMP280:
297 &pios_i2c_internal_id, &pios_i2c_internal_cfg))
304 #if defined(PIOS_INCLUDE_MPU)
306 uint8_t hw_orientation;
307 HwSprf3eMagnetometerGet(&hw_mag);
308 HwSprf3eExtMagOrientationGet(&hw_orientation);
312 case HWSPRF3E_MAGNETOMETER_INTERNAL:
315 case HWSPRF3E_MAGNETOMETER_NONE:
318 case HWSPRF3E_MAGNETOMETER_EXTERNALHMC5883:
320 #if defined(PIOS_INCLUDE_I2C)
323 &pios_i2c_internal_id, &pios_i2c_internal_cfg))
328 #endif // PIOS_INCLUDE_I2C
330 case HWSPRF3E_MAGNETOMETER_EXTERNALHMC5983:
332 #ifdef PIOS_INCLUDE_HMC5983_I2C
335 &pios_i2c_internal_id, &pios_i2c_internal_cfg))
348 HwSprf3eGyroRangeOptions hw_gyro_range;
349 HwSprf3eGyroRangeGet(&hw_gyro_range);
351 switch(hw_gyro_range) {
352 case HWSPRF3E_GYRORANGE_250:
355 case HWSPRF3E_GYRORANGE_500:
358 case HWSPRF3E_GYRORANGE_1000:
361 case HWSPRF3E_GYRORANGE_2000:
366 HwSprf3eAccelRangeOptions hw_accel_range;
367 HwSprf3eAccelRangeGet(&hw_accel_range);
368 switch(hw_accel_range) {
369 case HWSPRF3E_ACCELRANGE_2G:
372 case HWSPRF3E_ACCELRANGE_4G:
375 case HWSPRF3E_ACCELRANGE_8G:
378 case HWSPRF3E_ACCELRANGE_16G:
383 HwSprf3eMPU9250GyroLPFOptions hw_mpu_dlpf;
384 HwSprf3eMPU9250GyroLPFGet(&hw_mpu_dlpf);
385 uint16_t bandwidth = \
386 (hw_mpu_dlpf == HWSPRF3E_MPU9250GYROLPF_184) ? 184 : \
387 (hw_mpu_dlpf == HWSPRF3E_MPU9250GYROLPF_92) ? 92 : \
388 (hw_mpu_dlpf == HWSPRF3E_MPU9250GYROLPF_41) ? 41 : \
389 (hw_mpu_dlpf == HWSPRF3E_MPU9250GYROLPF_20) ? 20 : \
390 (hw_mpu_dlpf == HWSPRF3E_MPU9250GYROLPF_10) ? 10 : \
391 (hw_mpu_dlpf == HWSPRF3E_MPU9250GYROLPF_5) ? 5 : \
399 #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)
int PIOS_HAL_ConfigureExternalBaro(HwSharedExtBaroOptions baro, pios_i2c_t *i2c_id, const struct pios_i2c_adapter_cfg *i2c_cfg)
uintptr_t pios_com_debug_id
#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
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_17_cfg
static const struct pios_tim_clock_cfg tim_3_cfg
static const struct pios_tim_clock_cfg tim_16_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)
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.
void PIOS_SENSORS_SetMissing(enum pios_sensor_type type)
Assert that an optional (non-accel/gyro), but expected sensor is missing.