/** * PIOS_Board_Init() */ void PIOS_Board_Init(void) { /* Delay system */ PIOS_DELAY_Init(); /* Initialize UAVObject libraries */ // EventDispatcherInitialize(); // UAVObjInitialize(); // HwSettingsInitialize(); // ManualControlSettingsInitialize(); #if defined(PIOS_INCLUDE_RTC) /* Initialize the real-time clock and its associated tick */ PIOS_RTC_Init(&pios_rtc_main_cfg); #endif /* Initialize the alarms library */ // AlarmsInitialize(); /* Initialize the task monitor library */ // TaskMonitorInitialize(); #if 0 // XXX this is all very wrong now #if defined(PIOS_INCLUDE_SBUS) { uint32_t pios_usart_sbus_id; if (PIOS_USART_Init(&pios_usart_sbus_id, &pios_usart_sbus_main_cfg)) { PIOS_Assert(0); } uint32_t pios_sbus_id; if (PIOS_SBUS_Init(&pios_sbus_id, &pios_sbus_cfg, &pios_usart_com_driver, pios_usart_sbus_id)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_SBUS */ #if defined(PIOS_INCLUDE_SPEKTRUM) { uint32_t pios_usart_spektrum_id; if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_main_cfg)) { PIOS_Assert(0); } uint32_t pios_spektrum_id; if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_main_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, 0)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_SPEKTRUM */ #endif #if defined(PIOS_COM_AUX) uint32_t pios_usart_aux_id; if (PIOS_USART_Init(&pios_usart_aux_id, &pios_usart_aux_cfg)) { PIOS_DEBUG_Assert(0); } static uint8_t rx_buffer[128]; static uint8_t tx_buffer[128]; if (PIOS_COM_Init(&pios_com_aux_id, &pios_usart_com_driver, pios_usart_aux_id, rx_buffer, 128, tx_buffer, 128)) { PIOS_Assert(0); } #endif PIOS_COM_SendFormattedString(PIOS_COM_AUX, "PX2IO starting...\r\n"); /* Bring up the I2C slave interface */ PIOS_I2C_Slave_Init(pios_i2c_slave_id, &i2c_slave_cfg); PIOS_Servo_Init(); // PIOS_ADC_INIT(); PIOS_GPIO_Init(); /* Configure the selected receiver */ /* XXX we don't have these settings until we have config from FMU ... */ #if defined(PIOS_INCLUDE_PPM) #if !defined(PIOS_INCLUDE_RTC) # error PPM requires RTC #endif PIOS_PPM_Init(); uint32_t pios_ppm_rcvr_id; if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_ppm_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } #endif /* PIOS_INCLUDE_PPM */ #if defined(PIOS_INCLUDE_SPEKTRUM) if (hwsettings_cc_mainport == HWSETTINGS_CC_MAINPORT_SPEKTRUM || hwsettings_cc_flexiport == HWSETTINGS_CC_FLEXIPORT_SPEKTRUM) { uint32_t pios_spektrum_rcvr_id; if (PIOS_RCVR_Init(&pios_spektrum_rcvr_id, &pios_spektrum_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_spektrum_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } } #endif /* PIOS_INCLUDE_SPEKTRUM */ #if defined(PIOS_INCLUDE_SBUS) if (hwsettings_cc_mainport == HWSETTINGS_CC_MAINPORT_SBUS) { uint32_t pios_sbus_rcvr_id; if (PIOS_RCVR_Init(&pios_sbus_rcvr_id, &pios_sbus_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < SBUS_NUMBER_OF_CHANNELS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_sbus_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } } #endif /* PIOS_INCLUDE_SBUS */ //PIOS_WDG_Init(); }
/** * PIOS_Board_Init() * initializes all the core subsystems on this specific hardware * called from System/openpilot.c */ void PIOS_Board_Init(void) { /* Remap AFIO pin */ //GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); /* Debug services */ PIOS_DEBUG_Init(); /* Delay system */ PIOS_DELAY_Init(); #if defined(PIOS_INCLUDE_SPI) /* Set up the SPI interface to the SD card */ if (PIOS_SPI_Init(&pios_spi_sdcard_id, &pios_spi_sdcard_cfg)) { PIOS_Assert(0); } /* Enable and mount the SDCard */ PIOS_SDCARD_Init(pios_spi_sdcard_id); PIOS_SDCARD_MountFS(0); #endif /* PIOS_INCLUDE_SPI */ /* Initialize UAVObject libraries */ EventDispatcherInitialize(); UAVObjInitialize(); UAVObjectsInitializeAll(); #if defined(PIOS_INCLUDE_RTC) /* Initialize the real-time clock and its associated tick */ PIOS_RTC_Init(&pios_rtc_main_cfg); #endif /* Initialize the alarms library */ AlarmsInitialize(); /* Initialize the task monitor library */ TaskMonitorInitialize(); /* Prepare the AHRS Comms upper layer protocol */ AhrsInitComms(); /* Set up the SPI interface to the AHRS */ if (PIOS_SPI_Init(&pios_spi_ahrs_id, &pios_spi_ahrs_cfg)) { PIOS_Assert(0); } /* Bind the AHRS comms layer to the AHRS SPI link */ AhrsConnect(pios_spi_ahrs_id); /* Initialize the PiOS library */ #if defined(PIOS_INCLUDE_COM) #if defined(PIOS_INCLUDE_TELEMETRY_RF) uint32_t pios_usart_telem_rf_id; if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_cfg)) { PIOS_Assert(0); } if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id)) { PIOS_Assert(0); } #endif /* PIOS_INCLUDE_TELEMETRY_RF */ #if defined(PIOS_INCLUDE_GPS) uint32_t pios_usart_gps_id; if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_cfg)) { PIOS_Assert(0); } if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id)) { PIOS_Assert(0); } #endif /* PIOS_INCLUDE_GPS */ #endif PIOS_Servo_Init(); PIOS_ADC_Init(); PIOS_GPIO_Init(); #if defined(PIOS_INCLUDE_SPEKTRUM) #if (PIOS_SPEKTRUM_NUM_INPUTS > PIOS_RCVR_MAX_DEVS) #error More receiver inputs than available devices #endif /* SPEKTRUM init must come before comms */ PIOS_SPEKTRUM_Init(&pios_spektrum_cfg, false); uint32_t pios_usart_spektrum_id; if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_cfg)) { PIOS_Assert(0); } for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS && i < PIOS_RCVR_MAX_DEVS; i++) { if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], &pios_spektrum_rcvr_driver, i)) { pios_rcvr_max_channel++; } else { PIOS_Assert(0); } } #endif #if defined(PIOS_INCLUDE_PWM) #if (PIOS_PWM_NUM_INPUTS > PIOS_RCVR_MAX_DEVS) #error More receiver inputs than available devices #endif PIOS_PWM_Init(); for (uint8_t i = 0; i < PIOS_PWM_NUM_INPUTS && i < PIOS_RCVR_MAX_DEVS; i++) { if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], &pios_pwm_rcvr_driver, i)) { pios_rcvr_max_channel++; } else { PIOS_Assert(0); } } #endif #if defined(PIOS_INCLUDE_PPM) #if (PIOS_PPM_NUM_INPUTS > PIOS_RCVR_MAX_DEVS) #error More receiver inputs than available devices #endif PIOS_PPM_Init(); for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS && i < PIOS_RCVR_MAX_DEVS; i++) { if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], &pios_ppm_rcvr_driver, i)) { pios_rcvr_max_channel++; } else { PIOS_Assert(0); } } #endif #if defined(PIOS_INCLUDE_USB_HID) PIOS_USB_HID_Init(0); #if defined(PIOS_INCLUDE_COM) if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, 0)) { PIOS_Assert(0); } #endif /* PIOS_INCLUDE_COM */ #endif /* PIOS_INCLUDE_USB_HID */ #if defined(PIOS_INCLUDE_I2C) if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) { PIOS_Assert(0); } #endif /* PIOS_INCLUDE_I2C */ PIOS_IAP_Init(); PIOS_WDG_Init(); }
/** * PIOS_Board_Init() * initializes all the core subsystems on this specific hardware * called from System/openpilot.c */ void PIOS_Board_Init(void) { /* Delay system */ PIOS_DELAY_Init(); /* Set up the SPI interface to the serial flash */ if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg)) { PIOS_DEBUG_Assert(0); } PIOS_Flash_W25X_Init(pios_spi_flash_accel_id); PIOS_ADXL345_Attach(pios_spi_flash_accel_id); #if defined(PIOS_INCLUDE_SPEKTRUM) /* SPEKTRUM init must come before comms */ PIOS_SPEKTRUM_Init(); if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_cfg)) { PIOS_DEBUG_Assert(0); } if (PIOS_COM_Init(&pios_com_spektrum_id, &pios_usart_com_driver, pios_usart_spektrum_id)) { PIOS_DEBUG_Assert(0); } #endif /* Initialize UAVObject libraries */ EventDispatcherInitialize(); UAVObjInitialize(); UAVObjectsInitializeAll(); /* Initialize the alarms library */ AlarmsInitialize(); /* Initialize the task monitor library */ TaskMonitorInitialize(); /* Initialize the PiOS library */ #if defined(PIOS_INCLUDE_COM) if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_cfg)) { PIOS_DEBUG_Assert(0); } if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id)) { PIOS_DEBUG_Assert(0); } #if defined(PIOS_INCLUDE_GPS) if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_cfg)) { PIOS_DEBUG_Assert(0); } if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id)) { PIOS_DEBUG_Assert(0); } #endif /* PIOS_INCLUDE_GPS */ #endif /* PIOS_INCLUDE_COM */ /* Remap AFIO pin */ GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); PIOS_Servo_Init(); PIOS_ADC_Init(); PIOS_GPIO_Init(); #if defined(PIOS_INCLUDE_PWM) PIOS_PWM_Init(); #endif #if defined(PIOS_INCLUDE_PPM) PIOS_PPM_Init(); #endif #if defined(PIOS_INCLUDE_USB_HID) PIOS_USB_HID_Init(0); #if defined(PIOS_INCLUDE_COM) if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, 0)) { PIOS_DEBUG_Assert(0); } #endif /* PIOS_INCLUDE_COM */ #endif #if defined(PIOS_INCLUDE_I2C) if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) { PIOS_DEBUG_Assert(0); } #endif /* PIOS_INCLUDE_I2C */ PIOS_IAP_Init(); PIOS_WDG_Init(); }
/** * PIOS_Board_Init() * initializes all the core subsystems on this specific hardware * called from System/openpilot.c */ void PIOS_Board_Init(void) { /* Delay system */ PIOS_DELAY_Init(); /* Set up the SPI interface to the serial flash */ if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg)) { PIOS_Assert(0); } PIOS_Flash_W25X_Init(pios_spi_flash_accel_id); PIOS_ADXL345_Attach(pios_spi_flash_accel_id); PIOS_FLASHFS_Init(&PIOS_Flash_W25X_Driver); /* Initialize UAVObject libraries */ EventDispatcherInitialize(); UAVObjInitialize(); HwSettingsInitialize(); ManualControlSettingsInitialize(); #if defined(PIOS_INCLUDE_RTC) /* Initialize the real-time clock and its associated tick */ PIOS_RTC_Init(&pios_rtc_main_cfg); #endif /* Initialize the alarms library */ AlarmsInitialize(); /* Initialize the task monitor library */ TaskMonitorInitialize(); /* Configure the main IO port */ uint8_t hwsettings_DSMxBind; HwSettingsDSMxBindGet(&hwsettings_DSMxBind); uint8_t hwsettings_cc_mainport; HwSettingsCC_MainPortGet(&hwsettings_cc_mainport); switch (hwsettings_cc_mainport) { case HWSETTINGS_CC_MAINPORT_DISABLED: break; case HWSETTINGS_CC_MAINPORT_TELEMETRY: #if defined(PIOS_INCLUDE_TELEMETRY_RF) { uint32_t pios_usart_telem_rf_id; if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_main_cfg)) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN); uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN); PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id, rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN, tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_TELEMETRY_RF */ break; case HWSETTINGS_CC_MAINPORT_SBUS: #if defined(PIOS_INCLUDE_SBUS) { uint32_t pios_usart_sbus_id; if (PIOS_USART_Init(&pios_usart_sbus_id, &pios_usart_sbus_main_cfg)) { PIOS_Assert(0); } uint32_t pios_sbus_id; if (PIOS_SBUS_Init(&pios_sbus_id, &pios_sbus_cfg, &pios_usart_com_driver, pios_usart_sbus_id)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_SBUS */ break; case HWSETTINGS_CC_MAINPORT_GPS: #if defined(PIOS_INCLUDE_GPS) { uint32_t pios_usart_gps_id; if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_main_cfg)) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN); PIOS_Assert(rx_buffer); if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id, rx_buffer, PIOS_COM_GPS_RX_BUF_LEN, NULL, 0)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_GPS */ break; case HWSETTINGS_CC_MAINPORT_SPEKTRUM: #if defined(PIOS_INCLUDE_SPEKTRUM) { uint32_t pios_usart_spektrum_id; if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_main_cfg)) { PIOS_Assert(0); } uint32_t pios_spektrum_id; if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_main_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, 0)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_SPEKTRUM */ break; case HWSETTINGS_CC_MAINPORT_COMAUX: break; } /* Configure the flexi port */ uint8_t hwsettings_cc_flexiport; HwSettingsCC_FlexiPortGet(&hwsettings_cc_flexiport); switch (hwsettings_cc_flexiport) { case HWSETTINGS_CC_FLEXIPORT_DISABLED: break; case HWSETTINGS_CC_FLEXIPORT_TELEMETRY: #if defined(PIOS_INCLUDE_TELEMETRY_RF) { uint32_t pios_usart_telem_rf_id; if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_flexi_cfg)) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_RX_BUF_LEN); uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_RF_TX_BUF_LEN); PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id, rx_buffer, PIOS_COM_TELEM_RF_RX_BUF_LEN, tx_buffer, PIOS_COM_TELEM_RF_TX_BUF_LEN)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_TELEMETRY_RF */ break; case HWSETTINGS_CC_FLEXIPORT_GPS: #if defined(PIOS_INCLUDE_GPS) { uint32_t pios_usart_gps_id; if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_flexi_cfg)) { PIOS_Assert(0); } uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_GPS_RX_BUF_LEN); PIOS_Assert(rx_buffer); if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id, rx_buffer, PIOS_COM_GPS_RX_BUF_LEN, NULL, 0)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_GPS */ break; case HWSETTINGS_CC_FLEXIPORT_SPEKTRUM: #if defined(PIOS_INCLUDE_SPEKTRUM) { uint32_t pios_usart_spektrum_id; if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_flexi_cfg)) { PIOS_Assert(0); } uint32_t pios_spektrum_id; if (PIOS_SPEKTRUM_Init(&pios_spektrum_id, &pios_spektrum_flexi_cfg, &pios_usart_com_driver, pios_usart_spektrum_id, hwsettings_DSMxBind)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_SPEKTRUM */ break; case HWSETTINGS_CC_FLEXIPORT_COMAUX: break; case HWSETTINGS_CC_FLEXIPORT_I2C: #if defined(PIOS_INCLUDE_I2C) { if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) { PIOS_Assert(0); } } #endif /* PIOS_INCLUDE_I2C */ break; } /* Configure the selected receiver */ uint8_t manualcontrolsettings_inputmode; ManualControlSettingsInputModeGet(&manualcontrolsettings_inputmode); switch (manualcontrolsettings_inputmode) { case MANUALCONTROLSETTINGS_INPUTMODE_PWM: #if defined(PIOS_INCLUDE_PWM) PIOS_PWM_Init(); uint32_t pios_pwm_rcvr_id; if (PIOS_RCVR_Init(&pios_pwm_rcvr_id, &pios_pwm_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < PIOS_PWM_NUM_INPUTS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_pwm_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } #endif /* PIOS_INCLUDE_PWM */ break; case MANUALCONTROLSETTINGS_INPUTMODE_PPM: #if defined(PIOS_INCLUDE_PPM) PIOS_PPM_Init(); uint32_t pios_ppm_rcvr_id; if (PIOS_RCVR_Init(&pios_ppm_rcvr_id, &pios_ppm_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_ppm_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } #endif /* PIOS_INCLUDE_PPM */ break; case MANUALCONTROLSETTINGS_INPUTMODE_SPEKTRUM: #if defined(PIOS_INCLUDE_SPEKTRUM) if (hwsettings_cc_mainport == HWSETTINGS_CC_MAINPORT_SPEKTRUM || hwsettings_cc_flexiport == HWSETTINGS_CC_FLEXIPORT_SPEKTRUM) { uint32_t pios_spektrum_rcvr_id; if (PIOS_RCVR_Init(&pios_spektrum_rcvr_id, &pios_spektrum_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_spektrum_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } } #endif /* PIOS_INCLUDE_SPEKTRUM */ break; case MANUALCONTROLSETTINGS_INPUTMODE_SBUS: #if defined(PIOS_INCLUDE_SBUS) if (hwsettings_cc_mainport == HWSETTINGS_CC_MAINPORT_SBUS) { uint32_t pios_sbus_rcvr_id; if (PIOS_RCVR_Init(&pios_sbus_rcvr_id, &pios_sbus_rcvr_driver, 0)) { PIOS_Assert(0); } for (uint8_t i = 0; i < SBUS_NUMBER_OF_CHANNELS && pios_rcvr_max_channel < NELEMENTS(pios_rcvr_channel_to_id_map); i++) { pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].id = pios_sbus_rcvr_id; pios_rcvr_channel_to_id_map[pios_rcvr_max_channel].channel = i; pios_rcvr_max_channel++; } } #endif /* PIOS_INCLUDE_SBUS */ break; } /* Remap AFIO pin */ GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); PIOS_Servo_Init(); PIOS_ADC_Init(); PIOS_GPIO_Init(); #if defined(PIOS_INCLUDE_USB_HID) uint32_t pios_usb_hid_id; PIOS_USB_HID_Init(&pios_usb_hid_id, &pios_usb_hid_main_cfg); #if defined(PIOS_INCLUDE_COM) uint8_t * rx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_RX_BUF_LEN); uint8_t * tx_buffer = (uint8_t *) pvPortMalloc(PIOS_COM_TELEM_USB_TX_BUF_LEN); PIOS_Assert(rx_buffer); PIOS_Assert(tx_buffer); if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, pios_usb_hid_id, rx_buffer, PIOS_COM_TELEM_USB_RX_BUF_LEN, tx_buffer, PIOS_COM_TELEM_USB_TX_BUF_LEN)) { PIOS_Assert(0); } #endif /* PIOS_INCLUDE_COM */ #endif /* PIOS_INCLUDE_USB_HID */ PIOS_IAP_Init(); PIOS_WDG_Init(); }