Update README, LPC1766-STK button improvements, new Make targets, new Getting Started document

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4244 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2011-12-31 16:53:05 +00:00
parent 3152e92f88
commit 849f39c732
3 changed files with 70 additions and 32 deletions
+8 -1
View File
@@ -413,6 +413,9 @@ EXTERN void up_buttoninit(void);
* Name: up_buttons * Name: up_buttons
* *
* Description: * 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.
*
* After up_buttoninit() has been called, up_buttons() may be called to collect * 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 * the state of all buttons. up_buttons() returns an 8-bit bit set with each bit
* associated with a button. See the BOARD_BUTTON_*_BIT and BOARD_JOYSTICK_*_BIT * associated with a button. See the BOARD_BUTTON_*_BIT and BOARD_JOYSTICK_*_BIT
@@ -427,7 +430,6 @@ EXTERN uint8_t up_buttons(void);
* *
* Description: * Description:
* up_buttoninit() must be called to initialize button resources. After that, * 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. * up_irqbutton() may be called to register button interrupt handlers.
* *
* up_irqbutton() may be called to register an interrupt handler that will be called * up_irqbutton() may be called to register an interrupt handler that will be called
@@ -437,6 +439,11 @@ EXTERN uint8_t up_buttons(void);
* The previous interrupt handler address is returned (so that it may restored, if * The previous interrupt handler address is returned (so that it may restored, if
* so desired). * so desired).
* *
* Note that up_irqbutton() also enables button interrupts. Button interrupts
* will remain enabled after the interrupt handler is attached. Interrupts may
* be disabled (and detached) by calling up_irqbutton with irqhandler equal to
* NULL.
*
************************************************************************************/ ************************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) #if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ)
@@ -134,17 +134,21 @@
/* Buttons GPIO PIN SIGNAL NAME /* Buttons GPIO PIN SIGNAL NAME
* -------------------------------- ---- -------------- * -------------------------------- ---- --------------
* P2[12]/#EINT2/I2STX_WS 51 WAKE-UP
* P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] 9 BUT1 * P0[23]/AD0[0]/I2SRX_CLK/CAP3[0] 9 BUT1
* P2[13]/#EINT3/I2STX_SDA 50 BUT2 * P2[13]/#EINT3/I2STX_SDA 50 BUT2
* P2[12]/#EINT2/I2STX_WS 51 WAKE-UP
* *
* Pull-ups are not required because the pins are already pulled-up by through * NOTES:
* resistors on the board. * 1. Pull-ups are not required because the pins are already pulled-up by
* through resistors on the board.
* 2. All buttons are capable of supporting interrupts if up_irqbutton() is
* called to attach an interrupt handler. Interrupts are configured to
* occur on both edges.
*/ */
#define LPC1766STK_BUT1 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT0 | GPIO_PIN23) #define LPC1766STK_BUT1 (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT0 | GPIO_PIN23)
#define LPC1766STK_BUT2 (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN13) #define LPC1766STK_BUT2 (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN13)
#define LPC1766STK_WAKEUP (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN12) #define LPC1766STK_WAKEUP (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN12)
/* Button IRQ numbers */ /* Button IRQ numbers */
@@ -160,15 +164,19 @@
* P2[7]/RD2/RTS1 66 LEFT * P2[7]/RD2/RTS1 66 LEFT
* P2[8]/TD2/TXD2 65 RIGHT * P2[8]/TD2/TXD2 65 RIGHT
* *
* Pull-ups are not required because the pins are already pulled-up by through * NOTES:
* resistors on the board. * 1. Pull-ups are not required because the pins are already pulled-up by
* through resistors on the board.
* 2. All buttons are capable of supporting interrupts if up_irqbutton() is
* called to attach an interrupt handler. Interrupts are configured to
* occur on both edges.
*/ */
#define LPC1766STK_CENTER (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT0 | GPIO_PIN5) #define LPC1766STK_CENTER (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT0 | GPIO_PIN5)
#define LPC1766STK_UP (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN0) #define LPC1766STK_UP (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN0)
#define LPC1766STK_DOWN (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN1) #define LPC1766STK_DOWN (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN1)
#define LPC1766STK_LEFT (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN7) #define LPC1766STK_LEFT (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN7)
#define LPC1766STK_RIGHT (GPIO_INPUT | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN8) #define LPC1766STK_RIGHT (GPIO_INTBOTH | GPIO_FLOAT | GPIO_PORT2 | GPIO_PIN8)
/* Joystick IRQ numbers */ /* Joystick IRQ numbers */
+31 -8
View File
@@ -119,6 +119,10 @@ void up_buttoninit(void)
* Name: up_buttons * Name: up_buttons
* *
* Description: * 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.
*
* up_buttons() may be called at any time to harvest the state of every * up_buttons() may be called at any time to harvest the state of every
* button. The state of the buttons is returned as a bitset with one * button. The state of the buttons is returned as a bitset with one
* bit corresponding to each button: If the bit is set, then the button * bit corresponding to each button: If the bit is set, then the button
@@ -151,14 +155,12 @@ uint8_t up_buttons(void)
return ret; return ret;
} }
/************************************************************************************ /****************************************************************************
* Button support. * Button support.
* *
* Description: * Description:
* up_buttoninit() must be called to initialize button resources. After * up_buttoninit() must be called to initialize button resources. After
* that, up_buttons() may be called to collect the current state of all * that, up_irqbutton() may be called to register button interrupt handlers.
* buttons or up_irqbutton() may be called to register button interrupt
* handlers.
* *
* up_irqbutton() may be called to register an interrupt handler that will * up_irqbutton() may be called to register an interrupt handler that will
* be called when a button is depressed or released. The ID value is a * be called when a button is depressed or released. The ID value is a
@@ -167,13 +169,19 @@ uint8_t up_buttons(void)
* of enumeration values. The previous interrupt handler address is returned * of enumeration values. The previous interrupt handler address is returned
* (so that it may restored, if so desired). * (so that it may restored, if so desired).
* *
************************************************************************************/ * Note that up_irqbutton() also enables button interrupts. Button
* interrupts will remain enabled after the interrupt handler is attached.
* Interrupts may be disabled (and detached) by calling up_irqbutton with
* irqhandler equal to NULL.
*
****************************************************************************/
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ) #if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_GPIO_IRQ)
xcpt_t up_irqbutton(int id, xcpt_t irqhandler) xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
{ {
xcpt_t oldhandler = NULL; xcpt_t oldhandler = NULL;
irqstate_t flags; irqstate_t flags;
int irq;
/* Verify that the button ID is within range */ /* Verify that the button ID is within range */
@@ -188,10 +196,25 @@ xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
flags = irqsave(); flags = irqsave();
/* Configure the interrupt */ /* Configure the interrupt. Either attach and enable the new
* interrupt or disable and detach the old interrupt handler.
*/
(void)irq_attach(g_buttonirq[id], irqhandler); irq = g_buttonirq[id];
up_enable_irq(g_buttonirq[id]); if (irqhandler)
{
/* Attach then enable the new interrupt handler */
(void)irq_attach(irq, irqhandler);
up_enable_irq(irq);
}
else
{
/* Disable then then detach the the old interrupt handler */
up_disable_irq(irq);
(void)irq_detach(irq);
}
irqrestore(flags); irqrestore(flags);
} }
return oldhandler; return oldhandler;