From dadc38d82db83f96e3166b2fe61b759514d5327b Mon Sep 17 00:00:00 2001 From: James Cotton Date: Wed, 26 Sep 2012 01:17:32 -0500 Subject: [PATCH] Revo Mini 2: Get basic LED working. Board revision is actually 3 since right now it masquerades as Revo. --- flight/Bootloaders/RevoMini/pios_board.c | 6 ++- flight/RevoMini/System/pios_board.c | 8 +++- flight/board_hw_defs/revomini/board_hw_defs.c | 44 ++++++++++++++++++- make/boards/revomini/board-info.mk | 2 +- 4 files changed, 56 insertions(+), 4 deletions(-) diff --git a/flight/Bootloaders/RevoMini/pios_board.c b/flight/Bootloaders/RevoMini/pios_board.c index 143124ade..6587258c8 100644 --- a/flight/Bootloaders/RevoMini/pios_board.c +++ b/flight/Bootloaders/RevoMini/pios_board.c @@ -46,8 +46,12 @@ void PIOS_Board_Init() { /* Delay system */ PIOS_DELAY_Init(); + const struct pios_board_info * bdinfo = &pios_board_info_blob; + #if defined(PIOS_INCLUDE_LED) - PIOS_LED_Init(&pios_led_cfg); + 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/RevoMini/System/pios_board.c b/flight/RevoMini/System/pios_board.c index 76a81ce9f..4ca193b0b 100644 --- a/flight/RevoMini/System/pios_board.c +++ b/flight/RevoMini/System/pios_board.c @@ -296,7 +296,13 @@ void PIOS_Board_Init(void) { /* Delay system */ PIOS_DELAY_Init(); - PIOS_LED_Init(&pios_led_cfg); + const struct pios_board_info * bdinfo = &pios_board_info_blob; + +#if defined(PIOS_INCLUDE_LED) + 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 */ /* Set up the SPI interface to the gyro/acelerometer */ if (PIOS_SPI_Init(&pios_spi_gyro_id, &pios_spi_gyro_cfg)) { diff --git a/flight/board_hw_defs/revomini/board_hw_defs.c b/flight/board_hw_defs/revomini/board_hw_defs.c index 5516b64f0..bcdfaa7f9 100644 --- a/flight/board_hw_defs/revomini/board_hw_defs.c +++ b/flight/board_hw_defs/revomini/board_hw_defs.c @@ -52,9 +52,51 @@ static const struct pios_led_cfg pios_led_cfg = { .num_leds = NELEMENTS(pios_leds), }; +static const struct pios_led pios_leds_v2[] = { + [PIOS_LED_HEARTBEAT] = { + .pin = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_5, + .GPIO_Speed = GPIO_Speed_50MHz, + .GPIO_Mode = GPIO_Mode_OUT, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + }, + [PIOS_LED_ALARM] = { + .pin = { + .gpio = GPIOB, + .init = { + .GPIO_Pin = GPIO_Pin_4, + .GPIO_Speed = GPIO_Speed_50MHz, + .GPIO_Mode = GPIO_Mode_OUT, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP + }, + }, + }, +}; + +static const struct pios_led_cfg pios_led_v2_cfg = { + .leds = pios_leds_v2, + .num_leds = NELEMENTS(pios_leds_v2), +}; + const struct pios_led_cfg * PIOS_BOARD_HW_DEFS_GetLedCfg (uint32_t board_revision) { - return &pios_led_cfg; + switch(board_revision) { + case 2: + return &pios_led_cfg; + break; + case 3: + return &pios_led_v2_cfg; + break; + default: + PIOS_DEBUG_Assert(0); + } + return NULL; } #endif /* PIOS_INCLUDE_LED */ diff --git a/make/boards/revomini/board-info.mk b/make/boards/revomini/board-info.mk index 33fdb0591..799ffd382 100644 --- a/make/boards/revomini/board-info.mk +++ b/make/boards/revomini/board-info.mk @@ -1,5 +1,5 @@ BOARD_TYPE := 0x09 -BOARD_REVISION := 0x02 +BOARD_REVISION := 0x03 BOOTLOADER_VERSION := 0x01 HW_TYPE := 0x00