A10+pcDuino: PIO support, LED and button support

This commit is contained in:
Gregory Nutt 2013-12-11 13:23:40 -06:00
parent ccb40177c1
commit 37106095df
5 changed files with 294 additions and 48 deletions

View File

@ -198,8 +198,9 @@ Serial Console
LEDs
====
The pcDuino v1 has four green LEDs. Two are tied to ground and, hence,
illuminated by driving the output pins to a high value:
The pcDuino v1 has four green LEDs; three can be controlled from software.
Two are tied to ground and, hence, illuminated by driving the output pins
to a high value:
1. LED1 SPI0_CLK SPI0_CLK/UART5_RX/EINT23/PI11
2. LED5 IPSOUT From the PMU (not controllable by software)
@ -209,6 +210,28 @@ LEDs
3. LED3 RX_LED LCD1_D16/ATAD12/KP_IN6/SMC_DET/EINT16/CSI1_D16/PH16
4. LED4 TX_LED LCD1_D15/ATAD11/KP_IN5/SMC_VPPPP/EINT15/CSI1_D15/PH15
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/stm32_leds.c. The LEDs are used to encode OS-related
events as follows:
SYMBOL Meaning LED state
LED1 LED3 LED4
----------------- ----------------------- ---- ---- ------------
LED_STARTED NuttX has been started ON OFF OFF
LED_HEAPALLOCATE Heap has been allocated OFF ON OFF
LED_IRQSENABLED Interrupts enabled ON ON OFF
LED_STACKCREATED Idle stack created ON ON OFF
LED_INIRQ In an interrupt N/C N/C Soft glow
LED_SIGNAL In a signal handler N/C N/C Soft glow
LED_ASSERTION An assertion failed N/C N/C Soft glow
LED_PANIC The system has crashed N/C N/C 2Hz Flashing
LED_IDLE MCU is is sleep mode Not used
After booting, LED1 and 3 are not longer used by the system and can be used for
other purposes by the application (Of course, all LEDs are available to the
application if CONFIG_ARCH_LEDS is not defined.
Buttons
=======

View File

@ -47,22 +47,81 @@
************************************************************************************/
/* Clocking *************************************************************************/
#warning Missing Logic
/* Since NuttX is booted from a loader on the A10, clocking should already be setup
* when NuttX starts.
*/
/* LED definitions ******************************************************************/
#warning Missing Logic
/* The pcDuino v1 has four green LEDs; three can be controlled from software. Two
* are tied to ground and, hence, illuminated by driving the output pins to a high
* value:
*
* 1. LED1 SPI0_CLK SPI0_CLK/UART5_RX/EINT23/PI11
* 2. LED5 IPSOUT From the PMU (not controllable by software)
*
* And two are pull high and, hence, illuminated by grounding the output:
*
* 3. LED3 RX_LED LCD1_D16/ATAD12/KP_IN6/SMC_DET/EINT16/CSI1_D16/PH16
* 4. LED4 TX_LED LCD1_D15/ATAD11/KP_IN5/SMC_VPPPP/EINT15/CSI1_D15/PH15
*/
#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 a1x_setled() */
#define BOARD_LED1 0
#define BOARD_LED3 1
#define BOARD_LED4 2
#define BOARD_NLEDS 3
/* LED bits for use with a1x_setleds() */
#define BOARD_LED1_BIT (1 << BOARD_LED1)
#define BOARD_LED3_BIT (1 << BOARD_LED3)
#define BOARD_LED4_BIT (1 << BOARD_LED4)
/* 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/a1x_leds.c. The LEDs are used to encode OS-related
* events as follows:
*
* SYMBOL Value Meaning LED state
* LED1 LED3 LED4
* ----------------- ----- ----------------------- ---- ---- ------------ */
#define LED_STARTED 0 /* NuttX has been started ON OFF OFF */
#define LED_HEAPALLOCATE 1 /* Heap has been allocated OFF ON OFF */
#define LED_IRQSENABLED 2 /* Interrupts enabled ON ON OFF */
#define LED_STACKCREATED 2 /* Idle stack created ON ON OFF */
#define LED_INIRQ 3 /* In an interrupt N/C N/C Soft glow */
#define LED_SIGNAL 3 /* In a signal handler N/C N/C Soft glow */
#define LED_ASSERTION 3 /* An assertion failed N/C N/C Soft glow */
#define LED_PANIC 3 /* The system has crashed N/C N/C 2Hz Flashing */
/* LED_IDLE --- /* MCU is is sleep mode Not used
*
* After booting, LED1 and 3 are not longer used by the system and can be used for
* other purposes by the application (Of course, all LEDs are available to the
* application if CONFIG_ARCH_LEDS is not defined.
*/
/* Button definitions ***************************************************************/
#warning Missing Logic
/* There are a total of five switches on-board. All pulled high and, hence, will be
* sensed as low when closed.
*
* SW1 Reset (not available to software)
* SW2 UBOOT UBOOT_SEL (?)
* SW3 Key_Back LCD1_D17/ATAD13/KP_IN7/SMC_VCCEN/EINT17/CSI1_D17/PH17
* SW4 Key_Home LCD1_D18/ATAD14/KP_OUT0/SMC_SLK/EINT18/CSI1_D18/PH18
* SW5 Key_Menu LCD1_D19/ATAD15/KP_OUT1/SMC_SDA/EINT19/CSI1_D19/PH19
*/
#define BUTTON_KEY_BACK 0
#define BUTTON_KEY_HOME 1
#define BUTTON_KEY_MENU 2
#define NUM_BUTTONS 3
#define BUTTON_KEY_BACK_BIT (1 << BUTTON_KEY_BACK)
#define BUTTON_KEY_HOME_BIT (1 << BUTTON_KEY_HOME)
#define BUTTON_KEY_MENU_BIT (1 << BUTTON_KEY_MENU)
/* NAND *****************************************************************************/
#warning Missing Logic
@ -160,7 +219,7 @@ uint8_t up_buttons(void);
*
************************************************************************************/
#ifdef CONFIG_ARCH_IRQBUTTONS
#ifdef CONFIG_A1X_PIO_IRQ
xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
#endif
#endif /* CONFIG_ARCH_BUTTONS */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* configs/pcduino-a10/scripts/ddram.ld
* configs/pcduino-a10/scripts/sdram.ld
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -52,8 +52,42 @@
#include "pcduino_a10.h"
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* The pcDuino v1 has four green LEDs; three can be controlled from software.
* Two are tied to ground and, hence, illuminated by driving the output pins
* to a high value:
*
* 1. LED1 SPI0_CLK SPI0_CLK/UART5_RX/EINT23/PI11
* 2. LED5 IPSOUT From the PMU (not controllable by software)
*
* And two are pull high and, hence, illuminated by grounding the output:
*
* 3. LED3 RX_LED LCD1_D16/ATAD12/KP_IN6/SMC_DET/EINT16/CSI1_D16/PH16
* 4. LED4 TX_LED LCD1_D15/ATAD11/KP_IN5/SMC_VPPPP/EINT15/CSI1_D15/PH15
* 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/stm32_leds.c. The LEDs are used to encode OS-related
* events as follows:
*
* SYMBOL Meaning LED state
* LED1 LED3 LED4
* ----------------- ----------------------- ---- ---- ---- ------------
* LED_STARTED NuttX has been started ON OFF OFF
* LED_HEAPALLOCATE Heap has been allocated OFF ON OFF
* LED_IRQSENABLED Interrupts enabled ON ON OFF
* LED_STACKCREATED Idle stack created ON ON OFF
* LED_INIRQ In an interrupt N/C N/C Soft glow
* LED_SIGNAL In a signal handler N/C N/C Soft glow
* LED_ASSERTION An assertion failed N/C N/C Soft glow
* LED_PANIC The system has crashed N/C N/C 2Hz Flashing
* LED_IDLE MCU is is sleep mode Not used
*
* After booting, LED1 and 3 are not longer used by the system and can be used for
* other purposes by the application (Of course, all LEDs are available to the
* application if CONFIG_ARCH_LEDS is not defined.
*/
/* CONFIG_DEBUG_LEDS enables debug output from this file (needs CONFIG_DEBUG
* with CONFIG_DEBUG_VERBOSE too)
@ -89,7 +123,9 @@
void a1x_led_initialize(void)
{
#warning Missing Logic
a1x_configpio(PIO_LED1);
a1x_configpio(PIO_LED3);
a1x_configpio(PIO_LED4);
}
/****************************************************************************
@ -98,25 +134,51 @@ void a1x_led_initialize(void)
* Description:
* Select the "logical" ON state:
*
* SYMBOL Value Meaning LED state
* LED2 LED1
* ---------------- ----- ----------------------- -------- --------
* 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 N/C N/C
* LED_SIGNAL 2 In a signal handler N/C N/C
* LED_ASSERTION 2 An assertion failed N/C N/C
* LED_PANIC 3 The system has crashed N/C Blinking
* LED_IDLE - MCU is is sleep mode Not used
* SYMBOL Value Meaning LED state
* LED1 LED3 LED4
* ----------------- ----- ----------------------- ---- ---- ------------
* LED_STARTED 0 NuttX has been started ON OFF OFF
* LED_HEAPALLOCATE 1 Heap has been allocated OFF ON OFF
* LED_IRQSENABLED 2 Interrupts enabled ON ON OFF
* LED_STACKCREATED 2 Idle stack created ON ON OFF
* LED_INIRQ 3 In an interrupt N/C N/C Soft glow
* LED_SIGNAL 3 In a signal handler N/C N/C Soft glow
* LED_ASSERTION 3 An assertion failed N/C N/C Soft glow
* LED_PANIC 3 The system has crashed N/C N/C 2Hz Flashing
* LED_IDLE --- MCU is is sleep mode Not used
*
* LED1 is illuminated by driving the output pins to a high value
* LED3 and LED 4 are illuminated by taking the output to ground.
*
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void up_ledon(int led)
{
#warning Missing logic
switch (led)
{
case 0:
a1x_pio_write(PIO_LED1, true);
a1x_pio_write(PIO_LED3, true);
a1x_pio_write(PIO_LED4, true);
break;
case 1:
a1x_pio_write(PIO_LED1, false);
a1x_pio_write(PIO_LED3, false);
a1x_pio_write(PIO_LED4, true);
break;
case 2:
a1x_pio_write(PIO_LED1, false);
a1x_pio_write(PIO_LED3, true);
a1x_pio_write(PIO_LED4, true);
break;
case 3:
a1x_pio_write(PIO_LED4, false);
break;
}
}
#endif
@ -126,25 +188,38 @@ void up_ledon(int led)
* Description:
* Select the "logical" OFF state:
*
* SYMBOL Value Meaning LED state
* LED2 LED1
* ---------------- ----- ----------------------- -------- --------
* 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 N/C N/C
* LED_SIGNAL 2 In a signal handler N/C N/C
* LED_ASSERTION 2 An assertion failed N/C N/C
* LED_PANIC 3 The system has crashed N/C Blinking
* LED_IDLE - MCU is is sleep mode Not used
* SYMBOL Value Meaning LED state
* LED1 LED3 LED4
* ----------------- ----- ----------------------- ---- ---- ------------
* LED_STARTED 0 NuttX has been started ON OFF OFF
* LED_HEAPALLOCATE 1 Heap has been allocated OFF ON OFF
* LED_IRQSENABLED 2 Interrupts enabled ON ON OFF
* LED_STACKCREATED 2 Idle stack created ON ON OFF
* LED_INIRQ 3 In an interrupt N/C N/C Soft glow
* LED_SIGNAL 3 In a signal handler N/C N/C Soft glow
* LED_ASSERTION 3 An assertion failed N/C N/C Soft glow
* LED_PANIC 3 The system has crashed N/C N/C 2Hz Flashing
* LED_IDLE --- MCU is is sleep mode Not used
*
* LED1 is illuminated by driving the output pins to a high value
* LED3 and LED 4 are illuminated by taking the output to ground.
*
****************************************************************************/
#ifdef CONFIG_ARCH_LEDS
void up_ledoff(int led)
{
#warning Missing logic
switch (led)
{
case 0:
case 1:
case 2:
break;
case 3:
a1x_pio_write(PIO_LED4, true);
break;
}
}
#endif
@ -165,10 +240,29 @@ void up_ledoff(int led)
void a1x_setled(int led, bool ledon)
{
#warning Missing logic
switch (led)
{
case BOARD_LED1:
a1x_pio_write(PIO_LED1, ledon);
break;
case BOARD_LED3:
a1x_pio_write(PIO_LED3, !ledon);
break;
#ifndef CONFIG_ARCH_LEDS
case BOARD_LED4:
a1x_pio_write(PIO_LED4, !ledon);
break;
#endif
}
}
void a1x_setleds(uint8_t ledset)
{
#warning Missing logic
a1x_setled(BOARD_LED1, (ledset & BOARD_LED1) != 0);
a1x_setled(BOARD_LED3, (ledset & BOARD_LED3) != 0);
#ifndef CONFIG_ARCH_LEDS
a1x_setled(BOARD_LED4, (ledset & BOARD_LED4) != 0);
#endif
}

View File

@ -48,16 +48,86 @@
#include <arch/irq.h>
#include <nuttx/irq.h>
#include "a1x_pio.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Configuration ************************************************************/
/* Configuration ********************************************************************/
/* LEDs *****************************************************************************/
#warning Missing logic
/* The pcDuino v1 has four green LEDs; three can be controlled from software. Two
* are tied to ground and, hence, illuminated by driving the output pins to a high
* value:
*
* 1. LED1 SPI0_CLK SPI0_CLK/UART5_RX/EINT23/PI11
* 2. LED5 IPSOUT From the PMU (not controllable by software)
*/
#define PIO_LED1 (PIO_OUTPUT | PIO_PULL_NONE | PIO_DRIVE_MEDLOW | PIO_INT_NONE | \
PIO_OUTPUT_CLEAR | PIO_PORT_PIOI | PIO_PIN11)
/* And two are pull high and, hence, illuminated by grounding the output:
*
* 3. LED3 RX_LED LCD1_D16/ATAD12/KP_IN6/SMC_DET/EINT16/CSI1_D16/PH16
* 4. LED4 TX_LED LCD1_D15/ATAD11/KP_IN5/SMC_VPPPP/EINT15/CSI1_D15/PH15
*/
#define PIO_LED3 (PIO_OUTPUT | PIO_PULL_NONE | PIO_DRIVE_MEDLOW | PIO_INT_NONE | \
PIO_OUTPUT_SET | PIO_PORT_PIOH | PIO_PIN16)
#define PIO_LED4 (PIO_OUTPUT | PIO_PULL_NONE | PIO_DRIVE_MEDLOW | PIO_INT_NONE | \
PIO_OUTPUT_SET | PIO_PORT_PIOH | PIO_PIN15)
/* 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/stm32_leds.c. The LEDs are used to encode OS-related
* events as follows:
*
* SYMBOL Meaning LED state
* LED1 LED3 LED4
* ----------------- ----------------------- ---- ---- ---- ------------
* LED_STARTED NuttX has been started ON OFF OFF
* LED_HEAPALLOCATE Heap has been allocated OFF ON OFF
* LED_IRQSENABLED Interrupts enabled ON ON OFF
* LED_STACKCREATED Idle stack created ON ON OFF
* LED_INIRQ In an interrupt N/C N/C Soft glow
* LED_SIGNAL In a signal handler N/C N/C Soft glow
* LED_ASSERTION An assertion failed N/C N/C Soft glow
* LED_PANIC The system has crashed N/C N/C 2Hz Flashing
* LED_IDLE MCU is is sleep mode Not used
*
* After booting, LED1 and 3 are not longer used by the system and can be used for
* other purposes by the application (Of course, all LEDs are available to the
* application if CONFIG_ARCH_LEDS is not defined.
*/
/* Buttons **************************************************************************/
#warning Missing logic
/* There are a total of five switches on-board. All pulled high and, hence, will be
* sensed as low when closed.
*
* SW1 Reset (not available to software)
* SW2 UBOOT UBOOT_SEL (?)
* SW3 Key_Back LCD1_D17/ATAD13/KP_IN7/SMC_VCCEN/EINT17/CSI1_D17/PH17
* SW4 Key_Home LCD1_D18/ATAD14/KP_OUT0/SMC_SLK/EINT18/CSI1_D18/PH18
* SW5 Key_Menu LCD1_D19/ATAD15/KP_OUT1/SMC_SDA/EINT19/CSI1_D19/PH19
*/
#ifdef CONFIG_A1X_PIO_IRQ
# define PIO_KEY_BACK (PIO_EINT | PIO_PULL_NONE | PIO_DRIVE_NONE | \
PIO_INT_BOTHEDGES | IO_PORT_PIOH | PIO_PIN17)
# define PIO_KEY_HOME (PIO_EINT | PIO_PULL_NONE | PIO_DRIVE_NONE | \
PIO_INT_BOTHEDGES | IO_PORT_PIOH | PIO_PIN18)
# define PIO_KEY_MENU (PIO_EINT | PIO_PULL_NONE | PIO_DRIVE_NONE | \
PIO_INT_BOTHEDGES | IO_PORT_PIOH | PIO_PIN19)
#else
# define PIO_KEY_BACK (PIO_INPUT | PIO_PULL_NONE | PIO_DRIVE_NONE | \
PIO_INT_NONE | IO_PORT_PIOH | PIO_PIN17)
# define PIO_KEY_HOME (PIO_INPUT | PIO_PULL_NONE | PIO_DRIVE_NONE | \
PIO_INT_NONE | IO_PORT_PIOH | PIO_PIN18)
# define PIO_KEY_MENU (PIO_INPUT | PIO_PULL_NONE | PIO_DRIVE_NONE | \
PIO_INT_NONE | IO_PORT_PIOH | PIO_PIN19)
#endif
/* SPI Chip Selects *****************************************************************/
#warning Missing logic