2013-12-07 14:25:35 -06:00
|
|
|
/****************************************************************************
|
2019-08-05 12:04:14 +00:00
|
|
|
* boards/pcduino-a10/src/a1x_buttons.c
|
2013-12-07 14:25:35 -06:00
|
|
|
*
|
2017-03-02 14:37:22 -06:00
|
|
|
* Copyright (C) 2013-2015, 2017 Gregory Nutt. All rights reserved.
|
2013-12-07 14:25:35 -06:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2017-03-02 14:37:22 -06:00
|
|
|
#include <errno.h>
|
2013-12-07 14:25:35 -06:00
|
|
|
|
2014-01-24 13:50:23 -06:00
|
|
|
#include <nuttx/arch.h>
|
2015-02-27 20:02:03 -06:00
|
|
|
#include <nuttx/board.h>
|
2013-12-07 14:25:35 -06:00
|
|
|
#include <nuttx/irq.h>
|
|
|
|
|
2016-02-13 12:37:46 -06:00
|
|
|
#include <nuttx/irq.h>
|
2013-12-07 14:25:35 -06:00
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
|
|
|
#include "pcduino_a10.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_BUTTONS
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-01-24 13:50:23 -06:00
|
|
|
* Name: board_button_initialize
|
2013-12-07 14:25:35 -06:00
|
|
|
*
|
|
|
|
* Description:
|
2014-01-24 13:50:23 -06:00
|
|
|
* board_button_initialize() must be called to initialize button resources. After
|
2014-01-24 13:59:24 -06:00
|
|
|
* that, board_buttons() may be called to collect the current state of all
|
2014-01-24 14:04:07 -06:00
|
|
|
* buttons or board_button_irq() may be called to register button interrupt
|
2013-12-07 14:25:35 -06:00
|
|
|
* handlers.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-01-24 13:50:23 -06:00
|
|
|
void board_button_initialize(void)
|
2013-12-07 14:25:35 -06:00
|
|
|
{
|
|
|
|
# warning Missing logic
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-01-24 13:59:24 -06:00
|
|
|
* Name: board_buttons
|
2013-12-07 14:25:35 -06:00
|
|
|
*
|
|
|
|
* Description:
|
2014-01-24 13:59:24 -06:00
|
|
|
* After board_button_initialize() has been called, board_buttons() may be called to
|
2017-04-09 14:44:49 -06:00
|
|
|
* collect the state of all buttons. board_buttons() returns an 32-bit bit set
|
2013-12-07 14:25:35 -06:00
|
|
|
* with each bit associated with a button. See the BUTTON* definitions
|
|
|
|
* above for the meaning of each bit in the returned value.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2017-04-09 07:22:49 -06:00
|
|
|
uint32_t board_buttons(void)
|
2013-12-07 14:25:35 -06:00
|
|
|
{
|
|
|
|
# warning Missing logic
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2014-01-24 14:04:07 -06:00
|
|
|
* Name: board_button_irq
|
2013-12-07 14:25:35 -06:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This function may be called to register an interrupt handler that will
|
|
|
|
* be called when a button is depressed or released. The ID value is one
|
2017-03-02 14:37:22 -06:00
|
|
|
* of the BUTTON* definitions provided above.
|
2013-12-07 14:25:35 -06:00
|
|
|
*
|
|
|
|
* Configuration Notes:
|
|
|
|
* Configuration CONFIG_ARCH_IRQBUTTONS must be selected to enable the
|
|
|
|
* overall GPIO IRQ feature.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_IRQBUTTONS
|
2017-03-02 14:37:22 -06:00
|
|
|
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
2013-12-07 14:25:35 -06:00
|
|
|
{
|
2017-03-02 14:37:22 -06:00
|
|
|
int ret = -EINVAL;
|
2013-12-07 14:25:35 -06:00
|
|
|
|
|
|
|
if (id < BOARD_NBUTTONS)
|
|
|
|
{
|
|
|
|
irqstate_t flags;
|
|
|
|
|
|
|
|
/* Disable interrupts until we are done. This guarantees that the
|
|
|
|
* following operations are atomic.
|
|
|
|
*/
|
|
|
|
|
2016-02-13 12:37:46 -06:00
|
|
|
flags = enter_critical_section();
|
2013-12-07 14:25:35 -06:00
|
|
|
|
|
|
|
/* Configure the interrupt */
|
|
|
|
|
|
|
|
a1x_pioirq(xxx);
|
2017-03-02 15:10:37 -06:00
|
|
|
(void)irq_attach(xxx, irqhandler, arg);
|
2013-12-07 14:25:35 -06:00
|
|
|
a1x_pioirqenable(xxx);
|
2016-02-13 12:37:46 -06:00
|
|
|
leave_critical_section(flags);
|
2013-12-07 14:25:35 -06:00
|
|
|
|
2017-03-02 14:37:22 -06:00
|
|
|
ret = OK;
|
|
|
|
}
|
2013-12-07 14:25:35 -06:00
|
|
|
|
2017-03-02 14:37:22 -06:00
|
|
|
return ret;
|
2013-12-07 14:25:35 -06:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_ARCH_BUTTONS */
|