configs/tm4c1294-launchpad/src: Add IRQBUTTONS support to tm4c1294 launchpad.
This commit is contained in:
parent
37af1d4c76
commit
7d2413a6a0
@ -1552,6 +1552,7 @@ config ARCH_BOARD_TM4C1294_LAUNCHPAD
|
||||
depends on ARCH_CHIP_TM4C1294NC
|
||||
select ARCH_HAVE_LEDS
|
||||
select ARCH_HAVE_BUTTONS
|
||||
select ARCH_HAVE_IRQBUTTONS
|
||||
---help---
|
||||
Tiva EK-TM4C1294XL LaunchPad.
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/************************************************************************************
|
||||
* configs/tm4c1294-launchpad/src/ek-tm4c1294xl.h
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -122,8 +122,17 @@
|
||||
* PJ1 USR_SW2
|
||||
* --- ------------
|
||||
*/
|
||||
#define GPIO_SW1 (GPIO_FUNC_INPUT | GPIO_PORTJ | GPIO_PIN_0)
|
||||
#define GPIO_SW2 (GPIO_FUNC_INPUT | GPIO_PORTJ | GPIO_PIN_1)
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
# define GPIO_SW1 (GPIO_FUNC_INTERRUPT | GPIO_INT_BOTHEDGES | \
|
||||
GPIO_STRENGTH_2MA | GPIO_PADTYPE_STDWPU | \
|
||||
GPIO_PORTJ | GPIO_PIN_0)
|
||||
# define GPIO_SW2 (GPIO_FUNC_INTERRUPT | GPIO_INT_BOTHEDGES | \
|
||||
GPIO_STRENGTH_2MA | GPIO_PADTYPE_STDWPU | \
|
||||
GPIO_PORTJ | GPIO_PIN_1)
|
||||
#else
|
||||
# define GPIO_SW1 (GPIO_FUNC_INPUT | GPIO_PORTJ | GPIO_PIN_0)
|
||||
# define GPIO_SW2 (GPIO_FUNC_INPUT | GPIO_PORTJ | GPIO_PIN_1)
|
||||
#endif
|
||||
|
||||
/* SPI Chip selects ****************************************************************/
|
||||
/* SSI0: PA3 is used for SSI0 chip select to the second booster pack (No pull-
|
||||
|
@ -49,6 +49,10 @@
|
||||
|
||||
#include <nuttx/drivers/pwm.h>
|
||||
|
||||
#ifdef CONFIG_BUTTONS
|
||||
# include <nuttx/input/buttons.h>
|
||||
#endif
|
||||
|
||||
#include "tiva_i2c.h"
|
||||
#include "tiva_pwm.h"
|
||||
#include "tiva_qencoder.h"
|
||||
@ -306,9 +310,7 @@ static void tm4c_qei(void)
|
||||
|
||||
int tm4c_bringup(void)
|
||||
{
|
||||
#if defined(HAVE_TIMER) || defined(HAVE_HCIUART)
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
/* Register I2C drivers on behalf of the I2C tool */
|
||||
|
||||
@ -337,6 +339,8 @@ int tm4c_bringup(void)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HCIUART
|
||||
/* Register the Bluetooth HCI UART device */
|
||||
|
||||
ret = hciuart_dev_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
@ -344,5 +348,16 @@ int tm4c_bringup(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BUTTONS_LOWER
|
||||
/* Register the BUTTON driver */
|
||||
|
||||
ret = btn_lower_initialize("/dev/buttons");
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* configs/tm4c1294-launchpad/src/tm4c_buttons.c
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -96,6 +96,12 @@ void board_button_initialize(void)
|
||||
{
|
||||
tiva_configgpio(g_buttons[i]);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
/* Configure GPIO interrupts */
|
||||
|
||||
(void)tiva_gpioirqinitialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -125,4 +131,41 @@ uint32_t board_buttons(void)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_button_irq
|
||||
*
|
||||
* Description:
|
||||
* This function may be called to register an interrupt handler that will
|
||||
* be called when a button is depressed or released.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (id < 0 || id >= NUM_BUTTONS )
|
||||
{
|
||||
ret = -EINVAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Are we attaching or detaching? */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
{
|
||||
ret = tiva_gpioirqattach(g_buttons[id], irqhandler, arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = tiva_gpioirqdetach(g_buttons[id]);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
Loading…
Reference in New Issue
Block a user