Fixes LEDs on the Freedom KL25Z board

This commit is contained in:
Gregory Nutt 2013-05-06 11:07:53 -06:00
parent 09cefd5308
commit 7628d3aa57
6 changed files with 63 additions and 34 deletions

View File

@ -4676,4 +4676,8 @@
kconfig-frontends tools (2013-5-5).
* drivers/lcd/mio283qt2.c: LCD was not being selected in setpower
method (also not being deselected in hwinitialize function)
(2013-5-6).
(2013-5-6).
* arch/arm/src/kl/kl_gpio.c and .h, configs/freedom-kl25z/src/freedom-kl25z.h,
and configs/freedom-kl25z/src/kl_led.c: Fixes LEDs on the Freedom KL25Z
board (2013-5-6).

View File

@ -1,7 +1,7 @@
/****************************************************************************
* arch/arm/src/kl/kl_pin.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -103,7 +103,7 @@ int kl_configgpio(uint32_t cfgset)
* options are applicable.
*/
if (mode == _PIN_MODE_ANALOG)
if (mode == PIN_MODE_ANALOG)
{
/* Set the analog mode with all digital options zeroed */
@ -184,7 +184,7 @@ int kl_configgpio(uint32_t cfgset)
/* Additional configuration for the case of Alternative 1 (GPIO) modes */
if (mode == _PIN_MODE_GPIO)
if (mode == PIN_MODE_GPIO)
{
/* Set the GPIO port direction */
@ -213,6 +213,7 @@ int kl_configgpio(uint32_t cfgset)
return OK;
}
return -EINVAL;
}

View File

@ -62,18 +62,26 @@
/* Bits 25-31: 7 bits are used to encode the basic pin configuration:
*
* oooo mmm- ---- ---- ---- ---- ---- ----
* oooommm:
* | `--- mmm: mode
* | `--- mmm: mode
* `------- oooo: options (may be combined)
*/
#define _PIN_MODE_SHIFT (25) /* Bits 25-27: Pin mode */
#define _PIN_MODE_SHIFT (25) /* Bits 25-27: Pin mode */
#define _PIN_MODE_MASK (7 << _PIN_MODE_SHIFT)
#define _PIN_OPTIONS_SHIFT (28) /* Bits 28-31: Pin mode options */
#define _PIN_OPTIONS_SHIFT (28) /* Bits 28-31: Pin mode options */
#define _PIN_OPTIONS_MASK (15 << _PIN_OPTIONS_SHIFT)
/* Port Modes */
#define PIN_MODE_ANALOG (0) /* 000 Pin Disabled (Analog) */
#define PIN_MODE_GPIO (1) /* 001 Alternative 1 (GPIO) */
#define PIN_MODE_ALT2 (2) /* 010 Alternative 2 */
#define PIN_MODE_ALT3 (3) /* 011 Alternative 3 */
#define PIN_MODE_ALT4 (4) /* 100 Alternative 4 */
#define PIN_MODE_ALT5 (5) /* 101 Alternative 5 */
#define PIN_MODE_ALT6 (6) /* 110 Alternative 6 */
#define PIN_MODE_ALT7 (7) /* 111 Alternative 7 */
#define _PIN_MODE_ANALOG (0 << _PIN_MODE_SHIFT) /* 000 Pin Disabled (Analog) */
#define _PIN_MODE_GPIO (1 << _PIN_MODE_SHIFT) /* 001 Alternative 1 (GPIO) */
#define _PIN_MODE_ALT2 (2 << _PIN_MODE_SHIFT) /* 010 Alternative 2 */
@ -294,7 +302,7 @@
* Public Types
****************************************************************************/
typedef uint16_t gpio_cfgset_t;
typedef uint32_t gpio_cfgset_t;
/****************************************************************************
* Public Data

View File

@ -88,15 +88,15 @@ LEDs
SYMBOL Meaning LED state
Initially all LED is OFF
------------------- ----------------------- --------------------------
LED_STARTED NuttX has been started
LED_HEAPALLOCATE Heap has been allocated
LED_IRQSENABLED Interrupts enabled
LED_STACKCREATED Idle stack created
LED_INIRQ In an interrupt
LED_SIGNAL In a signal handler
LED_ASSERTION An assertion failed
LED_PANIC The system has crashed
LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
LED_HEAPALLOCATE Heap has been allocated (no change)
LED_IRQSENABLED Interrupts enabled (no change)
LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
LED_INIRQ In an interrupt (no change)
LED_SIGNAL In a signal handler (no change)
LED_ASSERTION An assertion failed (no change)
LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
Serial Console
==============

View File

@ -79,9 +79,9 @@
* LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
*/
#define GPIO_LED_R (GPIO_OUTPUT | PIN_PORTB | PIN18)
#define GPIO_LED_G (GPIO_OUTPUT | PIN_PORTB | PIN19)
#define GPIO_LED_B (GPIO_OUTPUT | PIN_PORTD | PIN1)
#define GPIO_LED_R (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTB | PIN18)
#define GPIO_LED_G (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTB | PIN19)
#define GPIO_LED_B (GPIO_OUTPUT | GPIO_OUTPUT_ONE | PIN_PORTD | PIN1)
/* Button definitions ***************************************************************/
/* The Freedom KL25Z has no buttons */

View File

@ -1,6 +1,6 @@
/****************************************************************************
* configs/freedom-kl25z/src/up_autoleds.c
* arch/arm/src/board/up_autoleds.c
* configs/freedom-kl25z/src/kl_led.c
* arch/arm/src/board/kl_led.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -48,15 +48,15 @@
* SYMBOL Meaning LED state
* Initially all LED is OFF
* ------------------- ----------------------- --------------------------
* LED_STARTED NuttX has been started
* LED_HEAPALLOCATE Heap has been allocated
* LED_IRQSENABLED Interrupts enabled
* LED_STACKCREATED Idle stack created
* LED_INIRQ In an interrupt
* LED_SIGNAL In a signal handler
* LED_ASSERTION An assertion failed
* LED_PANIC The system has crashed
* LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
* LED_STARTED NuttX has been started R=OFF G=OFF B=OFF
* LED_HEAPALLOCATE Heap has been allocated (no change)
* LED_IRQSENABLED Interrupts enabled (no change)
* LED_STACKCREATED Idle stack created R=OFF G=OFF B=ON
* LED_INIRQ In an interrupt (no change)
* LED_SIGNAL In a signal handler (no change)
* LED_ASSERTION An assertion failed (no change)
* LED_PANIC The system has crashed R=FLASHING G=OFF B=OFF
* LED_IDLE K25Z1XX is in sleep mode (Optional, not used)
*/
/****************************************************************************
@ -138,7 +138,18 @@ void kl_ledinit(void)
void up_ledon(int led)
{
kl_gpiowrite(GPIO_LED_B, false);
if (led == LED_STACKCREATED)
{
kl_gpiowrite(GPIO_LED_R, true);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, false);
}
else if (led == LED_PANIC)
{
kl_gpiowrite(GPIO_LED_R, false);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, true);
}
}
/****************************************************************************
@ -147,7 +158,12 @@ void up_ledon(int led)
void up_ledoff(int led)
{
kl_gpiowrite(GPIO_LED_B, true);
if (led == LED_PANIC)
{
kl_gpiowrite(GPIO_LED_R, true);
kl_gpiowrite(GPIO_LED_G, true);
kl_gpiowrite(GPIO_LED_B, true);
}
}
#endif /* CONFIG_ARCH_LEDS */