mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Update SAMA5D4-EK PIO usage
This commit is contained in:
@@ -160,6 +160,7 @@
|
||||
* - PE29. Pressing the switch connect PE29 to ground. Therefore, PE29
|
||||
* must be pulled high internally. When the button is pressed the SAMA5
|
||||
* will sense "0" is on PE29.
|
||||
*/
|
||||
|
||||
#define BUTTON_USER 0
|
||||
#define NUM_BUTTONS 1
|
||||
|
||||
@@ -91,32 +91,32 @@ static xcpt_t g_irquser1;
|
||||
* 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.
|
||||
* 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)
|
||||
{
|
||||
(void)sam_configpio(PIO_USER1);
|
||||
(void)sam_configpio(PIO_USER);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* 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)
|
||||
{
|
||||
return sam_pioread(PIO_USER1) ? 0 : BUTTON_USER1_BIT;
|
||||
return sam_pioread(PIO_USER) ? 0 : BUTTON_USER_BIT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -140,7 +140,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
|
||||
if (id == BUTTON_USER1)
|
||||
if (id == BUTTON_USER)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
|
||||
+336
-112
File diff suppressed because it is too large
Load Diff
@@ -95,30 +95,35 @@
|
||||
#endif
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
/* There are two LEDs on the SAMA5D4 series-CM board that can be controlled
|
||||
* by software. A blue LED is controlled via PIO pins. A red LED normally
|
||||
* provides an indication that power is supplied to the board but can also
|
||||
* be controlled via software.
|
||||
/* There are 3 LEDs on the SAMA5D4-EK:
|
||||
*
|
||||
* PE23. This blue LED is pulled high and is illuminated by pulling PE23
|
||||
* low.
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* PE28/NWAIT/RTS4/A19 1Wire_PE28 1-WIRE ROM, LCD, D8 (green)
|
||||
* PE8/A8/TCLK3/PWML3 LED_USER_PE8 LED_USER (D10)
|
||||
* PE9/A9/TIOA2 LED_POWER_PE9 LED_POWER (D9, Red)
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
*
|
||||
* 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 high output.
|
||||
* - D8: D8 is shared with other functions and cannot be used if the 1-Wire ROM
|
||||
* is used. I am not sure of the LCD function, but the LED may not be available
|
||||
* if the LCD is used either. We will avoid using D8 just for simplicity.
|
||||
* - D10: Nothing special here. A low output illuminates.
|
||||
* - D9: The Power ON LED. Connects to the via an IRLML2502 MOSFET. This LED will
|
||||
* be on when power is applied but otherwise a low output value will turn it
|
||||
* off.
|
||||
*/
|
||||
|
||||
/* LED index values for use with sam_setled() */
|
||||
|
||||
#define BOARD_BLUE 0
|
||||
#define BOARD_RED 1
|
||||
#define BOARD_USER 0
|
||||
#define BOARD_POWER 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 BOARD_USER_BIT (1 << BOARD_BLUE)
|
||||
#define BOARD_POWER_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
|
||||
@@ -138,28 +143,24 @@
|
||||
#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
|
||||
/* Thus if the D0 and D9 are statically on, NuttX has successfully booted and
|
||||
* is, apparently, running normally. If the red D9 LED is flashing at
|
||||
* approximately 2Hz, then a fatal error has been detected and the system
|
||||
* has halted.
|
||||
*/
|
||||
|
||||
/* Button definitions ***************************************************************/
|
||||
/* The following push buttons switches are available:
|
||||
/* A single button, PB_USER1 (PB2), is available on the SAMA5D4-EK:
|
||||
*
|
||||
* 1. One board reset button (BP2). When pressed and released, this push
|
||||
* button causes a power-on reset of the whole board.
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* PE13/A13/TIOB1/PWML2 PB_USER1_PE13 PB_USER1
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
*
|
||||
* 2. One wakeup pushbutton that brings the processor out of Low-power mode
|
||||
* (BP1)
|
||||
*
|
||||
* 3. One user pushbutton (BP3)
|
||||
*
|
||||
* Only the user push button (BP3) is controllable by software:
|
||||
*
|
||||
* - PE29. Pressing the switch connect PE29 to ground. Therefore, PE29
|
||||
* must be pulled high internally. When the button is pressed the SAMA5
|
||||
* will sense "0" is on PE29.
|
||||
* Closing JP2 will bring PE13 to ground so 1) PE13 should have a weak pull-up,
|
||||
* and 2) when PB2 is pressed, a low value will be senses.
|
||||
*/
|
||||
|
||||
#define BUTTON_USER 0
|
||||
#define NUM_BUTTONS 1
|
||||
@@ -181,111 +182,6 @@
|
||||
#define BOARD_EBICS3_NAND_DATAADDR 0x60000000
|
||||
|
||||
/* PIO configuration ****************************************************************/
|
||||
/* PWM. There are no dedicated PWM output pins available to the user for PWM
|
||||
* testing. Care must be taken because all PWM output pins conflict with some other
|
||||
* usage of the pin by other devices. Furthermore, many of these pins have not been
|
||||
* brought out to an external connector:
|
||||
*
|
||||
* -----+---+---+----+------+----------------
|
||||
* PWM PIN PER PIO I/O CONFLICTS
|
||||
* -----+---+---+----+------+----------------
|
||||
* PWM0 FI B PC28 J2.30 SPI1, ISI
|
||||
* H B PB0 --- GMAC
|
||||
* B PA20 J1.14 LCDC, ISI
|
||||
* L B PB1 --- GMAC
|
||||
* B PA21 J1.16 LCDC, ISI
|
||||
* -----+---+---+----+------+----------------
|
||||
* PWM1 FI B PC31 J2.36 HDMI
|
||||
* H B PB4 --- GMAC
|
||||
* B PA22 J1.18 LCDC, ISI
|
||||
* L B PB5 --- GMAC
|
||||
* B PE31 J3.20 ISI, HDMI
|
||||
* B PA23 J1.20 LCDC, ISI
|
||||
* -----+---+---+----+------+----------------
|
||||
* PWM2 FI B PC29 J2.29 UART0, ISI, HDMI
|
||||
* H C PD5 --- HSMCI0
|
||||
* B PB8 --- GMAC
|
||||
* L C PD6 --- HSMCI0
|
||||
* B PB9 --- GMAC
|
||||
* -----+---+---+----+------+----------------
|
||||
* PWM3 FI C PD16 --- SPI0, Audio
|
||||
* H C PD7 --- HSMCI0
|
||||
* B PB12 J3.7 GMAC
|
||||
* L C PD8 --- HSMCI0
|
||||
* B PB13 --- GMAC
|
||||
* -----+---+---+----+------+----------------
|
||||
*/
|
||||
|
||||
/* PWM channel 0:
|
||||
*
|
||||
* PA20 and PA21 can be used if the LCDC or ISI are not selected. These outputs are
|
||||
* available on J1, pins 14 and 16, respectively.
|
||||
*
|
||||
* If the GMAC is not selected, then PB0 and PB1 could also be used. However,
|
||||
* these pins are not available at the I/O expansion connectors.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_SAMA5_LCDC) && !defined(CONFIG_SAMA5_ISI)
|
||||
# define PIO_PWM0_H PIO_PWM0_H_2
|
||||
# define PIO_PWM0_L PIO_PWM0_L_2
|
||||
#elif !defined(CONFIG_SAMA5_GMAC)
|
||||
# define PIO_PWM0_H PIO_PWM0_H_1
|
||||
# define PIO_PWM0_L PIO_PWM0_L_1
|
||||
#endif
|
||||
|
||||
/* PWM channel 1:
|
||||
*
|
||||
* PA22 and PA23 can be used if the LCDC or ISI are not selected. These outputs are
|
||||
* available on J1, pins 18 and 20, respectively.
|
||||
*
|
||||
* PE31 can be used if the ISI is not selected (and the HDMI is not being used).
|
||||
* That signal is available at J3 pin 20.
|
||||
*
|
||||
* If the GMAC is not selected, then PB4 and PB5 could also be used. However,
|
||||
* these pins are not available at the I/O expansion connectors.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_SAMA5_LCDC) && !defined(CONFIG_SAMA5_ISI)
|
||||
# define PIO_PWM1_H PIO_PWM1_H_2
|
||||
#elif !defined(CONFIG_SAMA5_GMAC)
|
||||
# define PIO_PWM1_H PIO_PWM1_H_1
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_SAMA5_LCDC) && !defined(CONFIG_SAMA5_ISI)
|
||||
# define PIO_PWM1_L PIO_PWM1_L_3
|
||||
#elif !defined(CONFIG_SAMA5_ISI)
|
||||
# define PIO_PWM1_L PIO_PWM1_L_2
|
||||
#elif !defined(CONFIG_SAMA5_GMAC)
|
||||
# define PIO_PWM1_L PIO_PWM1_L_1
|
||||
#endif
|
||||
|
||||
/* PWM channel 2:
|
||||
*
|
||||
* None of the output pin options are available at any of the I/O expansion
|
||||
* connectors for PWM channel 2
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_SAMA5_HSMCI0)
|
||||
# define PIO_PWM2_H PIO_PWM2_H_1
|
||||
# define PIO_PWM2_L PIO_PWM2_L_1
|
||||
#elif !defined(CONFIG_SAMA5_GMAC)
|
||||
# define PIO_PWM2_H PIO_PWM2_H_2
|
||||
# define PIO_PWM2_L PIO_PWM2_L_2
|
||||
#endif
|
||||
|
||||
/* PWM channel 3:
|
||||
*
|
||||
* If the GMAC is not selected, then PB12 can used and is available at J3 pin 7.
|
||||
* None of the other output pins are accessible at the I/O expansion connectors.
|
||||
*/
|
||||
|
||||
#if !defined(CONFIG_SAMA5_GMAC)
|
||||
# define PIO_PWM3_H PIO_PWM3_H_2
|
||||
# define PIO_PWM3_L PIO_PWM3_L_2
|
||||
#elif !defined(CONFIG_SAMA5_HSMCI0)
|
||||
# define PIO_PWM3_H PIO_PWM3_H_1
|
||||
# define PIO_PWM3_L PIO_PWM3_L_1
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Assembly Language Macros
|
||||
|
||||
@@ -164,7 +164,7 @@ CONFIG_ARCH_CHIP_ATSAMA5D44=y
|
||||
# CONFIG_SAMA5_AES is not set
|
||||
# CONFIG_SAMA5_TDES is not set
|
||||
# CONFIG_SAMA5_AESB is not set
|
||||
CONFIG_SAMA5_DBGU=y
|
||||
# CONFIG_SAMA5_DBGU is not set
|
||||
# CONFIG_SAMA5_L2CC is not set
|
||||
# CONFIG_SAMA5_PIT is not set
|
||||
# CONFIG_SAMA5_WDT is not set
|
||||
@@ -177,8 +177,8 @@ CONFIG_SAMA5_HSMC=y
|
||||
# CONFIG_SAMA5_USART0 is not set
|
||||
# CONFIG_SAMA5_USART1 is not set
|
||||
# CONFIG_SAMA5_USART2 is not set
|
||||
# CONFIG_SAMA5_USART3 is not set
|
||||
# CONFIG_SAMA5_USART4 is not set
|
||||
CONFIG_SAMA5_USART3=y
|
||||
CONFIG_SAMA5_USART4=y
|
||||
# CONFIG_SAMA5_TWI0 is not set
|
||||
# CONFIG_SAMA5_TWI1 is not set
|
||||
# CONFIG_SAMA5_TWI2 is not set
|
||||
@@ -211,14 +211,6 @@ CONFIG_SAMA5_HSMC=y
|
||||
# CONFIG_SAMA5_VDEC is not set
|
||||
# CONFIG_SAMA5_PIO_IRQ is not set
|
||||
|
||||
#
|
||||
# DBGU Configuration
|
||||
#
|
||||
CONFIG_SAMA5_DBGU_CONSOLE=y
|
||||
CONFIG_SAMA5_DBGU_RXBUFSIZE=256
|
||||
CONFIG_SAMA5_DBGU_TXBUFSIZE=256
|
||||
CONFIG_SAMA5_DBGU_NOCONFIG=y
|
||||
|
||||
#
|
||||
# External Memory Configuration
|
||||
#
|
||||
@@ -450,8 +442,8 @@ CONFIG_SERIAL=y
|
||||
# CONFIG_ARCH_HAVE_USART0 is not set
|
||||
# CONFIG_ARCH_HAVE_USART1 is not set
|
||||
# CONFIG_ARCH_HAVE_USART2 is not set
|
||||
# CONFIG_ARCH_HAVE_USART3 is not set
|
||||
# CONFIG_ARCH_HAVE_USART4 is not set
|
||||
CONFIG_ARCH_HAVE_USART3=y
|
||||
CONFIG_ARCH_HAVE_USART4=y
|
||||
# CONFIG_ARCH_HAVE_USART5 is not set
|
||||
# CONFIG_ARCH_HAVE_USART6 is not set
|
||||
# CONFIG_ARCH_HAVE_USART7 is not set
|
||||
@@ -460,8 +452,37 @@ CONFIG_SERIAL=y
|
||||
#
|
||||
# USART Configuration
|
||||
#
|
||||
# CONFIG_MCU_SERIAL is not set
|
||||
CONFIG_USART3_ISUART=y
|
||||
CONFIG_USART4_ISUART=y
|
||||
CONFIG_MCU_SERIAL=y
|
||||
CONFIG_STANDARD_SERIAL=y
|
||||
CONFIG_USART3_SERIAL_CONSOLE=y
|
||||
# CONFIG_USART4_SERIAL_CONSOLE is not set
|
||||
# CONFIG_NO_SERIAL_CONSOLE is not set
|
||||
|
||||
#
|
||||
# USART3 Configuration
|
||||
#
|
||||
CONFIG_USART3_RXBUFSIZE=256
|
||||
CONFIG_USART3_TXBUFSIZE=256
|
||||
CONFIG_USART3_BAUD=115200
|
||||
CONFIG_USART3_BITS=8
|
||||
CONFIG_USART3_PARITY=0
|
||||
CONFIG_USART3_2STOP=0
|
||||
# CONFIG_USART3_IFLOWCONTROL is not set
|
||||
# CONFIG_USART3_OFLOWCONTROL is not set
|
||||
|
||||
#
|
||||
# USART4 Configuration
|
||||
#
|
||||
CONFIG_USART4_RXBUFSIZE=256
|
||||
CONFIG_USART4_TXBUFSIZE=256
|
||||
CONFIG_USART4_BAUD=115200
|
||||
CONFIG_USART4_BITS=8
|
||||
CONFIG_USART4_PARITY=0
|
||||
CONFIG_USART4_2STOP=0
|
||||
# CONFIG_USART4_IFLOWCONTROL is not set
|
||||
# CONFIG_USART4_OFLOWCONTROL is not set
|
||||
# CONFIG_SERIAL_IFLOWCONTROL is not set
|
||||
# CONFIG_SERIAL_OFLOWCONTROL is not set
|
||||
# CONFIG_USBDEV is not set
|
||||
|
||||
@@ -32,39 +32,44 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/* There are two LEDs on the SAMA5D4 series-CM board that can be controlled
|
||||
* by software. A blue LED is controlled via PIO pins. A red LED normally
|
||||
* provides an indication that power is supplied to the board but can also
|
||||
* be controlled via software.
|
||||
/* There are 3 LEDs on the SAMA5D4-EK:
|
||||
*
|
||||
* PE25. This blue LED is pulled high and is illuminated by pulling PE25
|
||||
* low.
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* PE28/NWAIT/RTS4/A19 1Wire_PE28 1-WIRE ROM, LCD, D8 (green)
|
||||
* PE8/A8/TCLK3/PWML3 LED_USER_PE8 LED_USER (D10)
|
||||
* PE9/A9/TIOA2 LED_POWER_PE9 LED_POWER (D9, Red)
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
*
|
||||
* 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.
|
||||
* - D8: D8 is shared with other functions and cannot be used if the 1-Wire ROM
|
||||
* is used. I am not sure of the LCD function, but the LED may not be available
|
||||
* if the LCD is used either. We will avoid using D8 just for simplicity.
|
||||
* - D10: Nothing special here. A low output illuminates.
|
||||
* - D9: The Power ON LED. Connects to the via an IRLML2502 MOSFET. This LED will
|
||||
* be on when power is applied but otherwise a low output value will turn it
|
||||
* off.
|
||||
*
|
||||
* 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
|
||||
* SYMBOL Meaning LED state
|
||||
* USER D10 POWER D9
|
||||
* ------------------- ----------------------- -------- --------
|
||||
* LED_STARTED NuttX has been started OFF ON
|
||||
* LED_HEAPALLOCATE Heap has been allocated OFF ON
|
||||
* LED_IRQSENABLED Interrupts enabled OFF ON
|
||||
* LED_STACKCREATED Idle stack created ON ON
|
||||
* 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 normally. If the red is flashing at
|
||||
* Thus if the D0 and D9 are statically on, NuttX has successfully booted and
|
||||
* is, apparently, running normally. If the red D9 LED is flashing at
|
||||
* approximately 2Hz, then a fatal error has been detected and the system
|
||||
* has halted.
|
||||
*/
|
||||
@@ -122,8 +127,8 @@ void board_led_initialize(void)
|
||||
{
|
||||
/* Configure LED PIOs for output */
|
||||
|
||||
sam_configpio(PIO_BLUE);
|
||||
sam_configpio(PIO_RED);
|
||||
sam_configpio(PIO_LED_USER);
|
||||
sam_configpio(PIO_LED_POWER);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -132,29 +137,31 @@ void board_led_initialize(void)
|
||||
|
||||
void board_led_on(int led)
|
||||
{
|
||||
bool blueoff = true; /* Low illuminates */
|
||||
bool redon = false; /* High illuminates */
|
||||
|
||||
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 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED */
|
||||
break; /* Leave USER LED off */
|
||||
|
||||
case 3: /* LED_PANIC */
|
||||
redon = true;
|
||||
case 1: /* LED_STACKCREATED */
|
||||
{
|
||||
/* User LED is ON (Low illuminates) */
|
||||
|
||||
sam_piowrite(PIO_LED_USER, false);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
|
||||
break; /* Ignored */
|
||||
|
||||
case 3: /* LED_PANIC */
|
||||
{
|
||||
/* Power LED is ON (High illuminates) */
|
||||
|
||||
sam_piowrite(PIO_LED_POWER, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
sam_piowrite(PIO_BLUE, blueoff);
|
||||
sam_piowrite(PIO_RED, redon);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -163,10 +170,23 @@ void board_led_on(int led)
|
||||
|
||||
void board_led_off(int led)
|
||||
{
|
||||
if (led != 2)
|
||||
switch (led)
|
||||
{
|
||||
sam_piowrite(PIO_BLUE, true); /* Low illuminates */
|
||||
sam_piowrite(PIO_RED, false); /* High illuminates */
|
||||
default:
|
||||
case 0: /* LED_STARTED, LED_HEAPALLOCATE, LED_IRQSENABLED, */
|
||||
case 1: /* LED_STACKCREATED */
|
||||
break; /* Will not happen */
|
||||
|
||||
case 2: /* LED_INIRQ, LED_SIGNAL, LED_ASSERTION */
|
||||
break; /* Ignored */
|
||||
|
||||
case 3: /* LED_PANIC */
|
||||
{
|
||||
/* Power LED is OFF (High illuminates) */
|
||||
|
||||
sam_piowrite(PIO_LED_POWER, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,20 +32,16 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/* There are five push button switches on the SAMA4D4-EK base board:
|
||||
/* A single button, PB_USER1 (PB2), is available on the SAMA5D4-EK:
|
||||
*
|
||||
* 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
|
||||
* ------------------------------ ------------------- ----------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- ----------------------
|
||||
* PE13/A13/TIOB1/PWML2 PB_USER1_PE13 PB_USER1
|
||||
* ------------------------------ ------------------- ----------------------
|
||||
*
|
||||
* 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.
|
||||
* Closing JP2 will bring PE13 to ground so 1) PE13 should have a weak
|
||||
* pull-up, and 2) when PB2 is pressed, a low value will be senses.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -91,32 +87,32 @@ static xcpt_t g_irquser1;
|
||||
* 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.
|
||||
* 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)
|
||||
{
|
||||
(void)sam_configpio(PIO_USER1);
|
||||
(void)sam_configpio(PIO_BTN_USER);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
* 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)
|
||||
{
|
||||
return sam_pioread(PIO_USER1) ? 0 : BUTTON_USER1_BIT;
|
||||
return sam_pioread(PIO_BTN_USER) ? 0 : BUTTON_USER_BIT;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -126,7 +122,7 @@ uint8_t board_buttons(void)
|
||||
* 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).
|
||||
* handler address is returned (so that it may restored, if so desired).
|
||||
*
|
||||
* Configuration Notes:
|
||||
* Configuration CONFIG_SAMA5_PIO_IRQ must be selected to enable the
|
||||
@@ -140,7 +136,7 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
|
||||
{
|
||||
xcpt_t oldhandler = NULL;
|
||||
|
||||
if (id == BUTTON_USER1)
|
||||
if (id == BUTTON_USER)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
|
||||
@@ -32,18 +32,22 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
/* There are two LEDs on the SAMA5D4 series-CM board that can be controlled
|
||||
* by software. A blue LED is controlled via PIO pins. A red LED normally
|
||||
* provides an indication that power is supplied to the board but can also
|
||||
* be controlled via software.
|
||||
/* There are 3 LEDs on the SAMA5D4-EK:
|
||||
*
|
||||
* PE25. This blue LED is pulled high and is illuminated by pulling PE25
|
||||
* low.
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* PE28/NWAIT/RTS4/A19 1Wire_PE28 1-WIRE ROM, LCD, D8 (green)
|
||||
* PE8/A8/TCLK3/PWML3 LED_USER_PE8 LED_USER (D10)
|
||||
* PE9/A9/TIOA2 LED_POWER_PE9 LED_POWER (D9, Red)
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
*
|
||||
* 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.
|
||||
* - D8: D8 is shared with other functions and cannot be used if the 1-Wire ROM
|
||||
* is used. I am not sure of the LCD function, but the LED may not be available
|
||||
* if the LCD is used either. We will avoid using D8 just for simplicity.
|
||||
* - D10: Nothing special here. A low output illuminates.
|
||||
* - D9: The Power ON LED. Connects to the via an IRLML2502 MOSFET. This LED will
|
||||
* be on when power is applied but otherwise, I think it works like D10.
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -84,7 +88,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Protototypes
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -107,8 +111,8 @@ void sam_ledinit(void)
|
||||
{
|
||||
/* Configure LED PIOs for output */
|
||||
|
||||
sam_configpio(PIO_BLUE);
|
||||
sam_configpio(PIO_RED);
|
||||
sam_configpio(PIO_LED_USER);
|
||||
sam_configpio(PIO_LED_POWER);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -123,14 +127,14 @@ void sam_setled(int led, bool ledon)
|
||||
{
|
||||
/* Low illuminates */
|
||||
|
||||
ledcfg = PIO_BLUE;
|
||||
ledcfg = PIO_LED_USER;
|
||||
ledon = !ledon;
|
||||
}
|
||||
else if (led == BOARD_RED)
|
||||
{
|
||||
/* High illuminates */
|
||||
|
||||
ledcfg = PIO_RED;
|
||||
ledcfg = PIO_LED_POWER;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -151,12 +155,12 @@ void sam_setleds(uint8_t ledset)
|
||||
/* Low illuminates */
|
||||
|
||||
ledon = ((ledset & BOARD_BLUE_BIT) == 0);
|
||||
sam_piowrite(PIO_BLUE, ledon);
|
||||
sam_piowrite(PIO_LED_USER, ledon);
|
||||
|
||||
/* High illuminates */
|
||||
|
||||
ledon = ((ledset & BOARD_RED_BIT) != 0);
|
||||
sam_piowrite(PIO_RED, ledon);
|
||||
sam_piowrite(PIO_LED_POWER, ledon);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_ARCH_LEDS */
|
||||
|
||||
@@ -260,45 +260,46 @@
|
||||
#endif
|
||||
|
||||
/* LEDs *****************************************************************************/
|
||||
/* There are two LEDs on the SAMA5D4 series-CM board that can be controlled
|
||||
* by software. A blue LED is controlled via PIO pins. A red LED normally
|
||||
* provides an indication that power is supplied to the board but can also
|
||||
* be controlled via software.
|
||||
/* There are 3 LEDs on the SAMA5D4-EK:
|
||||
*
|
||||
* PE23. This blue LED is pulled high and is illuminated by pulling PE23
|
||||
* low.
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* PE28/NWAIT/RTS4/A19 1Wire_PE28 1-WIRE ROM, LCD, D8 (green)
|
||||
* PE8/A8/TCLK3/PWML3 LED_USER_PE8 LED_USER (D10)
|
||||
* PE9/A9/TIOA2 LED_POWER_PE9 LED_POWER (D9, Red)
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
*
|
||||
* 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 high output.
|
||||
* - D8: D8 is shared with other functions and cannot be used if the 1-Wire ROM
|
||||
* is used. I am not sure of the LCD function, but the LED may not be available
|
||||
* if the LCD is used either. We will avoid using D8 just for simplicity.
|
||||
* - D10: Nothing special here. A low output illuminates.
|
||||
* - D9: The Power ON LED. Connects to the via an IRLML2502 MOSFET. This LED will
|
||||
* be on when power is applied but otherwise; a low output value will turn it
|
||||
* off.
|
||||
*/
|
||||
|
||||
#define PIO_BLUE (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_SET | \
|
||||
PIO_PORT_PIOE | PIO_PIN23)
|
||||
#define PIO_RED (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_CLEAR | \
|
||||
PIO_PORT_PIOE | PIO_PIN24)
|
||||
#define PIO_LED_USER (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_SET | \
|
||||
PIO_PORT_PIOE | PIO_PIN8)
|
||||
#define PIO_LED_POWER (PIO_OUTPUT | PIO_CFG_PULLUP | PIO_OUTPUT_SET | \
|
||||
PIO_PORT_PIOE | PIO_PIN9)
|
||||
|
||||
/* Buttons **************************************************************************/
|
||||
/* There are five push button switches on the SAMA4D4-EK base board:
|
||||
/* A single button, PB_USER1 (PB2), is available on the SAMA5D4-EK:
|
||||
*
|
||||
* 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
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* SAMA5D4 PIO SIGNAL USAGE
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
* PE13/A13/TIOB1/PWML2 PB_USER1_PE13 PB_USER1
|
||||
* ------------------------------ ------------------- -------------------------
|
||||
*
|
||||
* Only the user push button is controllable by software (labeled
|
||||
* "PB_USER1" on the board):
|
||||
*
|
||||
* - PE29. Pressing the switch connects PE29 to ground. Therefore, PE29
|
||||
* must be pulled high internally. When the button is pressed the SAMA5
|
||||
* will sense "0" is on PE29.
|
||||
* Closing JP2 will bring PE13 to ground so 1) PE13 should have a weak pull-up,
|
||||
* and 2) when PB2 is pressed, a low value will be senses.
|
||||
*/
|
||||
|
||||
#define PIO_USER (PIO_INPUT | PIO_CFG_PULLUP | PIO_CFG_DEGLITCH | \
|
||||
PIO_INT_BOTHEDGES | PIO_PORT_PIOE | PIO_PIN29)
|
||||
#define IRQ_USER SAM_IRQ_PE29
|
||||
#define PIO_BTN_USER (PIO_INPUT | PIO_CFG_PULLUP | PIO_CFG_DEGLITCH | \
|
||||
PIO_INT_BOTHEDGES | PIO_PORT_PIOE | PIO_PIN13)
|
||||
#define IRQ_BTN_USER SAM_IRQ_PE13
|
||||
|
||||
/* HSMCI Card Slots *****************************************************************/
|
||||
/* The SAMA4D4-EK provides a two SD memory card slots: (1) a full size SD card
|
||||
|
||||
Reference in New Issue
Block a user