38 #include "board_hw_defs.c"
43 #include <uavobjectsinit.h>
44 #include "hwpikoblx.h"
45 #include "manualcontrolsettings.h"
46 #include "modulesettings.h"
48 #define PIOS_COM_CAN_RX_BUF_LEN 256
49 #define PIOS_COM_CAN_TX_BUF_LEN 256
70 #if defined(PIOS_INCLUDE_ANNUNC)
76 #if defined(PIOS_INCLUDE_SPI)
85 #if defined(PIOS_INCLUDE_FLASH)
92 uint32_t num_partitions;
93 flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->
board_rev, &num_partitions);
99 #if defined(ERASE_FLASH)
108 HwPikoBLXInitialize();
109 ModuleSettingsInitialize();
111 #if defined(PIOS_INCLUDE_RTC)
119 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
137 if (boot_count < 3) {
142 HwPikoBLXSetDefaults(HwPikoBLXHandle(), 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 HwPikoBLXUSB_VCPPortGet(&hw_usb_vcpport);
177 if (!usb_cdc_present) {
179 hw_usb_vcpport = HWPIKOBLX_USB_VCPPORT_DISABLED;
185 #if defined(PIOS_INCLUDE_USB_HID)
187 uint8_t hw_usb_hidport;
188 HwPikoBLXUSB_HIDPortGet(&hw_usb_hidport);
190 if (!usb_hid_present) {
192 hw_usb_hidport = HWPIKOBLX_USB_HIDPORT_DISABLED;
202 HwPikoBLXDSMxModeOptions hw_DSMxMode;
203 HwPikoBLXDSMxModeGet(&hw_DSMxMode);
205 HwSharedPortTypesOptions hw_uart1;
206 HwPikoBLXUart1Get(&hw_uart1);
207 PIOS_HAL_ConfigurePort(hw_uart1,
208 &pios_uart1_usart_cfg,
220 HwSharedPortTypesOptions hw_uart2;
221 HwPikoBLXUart2Get(&hw_uart2);
222 PIOS_HAL_ConfigurePort(hw_uart2,
223 &pios_uart2_usart_cfg,
235 HwSharedPortTypesOptions hw_rxp;
236 HwPikoBLXRxPortGet(&hw_rxp);
237 PIOS_HAL_ConfigurePort(hw_rxp,
238 &pios_uart3_usart_cfg,
249 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
250 #ifdef PIOS_INCLUDE_SERVO
257 #if defined(PIOS_INCLUDE_ADC)
258 uintptr_t unused_adc;
268 #if defined(PIOS_INCLUDE_MPU)
273 HwPikoBLXGyroRangeOptions hw_gyro_range;
274 HwPikoBLXGyroRangeGet(&hw_gyro_range);
275 switch(hw_gyro_range) {
276 case HWPIKOBLX_GYRORANGE_250:
279 case HWPIKOBLX_GYRORANGE_500:
282 case HWPIKOBLX_GYRORANGE_1000:
285 case HWPIKOBLX_GYRORANGE_2000:
290 HwPikoBLXAccelRangeOptions hw_accel_range;
291 HwPikoBLXAccelRangeGet(&hw_accel_range);
292 switch(hw_accel_range) {
293 case HWPIKOBLX_ACCELRANGE_2G:
296 case HWPIKOBLX_ACCELRANGE_4G:
299 case HWPIKOBLX_ACCELRANGE_8G:
302 case HWPIKOBLX_ACCELRANGE_16G:
308 HwPikoBLXGyroLPFOptions hw_mpu_gyro_dlpf;
309 HwPikoBLXGyroLPFGet(&hw_mpu_gyro_dlpf);
310 uint16_t gyro_bandwidth =
311 (hw_mpu_gyro_dlpf == HWPIKOBLX_GYROLPF_188) ? 188 :
312 (hw_mpu_gyro_dlpf == HWPIKOBLX_GYROLPF_98) ? 98 :
313 (hw_mpu_gyro_dlpf == HWPIKOBLX_GYROLPF_42) ? 42 :
314 (hw_mpu_gyro_dlpf == HWPIKOBLX_GYROLPF_20) ? 20 :
315 (hw_mpu_gyro_dlpf == HWPIKOBLX_GYROLPF_10) ? 10 :
316 (hw_mpu_gyro_dlpf == HWPIKOBLX_GYROLPF_5) ? 5 :
320 HwPikoBLXAccelLPFOptions hw_mpu_accel_dlpf;
321 HwPikoBLXAccelLPFGet(&hw_mpu_accel_dlpf);
322 uint16_t acc_bandwidth =
323 (hw_mpu_accel_dlpf = HWPIKOBLX_ACCELLPF_218) ? 218 :
324 (hw_mpu_accel_dlpf = HWPIKOBLX_ACCELLPF_99) ? 99 :
325 (hw_mpu_accel_dlpf = HWPIKOBLX_ACCELLPF_45) ? 45 :
326 (hw_mpu_accel_dlpf = HWPIKOBLX_ACCELLPF_21) ? 21 :
327 (hw_mpu_accel_dlpf = HWPIKOBLX_ACCELLPF_10) ? 10 :
328 (hw_mpu_accel_dlpf = HWPIKOBLX_ACCELLPF_5) ? 5 :
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)
#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.
const struct pios_board_info pios_board_info_blob
struct pios_mpu_dev * pios_mpu_dev_t
uintptr_t pios_com_aux_id
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)
static const struct pios_tim_clock_cfg tim_1_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_MPU_SetAccelBandwidth(uint16_t bandwidth)
Sets the bandwidth desired from the accelerometer. The driver will automatically select the lowest ba...
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)
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.
int32_t PIOS_FLASHFS_Format(uintptr_t fs_id)
Erases all filesystem arenas and activate the first arena.
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)
void PIOS_RESET_Clear(void)
PIOS_RESET_Clear Does nothing on POSIX systems.
uintptr_t pios_com_can_id