mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Add an NSH configuration for the Arduino Due; Pluse several fixes related to the Due and to the SAM3X in general
This commit is contained in:
@@ -53,14 +53,17 @@
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
/* There are two user-controllable LEDs on board the Arduino Due board:
|
||||
/* There are three user-controllable LEDs on board the Arduino Due board:
|
||||
*
|
||||
* LED GPIO
|
||||
* ---------------- -----
|
||||
* L Amber LED PB27
|
||||
* TX Yellow LED PA21
|
||||
* RX Yellow LED PC30
|
||||
*
|
||||
* Both are pulled high and can be illuminated by driving the corresponding
|
||||
* LED L is connected to ground and can be illuminated by driving the PB27
|
||||
* output high. The TX and RX LEDs are pulled high and can be illuminated by
|
||||
* driving the corresponding
|
||||
* GPIO output to low.
|
||||
*
|
||||
* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
||||
@@ -68,24 +71,27 @@
|
||||
* include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related
|
||||
* events as follows:
|
||||
*
|
||||
* SYMBOL Meaning LED state
|
||||
* RX TX
|
||||
* ------------------- ----------------------- -------- --------
|
||||
* LED_STARTED NuttX has been started OFF OFF
|
||||
* LED_HEAPALLOCATE Heap has been allocated OFF OFF
|
||||
* LED_IRQSENABLED Interrupts enabled OFF OFF
|
||||
* LED_STACKCREATED Idle stack created ON OFF
|
||||
* 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 OFF Blinking
|
||||
* LED_IDLE MCU is is sleep mode Not used
|
||||
* SYMBOL MEANING LED STATE
|
||||
* L TX RX
|
||||
* ------------------- ----------------------- -------- -------- --------
|
||||
* LED_STARTED NuttX has been started OFF OFF OFF
|
||||
* LED_HEAPALLOCATE Heap has been allocated OFF OFF OFF
|
||||
* LED_IRQSENABLED Interrupts enabled OFF OFF OFF
|
||||
* LED_STACKCREATED Idle stack created ON OFF OFF
|
||||
* LED_INIRQ In an interrupt N/C GLOW OFF
|
||||
* LED_SIGNAL In a signal handler N/C GLOW OFF
|
||||
* LED_ASSERTION An assertion failed N/C GLOW OFF
|
||||
* LED_PANIC The system has crashed N/C N/C Blinking
|
||||
* LED_IDLE MCU is is sleep mode ------ Not used --------
|
||||
*
|
||||
* Thus if RX is statically on, NuttX has successfully booted and is,
|
||||
* apparently, running normmally. If TX is flashing at approximately
|
||||
* 2Hz, then a fatal error has been detected and the system has halted.
|
||||
* Thus if LED L is statically on, NuttX has successfully booted and is,
|
||||
* apparently, running normmally. If LED RX is glowing, then NuttX is
|
||||
* handling interupts (and also signals and assertions). If TX is flashing
|
||||
* at approximately 2Hz, then a fatal error has been detected and the system
|
||||
*/
|
||||
|
||||
#define GPIO_LED_L (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_CLEAR | \
|
||||
GPIO_PORT_PIOB | GPIO_PIN27)
|
||||
#define GPIO_LED_RX (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
|
||||
GPIO_PORT_PIOC | GPIO_PIN30)
|
||||
#define GPIO_LED_TX (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
|
||||
|
||||
@@ -54,14 +54,17 @@
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* There are two user-controllable LEDs on board the Arduino Due board:
|
||||
/* There are three user-controllable LEDs on board the Arduino Due board:
|
||||
*
|
||||
* LED GPIO
|
||||
* ---------------- -----
|
||||
* L Amber LED PB27
|
||||
* TX Yellow LED PA21
|
||||
* RX Yellow LED PC30
|
||||
*
|
||||
* Both are pulled high and can be illuminated by driving the corresponding
|
||||
* LED L is connected to ground and can be illuminated by driving the PB27
|
||||
* output high. The TX and RX LEDs are pulled high and can be illuminated by
|
||||
* driving the corresponding
|
||||
* GPIO output to low.
|
||||
*
|
||||
* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
|
||||
@@ -69,22 +72,23 @@
|
||||
* include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related
|
||||
* events as follows:
|
||||
*
|
||||
* SYMBOL Meaning LED state
|
||||
* RX TX
|
||||
* ------------------- ----------------------- -------- --------
|
||||
* LED_STARTED NuttX has been started OFF OFF
|
||||
* LED_HEAPALLOCATE Heap has been allocated OFF OFF
|
||||
* LED_IRQSENABLED Interrupts enabled OFF OFF
|
||||
* LED_STACKCREATED Idle stack created ON OFF
|
||||
* 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 OFF Blinking
|
||||
* LED_IDLE MCU is is sleep mode Not used
|
||||
* SYMBOL MEANING LED STATE
|
||||
* L TX RX
|
||||
* ------------------- ----------------------- -------- -------- --------
|
||||
* LED_STARTED NuttX has been started OFF OFF OFF
|
||||
* LED_HEAPALLOCATE Heap has been allocated OFF OFF OFF
|
||||
* LED_IRQSENABLED Interrupts enabled OFF OFF OFF
|
||||
* LED_STACKCREATED Idle stack created ON OFF OFF
|
||||
* LED_INIRQ In an interrupt N/C GLOW OFF
|
||||
* LED_SIGNAL In a signal handler N/C GLOW OFF
|
||||
* LED_ASSERTION An assertion failed N/C GLOW OFF
|
||||
* LED_PANIC The system has crashed N/C N/C Blinking
|
||||
* LED_IDLE MCU is is sleep mode ------ Not used --------
|
||||
*
|
||||
* Thus if RX is statically on, NuttX has successfully booted and is,
|
||||
* apparently, running normmally. If TX is flashing at approximately
|
||||
* 2Hz, then a fatal error has been detected and the system has halted.
|
||||
* Thus if LED L is statically on, NuttX has successfully booted and is,
|
||||
* apparently, running normmally. If LED RX is glowing, then NuttX is
|
||||
* handling interupts (and also signals and assertions). If TX is flashing
|
||||
* at approximately 2Hz, then a fatal error has been detected and the system
|
||||
*/
|
||||
|
||||
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
|
||||
@@ -119,6 +123,7 @@ void up_ledinit(void)
|
||||
{
|
||||
/* Configure RX and TX LED GPIOs for output */
|
||||
|
||||
sam_configgpio(GPIO_LED_L);
|
||||
sam_configgpio(GPIO_LED_RX);
|
||||
sam_configgpio(GPIO_LED_TX);
|
||||
}
|
||||
@@ -129,29 +134,47 @@ void up_ledinit(void)
|
||||
|
||||
void up_ledon(int led)
|
||||
{
|
||||
bool rxledon = false;
|
||||
bool txledon = false;
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */
|
||||
break;
|
||||
|
||||
case 1: /* LED_STACKCREATED */
|
||||
rxledon = true;
|
||||
break;
|
||||
/* 0: LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED: L=OFF TX=OFF
|
||||
* RX=OFF
|
||||
*
|
||||
* Since the LEDs were initially all OFF and since this state only
|
||||
* occurs one time, nothing need be done.
|
||||
*/
|
||||
|
||||
default:
|
||||
case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
|
||||
return;
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 3: /* LED_PANIC */
|
||||
txledon = true;
|
||||
/* 1: LED_STACKCREATED: L=ON TX=OFF RX=OFF
|
||||
*
|
||||
* This case will also occur only once. Note that unlike the other
|
||||
* LEDs, LED L is active high.
|
||||
*/
|
||||
|
||||
case 1:
|
||||
sam_gpiowrite(GPIO_LED_L, true);
|
||||
break;
|
||||
|
||||
/* 2: LED_INIRQ, LED_SIGNAL, LED_ASSERTION: L=N/C TX=ON RX=N/C
|
||||
*
|
||||
* This case will occur many times. LED TX is active low.
|
||||
*/
|
||||
|
||||
case 2:
|
||||
sam_gpiowrite(GPIO_LED_TX, false);
|
||||
break;
|
||||
|
||||
/* 3: LED_PANIC: L=N/X TX=N/C RX=ON
|
||||
*
|
||||
* This case will also occur many times. LED RX is active low.
|
||||
*/
|
||||
|
||||
case 3:
|
||||
sam_gpiowrite(GPIO_LED_RX, false);
|
||||
break;
|
||||
}
|
||||
|
||||
sam_gpiowrite(GPIO_LED_RX, rxledon);
|
||||
sam_gpiowrite(GPIO_LED_TX, txledon);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -160,10 +183,37 @@ void up_ledon(int led)
|
||||
|
||||
void up_ledoff(int led)
|
||||
{
|
||||
if (led != 2)
|
||||
switch (led)
|
||||
{
|
||||
sam_gpiowrite(GPIO_LED_RX, false);
|
||||
sam_gpiowrite(GPIO_LED_TX, false);
|
||||
/* 0: LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED: L=OFF TX=OFF
|
||||
* RX=OFF
|
||||
* 1: LED_STACKCREATED: L=ON TX=OFF RX=OFF
|
||||
*
|
||||
* These cases should never happen.
|
||||
*/
|
||||
|
||||
default:
|
||||
case 1:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
/* 2: LED_INIRQ, LED_SIGNAL, LED_ASSERTION: L=N/C TX=OFF RX=N/C
|
||||
*
|
||||
* This case will occur many times. LED TX is active low.
|
||||
*/
|
||||
|
||||
case 2:
|
||||
sam_gpiowrite(GPIO_LED_TX, true);
|
||||
break;
|
||||
|
||||
/* 3: LED_PANIC: L=N/X TX=N/C RX=OFF
|
||||
*
|
||||
* This case will also occur many times. LED RX is active low.
|
||||
*/
|
||||
|
||||
case 3:
|
||||
sam_gpiowrite(GPIO_LED_RX, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ void sam_ledinit(void)
|
||||
{
|
||||
/* Configure LED1-2 GPIOs for output */
|
||||
|
||||
sam_configgpio(GPIO_LED_L);
|
||||
sam_configgpio(GPIO_LED_RX);
|
||||
sam_configgpio(GPIO_LED_TX);
|
||||
}
|
||||
@@ -107,13 +108,19 @@ void sam_setled(int led, bool ledon)
|
||||
{
|
||||
uint32_t ledcfg;
|
||||
|
||||
if (led == BOARD_LED_RX)
|
||||
if (led == BOARD_LED_L)
|
||||
{
|
||||
ledcfg = GPIO_LED_RX;
|
||||
}
|
||||
else if (led == BOARD_LED_RX)
|
||||
{
|
||||
ledcfg = GPIO_LED_RX;
|
||||
ledon = !ledon;
|
||||
}
|
||||
else if (led == BOARD_LED_TX)
|
||||
{
|
||||
ledcfg = GPIO_LED_TX;
|
||||
ledon = !ledon;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -131,6 +138,9 @@ void sam_setleds(uint8_t ledset)
|
||||
{
|
||||
bool ledon;
|
||||
|
||||
ledon = ((ledset & BOARD_LED_L_BIT) != 0);
|
||||
sam_gpiowrite(GPIO_LED_L, ledon);
|
||||
|
||||
ledon = ((ledset & BOARD_LED_RX_BIT) != 0);
|
||||
sam_gpiowrite(GPIO_LED_RX, ledon);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user