esp32-wrover-kit/esp32_autoleds.c: Use LEDs to show CPUs activity.
Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>
This commit is contained in:
parent
6262f7e99a
commit
93def58b9d
@ -105,6 +105,10 @@
|
||||
* NuttX controls the LEDs:
|
||||
*/
|
||||
|
||||
/* These values index an array that contains the bit definitions for the
|
||||
* correct LEDs (see esp32_autoleds.c).
|
||||
*/
|
||||
|
||||
#define LED_STARTED 0 /* LED2 */
|
||||
#define LED_HEAPALLOCATE 1 /* LED3 */
|
||||
#define LED_IRQSENABLED 2 /* LED3 + LED2 */
|
||||
@ -114,6 +118,21 @@
|
||||
#define LED_ASSERTION 6 /* LED1 + LED2 + LED3 */
|
||||
#define LED_PANIC 7 /* LED1 + N/C + N/C */
|
||||
|
||||
/* The values below are used only to distinguish between the CPUs.
|
||||
* The LEDs are actually mapped as:
|
||||
* CPU0 -> GPIO_LED1 (Red LED)
|
||||
* CPU1 -> GPIO_LED2 (Green LED)
|
||||
* Note that from the previous list only LED_HEAPALLOCATE will still be
|
||||
* valid. This is to avoid collisions and to keep a way to show a successful
|
||||
* heap allocation. The LED used is still LED3 (Blue LED).
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_LEDS_CPU_ACTIVITY
|
||||
# define LED_CPU0 8
|
||||
# define LED_CPU1 9
|
||||
# define LED_CPU (LED_CPU0 + up_cpu_index())
|
||||
#endif
|
||||
|
||||
/* GPIO pins used by the GPIO Subsystem */
|
||||
|
||||
#define BOARD_NGPIOIN 1 /* Amount of GPIO Input pins */
|
||||
|
@ -42,20 +42,23 @@
|
||||
|
||||
/* The following definitions map the encoded LED setting to GPIO settings */
|
||||
|
||||
#define LED_STARTED_BITS (BOARD_LED2_BIT)
|
||||
#define LED_HEAPALLOCATE_BITS (BOARD_LED3_BIT)
|
||||
#define LED_IRQSENABLED_BITS (BOARD_LED3_BIT | BOARD_LED2_BIT)
|
||||
#define LED_STACKCREATED_BITS (BOARD_LED3_BIT)
|
||||
#define LED_INIRQ_BITS (BOARD_LED1_BIT | BOARD_LED3_BIT)
|
||||
#define LED_SIGNAL_BITS (BOARD_LED2_BIT | BOARD_LED3_BIT)
|
||||
#define LED_ASSERTION_BITS (BOARD_LED1_BIT | BOARD_LED2_BIT |\
|
||||
BOARD_LED3_BIT)
|
||||
#define LED_PANIC_BITS (BOARD_LED1_BIT)
|
||||
#ifndef CONFIG_ARCH_LEDS_CPU_ACTIVITY
|
||||
# define LED_STARTED_BITS (BOARD_LED2_BIT)
|
||||
# define LED_HEAPALLOCATE_BITS (BOARD_LED3_BIT)
|
||||
# define LED_IRQSENABLED_BITS (BOARD_LED3_BIT | BOARD_LED2_BIT)
|
||||
# define LED_STACKCREATED_BITS (BOARD_LED3_BIT)
|
||||
# define LED_INIRQ_BITS (BOARD_LED1_BIT | BOARD_LED3_BIT)
|
||||
# define LED_SIGNAL_BITS (BOARD_LED2_BIT | BOARD_LED3_BIT)
|
||||
# define LED_ASSERTION_BITS (BOARD_LED1_BIT | BOARD_LED2_BIT |\
|
||||
BOARD_LED3_BIT)
|
||||
# define LED_PANIC_BITS (BOARD_LED1_BIT)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS_CPU_ACTIVITY
|
||||
static const unsigned int g_ledbits[8] =
|
||||
{
|
||||
LED_STARTED_BITS,
|
||||
@ -67,6 +70,7 @@ static const unsigned int g_ledbits[8] =
|
||||
LED_ASSERTION_BITS,
|
||||
LED_PANIC_BITS
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -131,8 +135,25 @@ void board_autoled_initialize(void)
|
||||
|
||||
void board_autoled_on(int led)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_LEDS_CPU_ACTIVITY
|
||||
switch (led)
|
||||
{
|
||||
case LED_CPU0:
|
||||
esp32_gpiowrite(GPIO_LED1, true);
|
||||
break;
|
||||
case LED_CPU1:
|
||||
esp32_gpiowrite(GPIO_LED2, true);
|
||||
break;
|
||||
case LED_HEAPALLOCATE:
|
||||
esp32_gpiowrite(GPIO_LED3, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
led_clrbits(BOARD_LED1_BIT | BOARD_LED2_BIT | BOARD_LED3_BIT);
|
||||
led_setbits(g_ledbits[led]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -141,7 +162,24 @@ void board_autoled_on(int led)
|
||||
|
||||
void board_autoled_off(int led)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_LEDS_CPU_ACTIVITY
|
||||
switch (led)
|
||||
{
|
||||
case LED_CPU0:
|
||||
esp32_gpiowrite(GPIO_LED1, false);
|
||||
break;
|
||||
case LED_CPU1:
|
||||
esp32_gpiowrite(GPIO_LED2, false);
|
||||
break;
|
||||
case LED_HEAPALLOCATE:
|
||||
esp32_gpiowrite(GPIO_LED3, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
led_clrbits(g_ledbits[led]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
Loading…
Reference in New Issue
Block a user