1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

hw_defs: hide board-rev differences in LED definitions

Every board has at least one LED (HEARTBEAT).  Not all
users of LEDs need to be directly aware of which LED
configuration to choose when there may be more than one
possible configuration.

Hide the details of the differences between LEDs used in the
different HW revs for CC.  This will allow generic code to
run on CC and CC3D without being exposed to the details of
the different pins used for the LEDs.
This commit is contained in:
Stacey Sheldon 2012-05-23 00:22:11 -04:00
parent b97aba834a
commit d2615cac96
3 changed files with 19 additions and 20 deletions

View File

@ -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)

View File

@ -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)

View File

@ -27,6 +27,10 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pios_config.h>
#include <pios_board_info.h>
#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)