mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
Add PIC32MX GPIO handling; add button/LED support for the Sure PIC32MX
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4040 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -102,6 +102,24 @@
|
||||
#define LED_SIGNAL 4 /* N/C N/C ON N/C N/C N/C OFF N/C */
|
||||
#define LED_ASSERTION 4 /* N/C N/C ON N/C N/C N/C OFF N/C */
|
||||
#define LED_PANIC 5 /* N/C N/C N/C ON N/C N/C N/C OFF */
|
||||
#define LED_NVALUES 6
|
||||
|
||||
/* Button Definitions *******************************************************/
|
||||
/* The Sure PIC32MX board has three buttons.
|
||||
*
|
||||
* SW1 (SW_UP, left arrow) RB3 Pulled high, Grounded/low when depressed
|
||||
* SW2 (SW_DOWN, down/right arrow) RB2 Pulled high, Grounded/low when depressed
|
||||
* SW3 (SW_OK, right arrow) RB4 Pulled high, Grounded/low when depressed
|
||||
*/
|
||||
|
||||
#define BUTTON_SW1 0
|
||||
#define BUTTON_SW2 1
|
||||
#define BUTTON_SW3 2
|
||||
#define NUM_BUTTONS 3
|
||||
|
||||
#define BUTTON_SW1_BIT (1 << BUTTON_SW1)
|
||||
#define BUTTON_SW2_BIT (1 << BUTTON_SW2)
|
||||
#define BUTTON_SW3_BIT (1 << BUTTON_SW3)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@@ -124,6 +142,42 @@ extern "C" {
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Button support.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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_*_BIT
|
||||
* definitions in board.h for the meaning of each bit.
|
||||
*
|
||||
* 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
|
||||
* button enumeration value that uniquely identifies a button resource.
|
||||
* See the BUTTON_* definitions in board.h for the meaning of enumeration
|
||||
* value. The previous interrupt handler address is returned (so that it
|
||||
* may restored, if so desired).
|
||||
*
|
||||
* When an interrupt occurs, it is due to a change on the GPIO input pin
|
||||
* associated with the button. In that case, all attached change
|
||||
* notification handlers will be called. Each handler must maintain state
|
||||
* and determine if the unlying GPIO button input value changed.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
EXTERN void up_buttoninit(void);
|
||||
EXTERN uint8_t up_buttons(void);
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
EXTERN xcpt_t up_irqbutton(int id, xcpt_t irqhandler);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user