39 #include "board_hw_defs.c"
44 #include <uavobjectsinit.h>
45 #include "hwmatek405.h"
46 #include "manualcontrolsettings.h"
47 #include "modulesettings.h"
48 #include "rgbledsettings.h"
54 #ifdef PIOS_INCLUDE_MAX7456
69 #if defined(PIOS_INCLUDE_ANNUNC)
75 #if defined(PIOS_INCLUDE_SPI)
81 #if defined(PIOS_INCLUDE_FLASH)
88 uint32_t num_partitions;
89 flash_partition_table = PIOS_BOARD_HW_DEFS_GetPartitionTable(bdinfo->
board_rev, &num_partitions);
97 HwMatek405Initialize();
98 ModuleSettingsInitialize();
100 #if defined(PIOS_INCLUDE_RTC)
108 if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) == 0) {
112 HwMatek405FC_Pad_S6Options hw_fcPadS6;
113 HwMatek405FC_Pad_S6Get(&hw_fcPadS6);
125 if (hw_fcPadS6 == HWMATEK405_FC_PAD_S6_PWM_6)
130 #ifdef PIOS_INCLUDE_SPI
133 HwMatek405OSDPortGet(&hw_osdport);
135 if (hw_osdport != HWMATEK405_OSDPORT_DISABLED) {
140 switch (hw_osdport) {
141 #ifdef PIOS_INCLUDE_MAX7456
142 case HWMATEK405_OSDPORT_MAX7456OSD:
158 if (boot_count < 3) {
163 HwMatek405SetDefaults(HwMatek405Handle(), 0);
164 ModuleSettingsSetDefaults(ModuleSettingsHandle(),0);
165 AlarmsSet(SYSTEMALARMS_ALARM_BOOTFAULT, SYSTEMALARMS_ALARM_CRITICAL);
168 #if defined(PIOS_INCLUDE_USB)
173 bool usb_hid_present =
false;
174 bool usb_cdc_present =
false;
176 #if defined(PIOS_INCLUDE_USB_CDC)
180 usb_hid_present =
true;
181 usb_cdc_present =
true;
186 usb_hid_present =
true;
189 uintptr_t pios_usb_id;
192 #if defined(PIOS_INCLUDE_USB_CDC)
194 uint8_t hw_usb_vcpport;
196 HwMatek405USB_VCPPortGet(&hw_usb_vcpport);
198 if (!usb_cdc_present) {
200 hw_usb_vcpport = HWMATEK405_USB_VCPPORT_DISABLED;
207 #if defined(PIOS_INCLUDE_USB_HID)
209 uint8_t hw_usb_hidport;
210 HwMatek405USB_HIDPortGet(&hw_usb_hidport);
212 if (!usb_hid_present) {
214 hw_usb_hidport = HWMATEK405_USB_HIDPORT_DISABLED;
221 if (usb_hid_present || usb_cdc_present) {
230 #if defined(PIOS_INCLUDE_I2C)
231 if (
PIOS_I2C_Init(&pios_i2c_internal_id, &pios_i2c_internal_cfg))
235 AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_WARNING);
237 if (
AlarmsGet(SYSTEMALARMS_ALARM_I2C) == SYSTEMALARMS_ALARM_UNINITIALISED)
238 AlarmsSet(SYSTEMALARMS_ALARM_I2C, SYSTEMALARMS_ALARM_OK);
239 #endif // PIOS_INCLUDE_I2C
241 HwMatek405DSMxModeOptions hw_DSMxMode;
242 HwMatek405DSMxModeGet(&hw_DSMxMode);
246 HwMatek405Uart1Get(&hw_uart1);
248 PIOS_HAL_ConfigurePort(hw_uart1,
256 &pios_usart1_dsm_aux_cfg,
261 HwMatek405PPM_ReceiverGet(&hw_ppm);
263 if (hw_ppm == HWMATEK405_PPM_RECEIVER_ENABLED) {
264 PIOS_HAL_ConfigurePort(HWSHARED_PORTTYPES_PPM,
278 HwMatek405Uart2Get(&hw_uart2);
280 PIOS_HAL_ConfigurePort(hw_uart2,
288 &pios_usart2_dsm_aux_cfg,
295 HwMatek405Uart3Get(&hw_uart3);
297 PIOS_HAL_ConfigurePort(hw_uart3,
305 &pios_usart3_dsm_aux_cfg,
311 HwMatek405Uart4Get(&hw_uart4);
313 PIOS_HAL_ConfigurePort(hw_uart4,
321 &pios_usart4_dsm_aux_cfg,
327 HwMatek405Uart5Get(&hw_uart5);
329 PIOS_HAL_ConfigurePort(hw_uart5,
337 &pios_usart5_dsm_aux_cfg,
341 #if defined(PIOS_INCLUDE_SERVO) & defined(PIOS_INCLUDE_DMASHOT)
342 if (hw_fcPadS6 == HWMATEK405_FC_PAD_S6_PWM_6)
348 #if defined(PIOS_INCLUDE_TIM) && defined(PIOS_INCLUDE_SERVO)
349 #ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS
350 if (hw_fcPadS6 == HWMATEK405_FC_PAD_S6_PWM_6)
359 #ifdef PIOS_INCLUDE_WS2811
360 if (hw_fcPadS6 == HWMATEK405_FC_PAD_S6_LEDSTRING) {
361 RGBLEDSettingsInitialize();
365 RGBLEDSettingsNumLedsGet(&temp);
376 #ifdef PIOS_INCLUDE_DAC
379 PIOS_HAL_ConfigureDAC(pios_dac);
389 #if defined(PIOS_INCLUDE_MPU)
409 #if defined(PIOS_INCLUDE_I2C)
413 HwMatek405MagnetometerGet(&hw_ext_mag);
415 if (hw_ext_mag != HWMATEK405_MAGNETOMETER_NONE) {
416 uint8_t hw_orientation;
417 HwMatek405ExtMagOrientationGet(&hw_orientation);
420 &pios_i2c_internal_id,
421 &pios_i2c_internal_cfg);
424 #if defined(PIOS_INCLUDE_BMP280)
428 }
else if (PIOS_BMP280_Test()) {
438 #if defined(PIOS_INCLUDE_ADC)
441 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)
#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
Configuration structure for the BMP280 driver.
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.
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)
static const struct pios_tim_clock_cfg tim_1_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_MPU_SetAccelBandwidth(uint16_t bandwidth)
Sets the bandwidth desired from the accelerometer. The driver will automatically select the lowest ba...
int32_t PIOS_BMP280_Init(const struct pios_bmp280_cfg *cfg, pios_i2c_t i2c_device)
void PIOS_USBHOOK_Activate(void)
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
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)
void PIOS_SENSORS_SetMissing(enum pios_sensor_type type)
Assert that an optional (non-accel/gyro), but expected sensor is missing.