Add support for LEDs on the Ethernet Starter kit

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4223 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-12-25 14:28:12 +00:00
parent 5561667801
commit db207f194a
4 changed files with 171 additions and 48 deletions

View File

@ -52,7 +52,7 @@ Contents
PICtail
Toolchains
Powering the Board
Loading NuttX with PICkit2
Creating Compatible NuttX HEX files
Serial Console
PIC32MX Configuration Options
Configurations
@ -423,23 +423,46 @@ Toolchains
Powering the Board
==================
"Power can be supplied to the Multimedia Expansion Board through the DC
connector located on the Multimedia Expansion Board... By connecting
9-14V power supply to the DC connector, the Multimedia Expansion Board
and starter kit will receive the proper voltages. The user can also
supply power via the starter kit. However, if the application uses
multiple features of the Multimedia Expansion Board, it is recommended
to use 9-14V power supply."
Ethernet Starter Kit:
Loading NuttX with PICkit2
==========================
There are two ways to supply power to the PIC32 Ethernet Starter Kit:
NOTE: You need a PICKit3 if you plan to use the MPLAB debugger! The PICKit2
can, however, still be used to load programs. Instructions for the PICKit3
are similar.
- USB bus power connected to USB debug connector J1.
- An external application board with a regulated DC power supply that
provides +5V can be connected to the J2 application board connector
that is provided on the bottom side of the board.
Intel Hex Forma Files:
----------------------
One green LED (D3) is provided to show that the PIC32 microcontroller
is powered up.
Ethernet Starter Kit with MEB:
Power can be supplied to the Multimedia Expansion Board through the DC
connector located on the Multimedia Expansion Board... By connecting
9-14V power supply to the DC connector, the Multimedia Expansion Board
and starter kit will receive the proper voltages. The user can also
supply power via the starter kit. However, if the application uses
multiple features of the Multimedia Expansion Board, it is recommended
to use 9-14V power supply."
On Board Debug Support
======================
The PIC32 Ethernet Starter Kit includes a PIC32MX440F512H USB microcontroller
that provides debugger connectivity over USB. The PIC32MX440F512H is hard-wired
to the PIC32 device to provide two types of protocol translation:
- I/O pins of PIC32MX440F512H to the ICSP™ pins of the PIC32
- I/O pins of PIC32MX440F512H to the JTAG pins of the PIC32
The PIC32 Ethernet Starter Kit currently uses the JTAG pins of the PIC32 device for
programming and debugging.
Creating Compatible NuttX HEX files
===================================
Intel Hex Format Files:
-----------------------
When NuttX is built it will produce two files in the top-level NuttX
directory:
@ -448,7 +471,6 @@ Loading NuttX with PICkit2
2) nuttx.ihx - This is an Intel Hex format file. This is controlled by
the setting CONFIG_INTELHEX_BINARY in the .config file.
The PICkit tool wants an Intel Hex format file to burn into FLASH.
However, there are two problems with the generated nutt.ihx:
1) The tool expects Intel Hex format files to be named *.hex. This

View File

@ -84,13 +84,32 @@
#define BOARD_WD_PRESCALER 8 /* Watchdog pre-scaler */
/* LED definitions **********************************************************/
/* The PIC32 starter kit has 3 user LEDs
/* LED Configuration ********************************************************/
/* The PIC32MX Ethernet Starter kit has 3 user LEDs labeled LED1-3 on the
* board graphics (but referred to as LED4-6 in the schematic):
*
* RD0 User LED D4 (high illuminates)
* RD2 User LED D5 (high illuminates)
* RD1 User LED D6 (high illuminates)
* PIN User's Guide Board Stencil Notes
* --- ------------- -------------- -------------------
* RD0 "User LED D4" "LED1 (RD0") High illuminates
* RD2 "User LED D5" "LED3 (RD2)" High illuminates
* RD1 "User LED D6" "LED2 (RD1)" High illuminates
*
* There are 5 LEDs available on the MEB:
* We will use the labels on the board to identify LEDs
*
* ON OFF
* ------------------------- ---- ---- ---- ---- ---- ----
* LED1 LED2 LED3 LED1 LED2 LED3
* ------------------------- ---- ---- ---- ---- ---- ----
* LED_STARTED 0 OFF OFF OFF --- --- ---
* LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
* LED_IRQSENABLED 2 OFF ON N/C --- --- ---
* LED_STACKCREATED 3 ON ON N/C --- --- ---
* LED_INIRQ 4 N/C N/C ON N/C N/C OFF
* LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
* LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
* LED_PANIC 4 N/C N/C ON N/C N/C OFF
*
* There are 5 additional LEDs available on the MEB:
*
* RD1 LED1
* RD2 LED2
@ -104,9 +123,11 @@
#define LED_IRQSENABLED 2
#define LED_STACKCREATED 3
#define LED_INIRQ 4
#define LED_SIGNAL 5
#define LED_ASSERTION 6
#define LED_PANIC 7
#define LED_SIGNAL 4
#define LED_ASSERTION 4
#define LED_PANIC 4
#define LED_NVALUES 5
/* Switch definitions *******************************************************/
/* The PIC32 start kit has 3 switches:

View File

@ -84,7 +84,7 @@ CONFIG_ARCH_IRQPRIO=y
CONFIG_ARCH_INTERRUPTSTACK=n
CONFIG_ARCH_STACKDUMP=y
CONFIG_ARCH_BOOTLOADER=n
CONFIG_ARCH_LEDS=n
CONFIG_ARCH_LEDS=y
CONFIG_ARCH_BUTTONS=n
CONFIG_ARCH_CALIBRATION=n
CONFIG_ARCH_DMA=n

View File

@ -51,6 +51,7 @@
#include "up_internal.h"
#include "pic32mx-internal.h"
#include "pic32mx-ioport.h"
#include "starterkit_internal.h"
#ifdef CONFIG_ARCH_LEDS
@ -58,60 +59,133 @@
/****************************************************************************
* Definitions
****************************************************************************/
/* The PIC32 starter kit has 3 user LEDs
/* LED Configuration ********************************************************/
/* The PIC32MX Ethernet Starter kit has 3 user LEDs labeled LED1-3 on the
* board graphics (but referred to as LED4-6 in the schematic):
*
* RD0 User LED D4 (high illuminates)
* RD2 User LED D5 (high illuminates)
* RD1 User LED D6 (high illuminates)
* PIN User's Guide Board Stencil Notes
* --- ------------- -------------- -------------------
* RD0 "User LED D4" "LED1 (RD0") High illuminates
* RD2 "User LED D5" "LED3 (RD2)" High illuminates
* RD1 "User LED D6" "LED2 (RD1)" High illuminates
*
* There are 5 LEDs available on the MEB:
* We will use the labels on the board to identify LEDs
*
* RD1 LED1
* RD2 LED2
* RD3 LED3
* RC1 LED4
* RC2 LED5
* ON OFF
* ------------------------- ---- ---- ---- ---- ---- ----
* LED1 LED2 LED3 LED1 LED2 LED3
* ------------------------- ---- ---- ---- ---- ---- ----
* LED_STARTED 0 OFF OFF OFF --- --- ---
* LED_HEAPALLOCATE 1 ON OFF N/C --- --- ---
* LED_IRQSENABLED 2 OFF ON N/C --- --- ---
* LED_STACKCREATED 3 ON ON N/C --- --- ---
* LED_INIRQ 4 N/C N/C ON N/C N/C OFF
* LED_SIGNAL 4 N/C N/C ON N/C N/C OFF
* LED_ASSERTION 4 N/C N/C ON N/C N/C OFF
* LED_PANIC 4 N/C N/C ON N/C N/C OFF
*/
/* Enables debug output from this file (needs CONFIG_DEBUG with
* CONFIG_DEBUG_VERBOSE too)
*/
#define GPIO_LED_1 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN0)
#define GPIO_LED_2 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN1)
#define GPIO_LED_3 (GPIO_OUTPUT|GPIO_VALUE_ZERO|GPIO_PORTD|GPIO_PIN2)
#undef LED_DEBUG /* Define to enable debug */
#undef LED_VERBOSE /* Define to enable verbose debug */
/* LED Management Definitions ***********************************************/
#ifdef LED_DEBUG
#define LED_OFF 0
#define LED_ON 1
#define LED_NC 2
/* Debug ********************************************************************/
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_LEDS)
# define leddbg lldbg
# ifdef LED_VERBOSE
# ifdef CONFIG_DEBUG_VERBOSE
# define ledvdbg lldbg
# else
# define ledvdbg(x...)
# endif
#else
# undef LED_VERBOSE
# undef CONFIG_DEBUG_LEDS
# undef CONFIG_DEBUG_VERBOSE
# define leddbg(x...)
# define ledvdbg(x...)
#endif
/****************************************************************************
* Private types
****************************************************************************/
struct led_setting_s
{
uint8_t led1 : 2;
uint8_t led2 : 2;
uint8_t led3 : 2;
uint8_t unused : 2;
};
/****************************************************************************
* Private Data
****************************************************************************/
static const struct led_setting_s g_ledonvalues[LED_NVALUES] =
{
{LED_OFF, LED_OFF, LED_OFF, LED_OFF},
{LED_ON, LED_OFF, LED_NC, LED_OFF},
{LED_OFF, LED_ON, LED_NC, LED_OFF},
{LED_ON, LED_ON, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_ON, LED_OFF},
};
static const struct led_setting_s g_ledoffvalues[LED_NVALUES] =
{
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_NC, LED_OFF},
{LED_NC, LED_NC, LED_OFF, LED_OFF},
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: up_setleds
****************************************************************************/
void up_setleds(FAR const struct led_setting_s *setting)
{
if (setting->led1 != LED_NC)
{
pic32mx_gpiowrite(GPIO_LED_1, setting->led1 == LED_ON);
}
if (setting->led2 != LED_NC)
{
pic32mx_gpiowrite(GPIO_LED_2, setting->led2 == LED_ON);
}
if (setting->led3 != LED_NC)
{
pic32mx_gpiowrite(GPIO_LED_3, setting->led3 == LED_ON);
}
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_ledinit
* Name: pic32mx_ledinit
****************************************************************************/
void up_ledinit(void)
void pic32mx_ledinit(void)
{
#warning "Missing logic"
/* Configure output pins */
pic32mx_configgpio(GPIO_LED_1);
pic32mx_configgpio(GPIO_LED_2);
pic32mx_configgpio(GPIO_LED_3);
}
/****************************************************************************
@ -120,7 +194,10 @@ void up_ledinit(void)
void up_ledon(int led)
{
#warning "Missing logic"
if (led < LED_NVALUES)
{
up_setleds(&g_ledonvalues[led]);
}
}
/****************************************************************************
@ -129,6 +206,9 @@ void up_ledon(int led)
void up_ledoff(int led)
{
#warning "Missing logic"
if (led < LED_NVALUES)
{
up_setleds(&g_ledoffvalues[led]);
}
}
#endif /* CONFIG_ARCH_LEDS */