Update SAMA5D3x-EK board configuration to support on-board UART connections, LEDs, and push buttons

This commit is contained in:
Gregory Nutt 2013-07-24 12:27:12 -06:00
parent 23fd5e4626
commit dd420047eb
8 changed files with 691 additions and 33 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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.
*/
#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
/* 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)
/* 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

View File

@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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