1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-10 18:24:11 +01:00

bootcfg: additional validation during board init

This commit is contained in:
Stacey Sheldon 2011-07-06 22:34:59 -04:00
parent dbf7574946
commit e82539c654
2 changed files with 22 additions and 22 deletions

View File

@ -869,7 +869,7 @@ void PIOS_Board_Init(void) {
/* Set up the SPI interface to the serial flash */ /* Set up the SPI interface to the serial flash */
if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg)) { if (PIOS_SPI_Init(&pios_spi_flash_accel_id, &pios_spi_flash_accel_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
PIOS_Flash_W25X_Init(pios_spi_flash_accel_id); PIOS_Flash_W25X_Init(pios_spi_flash_accel_id);
@ -1022,13 +1022,13 @@ void PIOS_Board_Init(void) {
case MANUALCONTROLSETTINGS_INPUTMODE_PWM: case MANUALCONTROLSETTINGS_INPUTMODE_PWM:
#if defined(PIOS_INCLUDE_PWM) #if defined(PIOS_INCLUDE_PWM)
PIOS_PWM_Init(); PIOS_PWM_Init();
for (uint8_t i = 0; i < PIOS_PWM_NUM_INPUTS; i++) { for (uint8_t i = 0; i < PIOS_PWM_NUM_INPUTS && i < pios_rcvr_max_channel; i++) {
if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel],
&pios_pwm_rcvr_driver, &pios_pwm_rcvr_driver,
i)) { i)) {
pios_rcvr_max_channel++; pios_rcvr_max_channel++;
} else { } else {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
} }
#endif /* PIOS_INCLUDE_PWM */ #endif /* PIOS_INCLUDE_PWM */
@ -1036,13 +1036,13 @@ void PIOS_Board_Init(void) {
case MANUALCONTROLSETTINGS_INPUTMODE_PPM: case MANUALCONTROLSETTINGS_INPUTMODE_PPM:
#if defined(PIOS_INCLUDE_PPM) #if defined(PIOS_INCLUDE_PPM)
PIOS_PPM_Init(); PIOS_PPM_Init();
for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS; i++) { for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS && i < pios_rcvr_max_channel; i++) {
if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel],
&pios_ppm_rcvr_driver, &pios_ppm_rcvr_driver,
i)) { i)) {
pios_rcvr_max_channel++; pios_rcvr_max_channel++;
} else { } else {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
} }
#endif /* PIOS_INCLUDE_PPM */ #endif /* PIOS_INCLUDE_PPM */
@ -1051,7 +1051,7 @@ void PIOS_Board_Init(void) {
#if defined(PIOS_INCLUDE_SPEKTRUM) #if defined(PIOS_INCLUDE_SPEKTRUM)
if (hwsettings_cc_mainport == HWSETTINGS_CC_MAINPORT_SPEKTRUM || if (hwsettings_cc_mainport == HWSETTINGS_CC_MAINPORT_SPEKTRUM ||
hwsettings_cc_flexiport == HWSETTINGS_CC_FLEXIPORT_SPEKTRUM) { hwsettings_cc_flexiport == HWSETTINGS_CC_FLEXIPORT_SPEKTRUM) {
for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS; i++) { for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS && i < pios_rcvr_max_channel; i++) {
if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel],
&pios_spektrum_rcvr_driver, &pios_spektrum_rcvr_driver,
i)) { i)) {
@ -1094,7 +1094,7 @@ void PIOS_Board_Init(void) {
PIOS_USB_HID_Init(0); PIOS_USB_HID_Init(0);
#if defined(PIOS_INCLUDE_COM) #if defined(PIOS_INCLUDE_COM)
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, 0)) { if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, 0)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
#endif /* PIOS_INCLUDE_COM */ #endif /* PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_HID */ #endif /* PIOS_INCLUDE_USB_HID */

View File

@ -1024,7 +1024,7 @@ void PIOS_Board_Init(void) {
#if defined(PIOS_INCLUDE_SPI) #if defined(PIOS_INCLUDE_SPI)
/* Set up the SPI interface to the SD card */ /* Set up the SPI interface to the SD card */
if (PIOS_SPI_Init(&pios_spi_sdcard_id, &pios_spi_sdcard_cfg)) { if (PIOS_SPI_Init(&pios_spi_sdcard_id, &pios_spi_sdcard_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
/* Enable and mount the SDCard */ /* Enable and mount the SDCard */
@ -1053,7 +1053,7 @@ void PIOS_Board_Init(void) {
/* Set up the SPI interface to the AHRS */ /* Set up the SPI interface to the AHRS */
if (PIOS_SPI_Init(&pios_spi_ahrs_id, &pios_spi_ahrs_cfg)) { if (PIOS_SPI_Init(&pios_spi_ahrs_id, &pios_spi_ahrs_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
/* Bind the AHRS comms layer to the AHRS SPI link */ /* Bind the AHRS comms layer to the AHRS SPI link */
@ -1064,20 +1064,20 @@ void PIOS_Board_Init(void) {
#if defined(PIOS_INCLUDE_TELEMETRY_RF) #if defined(PIOS_INCLUDE_TELEMETRY_RF)
uint32_t pios_usart_telem_rf_id; uint32_t pios_usart_telem_rf_id;
if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_cfg)) { if (PIOS_USART_Init(&pios_usart_telem_rf_id, &pios_usart_telem_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id)) { if (PIOS_COM_Init(&pios_com_telem_rf_id, &pios_usart_com_driver, pios_usart_telem_rf_id)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
#endif /* PIOS_INCLUDE_TELEMETRY_RF */ #endif /* PIOS_INCLUDE_TELEMETRY_RF */
#if defined(PIOS_INCLUDE_GPS) #if defined(PIOS_INCLUDE_GPS)
uint32_t pios_usart_gps_id; uint32_t pios_usart_gps_id;
if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_cfg)) { if (PIOS_USART_Init(&pios_usart_gps_id, &pios_usart_gps_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id)) { if (PIOS_COM_Init(&pios_com_gps_id, &pios_usart_com_driver, pios_usart_gps_id)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
#endif /* PIOS_INCLUDE_GPS */ #endif /* PIOS_INCLUDE_GPS */
#endif #endif
@ -1095,15 +1095,15 @@ void PIOS_Board_Init(void) {
uint32_t pios_usart_spektrum_id; uint32_t pios_usart_spektrum_id;
if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_cfg)) { if (PIOS_USART_Init(&pios_usart_spektrum_id, &pios_usart_spektrum_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS; i++) { for (uint8_t i = 0; i < PIOS_SPEKTRUM_NUM_INPUTS && i < pios_rcvr_max_channel; i++) {
if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel],
&pios_spektrum_rcvr_driver, &pios_spektrum_rcvr_driver,
i)) { i)) {
pios_rcvr_max_channel++; pios_rcvr_max_channel++;
} else { } else {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
} }
#endif #endif
@ -1113,13 +1113,13 @@ void PIOS_Board_Init(void) {
#error More receiver inputs than available devices #error More receiver inputs than available devices
#endif #endif
PIOS_PWM_Init(); PIOS_PWM_Init();
for (uint8_t i = 0; i < PIOS_PWM_NUM_INPUTS; i++) { for (uint8_t i = 0; i < PIOS_PWM_NUM_INPUTS && i < pios_rcvr_max_channel; i++) {
if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel],
&pios_pwm_rcvr_driver, &pios_pwm_rcvr_driver,
i)) { i)) {
pios_rcvr_max_channel++; pios_rcvr_max_channel++;
} else { } else {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
} }
#endif #endif
@ -1128,13 +1128,13 @@ void PIOS_Board_Init(void) {
#error More receiver inputs than available devices #error More receiver inputs than available devices
#endif #endif
PIOS_PPM_Init(); PIOS_PPM_Init();
for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS; i++) { for (uint8_t i = 0; i < PIOS_PPM_NUM_INPUTS && i < pios_rcvr_max_channel; i++) {
if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel], if (!PIOS_RCVR_Init(&pios_rcvr_channel_to_id_map[pios_rcvr_max_channel],
&pios_ppm_rcvr_driver, &pios_ppm_rcvr_driver,
i)) { i)) {
pios_rcvr_max_channel++; pios_rcvr_max_channel++;
} else { } else {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
} }
#endif #endif
@ -1142,14 +1142,14 @@ void PIOS_Board_Init(void) {
PIOS_USB_HID_Init(0); PIOS_USB_HID_Init(0);
#if defined(PIOS_INCLUDE_COM) #if defined(PIOS_INCLUDE_COM)
if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, 0)) { if (PIOS_COM_Init(&pios_com_telem_usb_id, &pios_usb_com_driver, 0)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
#endif /* PIOS_INCLUDE_COM */ #endif /* PIOS_INCLUDE_COM */
#endif /* PIOS_INCLUDE_USB_HID */ #endif /* PIOS_INCLUDE_USB_HID */
#if defined(PIOS_INCLUDE_I2C) #if defined(PIOS_INCLUDE_I2C)
if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) { if (PIOS_I2C_Init(&pios_i2c_main_adapter_id, &pios_i2c_main_adapter_cfg)) {
PIOS_DEBUG_Assert(0); PIOS_Assert(0);
} }
#endif /* PIOS_INCLUDE_I2C */ #endif /* PIOS_INCLUDE_I2C */
PIOS_IAP_Init(); PIOS_IAP_Init();