mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Freedom K64F: Correct button support
This commit is contained in:
@@ -87,6 +87,18 @@ LEDs and Buttons
|
|||||||
LED_PANIC The system has crashed FLASH OFF OFF
|
LED_PANIC The system has crashed FLASH OFF OFF
|
||||||
LED_IDLE K64 is in sleep mode (Optional, not used)
|
LED_IDLE K64 is in sleep mode (Optional, not used)
|
||||||
|
|
||||||
|
Buttons
|
||||||
|
-------
|
||||||
|
Two push buttons, SW2 and SW3, are available on FRDM-K64F board, where
|
||||||
|
SW2 is connected to PTC6 and SW3 is connected to PTA4. Besides the
|
||||||
|
general purpose input/output functions, SW2 and SW3 can be low-power
|
||||||
|
wake up signal. Also, only SW3 can be a non-maskable interrupt.
|
||||||
|
|
||||||
|
Switch GPIO Function
|
||||||
|
--------- ---------------------------------------------------------------
|
||||||
|
SW2 PTC6/SPI0_SOUT/PD0_EXTRG/I2S0_RX_BCLK/FB_AD9/I2S0_MCLK/LLWU_P10
|
||||||
|
SW3 PTA4/FTM0_CH1/NMI_b/LLWU_P3
|
||||||
|
|
||||||
Development Environment
|
Development Environment
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
|||||||
@@ -167,17 +167,22 @@
|
|||||||
#undef LED_IDLE /* K64 is in sleep mode (Not used) */
|
#undef LED_IDLE /* K64 is in sleep mode (Not used) */
|
||||||
|
|
||||||
/* Button definitions ***************************************************************/
|
/* Button definitions ***************************************************************/
|
||||||
/* The FREEDOM-K64F has user buttons (plus a reset button):
|
/* Two push buttons, SW2 and SW3, are available on FRDM-K64F board, where SW2 is
|
||||||
|
* connected to PTC6 and SW3 is connected to PTA4. Besides the general purpose
|
||||||
|
* input/output functions, SW2 and SW3 can be low-power wake up signal. Also, only
|
||||||
|
* SW3 can be a non-maskable interrupt.
|
||||||
*
|
*
|
||||||
* 1. SW1 (IRQ0) PTA19
|
* Switch GPIO Function
|
||||||
* 2. SW2 (IRQ1) PTE26
|
* --------- ---------------------------------------------------------------
|
||||||
|
* SW2 PTC6/SPI0_SOUT/PD0_EXTRG/I2S0_RX_BCLK/FB_AD9/I2S0_MCLK/LLWU_P10
|
||||||
|
* SW3 PTA4/FTM0_CH1/NMI_b/LLWU_P3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define BUTTON_SW1 0
|
#define BUTTON_SW2 0
|
||||||
#define BUTTON_SW2 1
|
#define BUTTON_SW3 1
|
||||||
|
|
||||||
#define BUTTON_SW1_BIT (1 << BUTTON_WAKEUP)
|
#define BUTTON_SW2_BIT (1 << BUTTON_WAKEUP)
|
||||||
#define BUTTON_SW2_BIT (1 << BUTTON_TAMPER)
|
#define BUTTON_SW3_BIT (1 << BUTTON_TAMPER)
|
||||||
|
|
||||||
/* Alternative pin resolution *******************************************************/
|
/* Alternative pin resolution *******************************************************/
|
||||||
/* If there are alternative configurations for various pins in the
|
/* If there are alternative configurations for various pins in the
|
||||||
|
|||||||
@@ -62,12 +62,29 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FREEDOM-K64F GPIOs ****************************************************************/
|
/* FREEDOM-K64F GPIOs ****************************************************************/
|
||||||
|
/* A micro Secure Digital (SD) card slot is available on the FRDM-K64F connected to
|
||||||
|
* the SD Host Controller (SDHC) signals of the MCU. This slot will accept micro
|
||||||
|
* format SD memory cards. The SD card detect pin (PTE6) is an open switch that
|
||||||
|
* shorts with VDD when card is inserted.
|
||||||
|
*
|
||||||
|
* There is no Write Protect pin available to the K64F.
|
||||||
|
*/
|
||||||
|
|
||||||
#define GPIO_SD_CARDDETECT (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTE | PIN28)
|
#define GPIO_SD_CARDDETECT (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTE | PIN6)
|
||||||
#define GPIO_SD_WRPROTECT (GPIO_PULLUP | PIN_PORTE | PIN27)
|
|
||||||
|
|
||||||
#define GPIO_SW1 (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTA | PIN19)
|
/* Two push buttons, SW2 and SW3, are available on FRDM-K64F board, where SW2 is
|
||||||
#define GPIO_SW2 (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTE | PIN26)
|
* connected to PTC6 and SW3 is connected to PTA4. Besides the general purpose
|
||||||
|
* input/output functions, SW2 and SW3 can be low-power wake up signal. Also, only
|
||||||
|
* SW3 can be a non-maskable interrupt.
|
||||||
|
*
|
||||||
|
* Switch GPIO Function
|
||||||
|
* --------- ---------------------------------------------------------------
|
||||||
|
* SW2 PTC6/SPI0_SOUT/PD0_EXTRG/I2S0_RX_BCLK/FB_AD9/I2S0_MCLK/LLWU_P10
|
||||||
|
* SW3 PTA4/FTM0_CH1/NMI_b/LLWU_P3
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define GPIO_SW2 (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTC | PIN6)
|
||||||
|
#define GPIO_SW3 (GPIO_PULLUP | PIN_INT_BOTH | PIN_PORTA | PIN4)
|
||||||
|
|
||||||
/* An RGB LED is connected through GPIO as shown below:
|
/* An RGB LED is connected through GPIO as shown below:
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -53,10 +53,15 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* The TWR-K60N512 has user buttons (plus a reset button):
|
/* Two push buttons, SW2 and SW3, are available on FRDM-K64F board, where SW2 is
|
||||||
|
* connected to PTC6 and SW3 is connected to PTA4. Besides the general purpose
|
||||||
|
* input/output functions, SW2 and SW3 can be low-power wake up signal. Also, only
|
||||||
|
* SW3 can be a non-maskable interrupt.
|
||||||
*
|
*
|
||||||
* 1. SW1 (IRQ0) PTA19
|
* Switch GPIO Function
|
||||||
* 2. SW2 (IRQ1) PTE26
|
* --------- ---------------------------------------------------------------
|
||||||
|
* SW2 PTC6/SPI0_SOUT/PD0_EXTRG/I2S0_RX_BCLK/FB_AD9/I2S0_MCLK/LLWU_P10
|
||||||
|
* SW3 PTA4/FTM0_CH1/NMI_b/LLWU_P3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -78,8 +83,8 @@ void board_button_initialize(void)
|
|||||||
{
|
{
|
||||||
/* Configure the two buttons as inputs */
|
/* Configure the two buttons as inputs */
|
||||||
|
|
||||||
kinetis_pinconfig(GPIO_SW1);
|
|
||||||
kinetis_pinconfig(GPIO_SW2);
|
kinetis_pinconfig(GPIO_SW2);
|
||||||
|
kinetis_pinconfig(GPIO_SW3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -90,16 +95,16 @@ uint8_t board_buttons(void)
|
|||||||
{
|
{
|
||||||
uint8_t ret = 0;
|
uint8_t ret = 0;
|
||||||
|
|
||||||
if (kinetis_gpioread(GPIO_SW1))
|
|
||||||
{
|
|
||||||
ret |= BUTTON_SW1_BIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kinetis_gpioread(GPIO_SW2))
|
if (kinetis_gpioread(GPIO_SW2))
|
||||||
{
|
{
|
||||||
ret |= BUTTON_SW2_BIT;
|
ret |= BUTTON_SW2_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kinetis_gpioread(GPIO_SW3))
|
||||||
|
{
|
||||||
|
ret |= BUTTON_SW3_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,14 +140,14 @@ xcpt_t board_button_irq(int id, xcpt_t irqhandler)
|
|||||||
|
|
||||||
/* Map the button id to the GPIO bit set. */
|
/* Map the button id to the GPIO bit set. */
|
||||||
|
|
||||||
if (id == BUTTON_SW1)
|
if (id == BUTTON_SW2)
|
||||||
{
|
|
||||||
pinset = GPIO_SW1;
|
|
||||||
}
|
|
||||||
else if (id == BUTTON_SW2)
|
|
||||||
{
|
{
|
||||||
pinset = GPIO_SW2;
|
pinset = GPIO_SW2;
|
||||||
}
|
}
|
||||||
|
else if (id == BUTTON_SW3)
|
||||||
|
{
|
||||||
|
pinset = GPIO_SW3;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user