SAMV71-XULT: Add support for on-board LEDs. Includes partial support for on-board buttons. Some corrections fo to egg-stk37000 and sam4e-ek discovered during leveraging. Add board READEM.txt file

This commit is contained in:
Gregory Nutt 2015-03-09 08:23:09 -06:00
parent fb4324e6c5
commit 40f92938e3
10 changed files with 828 additions and 28 deletions

View File

@ -103,10 +103,10 @@
****************************************************************************/
/****************************************************************************
* Name: sam_ledinit
* Name: efm32_ledinit
****************************************************************************/
void sam_ledinit(void)
void efm32_ledinit(void)
{
/* Configure LED PIOs for output */
@ -115,10 +115,10 @@ void sam_ledinit(void)
}
/****************************************************************************
* Name: sam_setled
* Name: efm32_setled
****************************************************************************/
void sam_setled(int led, bool ledon)
void efm32_setled(int led, bool ledon)
{
uint32_t ledcfg;
@ -139,10 +139,10 @@ void sam_setled(int led, bool ledon)
}
/****************************************************************************
* Name: sam_setleds
* Name: efm32_setleds
****************************************************************************/
void sam_setleds(uint8_t ledset)
void efm32_setleds(uint8_t ledset)
{
/* Hight illuminates */

View File

@ -291,10 +291,6 @@
#define IRQ_SCROLLDWN SAM_IRQ_PA2
#define IRQ_WAKU SAM_IRQ_PA19
#define IRQ_TAMP SAM_IRQ_PA20
#define IRQ_SCROLLUP SAM_IRQ_PA1
#define IRQ_SCROLLDWN SAM_IRQ_PA2
#define IRQ_WAKU SAM_IRQ_PA19
#define IRQ_TAMP SAM_IRQ_PA20
/* USART1: To avoid any electrical conflict, the RS232 and RS485 transceiver
* are isolated from the receiving line PA21.

View File

@ -206,7 +206,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
irqhandler, &g_irq_waku);
case BUTTON_TAMP:
return board_button_irqx(GPIO_TAMP, IRQ_WAKU,
return board_button_irqx(GPIO_TAMP, IRQ_TAMP,
irqhandler, &g_irq_tamp);
default:

View File

@ -0,0 +1,174 @@
README
======
This README file discusses the port of NuttX to the Atmel SAM V71 Xplained
Ultra Evaluation Kit (SAMV71-XULT). This board features the ATSAMV71Q21 Cortex-M7
microcontroller.
Contents
========
- Board Features
- Serial Console
- LEDs and Buttons
- Configurations
Board Features
==============
- ATSAMV71Q21 microcontroller: Cortex-M7, 300MHz, 2MiB FLASH, 384KiB SRAM,
I/D-caches
- One mechanical reset button
- One power switch button
- Two mechanical user pushbuttons
- Two yellow user LEDs
- Supercap backup
- 12.0 MHz crystal
- 32.768 kHz crystal
- 2 MB SDRAM
- 2 MB QSPI Flash
- IEEE 802.3az 10Base-T/100Base-TX Ethernet RMII PHY
- AT24MAC402 256KByte EEPROM with EUI-48 address
- WM8904 stereo audio codec
- ATA6561 CAN Transceiver
- SD Card connector with SDIO support
- Camera interface connector
- MediaLB connector
- Two Xplained Pro extension headers
- One Xplained Pro LCD header
- Coresight 20 connector for 4-bit ETM
- Arduino due compatible shield connectors
- External debugger connector
- USB interface, device and host mode
- Embedded Debugger with Data Gateway Interface and Virtual COM port (CDC)
- External power input (5-14V) or USB powered
See the Atmel webite for further information about this board:
- http://www.atmel.com/tools/atsamv71-xult.aspx
Serial Console
==============
The SAMV71-XULT has no on-board RS-232 drivers so it will be necessary to
use either the VCOM or an external RS-232 driver. Here are some options.
- Arduino Serial Shield: One option is to use an Arduino-compatible
serial shield. This will use the RXD and TXD signals available at pins
0 an 1, respectively, of the Arduino "Digital Low" connector. On the
SAMV71-XULT board, this corresponds to UART3:
------ ------ ------- ------- --------
Pin on SAMV71 Arduino Arduino SAMV71
J503 PIO Name Pin Function
------ ------ ------- ------- --------
1 PD28 RX0 0 URXD3
2 PD30 TX0 1 UTXD3
------ ------ ------- ------- --------
- SAMV7-XULT EXTn connectors. USART pins are also available the EXTn
connectors. The following are labelled in the User Guide for USART
functionality:
---- -------- ------ --------
EXT1 EXTI1 SAMV71 SAMV71
Pin Name PIO Function
---- -------- ------ --------
13 USART_RX PB00 RXD0
14 USART_TX PB01 TXD0
---- -------- ------ --------
EXT2 EXTI2 SAMV71 SAMV71
Pin Name PIO Function
---- -------- ------ --------
13 USART_RX PA21 RXD1
14 USART_TX PB04 TXD1
- VCOM. The Virtual Com Port gateway is available on USART1:
------ --------
SAMV71 SAMV71
PIO Function
------ --------
PB04 TXD1
PA21 RXD1
------ --------
Any of these options can be selected as the serial console by:
1. Enabling the UART/USART peripheral in the
"System Type -> Peripheral Selection" menu, then
2. Configuring the peripheral in the "Drivers -> Serial Configuration"
menu.
LEDs and Buttons
================
LEDs
----
There are two yellow LED available on the SAM V71 Xplained Ultra board that
can be turned on and off. The LEDs can be activated by driving the
connected I/O line to GND.
------ ----------- ---------------------
SAMV71 Function Shared functionality
PIO
------ ----------- ---------------------
PA23 Yellow LED0 EDBG GPIO
PC09 Yellow LED1 LCD, and Shield
------ ----------- ---------------------
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_autoleds.c. The LEDs are used to encode
OS-related events as follows:
------------------- ----------------------- -------- --------
SYMBOL Meaning LED state
LED0 LED1
------------------- ----------------------- -------- --------
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 N/C Blinking
LED_IDLE MCU is is sleep mode Not used
------------------- ----------------------- -------- --------
Thus if LED0 is statically on, NuttX has successfully booted and is,
apparently, running normally. If LED1 is flashing at approximately
2Hz, then a fatal error has been detected and the system has halted.
NOTE: That LED0 is not used after completion of booting and may
be used by other board-specific logic.
Buttons
-------
SAM V71 Xplained Ultra contains three mechanical buttons. One button is the
RESET button connected to the SAM V71 reset line and the others are generic
user configurable buttons. When a button is pressed it will drive the I/O
line to GND.
------ ----------- ---------------------
SAMV71 Function Shared functionality
PIO
------ ----------- ---------------------
RESET RESET Trace, Shield, and EDBG
PA09 SW0 EDBG GPIO and Camera
PB12 SW1 EDBG SWD and Chip Erase
------ ----------- ---------------------
NOTES:
- There are no pull-up resistors connected to the generic user buttons so
it is necessary to enable the internal pull-up in the SAM V71 to use the
button.
- PB12 is set up as a system flash ERASE pin when the firmware boots. To
use the SW1, PB12 has to be configured as a normal regular I/O pin in
the MATRIX module. For more information see the SAM V71 datasheet.
Configurations
==============

View File

@ -169,8 +169,153 @@
#define BOARD_FWS 4
/* LED definitions ******************************************************************/
/* LEDs
*
* There are two yellow LED available on the SAM V71 Xplained Ultra board that
* can be turned on and off. The LEDs can be activated by driving the
* connected I/O line to GND.
*
* ------ ----------- ---------------------
* SAMV71 Function Shared functionality
* PIO
* ------ ----------- ---------------------
* PA23 Yellow LED0 EDBG GPIO
* PC09 Yellow LED1 LCD, and Shield
* ------ ----------- ---------------------
*
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in any
* way. The following definitions are used to access individual LEDs.
*/
/* LED index values for use with lpc31_setled() */
#define BOARD_LED0 0
#define BOARD_LED1 1
#define BOARD_NLEDS 2
/* LED bits for use with lpc31_setleds() */
#define BOARD_LED0_BIT (1 << BOARD_LED0)
#define BOARD_LED1_BIT (1 << BOARD_LED1)
/* 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_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* SYMBOL Meaning LED state
* LED2 LED1
* ------------------------ -------------------------- ------ ------ */
#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 N/C Blinking */
#undef LED_IDLE /* MCU is is sleep mode Not used */
/* Thus if LED0 is statically on, NuttX has successfully booted and is,
* apparently, running normally. If LED1 is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*
* NOTE: That LED0 is not used after completion of booting and may
* be used by other board-specific logic.
*/
/* Button definitions ***************************************************************/
/* Buttons
*
* SAM V71 Xplained Ultra contains three mechanical buttons. One button is the
* RESET button connected to the SAM V71 reset line and the others are generic
* user configurable buttons. When a button is pressed it will drive the I/O
* line to GND.
*
* ------ ----------- ---------------------
* SAMV71 Function Shared functionality
* PIO
* ------ ----------- ---------------------
* RESET RESET Trace, Shield, and EDBG
* PA09 SW0 EDBG GPIO and Camera
* PB12 SW1 EDBG SWD and Chip Erase
* ------ ----------- ---------------------
*
* NOTES:
*
* - There are no pull-up resistors connected to the generic user buttons so
* it is necessary to enable the internal pull-up in the SAM V71 to use the
* button.
* - PB12 is set up as a system flash ERASE pin when the firmware boots. To
* use the SW1, PB12 has to be configured as a normal regular I/O pin in
* the MATRIX module. For more information see the SAM V71 datasheet.
*/
#define BUTTON_SW0 0
#define BUTTON_SW1 1
#define NUM_BUTTONS 2
#define BUTTON_SW0_BIT (1 << BUTTON_SW0)
#define BUTTON_SW1_BIT (1 << BUTTON_SW1)
/* PIO Disambiguation ***************************************************************/
/* Serial Console
*
* The SAMV71-XULT has no on-board RS-232 drivers so it will be necessary to use
* either the VCOM or an external RS-232 driver. Here are some options.
*
* - Arduino Serial Shield: One option is to use an Arduino-compatible
* serial shield. This will use the RXD and TXD signals available at pins
* 0 an 1, respectively, of the Arduino "Digital Low" connector. On the
* SAMV71-XULT board, this corresponds to UART3:
*
* ------ ------ ------- ------- --------
* Pin on SAMV71 Arduino Arduino SAMV71
* J503 PIO Name Pin Function
* ------ ------ ------- ------- --------
* 1 PD28 RX0 0 URXD3
* 2 PD30 TX0 1 UTXD3
* ------ ------ ------- ------- --------
*
* There are alternative pin selections only for UTXD3:
*/
#define GPIO_UART3_TXD GPIO_UART3_TXD_1
/* - SAMV7-XULT EXTn connectors. USART pins are also available the EXTn
* connectors. The following are labelled in the User Guide for USART
* functionality:
*
* ---- -------- ------ --------
* EXT1 EXTI1 SAMV71 SAMV71
* Pin Name PIO Function
* ---- -------- ------ --------
* 13 USART_RX PB00 RXD0
* 14 USART_TX PB01 TXD0
*
* ---- -------- ------ --------
* EXT2 EXTI2 SAMV71 SAMV71
* Pin Name PIO Function
* ---- -------- ------ --------
* 13 USART_RX PA21 RXD1
* 14 USART_TX PB04 TXD1
*
* There are no alternative pin selections for USART0 or USART1.
*/
/* - VCOM. The Virtual Com Port gateway is available on USART1:
*
* ------ --------
* SAMV71 SAMV71
* PIO Function
* ------ --------
* PB04 TXD1
* PA21 RXD1
* ------ --------
*
* There are no alternative pin selections for USART1.
*/
/************************************************************************************
* Public Types
@ -200,7 +345,7 @@ extern "C"
*
* Description:
* If CONFIG_ARCH_LEDS is defined, then NuttX will control the on-board LEDs. If
* CONFIG_ARCH_LEDS is not defined, then the following interfacesare available to
* CONFIG_ARCH_LEDS is not defined, then the following interfaces are available to
* control the LEDs from user applications.
*
************************************************************************************/

View File

@ -148,6 +148,7 @@ CONFIG_SAMV7_HAVE_EBI=y
CONFIG_SAMV7_HAVE_HSMCI=y
# CONFIG_SAMV7_HAVE_ISI8 is not set
CONFIG_SAMV7_HAVE_SDRAMC=y
# CONFIG_SAMV7_HAVE_SPI is not set
CONFIG_SAMV7_HAVE_SPI0=y
CONFIG_SAMV7_HAVE_SPI1=y
# CONFIG_SAMV7_QSPI_IS_SPI is not set
@ -282,7 +283,7 @@ CONFIG_ARCH_BOARD="samv71-xult"
# Common Board Options
#
CONFIG_ARCH_HAVE_LEDS=y
# CONFIG_ARCH_LEDS is not set
CONFIG_ARCH_LEDS=y
CONFIG_ARCH_HAVE_BUTTONS=y
# CONFIG_ARCH_BUTTONS is not set
CONFIG_ARCH_HAVE_IRQBUTTONS=y
@ -735,7 +736,6 @@ CONFIG_EXAMPLES_NSH=y
# CONFIG_NETUTILS_CODECS is not set
# CONFIG_NETUTILS_FTPC is not set
# CONFIG_NETUTILS_JSON is not set
# CONFIG_NETUTILS_DNSCLIENT_IPv4 is not set
# CONFIG_NETUTILS_SMTP is not set
CONFIG_NETUTILS_TFTPC=y
# CONFIG_NETUTILS_THTTPD is not set
@ -835,8 +835,6 @@ CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_CONSOLE=y
# CONFIG_NSH_ALTCONDEV is not set
# CONFIG_NSH_ARCHINIT is not set
# CONFIG_NSH_SWMAC is not set
# CONFIG_NSH_ARCHMAC is not set
#
# NxWidgets/NxWM

View File

@ -0,0 +1,180 @@
/****************************************************************************
* configs/samv71-xult/include/sam_autoleds.c
*
* Copyright (C) 2015 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.
*
****************************************************************************/
/* LEDs
*
* There are two yellow LED available on the SAM V71 Xplained Ultra board that
* can be turned on and off. The LEDs can be activated by driving the
* connected I/O line to GND.
*
* ------ ----------- ---------------------
* SAMV71 Function Shared functionality
* PIO
* ------ ----------- ---------------------
* PA23 Yellow LED0 EDBG GPIO
* PC09 Yellow LED1 LCD, and Shield
* ------ ----------- ---------------------
*
* 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_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* ------------------- ----------------------- -------- --------
* SYMBOL Meaning LED state
* LED0 LED1
* ------------------- ----------------------- -------- --------
* 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 N/C Blinking
* LED_IDLE MCU is is sleep mode Not used
* ------------------- ----------------------- -------- --------
*
* Thus if LED0 is statically on, NuttX has successfully booted and is,
* apparently, running normally. If LED1 is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*
* NOTE: That LED0 is not used after completion of booting and may
* be used by other board-specific logic.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "samv71-xult.h"
#ifdef 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
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_led_initialize
****************************************************************************/
void board_led_initialize(void)
{
/* Configure LED PIOs for output */
sam_configgpio(GPIO_LED0);
sam_configgpio(GPIO_LED1);
}
/****************************************************************************
* Name: board_led_on
****************************************************************************/
void board_led_on(int led)
{
bool led0on = false; /* High illuminates */
bool led1on = false; /* High illuminates */
switch (led)
{
case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */
break;
case 1: /* LED_STACKCREATED */
led0on = true;
break;
default:
case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
return;
case 3: /* LED_PANIC */
led1on = true;
break;
}
sam_gpiowrite(GPIO_LED0, led0on);
sam_gpiowrite(GPIO_LED1, led1on);
}
/****************************************************************************
* Name: board_led_off
****************************************************************************/
void board_led_off(int led)
{
if (led != 2)
{
sam_gpiowrite(GPIO_LED0, false); /* High illuminates */
sam_gpiowrite(GPIO_LED1, false); /* High illuminates */
}
}
#endif /* CONFIG_ARCH_LEDS */

View File

@ -0,0 +1,207 @@
/****************************************************************************
* configs/sam4e-ek/src/sam_buttons.c
*
* Copyright (C) 2014-2015 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/irq.h>
#include <arch/irq.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "samv7i-xult.h"
#ifdef CONFIG_ARCH_BUTTONS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
static xcpt_t g_irq_sw0;
static xcpt_t g_irq_sw1;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_irqx
*
* Description:
* This function implements the core of the board_button_irq() logic.
*
****************************************************************************/
#if defined(CONFIG_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
xcpt_t irqhandler, xcpt_t *store)
{
xcpt_t oldhandler;
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 = *store;
*store = irqhandler;
/* Are we attaching or detaching? */
if (irqhandler != NULL)
{
/* Configure the interrupt */
sam_gpioirq(pinset);
(void)irq_attach(irq, irqhandler);
sam_gpioirqenable(irq);
}
else
{
/* Detach and disable the interrupt */
(void)irq_detach(irq);
sam_gpioirqdisable(irq);
}
irqrestore(flags);
/* Return the old button handler (so that it can be restored) */
return oldhandler;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_button_initialize
*
* Description:
* board_button_initialize() must be called to initialize button resources.
* After that, board_buttons() may be called to collect the current state
* of all buttons or board_button_irq() may be called to register button
* interrupt handlers.
*
****************************************************************************/
void board_button_initialize(void)
{
#warning Missing logic
* - PB12 is set up as a system flash ERASE pin when the firmware boots. To
* use the SW1, PB12 has to be configured as a normal regular I/O pin in
* the MATRIX module. For more information see the SAM V71 datasheet.
(void)sam_configgpio(GPIO_SW0);
(void)sam_configgpio(GPIO_SW1);
}
/****************************************************************************
* Name: board_buttons
*
* Description:
* After board_button_initialize() has been called, board_buttons() may be
* called to collect the state of all buttons. board_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 board_buttons(void)
{
uint8_t retval;
retval = sam_gpioread(GPIO_SW0) ? 0 : BUTTON_SW0_BIT;
retval |= sam_gpioread(GPIO_SW1) ? 0 : BUTTON_SW1_BIT;
return retval;
}
/****************************************************************************
* Name: board_button_irq
*
* 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 is returned (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_SAM34_GPIOA_IRQ) && defined(CONFIG_ARCH_IRQBUTTONS)
xcpt_t board_button_irq(int id, xcpt_t irqhandler)
{
switch (id)
{
case BUTTON_SW0:
return board_button_irqx(GPIO_SW0, IRQ_SW0, irqhandler, &g_irq_sw0);
case BUTTON_SW1:
return board_button_irqx(GPIO_SW1, IRQ_SW1, irqhandler, &g_irq_sw1);
default:
return NULL;
}
}
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,4 +1,4 @@
/************************************************************************************
/****************************************************************************
* configs/samv71-xult/src/sam_userleds.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
@ -31,24 +31,78 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Included Files
************************************************************************************/
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <arch/board/board.h>
#include "sam_gpio.h"
#include "samv71-xult.h"
/************************************************************************************
/****************************************************************************
* Pre-processor Definitions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Private Functions
************************************************************************************/
****************************************************************************/
/************************************************************************************
/****************************************************************************
* Public Functions
************************************************************************************/
****************************************************************************/
/****************************************************************************
* Name: sam_ledinit
****************************************************************************/
void sam_ledinit(void)
{
/* Configure LED PIOs for output */
sam_configgpio(GPIO_LED0);
sam_configgpio(GPIO_LED1);
}
/****************************************************************************
* Name: sam_setled
****************************************************************************/
void sam_setled(int led, bool ledon)
{
uint32_t ledcfg;
if (led == BOARD_LED0)
{
ledcfg = GPIO_LED0;
}
else if (led == BOARD_LED1)
{
ledcfg = GPIO_LED1;
}
else
{
return;
}
sam_gpiowrite(ledcfg, !ledon); /* Low illuminates */
}
/****************************************************************************
* Name: sam_setleds
****************************************************************************/
void sam_setleds(uint8_t ledset)
{
/* Hight illuminates */
sam_gpiowrite(GPIO_LED0, (ledset & BOARD_LED0_BIT) == 0);
sam_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0);
}

View File

@ -117,13 +117,59 @@
*/
/* LEDs
* To be provided
*
* There are two yellow LED available on the SAM V71 Xplained Ultra board that
* can be turned on and off. The LEDs can be activated by driving the
* connected I/O line to GND.
*
* ------ ----------- ---------------------
* SAMV71 Function Shared functionality
* PIO
* ------ ----------- ---------------------
* PA23 Yellow LED0 EDBG GPIO
* PC09 Yellow LED1 LCD, and Shield
* ------ ----------- ---------------------
*/
#define GPIO_LED0 (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOA | GPIO_PIN23)
#define GPIO_LED1 (GPIO_OUTPUT | GPIO_CFG_DEFAULT | GPIO_OUTPUT_CLEAR | \
GPIO_PORT_PIOC | GPIO_PIN9)
/* Buttons
* To be provided
*
* SAM V71 Xplained Ultra contains three mechanical buttons. One button is the
* RESET button connected to the SAM V71 reset line and the others are generic
* user configurable buttons. When a button is pressed it will drive the I/O
* line to GND.
*
* ------ ----------- ---------------------
* SAMV71 Function Shared functionality
* PIO
* ------ ----------- ---------------------
* RESET RESET Trace, Shield, and EDBG
* PA09 SW0 EDBG GPIO and Camera
* PB12 SW1 EDBG SWD and Chip Erase
* ------ ----------- ---------------------
*
* NOTES:
*
* - There are no pull-up resistors connected to the generic user buttons so
* it is necessary to enable the internal pull-up in the SAM V71 to use the
* button.
* - PB12 is set up as a system flash ERASE pin when the firmware boots. To
* use the SW1, PB12 has to be configured as a normal regular I/O pin in
* the MATRIX module. For more information see the SAM V71 datasheet.
*/
#define GPIO_SW0 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \
GPIO_INT_BOTHEDGES | GPIO_PORT_PIOA | GPIO_PIN9)
#define GPIO_SW1 (GPIO_INPUT | GPIO_CFG_PULLUP | GPIO_CFG_DEGLITCH | \
GPIO_INT_BOTHEDGES | GPIO_PORT_PIOB | GPIO_PIN12)
#define IRQ_SW0 SAM_IRQ_PA9
#define IRQ_SW1 SAM_IRQ_PB12
/* HSMCI SD Card Detect
* To be provided
*/