diff --git a/flight/Bootloaders/CopterControl/pios_board.c b/flight/Bootloaders/CopterControl/pios_board.c index 245f78297..92092a5ff 100644 --- a/flight/Bootloaders/CopterControl/pios_board.c +++ b/flight/Bootloaders/CopterControl/pios_board.c @@ -62,16 +62,9 @@ void PIOS_Board_Init(void) { const struct pios_board_info * bdinfo = &pios_board_info_blob; #if defined(PIOS_INCLUDE_LED) - switch(bdinfo->board_rev) { - case 0x01: // Revision 1 - PIOS_LED_Init(&pios_led_cfg_cc); - break; - case 0x02: // Revision 2 - PIOS_LED_Init(&pios_led_cfg_cc3d); - break; - default: - PIOS_Assert(0); - } + const struct pios_led_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); + PIOS_Assert(led_cfg); + PIOS_LED_Init(led_cfg); #endif /* PIOS_INCLUDE_LED */ #if defined(PIOS_INCLUDE_USB) diff --git a/flight/CopterControl/System/pios_board.c b/flight/CopterControl/System/pios_board.c index 4102bd195..e050d3f08 100644 --- a/flight/CopterControl/System/pios_board.c +++ b/flight/CopterControl/System/pios_board.c @@ -156,16 +156,9 @@ void PIOS_Board_Init(void) { const struct pios_board_info * bdinfo = &pios_board_info_blob; #if defined(PIOS_INCLUDE_LED) - switch(bdinfo->board_rev) { - case 0x01: // Revision 1 - PIOS_LED_Init(&pios_led_cfg_cc); - break; - case 0x02: // Revision 2 - PIOS_LED_Init(&pios_led_cfg_cc3d); - break; - default: - PIOS_Assert(0); - } + const struct pios_led_cfg * led_cfg = PIOS_BOARD_HW_DEFS_GetLedCfg(bdinfo->board_rev); + PIOS_Assert(led_cfg); + PIOS_LED_Init(led_cfg); #endif /* PIOS_INCLUDE_LED */ #if defined(PIOS_INCLUDE_SPI) diff --git a/flight/board_hw_defs/coptercontrol/board_hw_defs.c b/flight/board_hw_defs/coptercontrol/board_hw_defs.c index 0ac796b88..328fd44ce 100644 --- a/flight/board_hw_defs/coptercontrol/board_hw_defs.c +++ b/flight/board_hw_defs/coptercontrol/board_hw_defs.c @@ -27,6 +27,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include + +#define BOARD_REVISION_CC 1 +#define BOARD_REVISION_CC3D 2 #if defined(PIOS_INCLUDE_LED) @@ -68,6 +72,15 @@ static const struct pios_led_cfg pios_led_cfg_cc3d = { .num_leds = NELEMENTS(pios_leds_cc3d), }; +const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revision) +{ + switch (board_revision) { + case BOARD_REVISION_CC: return &pios_led_cfg_cc; + case BOARD_REVISION_CC3D: return &pios_led_cfg_cc3d; + default: return NULL; + } +} + #endif /* PIOS_INCLUDE_LED */ #if defined(PIOS_INCLUDE_SPI)