summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-07-24 12:27:12 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-07-24 12:27:12 -0600
commitf321b903f8a03feb5997f39ff865d7e7e60abfad (patch)
tree3b609d75622b1bc19f8a04e86c4e96f212bf122a
parentba377ddfd3168092de8cc00f18eae604479b4e6b (diff)
downloadnuttx-f321b903f8a03feb5997f39ff865d7e7e60abfad.tar.gz
nuttx-f321b903f8a03feb5997f39ff865d7e7e60abfad.tar.bz2
nuttx-f321b903f8a03feb5997f39ff865d7e7e60abfad.zip
Update SAMA5D3x-EK board configuration to support on-board UART connections, LEDs, and push buttons
-rw-r--r--nuttx/ChangeLog11
-rw-r--r--nuttx/arch/arm/src/armv7-a/arm_doirq.c2
-rw-r--r--nuttx/arch/arm/src/sam34/Kconfig26
-rw-r--r--nuttx/configs/sam4s-xplained/src/sam_userleds.c10
-rw-r--r--nuttx/configs/sama5d3x-ek/README.txt169
-rw-r--r--nuttx/configs/sama5d3x-ek/include/board.h76
-rw-r--r--nuttx/configs/sama5d3x-ek/ostest/defconfig31
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_autoleds.c72
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_buttons.c172
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_userleds.c154
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h40
-rw-r--r--nuttx/drivers/serial/Kconfig102
12 files changed, 780 insertions, 85 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index d03fd845d..8e12b13b1 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5159,7 +5159,7 @@
* arch/arm/src/sama5/sam_lowputc.c and sam_serial.c: Add support
for SAMA5 UARTs. Does not even compile as of initial checkin.
(2013-7-22).
- * arch/arm/src/sama5/sam_gpio.c: Add GPIO configuratino support
+ * arch/arm/src/sama5/sam_gpio.c: Add GPIO configuration support
for the SAMA5. Still compilation issues. (2013-7-22).
* arch/arm/src/sama5/chip/sama5d3x_pinmap.h: Add pin multiplexing
definitions for the SAMA5D3 (2013-7-23).
@@ -5187,3 +5187,12 @@
configuration options for SAMA5 external memory regions; add a custom
sam_allocateheap.c to add the various configured memory regions to the
heap (2013-7-24).
+ * configs/sama5d3x-ek/src/sam_buttons.c, sam_userleds.c, and
+ sam_autoleds.c: Add support for the buttons and LEDs on-board the
+ SAMA5D3x-EK (2013-7-24).
+ * configs/sama5d3x-ek/ostest/defconfig: Switch console to USART1
+ (2013-7-4).
+ * arch/arm/src/sam34/Kconfig and drivers/serial/Kconfig: All serial
+ configuration logic for USARTs needs to depend on if the USART is
+ configured as a UART or not. And this is for all CPUS, not just
+ SAM3/4 (2013-7-24).
diff --git a/nuttx/arch/arm/src/armv7-a/arm_doirq.c b/nuttx/arch/arm/src/armv7-a/arm_doirq.c
index 154c52c1d..3cd32518d 100644
--- a/nuttx/arch/arm/src/armv7-a/arm_doirq.c
+++ b/nuttx/arch/arm/src/armv7-a/arm_doirq.c
@@ -113,7 +113,7 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
* interrupt handler.
*/
- regs = current_regs;
+ regs = (uint32_t *)current_regs;
current_regs = NULL;
/* Unmask the last interrupt (global interrupts are still disabled) */
diff --git a/nuttx/arch/arm/src/sam34/Kconfig b/nuttx/arch/arm/src/sam34/Kconfig
index ffa5269e3..14ebc357e 100644
--- a/nuttx/arch/arm/src/sam34/Kconfig
+++ b/nuttx/arch/arm/src/sam34/Kconfig
@@ -754,32 +754,6 @@ config SAM34_EXTSRAM1HEAP
endif # SAM34_EXTSRAM1
endmenu # External Memory Configuration
-comment "AT91SAM3/4 USART Configuration"
-
-config USART0_ISUART
- bool "USART0 is a UART"
- default y
- depends on SAM34_USART0
- select ARCH_HAVE_USART0
-
-config USART1_ISUART
- bool "USART1 is a UART"
- default y
- depends on SAM34_USART1
- select ARCH_HAVE_USART1
-
-config USART2_ISUART
- bool "USART2 is a UART"
- default n
- depends on SAM34_USART2
- select ARCH_HAVE_USART2
-
-config USART3_ISUART
- bool "USART3 is a UART"
- default y
- depends on SAM34_USART3
- select ARCH_HAVE_USART2
-
comment "AT91SAM3/4 GPIO Interrupt Configuration"
config GPIO_IRQ
diff --git a/nuttx/configs/sam4s-xplained/src/sam_userleds.c b/nuttx/configs/sam4s-xplained/src/sam_userleds.c
index 21b0e2486..19225d1b6 100644
--- a/nuttx/configs/sam4s-xplained/src/sam_userleds.c
+++ b/nuttx/configs/sam4s-xplained/src/sam_userleds.c
@@ -93,7 +93,7 @@
void sam_ledinit(void)
{
- /* Configure LED1-2 GPIOs for output */
+ /* Configure D9-2 GPIOs for output */
sam_configgpio(GPIO_D9);
sam_configgpio(GPIO_D10);
@@ -107,11 +107,11 @@ void sam_setled(int led, bool ledon)
{
uint32_t ledcfg;
- if (led == BOARD_LED1)
+ if (led == BOARD_D9)
{
ledcfg = GPIO_D9;
}
- else if (led == BOARD_LED2)
+ else if (led == BOARD_D10)
{
ledcfg = GPIO_D10;
}
@@ -131,10 +131,10 @@ void sam_setleds(uint8_t ledset)
{
bool ledon;
- ledon = ((ledset & BOARD_LED1_BIT) != 0);
+ ledon = ((ledset & BOARD_D9_BIT) != 0);
sam_gpiowrite(GPIO_D9, ledon);
- ledon = ((ledset & BOARD_LED2_BIT) != 0);
+ ledon = ((ledset & BOARD_D10_BIT) != 0);
sam_gpiowrite(GPIO_D10, ledon);
}
diff --git a/nuttx/configs/sama5d3x-ek/README.txt b/nuttx/configs/sama5d3x-ek/README.txt
index d7260e3cb..0d54b83c8 100644
--- a/nuttx/configs/sama5d3x-ek/README.txt
+++ b/nuttx/configs/sama5d3x-ek/README.txt
@@ -3,7 +3,63 @@ README
This README file describes the port of NuttX to the SAMA5D3x-EK
development boards. These boards feature the Atmel SAMA5D3
- microprocessors.
+ microprocessors. Three different SAMA5D3x-EK kits are available
+
+ - SAMA5D31-EK with the ATSAMA5D1 (http://www.atmel.com/devices/sama5d31.aspx)
+ - SAMA5D33-EK with the ATSAMA5D3 (http://www.atmel.com/devices/sama5d31.aspx)
+ - SAMA5D34-EK with the ATSAMA5D4 (http://www.atmel.com/devices/sama5d31.aspx)
+ - SAMA5D35-EK with the ATSAMA5D5 (http://www.atmel.com/devices/sama5d31.aspx)
+
+ The each consist of an identical base board with different plug-in
+ modules for each CPU. An option 7 inch LCD is also available..
+
+ The SAMA5D3FAE-EK bundle includes everything: The base board, all four
+ CPU modules, and the LCD.
+
+ SAMA5D3 Family
+
+ ATSAMA5D31 ATSAMA5D33 ATSAMA5D34 ATSAMA5D35
+ ------------------------- ------------- ------------- ------------- -------------
+ Pin Count 324 324 324 324
+ Max. Operating Frequency 536 536 536 536
+ CPU Cortex-A5 Cortex-A5 Cortex-A5 Cortex-A5
+ Max I/O Pins 160 160 160 160
+ Ext Interrupts 160 160 160 160
+ USB Transceiver 3 3 3 3
+ USB Speed Hi-Speed Hi-Speed Hi-Speed Hi-Speed
+ USB Interface Host, Device Host, Device Host, Device Host, Device
+ SPI 6 6 6 6
+ TWI (I2C) 3 3 3 3
+ UART 7 5 5 7
+ CAN - - 2 2
+ LIN 4 4 4 4
+ SSC 2 2 2 2
+ Ethernet 1 1 1 2
+ SD / eMMC 3 2 3 3
+ Graphic LCD Yes Yes Yes -
+ Camera Interface Yes Yes Yes Yes
+ ADC channels 12 12 12 12
+ ADC Resolution (bits) 12 12 12 12
+ ADC Speed (ksps) 440 440 440 440
+ Resistive Touch Screen Yes Yes Yes Yes
+ Crypto Engine AES/DES/ AES/DES/ AES/DES/ AES/DES/
+ SHA/TRNG SHA/TRNG SHA/TRNG SHA/TRNG
+ SRAM (Kbytes) 128 128 128 128
+ External Bus Interface 1 1 1 1
+ DRAM Memory DDR2/LPDDR, DDR2/LPDDR, DDR2/LPDDR, DDR2/LPDDR,
+ SDRAM/LPSDR SDRAM/LPSDR DDR2/LPDDR, DDR2/LPDDR,
+ NAND Interface Yes Yes Yes Yes
+ Temp. Range (deg C) -40 to 85 -40 to 85 -40 to 85 -40 to 85
+ I/O Supply Class 1.8/3.3 1.8/3.3 1.8/3.3 1.8/3.3
+ Operating Voltage (Vcc) 1.08 to 1.32 1.08 to 1.32 1.08 to 1.32 1.08 to 1.32
+ FPU Yes Yes Yes Yes
+ MPU / MMU No/Yes No/Yes No/Yes No/Yes
+ Timers 5 5 5 6
+ Output Compare channels 6 6 6 6
+ Input Capture Channels 6 6 6 6
+ PWM Channels 4 4 4 4
+ 32kHz RTC Yes Yes Yes Yes
+ Packages LFBGA324_A LFBGA324_A LFBGA324_A LFBGA324_A
Contents
========
@@ -230,16 +286,99 @@ Buttons and LEDs
Buttons
-------
- To be provided
+ There are five push button switches on the SAMA5D3X-EK base board:
+
+ 1. One Reset, board reset (BP1)
+ 2. One Wake up, push button to bring the processor out of low power mode
+ (BP2)
+ 3. One User momentary Push Button
+ 4. One Disable CS Push Button
+
+ Only the momentary push button is controllable by software (labeled
+ "PB_USER1" on the board):
+
+ - PE27. Pressing the switch connect PE27 to grounded. Therefore, PE27
+ must be pulled high internally. When the button is pressed the SAMA5
+ will sense "0" is on PE27.
LEDs
----
- To be provided
+ There are two LEDs on the SAMA5D3 series-CM board that can be controlled
+ by software. A blue LED is controlled via GPIO pins. A red LED normally
+ provides an indication that power is supplied to the board but can also
+ be controlled via software.
+
+ PE25. This blue LED is pulled high and is illuminated by pulling PE25
+ low.
+
+ PE24. The red LED is also pulled high but is driven by a transistor so
+ that it is illuminated when power is applied even if PE24 is not
+ configured as an output. If PE24 is configured as an output, then the
+ LCD is illuminated by a low output.
+
+ These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
+ defined. In that case, the usage by the board port is defined in
+ include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related
+ events as follows:
+
+ SYMBOL Meaning LED state
+ Blue Red
+ ------------------- ----------------------- -------- --------
+ 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
+
+ Thus if the blue LED is statically on, NuttX has successfully booted and
+ is, apparently, running normmally. If the red is flashing at
+ approximately 2Hz, then a fatal error has been detected and the system
+ has halted.
Serial Consoles
===============
- To be provided
+ USART1
+ ------
+ By default USART1 is used as the NuttX serial console in all
+ configurations (unless otherwise noted). USART1 is buffered with an
+ RS-232 Transceiver (Analog Devices ADM3312EARU) and connected to the DB-9
+ male socket (J8).
+
+ USART1 Connector J8
+ -------------------------------
+ SAMA5 FUNCTION NUTTX GPIO
+ PIO NAME CONFIGURATION
+ ---- ---------- ---------------
+ PB27 RTS1 GPIO_USART1_RTS
+ PB29 TXD1 GPIO_USART1_TXD
+ PB28 RXD1 GPIO_USART1_RXD
+ PB26 CTS1 GPIO_USART1_CTS
+
+ NOTE: Debug TX and RX pins also go the the ADM3312EARU, but I am
+ uncertain of the functionality.
+
+ -------------------------------
+ SAMA5 FUNCTION NUTTX GPIO
+ PIO NAME CONFIGURATION
+ ---- ---------- ---------------
+ PB31 DTXD GPIO_DBGU_DTXD
+ PB30 DRXD GPIO_DBGU_DRXD
+
+ Hardware UART via CDC
+ ---------------------
+ "J-Link-OB-ATSAM3U4C comes with an additional hardware UART that is
+ accessible from a host via CDC which allows terminal communication with
+ the target device. This feature is enabled only if a certain port (CDC
+ disabled, PA25, pin 24 on J-Link-OB-ATSAM3U4C) is NOT connected to ground
+ (open).
+
+ - Jumper JP16 not fitted: CDC is enabled
+ - Jumper JP16 fitted : CDC is disabled"
SAMA5D3x-EK Configuration Options
=================================
@@ -471,3 +610,25 @@ Configurations
ostest:
This configuration directory, performs a simple OS test using
examples/ostest.
+
+ NOTES:
+ 1. This configuration uses the default USART1 serial console. That
+ is easily changed by reconfiguring to (1) enable a different
+ serial peripheral, and (2) selecting that serial peripheral as
+ the console device.
+
+ 2. By default, this configuration is set up to build on Windows
+ under either a Cygwin or MSYS environment using a recent, Windows-
+ native, generic ARM EABI GCC toolchain (such as the CodeSourcery
+ toolchain). Both the build environment and the toolchain
+ selection can easily be changed by reconfiguring:
+
+ CONFIG_HOST_WINDOWS=y : Windows operating system
+ CONFIG_WINDOWS_CYGWIN=y : POSIX environment under windows
+ CONFIG_ARMV7A_TOOLCHAIN_CODESOURCERYW=y : CodeSourcery for Windows
+
+ 3. This configuration executes out of internal SRAM an can only
+ be loaded via JTAG.
+
+ CONFIG_SAMA5_BOOT_ISRAM=y : Boot into internal SRAM
+ CONFIG_BOOT_RUNFROMISRAM=y : Run from internal SRAM
diff --git a/nuttx/configs/sama5d3x-ek/include/board.h b/nuttx/configs/sama5d3x-ek/include/board.h
index 7557d5563..82a6025ae 100644
--- a/nuttx/configs/sama5d3x-ek/include/board.h
+++ b/nuttx/configs/sama5d3x-ek/include/board.h
@@ -145,17 +145,77 @@
#define BOARD_FWS 3
/* LED definitions ******************************************************************/
+/* There are two LEDs on the SAMA5D3 series-CM board that can be controlled
+ * by software. A blue LED is controlled via GPIO pins. A red LED normally
+ * provides an indication that power is supplied to the board but can also
+ * be controlled via software.
+ *
+ * PE25. This blue LED is pulled high and is illuminated by pulling PE25
+ * low.
+ *
+ * PE24. The red LED is also pulled high but is driven by a transistor so
+ * that it is illuminated when power is applied even if PE24 is not
+ * configured as an output. If PE24 is configured as an output, then the
+ * LCD is illuminated by a low output.
+ */
+
+/* LED index values for use with sam_setled() */
+
+#define BOARD_BLUE 0
+#define BOARD_RED 1
+#define BOARD_NLEDS 2
+
+/* LED bits for use with sam_setleds() */
+
+#define BOARD_BLUE_BIT (1 << BOARD_BLUE)
+#define BOARD_RED_BIT (1 << BOARD_RED)
+
-#define LED_STARTED 0
-#define LED_HEAPALLOCATE 1
-#define LED_IRQSENABLED 2
-#define LED_STACKCREATED 3
-#define LED_INIRQ 4
-#define LED_SIGNAL 5
-#define LED_ASSERTION 6
-#define LED_PANIC 7
+/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
+ * defined. In that case, the usage by the board port is defined in
+ * include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related
+ * events as follows:
+ *
+ * SYMBOL Val Meaning LED state
+ * Blue Red
+ * ----------------- --- ----------------------- -------- -------- */
+#define LED_STARTED 0 /* NuttX has been started OFF OFF */
+#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF OFF */
+#define LED_IRQSENABLED 0 /* Interrupts enabled OFF OFF */
+#define LED_STACKCREATED 1 /* Idle stack created ON OFF */
+#define LED_INIRQ 2 /* In an interrupt No change */
+#define LED_SIGNAL 2 /* In a signal handler No change */
+#define LED_ASSERTION 2 /* An assertion failed No change */
+#define LED_PANIC 3 /* The system has crashed OFF Blinking */
+#undef LED_IDLE /* MCU is is sleep mode Not used */
+
+/* Thus if the blue LED is statically on, NuttX has successfully booted and
+ * is, apparently, running normmally. If the red is flashing at
+ * approximately 2Hz, then a fatal error has been detected and the system
+ * has halted.
+ */
/* Button definitions ***************************************************************/
+/* There are five push button switches on the SAMA5D3X-EK base board:
+ *
+ * 1. One Reset, board reset (BP1)
+ * 2. One Wake up, push button to bring the processor out of low power mode
+ * (BP2)
+ * 3. One User momentary Push Button
+ * 4. One Disable CS Push Button
+ *
+ * Only the momentary push button is controllable by software (labeled
+ * "PB_USER1" on the board):
+ *
+ * - PE27. Pressing the switch connect PE27 to grounded. Therefore, PE27
+ * must be pulled high internally. When the button is pressed the SAMA5
+ * will sense "0" is on PE27.
+ */
+
+#define BUTTON_USER1 0
+#define NUM_BUTTONS 1
+
+#define BUTTON_USER1_BIT (1 << BUTTON_USER1)
/************************************************************************************
* Public Data
diff --git a/nuttx/configs/sama5d3x-ek/ostest/defconfig b/nuttx/configs/sama5d3x-ek/ostest/defconfig
index f4a6eb9a1..2247c2733 100644
--- a/nuttx/configs/sama5d3x-ek/ostest/defconfig
+++ b/nuttx/configs/sama5d3x-ek/ostest/defconfig
@@ -125,10 +125,10 @@ CONFIG_ARCH_CHIP_ATSAMA5D33=y
# CONFIG_SAMA5_WDT is not set
# CONFIG_SAMA5_HSMC is not set
# CONFIG_SAMA5_SMD is not set
-CONFIG_SAMA5_UART0=y
+# CONFIG_SAMA5_UART0 is not set
# CONFIG_SAMA5_UART1 is not set
# CONFIG_SAMA5_USART0 is not set
-# CONFIG_SAMA5_USART1 is not set
+CONFIG_SAMA5_USART1=y
# CONFIG_SAMA5_USART2 is not set
# CONFIG_SAMA5_USART3 is not set
# CONFIG_SAMA5_TWI0 is not set
@@ -325,22 +325,27 @@ CONFIG_DEV_NULL=y
CONFIG_SERIAL=y
CONFIG_DEV_LOWCONSOLE=y
# CONFIG_16550_UART is not set
-CONFIG_ARCH_HAVE_UART0=y
+CONFIG_ARCH_HAVE_USART1=y
+
+#
+# USART Configuration
+#
+CONFIG_USART1_ISUART=y
CONFIG_MCU_SERIAL=y
-CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_USART1_SERIAL_CONSOLE=y
# CONFIG_NO_SERIAL_CONSOLE is not set
#
-# UART0 Configuration
+# USART1 Configuration
#
-CONFIG_UART0_RXBUFSIZE=128
-CONFIG_UART0_TXBUFSIZE=128
-CONFIG_UART0_BAUD=115200
-CONFIG_UART0_BITS=8
-CONFIG_UART0_PARITY=0
-CONFIG_UART0_2STOP=0
-# CONFIG_UART0_IFLOWCONTROL is not set
-# CONFIG_UART0_OFLOWCONTROL is not set
+CONFIG_USART1_RXBUFSIZE=256
+CONFIG_USART1_TXBUFSIZE=256
+CONFIG_USART1_BAUD=115200
+CONFIG_USART1_BITS=8
+CONFIG_USART1_PARITY=0
+CONFIG_USART1_2STOP=0
+# CONFIG_USART1_IFLOWCONTROL is not set
+# CONFIG_USART1_OFLOWCONTROL is not set
# CONFIG_SERIAL_IFLOWCONTROL is not set
# CONFIG_SERIAL_OFLOWCONTROL is not set
# CONFIG_USBDEV is not set
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c b/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c
index 29048a3bb..1fdc6f6ae 100644
--- a/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c
+++ b/nuttx/configs/sama5d3x-ek/src/sam_autoleds.c
@@ -32,6 +32,42 @@
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
+/* There are two LEDs on the SAMA5D3 series-CM board that can be controlled
+ * by software. A blue LED is controlled via GPIO pins. A red LED normally
+ * provides an indication that power is supplied to the board but can also
+ * be controlled via software.
+ *
+ * PE25. This blue LED is pulled high and is illuminated by pulling PE25
+ * low.
+ *
+ * PE24. The red LED is also pulled high but is driven by a transistor so
+ * that it is illuminated when power is applied even if PE24 is not
+ * configured as an output. If PE24 is configured as an output, then the
+ * LCD is illuminated by a low output.
+ *
+ * These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
+ * defined. In that case, the usage by the board port is defined in
+ * include/board.h and src/sam_leds.c. The LEDs are used to encode OS-related
+ * events as follows:
+ *
+ * SYMBOL Val Meaning LED state
+ * Blue Red
+ * ----------------- --- ----------------------- -------- --------
+ * LED_STARTED 0 NuttX has been started OFF OFF
+ * LED_HEAPALLOCATE 0 Heap has been allocated OFF OFF
+ * LED_IRQSENABLED 0 Interrupts enabled OFF OFF
+ * LED_STACKCREATED 1 Idle stack created ON OFF
+ * LED_INIRQ 2 In an interrupt No change
+ * LED_SIGNAL 2 In a signal handler No change
+ * LED_ASSERTION 2 An assertion failed No change
+ * LED_PANIC 3 The system has crashed OFF Blinking
+ * LED_IDLE N/A MCU is is sleep mode Not used
+ *
+ * Thus if the blue LED is statically on, NuttX has successfully booted and
+ * is, apparently, running normmally. If the red is flashing at
+ * approximately 2Hz, then a fatal error has been detected and the system
+ * has halted.
+ */
/****************************************************************************
* Included Files
@@ -83,7 +119,10 @@
void up_ledinit(void)
{
-# warning Missing logic
+ /* Configure LED GPIOs for output */
+
+ sam_configgpio(GPIO_BLUE);
+ sam_configgpio(GPIO_RED);
}
/****************************************************************************
@@ -92,7 +131,30 @@ void up_ledinit(void)
void up_ledon(int led)
{
-# warning Missing logic
+ bool blueoff = true;
+ bool redoff = true;
+
+ switch (led)
+ {
+ case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */
+ break;
+
+ case 1: /* LED_STACKCREATED */
+ blueoff = false;
+ break;
+
+ default:
+ case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
+ return;
+
+ case 3: /* LED_PANIC */
+ redoff = false;
+ break;
+ }
+
+ sam_gpiowrite(GPIO_BLUE, blueoff);
+ sam_gpiowrite(GPIO_RED, redoff);
+
}
/****************************************************************************
@@ -101,7 +163,11 @@ void up_ledon(int led)
void up_ledoff(int led)
{
-# warning Missing logic
+ if (led != 2)
+ {
+ sam_gpiowrite(GPIO_BLUE, true);
+ sam_gpiowrite(GPIO_RED, true);
+ }
}
#endif /* CONFIG_ARCH_LEDS */
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_buttons.c b/nuttx/configs/sama5d3x-ek/src/sam_buttons.c
new file mode 100644
index 000000000..bce98dbd5
--- /dev/null
+++ b/nuttx/configs/sama5d3x-ek/src/sam_buttons.c
@@ -0,0 +1,172 @@
+/****************************************************************************
+ * configs/sam4l-xplained/src/sam_buttons.c
+ *
+ * Copyright (C) 2013 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.
+ *
+ ****************************************************************************/
+/* There are five push button switches on the SAMA5D3X-EK base board:
+ *
+ * 1. One Reset, board reset (BP1)
+ * 2. One Wake up, push button to bring the processor out of low power mode
+ * (BP2)
+ * 3. One User momentary Push Button
+ * 4. One Disable CS Push Button
+ *
+ * Only the momentary push button is controllable by software (labeled
+ * "PB_USER1" on the board):
+ *
+ * - PE27. Pressing the switch connect PE27 to grounded. Therefore, PE27
+ * must be pulled high internally. When the button is pressed the SAMA5
+ * will sense "0" is on PE27.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+
+#include <nuttx/irq.h>
+
+#include <arch/irq.h>
+#include <arch/board/board.h>
+
+#include "sam_gpio.h"
+#include "sama5d3x-ek.h"
+
+#ifdef CONFIG_ARCH_BUTTONS
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+#if defined(CONFIG_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
+static xcpt_t g_irquser1;
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_buttoninit
+ *
+ * Description:
+ * up_buttoninit() must be called to initialize button resources. After
+ * that, up_buttons() may be called to collect the current state of all
+ * buttons or up_irqbutton() may be called to register button interrupt
+ * handlers.
+ *
+ ****************************************************************************/
+
+void up_buttoninit(void)
+{
+ (void)sam_configgpio(GPIO_USER1);
+}
+
+/************************************************************************************
+ * Name: up_buttons
+ *
+ * Description:
+ * After up_buttoninit() has been called, up_buttons() may be called to collect
+ * the state of all buttons. up_buttons() returns an 8-bit bit set with each bit
+ * associated with a button. See the BUTTON* definitions above for the meaning of
+ * each bit in the returned value.
+ *
+ ************************************************************************************/
+
+uint8_t up_buttons(void)
+{
+ return sam_gpioread(GPIO_USER1) ? 0 : BUTTON_USER1_BIT;
+}
+
+/****************************************************************************
+ * Name: up_irqbutton
+ *
+ * Description:
+ * This function may be called to register an interrupt handler that will
+ * be called when a button is depressed or released. The ID value is one
+ * of the BUTTON* definitions provided above. The previous interrupt
+ * handler address isreturned (so that it may restored, if so desired).
+ *
+ * Configuration Notes:
+ * Configuration CONFIG_AVR32_GPIOIRQ must be selected to enable the
+ * overall GPIO IRQ feature and CONFIG_AVR32_GPIOIRQSETA and/or
+ * CONFIG_AVR32_GPIOIRQSETB must be enabled to select GPIOs to support
+ * interrupts on. For button support, bits 2 and 3 must be set in
+ * CONFIG_AVR32_GPIOIRQSETB (PB2 and PB3).
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_PIOE_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
+xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
+{
+ xcpt_t oldhandler = NULL;
+
+ if (id == BUTTON_USER1)
+ {
+ irqstate_t flags;
+
+ /* Disable interrupts until we are done. This guarantees that the
+ * following operations are atomic.
+ */
+
+ flags = irqsave();
+
+ /* Get the old button interrupt handler and save the new one */
+
+ oldhandler = *g_irquser1;
+ *g_irquser1 = irqhandler;
+
+ /* Configure the interrupt */
+
+ sam_gpioirq(IRQ_USER1);
+ (void)irq_attach(IRQ_USER1, irqhandler);
+ sam_gpioirqenable(IRQ_USER1);
+ }
+
+ /* Return the old button handler (so that it can be restored) */
+
+ return oldhandler;
+}
+#endif
+
+#endif /* CONFIG_ARCH_BUTTONS */
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_userleds.c b/nuttx/configs/sama5d3x-ek/src/sam_userleds.c
new file mode 100644
index 000000000..725f64abe
--- /dev/null
+++ b/nuttx/configs/sama5d3x-ek/src/sam_userleds.c
@@ -0,0 +1,154 @@
+/****************************************************************************
+ * configs/sama5d3x-ek/src/sam_userleds.c
+ *
+ * Copyright (C) 2013 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.
+ *
+ ****************************************************************************/
+/* There are two LEDs on the SAMA5D3 series-CM board that can be controlled
+ * by software. A blue LED is controlled via GPIO pins. A red LED normally
+ * provides an indication that power is supplied to the board but can also
+ * be controlled via software.
+ *
+ * PE25. This blue LED is pulled high and is illuminated by pulling PE25
+ * low.
+ *
+ * PE24. The red LED is also pulled high but is driven by a transistor so
+ * that it is illuminated when power is applied even if PE24 is not
+ * configured as an output. If PE24 is configured as an output, then the
+ * LCD is illuminated by a low output.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <debug.h>
+
+#include <arch/board/board.h>
+
+#include "chip.h"
+#include "sam_gpio.h"
+#include "sama5d3x-ek.h"
+
+#ifndef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * 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
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Protototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sam_ledinit
+ ****************************************************************************/
+
+void sam_ledinit(void)
+{
+ /* Configure LED GPIOs for output */
+
+ sam_configgpio(GPIO_BLUE);
+ sam_configgpio(GPIO_RED);
+}
+
+/****************************************************************************
+ * Name: sam_setled
+ ****************************************************************************/
+
+void sam_setled(int led, bool ledon)
+{
+ uint32_t ledcfg;
+
+ if (led == BOARD_BLUE)
+ {
+ ledcfg = GPIO_BLUE;
+ }
+ else if (led == BOARD_RED)
+ {
+ ledcfg = GPIO_RED;
+ }
+ else
+ {
+ return;
+ }
+
+ sam_gpiowrite(ledcfg, ledon);
+}
+
+/****************************************************************************
+ * Name: sam_setleds
+ ****************************************************************************/
+
+void sam_setleds(uint8_t ledset)
+{
+ bool ledon;
+
+ ledon = ((ledset & BOARD_BLUE_BIT) != 0);
+ sam_gpiowrite(GPIO_BLUE, ledon);
+
+ ledon = ((ledset & BOARD_RED_BIT) != 0);
+ sam_gpiowrite(GPIO_RED, ledon);
+}
+
+#endif /* !CONFIG_ARCH_LEDS */
diff --git a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
index eacc7a873..adcfa0a27 100644
--- a/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
+++ b/nuttx/configs/sama5d3x-ek/src/sama5d3x-ek.h
@@ -53,6 +53,46 @@
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
+/* LEDs *****************************************************************************/
+/* There are two LEDs on the SAMA5D3 series-CM board that can be controlled
+ * by software. A blue LED is controlled via GPIO pins. A red LED normally
+ * provides an indication that power is supplied to the board but can also
+ * be controlled via software.
+ *
+ * PE25. This blue LED is pulled high and is illuminated by pulling PE25
+ * low.
+ *
+ * PE24. The red LED is also pulled high but is driven by a transistor so
+ * that it is illuminated when power is applied even if PE24 is not
+ * configured as an output. If PE24 is configured as an output, then the
+ * LCD is illuminated by a low output.
+ */
+
+#define GPIO_BLUE (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
+ GPIO_PORT_PIOE | GPIO_PIN25)
+#define GPIO_RED (GPIO_OUTPUT | GPIO_CFG_PULLUP | GPIO_OUTPUT_SET | \
+ GPIO_PORT_PIOE | GPIO_PIN24)
+
+/* Buttons **************************************************************************/
+/* There are five push button switches on the SAMA5D3X-EK base board:
+ *
+ * 1. One Reset, board reset (BP1)
+ * 2. One Wake up, push button to bring the processor out of low power mode
+ * (BP2)
+ * 3. One User momentary Push Button
+ * 4. One Disable CS Push Button
+ *
+ * Only the momentary push button is controllable by software (labeled
+ * "PB_USER1" on the board):
+ *
+ * - PE27. Pressing the switch connect PE27 to grounded. Therefore, PE27
+ * must be pulled high internally. When the button is pressed the SAMA5
+ * will sense "0" is on PE27.
+ */
+
+#define GPIO_USER1 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \
+ GPIO_INT_BOTHEDGES | GPIO_PORT_PIOE | GPIO_PIN27)
+#define IRQ_USER1 SAM_IRQ_PE27
/************************************************************************************
* Public Types
diff --git a/nuttx/drivers/serial/Kconfig b/nuttx/drivers/serial/Kconfig
index 8b5868d44..3757cd657 100644
--- a/nuttx/drivers/serial/Kconfig
+++ b/nuttx/drivers/serial/Kconfig
@@ -372,13 +372,64 @@ config ARCH_HAVE_USART7
config ARCH_HAVE_USART8
bool
+#
+# USARTn configuration. Is the USART configured to behave like a UART?
+#
+
+comment "USART Configuration"
+
+config USART0_ISUART
+ bool "USART0 is a UART"
+ default y
+ depends on ARCH_HAVE_USART0
+
+config USART1_ISUART
+ bool "USART1 is a UART"
+ default y
+ depends on ARCH_HAVE_USART1
+
+config USART2_ISUART
+ bool "USART2 is a UART"
+ default y
+ depends on ARCH_HAVE_USART2
+
+config USART3_ISUART
+ bool "USART3 is a UART"
+ default y
+ depends on USART3_ISUART
+
+config USART4_ISUART
+ bool "USART4 is a UART"
+ default y
+ depends on ARCH_HAVE_USART4
+
+config USART5_ISUART
+ bool "USART5 is a UART"
+ default y
+ depends on ARCH_HAVE_USART5
+
+config USART6_ISUART
+ bool "USART6 is a UART"
+ default y
+ depends on ARCH_HAVE_USART6
+
+config USART7_ISUART
+ bool "USART7 is a UART"
+ default y
+ depends on ARCH_HAVE_USART7
+
+config USART8_ISUART
+ bool "USART8 is a UART"
+ default y
+ depends on ARCH_HAVE_USART8
+
config MCU_SERIAL
bool
- default y if ARCH_HAVE_UART || ARCH_HAVE_UART0 || ARCH_HAVE_USART0 || \
- ARCH_HAVE_UART1 || ARCH_HAVE_USART1 || ARCH_HAVE_UART2 || ARCH_HAVE_USART2 || \
- ARCH_HAVE_UART3 || ARCH_HAVE_USART3 || ARCH_HAVE_UART4 || ARCH_HAVE_USART4 || \
- ARCH_HAVE_UART5 || ARCH_HAVE_USART5 || ARCH_HAVE_UART6 || ARCH_HAVE_USART6 || \
- ARCH_HAVE_UART7 || ARCH_HAVE_USART7 || ARCH_HAVE_UART8 || ARCH_HAVE_USART8
+ default y if ARCH_HAVE_UART || ARCH_HAVE_UART0 || USART0_ISUART || \
+ ARCH_HAVE_UART1 || USART1_ISUART || ARCH_HAVE_UART2 || USART2_ISUART || \
+ ARCH_HAVE_UART3 || USART3_ISUART || ARCH_HAVE_UART4 || USART4_ISUART || \
+ ARCH_HAVE_UART5 || USART5_ISUART || ARCH_HAVE_UART6 || USART6_ISUART || \
+ ARCH_HAVE_UART7 || USART7_ISUART || ARCH_HAVE_UART8 || USART8_ISUART
#
# Standard serial driver configuration
@@ -411,9 +462,8 @@ config SERIAL_TIOCSERGSTRUCT
supports the TIOCSERGSTRUCT ioctl, and (2) this option is selected, then
support for the TIOCSERGSTRUCT will be enabled.
-
#
-# U[S]ARTn_XYZ settings for MCU serial drivers
+# Serial console selection
#
choice
@@ -431,7 +481,7 @@ config UART0_SERIAL_CONSOLE
config USART0_SERIAL_CONSOLE
bool "USART0"
- depends on ARCH_HAVE_USART0
+ depends on USART0_ISUART
config UART1_SERIAL_CONSOLE
bool "UART1"
@@ -439,7 +489,7 @@ config UART1_SERIAL_CONSOLE
config USART1_SERIAL_CONSOLE
bool "USART1"
- depends on ARCH_HAVE_USART1
+ depends on USART1_ISUART
config UART2_SERIAL_CONSOLE
bool "UART2"
@@ -447,7 +497,7 @@ config UART2_SERIAL_CONSOLE
config USART2_SERIAL_CONSOLE
bool "USART2"
- depends on ARCH_HAVE_USART2
+ depends on USART2_ISUART
config UART3_SERIAL_CONSOLE
bool "UART3"
@@ -463,7 +513,7 @@ config UART4_SERIAL_CONSOLE
config USART4_SERIAL_CONSOLE
bool "USART4"
- depends on ARCH_HAVE_USART4
+ depends on USART4_ISUART
config UART5_SERIAL_CONSOLE
bool "UART5"
@@ -471,7 +521,7 @@ config UART5_SERIAL_CONSOLE
config USART5_SERIAL_CONSOLE
bool "USART5"
- depends on ARCH_HAVE_USART5
+ depends on USART5_ISUART
config UART6_SERIAL_CONSOLE
bool "UART6"
@@ -479,7 +529,7 @@ config UART6_SERIAL_CONSOLE
config USART6_SERIAL_CONSOLE
bool "USART6"
- depends on ARCH_HAVE_USART6
+ depends on USART6_ISUART
config UART7_SERIAL_CONSOLE
bool "UART7"
@@ -487,7 +537,7 @@ config UART7_SERIAL_CONSOLE
config USART7_SERIAL_CONSOLE
bool "USART7"
- depends on ARCH_HAVE_USART7
+ depends on USART7_ISUART
config UART8_SERIAL_CONSOLE
bool "UART8"
@@ -495,13 +545,17 @@ config UART8_SERIAL_CONSOLE
config USART8_SERIAL_CONSOLE
bool "USART8"
- depends on ARCH_HAVE_USART8
+ depends on USART8_ISUART
config NO_SERIAL_CONSOLE
bool "No serial console"
endchoice
+#
+# U[S]ARTn_XYZ settings for MCU serial drivers
+#
+
menu "UART Configuration"
depends on ARCH_HAVE_UART
@@ -617,7 +671,7 @@ config UART0_OFLOWCONTROL
endmenu
menu "USART0 Configuration"
- depends on ARCH_HAVE_USART0
+ depends on USART0_ISUART
config USART0_RXBUFSIZE
int "Receive buffer size"
@@ -731,7 +785,7 @@ config UART1_OFLOWCONTROL
endmenu
menu "USART1 Configuration"
- depends on ARCH_HAVE_USART1
+ depends on USART1_ISUART
config USART1_RXBUFSIZE
int "Receive buffer size"
@@ -845,7 +899,7 @@ config UART2_OFLOWCONTROL
endmenu
menu "USART2 Configuration"
- depends on ARCH_HAVE_USART2
+ depends on USART2_ISUART
config USART2_RXBUFSIZE
int "Receive buffer size"
@@ -959,7 +1013,7 @@ config UART3_OFLOWCONTROL
endmenu
menu "USART3 Configuration"
- depends on ARCH_HAVE_USART3
+ depends on USART3_ISUART
config USART3_RXBUFSIZE
int "Receive buffer size"
@@ -1073,7 +1127,7 @@ config UART4_OFLOWCONTROL
endmenu
menu "USART4 Configuration"
- depends on ARCH_HAVE_USART4
+ depends on USART4_ISUART
config USART4_RXBUFSIZE
int "Receive buffer size"
@@ -1187,7 +1241,7 @@ config UART5_OFLOWCONTROL
endmenu
menu "USART5 Configuration"
- depends on ARCH_HAVE_USART5
+ depends on USART5_ISUART
config USART5_RXBUFSIZE
int "Receive buffer size"
@@ -1244,7 +1298,7 @@ config USART5_OFLOWCONTROL
endmenu
menu "USART6 Configuration"
- depends on ARCH_HAVE_USART6
+ depends on USART6_ISUART
config USART6_RXBUFSIZE
int "Receive buffer size"
@@ -1358,7 +1412,7 @@ config UART6_OFLOWCONTROL
endmenu
menu "USART7 Configuration"
- depends on ARCH_HAVE_USART7
+ depends on USART7_ISUART
config USART7_RXBUFSIZE
int "Receive buffer size"
@@ -1472,7 +1526,7 @@ config UART7_OFLOWCONTROL
endmenu
menu "USART8 Configuration"
- depends on ARCH_HAVE_USART8
+ depends on USART8_ISUART
config USART8_RXBUFSIZE
int "Receive buffer size"