EFM32: Fix GPIO configuration logic; Add missing board initializatin logic; Fix LED naming
This commit is contained in:
parent
a839463322
commit
f8b2f291b4
@ -54,7 +54,7 @@ LEDs
|
||||
include/board.h and src/efm32_autoleds.c. The LEDs are used to
|
||||
encode OS-related events as follows:
|
||||
|
||||
SYMBOL Meaning LED1* LED2 LED3 LED4
|
||||
SYMBOL Meaning LED0* LED1 LED2 LED3
|
||||
----------------- ----------------------- ------ ----- ----- ------
|
||||
LED_STARTED NuttX has been started ON OFF OFF OFF
|
||||
LED_HEAPALLOCATE Heap has been allocated OFF ON OFF OFF
|
||||
@ -66,12 +66,12 @@ LEDs
|
||||
LED_PANIC The system has crashed N/C N/C N/C ON
|
||||
LED_IDLE STM32 is is sleep mode (Optional, not used)
|
||||
|
||||
* If LED1, LED2, LED3 are statically on, then NuttX probably failed to boot
|
||||
* If LED0, LED1, LED2 are statically on, then NuttX probably failed to boot
|
||||
and these LEDs will give you some indication of where the failure was
|
||||
** The normal state is LED3 ON and LED1 faintly glowing. This faint glow
|
||||
** The normal state is LED2 ON and LED3 faintly glowing. This faint glow
|
||||
is because of timer interrupt that result in the LED being illuminated
|
||||
on a small proportion of the time.
|
||||
*** LED2 may also flicker normally if signals are processed.
|
||||
*** LED1 may also flicker normally if signals are processed.
|
||||
|
||||
SERIAL CONSOLE
|
||||
==============
|
||||
|
@ -172,37 +172,32 @@
|
||||
|
||||
/* LED index values for use with efm32_setled() */
|
||||
|
||||
#define BOARD_LED1 0
|
||||
#define BOARD_LED2 1
|
||||
#define BOARD_LED3 2
|
||||
#define BOARD_LED4 3
|
||||
#define BOARD_LED0 0
|
||||
#define BOARD_LED1 1
|
||||
#define BOARD_LED2 2
|
||||
#define BOARD_LED3 3
|
||||
#define BOARD_NLEDS 4
|
||||
|
||||
#define BOARD_LED_GREEN BOARD_LED1
|
||||
#define BOARD_LED_ORANGE BOARD_LED2
|
||||
#define BOARD_LED_RED BOARD_LED3
|
||||
#define BOARD_LED_BLUE BOARD_LED4
|
||||
|
||||
/* LED bits for use with efm32_setleds() */
|
||||
|
||||
#define BOARD_LED0_BIT (1 << BOARD_LED0)
|
||||
#define BOARD_LED1_BIT (1 << BOARD_LED1)
|
||||
#define BOARD_LED2_BIT (1 << BOARD_LED2)
|
||||
#define BOARD_LED3_BIT (1 << BOARD_LED3)
|
||||
#define BOARD_LED4_BIT (1 << BOARD_LED4)
|
||||
|
||||
/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the 4 LEDs on
|
||||
* board the EFM32 Gecko Starter Kit. The following definitions describe
|
||||
* how NuttX controls the LEDs in this configuration:
|
||||
*/
|
||||
|
||||
#define LED_STARTED 0 /* LED1 */
|
||||
#define LED_HEAPALLOCATE 1 /* LED2 */
|
||||
#define LED_IRQSENABLED 2 /* LED1 + LED2 */
|
||||
#define LED_STACKCREATED 3 /* LED3 */
|
||||
#define LED_INIRQ 4 /* LED1 + LED3 */
|
||||
#define LED_SIGNAL 5 /* LED2 + LED3 */
|
||||
#define LED_ASSERTION 6 /* LED1 + LED2 + LED3 */
|
||||
#define LED_PANIC 7 /* N/C + N/C + N/C + LED4 */
|
||||
#define LED_STARTED 0 /* LED0 */
|
||||
#define LED_HEAPALLOCATE 1 /* LED1 */
|
||||
#define LED_IRQSENABLED 2 /* LED0 + LED1 */
|
||||
#define LED_STACKCREATED 3 /* LED2 */
|
||||
#define LED_INIRQ 4 /* LED0 + LED2 */
|
||||
#define LED_SIGNAL 5 /* LED1 + LED3 */
|
||||
#define LED_ASSERTION 6 /* LED0 + LED2 + LED2 */
|
||||
#define LED_PANIC 7 /* N/C + N/C + N/C + LED3 */
|
||||
|
||||
/* Pin routing **************************************************************/
|
||||
/* UART0:
|
||||
|
@ -78,13 +78,13 @@
|
||||
* value to the LED.
|
||||
*/
|
||||
|
||||
#define GPIO_LED1 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
#define GPIO_LED0 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN0)
|
||||
#define GPIO_LED2 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
#define GPIO_LED1 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN1)
|
||||
#define GPIO_LED3 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
#define GPIO_LED2 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN2)
|
||||
#define GPIO_LED4 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
#define GPIO_LED3 (GPIO_OUTPUT_WIREDOR_PULLDOWN|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN3)
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -72,10 +72,10 @@
|
||||
|
||||
/* The following definitions map the encoded LED setting to GPIO settings */
|
||||
|
||||
#define EFM32F4_LED1 (1 << 0)
|
||||
#define EFM32F4_LED2 (1 << 1)
|
||||
#define EFM32F4_LED3 (1 << 2)
|
||||
#define EFM32F4_LED4 (1 << 3)
|
||||
#define EFM32_LED0 (1 << 0)
|
||||
#define EFM32_LED1 (1 << 1)
|
||||
#define EFM32_LED2 (1 << 2)
|
||||
#define EFM32_LED3 (1 << 3)
|
||||
|
||||
#define ON_SETBITS_SHIFT (0)
|
||||
#define ON_CLRBITS_SHIFT (4)
|
||||
@ -92,45 +92,45 @@
|
||||
#define OFF_SETBITS(v) (SETBITS(OFF_BITS(v))
|
||||
#define OFF_CLRBITS(v) (CLRBITS(OFF_BITS(v))
|
||||
|
||||
#define LED_STARTED_ON_SETBITS ((EFM32F4_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_STARTED_ON_CLRBITS ((EFM32F4_LED2|EFM32F4_LED3|EFM32F4_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STARTED_ON_SETBITS ((EFM32_LED0) << ON_SETBITS_SHIFT)
|
||||
#define LED_STARTED_ON_CLRBITS ((EFM32_LED1|EFM32_LED2|EFM32_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STARTED_OFF_SETBITS (0 << OFF_SETBITS_SHIFT)
|
||||
#define LED_STARTED_OFF_CLRBITS ((EFM32F4_LED1|EFM32F4_LED2|EFM32F4_LED3|EFM32F4_LED4) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_STARTED_OFF_CLRBITS ((EFM32_LED0|EFM32_LED1|EFM32_LED2|EFM32_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_HEAPALLOCATE_ON_SETBITS ((EFM32F4_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_ON_CLRBITS ((EFM32F4_LED1|EFM32F4_LED3|EFM32F4_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_SETBITS ((EFM32F4_LED1) << OFF_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_CLRBITS ((EFM32F4_LED2|EFM32F4_LED3|EFM32F4_LED4) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_ON_SETBITS ((EFM32_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_ON_CLRBITS ((EFM32_LED0|EFM32_LED2|EFM32_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_SETBITS ((EFM32_LED0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_HEAPALLOCATE_OFF_CLRBITS ((EFM32_LED1|EFM32_LED2|EFM32_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_IRQSENABLED_ON_SETBITS ((EFM32F4_LED1|EFM32F4_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_ON_CLRBITS ((EFM32F4_LED3|EFM32F4_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_SETBITS ((EFM32F4_LED2) << OFF_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_CLRBITS ((EFM32F4_LED1|EFM32F4_LED3|EFM32F4_LED4) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_ON_SETBITS ((EFM32_LED0|EFM32_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_ON_CLRBITS ((EFM32_LED2|EFM32_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_SETBITS ((EFM32_LED1) << OFF_SETBITS_SHIFT)
|
||||
#define LED_IRQSENABLED_OFF_CLRBITS ((EFM32_LED0|EFM32_LED2|EFM32_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_STACKCREATED_ON_SETBITS ((EFM32F4_LED3) << ON_SETBITS_SHIFT)
|
||||
#define LED_STACKCREATED_ON_CLRBITS ((EFM32F4_LED1|EFM32F4_LED2|EFM32F4_LED4) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_SETBITS ((EFM32F4_LED1|EFM32F4_LED2) << OFF_SETBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_CLRBITS ((EFM32F4_LED3|EFM32F4_LED4) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_STACKCREATED_ON_SETBITS ((EFM32_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_STACKCREATED_ON_CLRBITS ((EFM32_LED0|EFM32_LED1|EFM32_LED3) << ON_CLRBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_SETBITS ((EFM32_LED0|EFM32_LED1) << OFF_SETBITS_SHIFT)
|
||||
#define LED_STACKCREATED_OFF_CLRBITS ((EFM32_LED2|EFM32_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_INIRQ_ON_SETBITS ((EFM32F4_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_INIRQ_ON_SETBITS ((EFM32_LED0) << ON_SETBITS_SHIFT)
|
||||
#define LED_INIRQ_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_INIRQ_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_INIRQ_OFF_CLRBITS ((EFM32F4_LED1) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_INIRQ_OFF_CLRBITS ((EFM32_LED0) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_SIGNAL_ON_SETBITS ((EFM32F4_LED2) << ON_SETBITS_SHIFT)
|
||||
#define LED_SIGNAL_ON_SETBITS ((EFM32_LED1) << ON_SETBITS_SHIFT)
|
||||
#define LED_SIGNAL_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_SIGNAL_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_SIGNAL_OFF_CLRBITS ((EFM32F4_LED2) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_SIGNAL_OFF_CLRBITS ((EFM32_LED1) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_ASSERTION_ON_SETBITS ((EFM32F4_LED4) << ON_SETBITS_SHIFT)
|
||||
#define LED_ASSERTION_ON_SETBITS ((EFM32_LED3) << ON_SETBITS_SHIFT)
|
||||
#define LED_ASSERTION_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_ASSERTION_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_ASSERTION_OFF_CLRBITS ((EFM32F4_LED4) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_ASSERTION_OFF_CLRBITS ((EFM32_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
#define LED_PANIC_ON_SETBITS ((EFM32F4_LED4) << ON_SETBITS_SHIFT)
|
||||
#define LED_PANIC_ON_SETBITS ((EFM32_LED3) << ON_SETBITS_SHIFT)
|
||||
#define LED_PANIC_ON_CLRBITS ((0) << ON_CLRBITS_SHIFT)
|
||||
#define LED_PANIC_OFF_SETBITS ((0) << OFF_SETBITS_SHIFT)
|
||||
#define LED_PANIC_OFF_CLRBITS ((EFM32F4_LED4) << OFF_CLRBITS_SHIFT)
|
||||
#define LED_PANIC_OFF_CLRBITS ((EFM32_LED3) << OFF_CLRBITS_SHIFT)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@ -169,48 +169,48 @@ static const uint16_t g_ledbits[8] =
|
||||
|
||||
static inline void led_clrbits(unsigned int clrbits)
|
||||
{
|
||||
if ((clrbits & EFM32F4_LED1) != 0)
|
||||
if ((clrbits & EFM32_LED0) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED0, false);
|
||||
}
|
||||
|
||||
if ((clrbits & EFM32_LED1) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED1, false);
|
||||
}
|
||||
|
||||
if ((clrbits & EFM32F4_LED2) != 0)
|
||||
if ((clrbits & EFM32_LED2) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED2, false);
|
||||
}
|
||||
|
||||
if ((clrbits & EFM32F4_LED3) != 0)
|
||||
if ((clrbits & EFM32_LED3) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED3, false);
|
||||
}
|
||||
|
||||
if ((clrbits & EFM32F4_LED4) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED4, false);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void led_setbits(unsigned int setbits)
|
||||
{
|
||||
if ((setbits & EFM32F4_LED1) != 0)
|
||||
if ((setbits & EFM32_LED0) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED0, true);
|
||||
}
|
||||
|
||||
if ((setbits & EFM32_LED1) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED1, true);
|
||||
}
|
||||
|
||||
if ((setbits & EFM32F4_LED2) != 0)
|
||||
if ((setbits & EFM32_LED2) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED2, true);
|
||||
}
|
||||
|
||||
if ((setbits & EFM32F4_LED3) != 0)
|
||||
if ((setbits & EFM32_LED3) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED3, true);
|
||||
}
|
||||
|
||||
if ((setbits & EFM32F4_LED4) != 0)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED4, true);
|
||||
}
|
||||
}
|
||||
|
||||
static void led_setonoff(unsigned int bits)
|
||||
@ -229,12 +229,12 @@ static void led_setonoff(unsigned int bits)
|
||||
|
||||
void board_led_initialize(void)
|
||||
{
|
||||
/* Configure LED1-4 GPIOs for output */
|
||||
/* Configure LED0-4 GPIOs for output */
|
||||
|
||||
efm32_configgpio(GPIO_LED0);
|
||||
efm32_configgpio(GPIO_LED1);
|
||||
efm32_configgpio(GPIO_LED2);
|
||||
efm32_configgpio(GPIO_LED3);
|
||||
efm32_configgpio(GPIO_LED4);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -78,7 +78,7 @@
|
||||
|
||||
static gpio_pinset_t g_ledcfg[BOARD_NLEDS] =
|
||||
{
|
||||
GPIO_LED1, GPIO_LED2, GPIO_LED3, GPIO_LED4
|
||||
GPIO_LED0, GPIO_LED1, GPIO_LED2, GPIO_LED3
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -193,12 +193,12 @@ static int led_pm_prepare(struct pm_callback_s *cb , enum pm_state_e pmstate)
|
||||
|
||||
void efm32_ledinit(void)
|
||||
{
|
||||
/* Configure LED1-4 GPIOs for output */
|
||||
/* Configure LED0-4 GPIOs for output */
|
||||
|
||||
efm32_configgpio(GPIO_LED0);
|
||||
efm32_configgpio(GPIO_LED1);
|
||||
efm32_configgpio(GPIO_LED2);
|
||||
efm32_configgpio(GPIO_LED3);
|
||||
efm32_configgpio(GPIO_LED4);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -219,10 +219,10 @@ void efm32_setled(int led, bool ledon)
|
||||
|
||||
void efm32_setleds(uint8_t ledset)
|
||||
{
|
||||
efm32_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0);
|
||||
efm32_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0);
|
||||
efm32_gpiowrite(GPIO_LED3, (ledset & BOARD_LED3_BIT) == 0);
|
||||
efm32_gpiowrite(GPIO_LED4, (ledset & BOARD_LED4_BIT) == 0);
|
||||
efm32_gpiowrite(GPIO_LED0, (ledset & BOARD_LED0_BIT) != 0);
|
||||
efm32_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) != 0);
|
||||
efm32_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) != 0);
|
||||
efm32_gpiowrite(GPIO_LED3, (ledset & BOARD_LED3_BIT) != 0);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user