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
76 #if defined(PIOS_INCLUDE_ANNUNC)
82 #if defined(PIOS_INCLUDE_SPI)
91 #if defined(PIOS_INCLUDE_FLASH)
98 uint32_t num_partitions;
99 flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->
board_rev, &num_partitions);
111 ModuleSettingsInitialize();
113 #if defined(PIOS_INCLUDE_RTC)
121 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
139 if (boot_count < 3) {
144 HwLuxSetDefaults(HwLuxHandle(), 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 HwLuxUSB_VCPPortGet(&hw_usb_vcpport);
179 if (!usb_cdc_present) {
181 hw_usb_vcpport = HWLUX_USB_VCPPORT_DISABLED;
187 #if defined(PIOS_INCLUDE_USB_HID)
189 uint8_t hw_usb_hidport;
190 HwLuxUSB_HIDPortGet(&hw_usb_hidport);
192 if (!usb_hid_present) {
194 hw_usb_hidport = HWLUX_USB_HIDPORT_DISABLED;
203 HwLuxDSMxModeOptions hw_DSMxMode;
204 HwLuxDSMxModeGet(&hw_DSMxMode);
207 HwLuxUart3Get(&hw_uart3);
208 PIOS_HAL_ConfigurePort(hw_uart3,
216 &pios_uart3_dsm_aux_cfg,
221 HwLuxUart2Get(&hw_uart2);
222 PIOS_HAL_ConfigurePort(hw_uart2,
230 &pios_uart2_dsm_aux_cfg,
236 HwLuxRxPortGet(&hw_rxport);
237 PIOS_HAL_ConfigurePort(hw_rxport,
238 &pios_rxport_usart_cfg,
245 &pios_rxport_dsm_aux_cfg,
250 const uint8_t hw_rxppm = HWSHARED_PORTTYPES_PPM;
251 PIOS_HAL_ConfigurePort(hw_rxppm,
263 #ifdef PIOS_INCLUDE_WS2811
266 RGBLEDSettingsInitialize();
268 RGBLEDSettingsNumLedsGet(&num_leds);
274 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
275 #ifdef PIOS_INCLUDE_SERVO
282 #if defined(PIOS_INCLUDE_ADC)
283 uintptr_t unused_adc;
293 #if defined(PIOS_INCLUDE_MPU)
300 uint8_t hw_gyro_range;
301 HwLuxGyroRangeGet(&hw_gyro_range);
302 switch(hw_gyro_range) {
303 case HWLUX_GYRORANGE_250:
306 case HWLUX_GYRORANGE_500:
309 case HWLUX_GYRORANGE_1000:
312 case HWLUX_GYRORANGE_2000:
317 uint8_t hw_accel_range;
318 HwLuxAccelRangeGet(&hw_accel_range);
319 switch(hw_accel_range) {
320 case HWLUX_ACCELRANGE_2G:
323 case HWLUX_ACCELRANGE_4G:
326 case HWLUX_ACCELRANGE_8G:
329 case HWLUX_ACCELRANGE_16G:
335 uint8_t hw_mpu9250_dlpf;
336 HwLuxMPU9250GyroLPFGet(&hw_mpu9250_dlpf);
338 uint16_t bandwidth = \
339 (hw_mpu9250_dlpf == HWLUX_MPU9250GYROLPF_184) ? 184 : \
340 (hw_mpu9250_dlpf == HWLUX_MPU9250GYROLPF_92) ? 92 : \
341 (hw_mpu9250_dlpf == HWLUX_MPU9250GYROLPF_41) ? 41 : \
342 (hw_mpu9250_dlpf == HWLUX_MPU9250GYROLPF_20) ? 20 : \
343 (hw_mpu9250_dlpf == HWLUX_MPU9250GYROLPF_10) ? 10 : \
344 (hw_mpu9250_dlpf == HWLUX_MPU9250GYROLPF_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)
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.
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
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_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)
void PIOS_RESET_Clear(void)
PIOS_RESET_Clear Does nothing on POSIX systems.
uintptr_t pios_com_can_id