DK-TM4C129X: Add LED support
This commit is contained in:
parent
e0540f2b96
commit
c6471c64ae
@ -322,10 +322,57 @@ NXFLAT Toolchain
|
||||
8. Edit setenv.h, if necessary, so that the PATH variable includes
|
||||
the path to the newly builtNXFLAT binaries.
|
||||
|
||||
LEDs
|
||||
====
|
||||
Buttons and LEDs
|
||||
================
|
||||
|
||||
[To be provided]
|
||||
Buttons
|
||||
-------
|
||||
There are three push buttons on the board.
|
||||
|
||||
--- ------------ -----------------
|
||||
Pin Pin Function Jumper
|
||||
--- ------------ -----------------
|
||||
PP1 Select SW4 J37 pins 1 and 2
|
||||
PN3 Up SW2 J37 pins 3 and 4
|
||||
PE5 Down SW3 J37 pins 5 and 6
|
||||
--- ------------ -----------------
|
||||
|
||||
LEDs
|
||||
----
|
||||
The development board has one tri-color user LED.
|
||||
|
||||
--- ------------ -----------------
|
||||
Pin Pin Function Jumper
|
||||
--- ------------ -----------------
|
||||
PN5 Red LED J36 pins 1 and 2
|
||||
PQ4 Blue LED J36 pins 3 and 4
|
||||
PQ7 Green LED J36 pins 5 and 6
|
||||
--- ------------ -----------------
|
||||
|
||||
If CONFIG_ARCH_LEDS is not defined, this LED is not used by the NuttX
|
||||
logic. APIs are provided to support application control of the LED in
|
||||
that case (in include/board.h and src/tm4c_userleds.c).
|
||||
|
||||
If CONFIG_ARCH_LEDS is defined then the usage of the LEDs by Nuttx is
|
||||
defined in include/board.h and src/tm4c_autoleds.c. The LEDs are used to
|
||||
encode OS-related events as follows:
|
||||
|
||||
SYMBOL Meaning LED state
|
||||
------------------- ----------------------- -------- --------
|
||||
LED_STARTED NuttX has been started Blue
|
||||
LED_HEAPALLOCATE Heap has been allocated (No change)
|
||||
LED_IRQSENABLED Interrupts enabled (No change)
|
||||
LED_STACKCREATED Idle stack created Green
|
||||
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 Blinking OFF/RED
|
||||
LED_IDLE MCU is is sleep mode (Not used)
|
||||
|
||||
Thus if the LED is GREEN then NuttX has successfully booted and is,
|
||||
apparently, running normally. If the LED is flashing OFF/RED at
|
||||
approximately 2Hz, then a fatal error has been detected and the
|
||||
system has halted.
|
||||
|
||||
Serial Console
|
||||
==============
|
||||
|
@ -40,8 +40,12 @@
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Definitions
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Clocking *************************************************************************/
|
||||
@ -112,9 +116,13 @@
|
||||
* will vary in color. But, from the standpoint of the firmware, this appears as
|
||||
* three LEDs:
|
||||
*
|
||||
* BOARD_LED_R -- Connected to PF1
|
||||
* BOARD_LED_G -- Connected to PF3
|
||||
* BOARD_LED_B -- Connected to PF2
|
||||
* --- ------------ -----------------
|
||||
* Pin Pin Function Jumper
|
||||
* --- ------------ -----------------
|
||||
* PN5 Red LED J36 pins 1 and 2
|
||||
* PQ4 Blue LED J36 pins 3 and 4
|
||||
* PQ7 Green LED J36 pins 5 and 6
|
||||
* --- ------------ -----------------
|
||||
*/
|
||||
|
||||
/* LED index values for use with tm4c_setled() */
|
||||
@ -126,44 +134,24 @@
|
||||
|
||||
/* LED bits for use with tm4c_setleds() */
|
||||
|
||||
#define BOARD_LED1_BIT (1 << BOARD_LED1)
|
||||
#define BOARD_LED2_BIT (1 << BOARD_LED2)
|
||||
#define BOARD_LED_R_BIT (1 << BOARD_LED_R)
|
||||
#define BOARD_LED_G_BIT (1 << BOARD_LED_G)
|
||||
#define BOARD_LED_B_BIT (1 << BOARD_LED_B)
|
||||
|
||||
/* If CONFIG_ARCH_LEDS is defined, then automated support for the LaunchPad LEDs
|
||||
/* If CONFIG_ARCH_LEDS is defined, then automated support for the DK-TM4C129X LED
|
||||
* will be included in the build:
|
||||
*
|
||||
* OFF:
|
||||
* - OFF means that the OS is still initializing. Initialization is very fast so
|
||||
* if you see this at all, it probably means that the system is hanging up
|
||||
* somewhere in the initialization phases.
|
||||
*
|
||||
* GREEN or GREEN-ish
|
||||
* - This means that the OS completed initialization.
|
||||
*
|
||||
* Bluish:
|
||||
* - Whenever and interrupt or signal handler is entered, the BLUE LED is
|
||||
* illuminated and extinguished when the interrupt or signal handler exits.
|
||||
* This will add a BLUE-ish tinge to the LED.
|
||||
*
|
||||
* Redish:
|
||||
* - If a recovered assertion occurs, the RED component will be illuminated
|
||||
* briefly while the assertion is handled. You will probably never see this.
|
||||
*
|
||||
* Flashing RED:
|
||||
* - In the event of a fatal crash, the BLUE and GREEN components will be
|
||||
* extinguished and the RED component will FLASH at a 2Hz rate.
|
||||
*/
|
||||
/* RED GREEN BLUE */
|
||||
#define LED_STARTED 0 /* OFF OFF OFF */
|
||||
#define LED_HEAPALLOCATE 0 /* OFF OFF OFF */
|
||||
#define LED_IRQSENABLED 0 /* OFF OFF OFF */
|
||||
#define LED_STACKCREATED 1 /* OFF ON OFF */
|
||||
#define LED_INIRQ 2 /* NC NC ON (momentary) */
|
||||
#define LED_SIGNAL 2 /* NC NC ON (momentary) */
|
||||
#define LED_ASSERTION 3 /* ON NC NC (momentary) */
|
||||
#define LED_PANIC 4 /* ON OFF OFF (flashing 2Hz) */
|
||||
/* RED GREEN BLUE */
|
||||
#define LED_STARTED 0 /* OFF OFF ON */
|
||||
#define LED_HEAPALLOCATE 1 /* NC NC NC */
|
||||
#define LED_IRQSENABLED 1 /* NC NC NC */
|
||||
#define LED_STACKCREATED 2 /* OFF ON OFF */
|
||||
#define LED_INIRQ 1 /* NC NC NC */
|
||||
#define LED_SIGNAL 1 /* NC NC NC */
|
||||
#define LED_ASSERTION 1 /* NC NC NC */
|
||||
#define LED_PANIC 3 /* ON OFF OFF (flashing 2Hz) */
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
/* Button definitions ***************************************************************/
|
||||
/* The TMC4C123G LaunchPad has a two buttons:
|
||||
*
|
||||
* BOARD_SW1 -- Connected to PF4
|
||||
@ -195,7 +183,7 @@
|
||||
*
|
||||
* Description:
|
||||
* All Tiva architectures must provide the following entry point. This entry
|
||||
* point is called early in the intitialization -- after all memory has been
|
||||
* point is called early in the initialization -- after all memory has been
|
||||
* configured and mapped but before any devices have been initialized.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
@ -43,6 +43,8 @@ CSRCS = tm4c_boot.c tm4c_bringup.c tm4c_ssi.c
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += tm4c_autoleds.c
|
||||
else
|
||||
CSRCS += tm4c_userleds.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NSH_ARCHINIT),y)
|
||||
|
@ -63,9 +63,25 @@
|
||||
# define CONFIG_SSI1_DISABLE 1
|
||||
#endif
|
||||
|
||||
/* DK-TM4C129x *********************************************************************/
|
||||
/* LEDS -- To be provided */
|
||||
/* LED definitions ******************************************************************/
|
||||
/* The TMC4C123G LaunchPad has a single RGB LED. There is only one visible LED which
|
||||
* will vary in color. But, from the standpoint of the firmware, this appears as
|
||||
* three LEDs:
|
||||
*
|
||||
* --- ------------ -----------------
|
||||
* Pin Pin Function Jumper
|
||||
* --- ------------ -----------------
|
||||
* PN5 Red LED J36 pins 1 and 2
|
||||
* PQ4 Blue LED J36 pins 3 and 4
|
||||
* PQ7 Green LED J36 pins 5 and 6
|
||||
* --- ------------ -----------------
|
||||
*/
|
||||
|
||||
#define GPIO_LED_R (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTN | GPIO_PIN_5)
|
||||
#define GPIO_LED_G (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTQ | GPIO_PIN_4)
|
||||
#define GPIO_LED_B (GPIO_FUNC_OUTPUT | GPIO_VALUE_ONE | GPIO_PORTQ | GPIO_PIN_7)
|
||||
|
||||
/* Button definitions ***************************************************************/
|
||||
/* Buttons -- To be provided */
|
||||
|
||||
/************************************************************************************
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* configs/dk-tm4c129x/src/tm4c_leds.c
|
||||
* configs/dk-tm4c129x/src/tm4c_autoleds.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@ -39,49 +39,13 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "up_arch.h"
|
||||
#include "up_internal.h"
|
||||
#include "tiva_gpio.h"
|
||||
#include "dk-tm4c129x.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Preprocessor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
|
||||
* with CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DEBUG_LEDS
|
||||
# define leddbg lldbg
|
||||
# define ledvdbg llvdbg
|
||||
#else
|
||||
# define leddbg(x...)
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/* Dump GPIO registers */
|
||||
|
||||
#ifdef CONFIG_DEBUG_LEDS
|
||||
# define led_dumpgpio(m) tiva_dumpgpio(LED_GPIO, m)
|
||||
#else
|
||||
# define led_dumpgpio(m)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -97,10 +61,11 @@
|
||||
#ifdef CONFIG_ARCH_LEDS
|
||||
void tm4c_ledinit(void)
|
||||
{
|
||||
leddbg("Initializing\n");
|
||||
/* Configure LED PIOs for output */
|
||||
|
||||
led_dumpgpio("tm4c_ledinit before tiva_configgpio()");
|
||||
led_dumpgpio("tm4c_ledinit after tiva_configgpio()");
|
||||
tiva_configgpio(GPIO_LED_R);
|
||||
tiva_configgpio(GPIO_LED_G);
|
||||
tiva_configgpio(GPIO_LED_B);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -109,6 +74,47 @@ void tm4c_ledinit(void)
|
||||
|
||||
void board_led_on(int led)
|
||||
{
|
||||
/* --------------- ------- ---- ----- --------------------
|
||||
* STATE VALUE RED GREEN BLUE
|
||||
* --------------- ------- ---- ----- --------------------
|
||||
* LED_STARTED 0 OFF OFF ON
|
||||
* LED_HEAPALLOCATE 1 NC NC NC
|
||||
* LED_IRQSENABLED 1 NC NC NC
|
||||
* LED_STACKCREATED 2 OFF ON OFF
|
||||
* LED_INIRQ 1 NC NC NC
|
||||
* LED_SIGNAL 1 NC NC NC
|
||||
* LED_ASSERTION 1 NC NC NC
|
||||
* LED_PANIC 3 ON OFF OFF (flashing 2Hz)
|
||||
* --------------- ------- ---- ----- --------------------
|
||||
*/
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0: /* R=OFF, G=OFF, B=ON */
|
||||
/* Previous state was all OFF */
|
||||
|
||||
tiva_gpiowrite(GPIO_LED_B, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
case 1: /* No change */
|
||||
break;
|
||||
|
||||
case 2: /* R=OFF, G=ON, B=OFF */
|
||||
/* Previous state was all: R=OFF, G=OFF, B=ON */
|
||||
|
||||
tiva_gpiowrite(GPIO_LED_G, false);
|
||||
tiva_gpiowrite(GPIO_LED_B, true);
|
||||
break;
|
||||
|
||||
case 3: /* R=ON, G=OFF, B=OFF */
|
||||
/* Previous state was all: R=OFF, G=Unknown, B=Unknown */
|
||||
|
||||
tiva_gpiowrite(GPIO_LED_R, false);
|
||||
tiva_gpiowrite(GPIO_LED_G, true);
|
||||
tiva_gpiowrite(GPIO_LED_B, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -117,6 +123,33 @@ void board_led_on(int led)
|
||||
|
||||
void board_led_off(int led)
|
||||
{
|
||||
/* --------------- ------- ---- ----- --------------------
|
||||
* STATE VALUE RED GREEN BLUE
|
||||
* --------------- ------- ---- ----- --------------------
|
||||
* LED_STARTED 0 OFF OFF ON
|
||||
* LED_HEAPALLOCATE 1 NC NC NC
|
||||
* LED_IRQSENABLED 1 NC NC NC
|
||||
* LED_STACKCREATED 2 OFF ON OFF
|
||||
* LED_INIRQ 1 NC NC NC
|
||||
* LED_SIGNAL 1 NC NC NC
|
||||
* LED_ASSERTION 1 NC NC NC
|
||||
* LED_PANIC 3 ON OFF OFF (flashing 2Hz)
|
||||
* --------------- ------- ---- ----- --------------------
|
||||
*/
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0: /* Will not happen */
|
||||
case 1: /* No change */
|
||||
case 2: /* Will not happen */
|
||||
default:
|
||||
break;
|
||||
|
||||
case 3: /* R=OFF, G=OFF, B=OFF */
|
||||
/* Previous state was all: R=ON, G=OFF, B=OFF */
|
||||
|
||||
tiva_gpiowrite(GPIO_LED_R, true);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
142
configs/dk-tm4c129x/src/tm4c_userleds.c
Normal file
142
configs/dk-tm4c129x/src/tm4c_userleds.c
Normal file
@ -0,0 +1,142 @@
|
||||
/****************************************************************************
|
||||
* configs/dk-tm4c129x/src/tm4c_userleds.c
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/* The development board has one tri-color user LED.
|
||||
*
|
||||
* --- ------------ -----------------
|
||||
* Pin Pin Function Jumper
|
||||
* --- ------------ -----------------
|
||||
* PN5 Red LED J36 pins 1 and 2
|
||||
* PQ4 Blue LED J36 pins 3 and 4
|
||||
* PQ7 Green LED J36 pins 5 and 6
|
||||
* --- ------------ -----------------
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#include "tiva_gpio.h"
|
||||
#include "dk-tm4c129x.h"
|
||||
|
||||
#ifndef CONFIG_ARCH_LEDS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
|
||||
* with CONFIG_DEBUG_VERBOSE too)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_DEBUG_LEDS
|
||||
# define leddbg lldbg
|
||||
# define ledvdbg llvdbg
|
||||
#else
|
||||
# define leddbg(x...)
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_ledinit
|
||||
****************************************************************************/
|
||||
|
||||
void tiva_ledinit(void)
|
||||
{
|
||||
/* Configure LED PIOs for output */
|
||||
|
||||
tiva_configgpio(GPIO_LED_R);
|
||||
tiva_configgpio(GPIO_LED_G);
|
||||
tiva_configgpio(GPIO_LED_B);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_setled
|
||||
****************************************************************************/
|
||||
|
||||
void tiva_setled(int led, bool ledon)
|
||||
{
|
||||
uint32_t ledcfg;
|
||||
|
||||
if (led == BOARD_LED_R)
|
||||
{
|
||||
ledcfg = GPIO_LED_R;
|
||||
}
|
||||
else if (led == BOARD_LED_B)
|
||||
{
|
||||
ledcfg = GPIO_LED_B;
|
||||
}
|
||||
else if (led == BOARD_LED_G)
|
||||
{
|
||||
ledcfg = GPIO_LED_G;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tiva_gpiowrite(ledcfg, !ledon);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: tiva_setleds
|
||||
****************************************************************************/
|
||||
|
||||
void tiva_setleds(uint8_t ledset)
|
||||
{
|
||||
bool ledoff;
|
||||
|
||||
ledoff = ((ledset & BOARD_LED_R_BIT) == 0);
|
||||
tiva_gpiowrite(GPIO_LED_R, ledoff);
|
||||
|
||||
ledoff = ((ledset & BOARD_LED_G_BIT) == 0);
|
||||
tiva_gpiowrite(GPIO_LED_G, ledoff);
|
||||
|
||||
ledoff = ((ledset & BOARD_LED_B_BIT) == 0);
|
||||
tiva_gpiowrite(GPIO_LED_B, ledoff);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
@ -83,22 +83,6 @@
|
||||
# define ledvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
Loading…
Reference in New Issue
Block a user