Add support for GPIO interrupts & STM3210E-EVAL board buttons
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2226 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
50f2fe304d
commit
c0675a0711
@ -947,3 +947,8 @@
|
||||
range!
|
||||
|
||||
0.4.14 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* arch/arm/src/stm32/stm32_gpio.c - Add support for configure an input GPIO
|
||||
to generate an EXTI interrupt.
|
||||
* config/stm3210e-eval/src/up_buttons.c - Add support for on-board buttons.
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: October 30, 2009</p>
|
||||
<p>Last Updated: November 5, 2009</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1596,6 +1596,10 @@ buildroot-0.1.7 2009-06-26 <spudmonkey@racsa.co.cr>
|
||||
<ul><pre>
|
||||
nuttx-0.4.14 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
* arch/arm/src/stm32/stm32_gpio.c - Add support for configure an input GPIO
|
||||
to generate an EXTI interrupt.
|
||||
* config/stm3210e-eval/src/up_buttons.c - Add support for on-board buttons.
|
||||
|
||||
pascal-0.1.3 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
buildroot-0.1.8 2009-xx-xx <spudmonkey@racsa.co.cr>
|
||||
|
@ -203,9 +203,24 @@ int stm32_configgpio(uint32 cfgset)
|
||||
}
|
||||
else
|
||||
{
|
||||
/* It is an input pin... If it is pull-down or pull up,
|
||||
* then we need to set the ODR appropriately for that
|
||||
* function.
|
||||
/* It is an input pin... Should it configured as an EXTI interrupt? */
|
||||
|
||||
if ((cfgset & GPIO_EXTI) != 0)
|
||||
{
|
||||
int shift;
|
||||
|
||||
/* Yes.. Set the bits in the EXTI CR register */
|
||||
|
||||
regaddr = STM32_AFIO_EXTICR(pin);
|
||||
regval = getreg32(regaddr);
|
||||
shift = AFIO_EXTICR_EXTI_SHIFT(pin);
|
||||
regval &= ~(AFIO_EXTICR_PORT_MASK << shift);
|
||||
regval |= (((uint32)port) << shift);
|
||||
putreg32(regval, regaddr);
|
||||
}
|
||||
|
||||
/* If it is pull-down or pull up, then we need to set the ODR
|
||||
* appropriately for that function.
|
||||
*/
|
||||
|
||||
if ((cfgset & GPIO_CNF_MASK) == GPIO_CNF_INPULLUP)
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
#define STM32_AFIO_EVCR_OFFSET 0x0000 /* Event control register */
|
||||
#define STM32_AFIO_MAPR_OFFSET 0x0004 /* AF remap and debug I/O configuration register */
|
||||
#define STM32_AFIO_EXTICR_OFFSET(p) (0x0008 + ((p) >> 2))
|
||||
#define STM32_AFIO_EXTICR1_OFFSET 0x0008 /* External interrupt configuration register 1 */
|
||||
#define STM32_AFIO_EXTICR2_OFFSET 0x000c /* External interrupt configuration register 2 */
|
||||
#define STM32_AFIO_EXTICR3_OFFSET 0x0010 /* External interrupt configuration register 3 */
|
||||
@ -141,6 +142,7 @@
|
||||
|
||||
#define STM32_AFIO_EVCR (STM32_AFIO_BASE+STM32_AFIO_EVCR_OFFSET)
|
||||
#define STM32_AFIO_MAPR (STM32_AFIO_BASE+STM32_AFIO_MAPR_OFFSET)
|
||||
#define STM32_AFIO_EXTICR(p) (STM32_AFIO_BASE+STM32_AFIO_EXTICR_OFFSET(p))
|
||||
#define STM32_AFIO_EXTICR1 (STM32_AFIO_BASE+STM32_AFIO_EXTICR1_OFFSET)
|
||||
#define STM32_AFIO_EXTICR2 (STM32_AFIO_BASE+STM32_AFIO_EXTICR3_OFFSET)
|
||||
#define STM32_AFIO_EXTICR3 (STM32_AFIO_BASE+STM32_AFIO_EXTICR3_OFFSET)
|
||||
@ -312,53 +314,59 @@
|
||||
|
||||
/* External interrupt configuration register 1 */
|
||||
|
||||
#define AFIO_EXTICR_PORT_MASK (0x0f)
|
||||
#define AFIO_EXTICR_EXTI_SHIFT(g) (((g) & 3) << 2)
|
||||
#define AFIO_EXTICR_EXTI_MASK(g) (AFIO_EXTICR_PORT_MASK << (AFIO_EXTICR_EXTI_SHIFT(g)))
|
||||
|
||||
#define AFIO_EXTICR1_EXTI0_SHIFT (0) /* Bits 3-0: EXTI 0 configuration */
|
||||
#define AFIO_EXTICR1_EXTI0_MASK (0x0f << AFIO_EXTICR1_EXTI0_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI0_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR1_EXTI0_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI1_SHIFT (4) /* Bits 7-4: EXTI 1 configuration */
|
||||
#define AFIO_EXTICR1_EXTI1_MASK (0x0f << AFIO_EXTICR1_EXTI1_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI1_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR1_EXTI1_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI2_SHIFT (8) /* Bits 11-8: EXTI 2 configuration */
|
||||
#define AFIO_EXTICR1_EXTI2_MASK (0x0f << AFIO_EXTICR1_EXTI2_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI2_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR1_EXTI2_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI3_SHIFT (12) /* Bits 15-12: EXTI 3 configuration */
|
||||
#define AFIO_EXTICR1_EXTI3_MASK (0x0f << AFIO_EXTICR1_EXTI3_SHIFT)
|
||||
#define AFIO_EXTICR1_EXTI3_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR1_EXTI3_SHIFT)
|
||||
|
||||
#define AFIO_EXTICR_PORTA (0) /* 0000: PA[x] pin */
|
||||
#define AFIO_EXTICR_PORTB (1) /* 0001: PB[x] pin */
|
||||
#define AFIO_EXTICR_PORTC (2) /* 0010: PC[x] pin */
|
||||
#define AFIO_EXTICR_PORTD (3) /* 0011: PD[x] pin */
|
||||
#define AFIO_EXTICR_PORTE (4) /* 0100: PE[x] pin */
|
||||
#define AFIO_EXTICR_PORTF (5) /* 0101: PF[x] pin */
|
||||
#define AFIO_EXTICR_PORTG (6) /* 0110: PG[x] pin */
|
||||
|
||||
/* External interrupt configuration register 2 */
|
||||
|
||||
#define AFIO_EXTICR2_EXTI4_SHIFT (0) /* Bits 3-0: EXTI 4 configuration */
|
||||
#define AFIO_EXTICR2_EXTI4_MASK (0x0f << AFIO_EXTICR2_EXTI4_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI4_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR2_EXTI4_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI5_SHIFT (4) /* Bits 7-4: EXTI 5 configuration */
|
||||
#define AFIO_EXTICR2_EXTI5_MASK (0x0f << AFIO_EXTICR2_EXTI5_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI5_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR2_EXTI5_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI6_SHIFT (8) /* Bits 11-8: EXTI 6 configuration */
|
||||
#define AFIO_EXTICR2_EXTI6_MASK (0x0f << AFIO_EXTICR2_EXTI6_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI6_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR2_EXTI6_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI7_SHIFT (12) /* Bits 15-12: EXTI 7 configuration */
|
||||
#define AFIO_EXTICR2_EXTI7_MASK (0x0f << AFIO_EXTICR2_EXTI7_SHIFT)
|
||||
#define AFIO_EXTICR2_EXTI7_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR2_EXTI7_SHIFT)
|
||||
|
||||
/* External interrupt configuration register 3 */
|
||||
|
||||
#define AFIO_EXTICR3_EXTI8_SHIFT (0) /* Bits 3-0: EXTI 8 configuration */
|
||||
#define AFIO_EXTICR3_EXTI8_MASK (0x0f << AFIO_EXTICR3_EXTI8_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI8_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR3_EXTI8_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI9_SHIFT (4) /* Bits 7-4: EXTI 9 configuration */
|
||||
#define AFIO_EXTICR3_EXTI9_MASK (0x0f << AFIO_EXTICR3_EXTI9_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI9_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR3_EXTI9_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI10_SHIFT (8) /* Bits 11-8: EXTI 10 configuration */
|
||||
#define AFIO_EXTICR3_EXTI10_MASK (0x0f << AFIO_EXTICR3_EXTI10_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI10_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR3_EXTI10_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI11_SHIFT (12) /* Bits 15-12: EXTI 11 configuration */
|
||||
#define AFIO_EXTICR3_EXTI11_MASK (0x0f << AFIO_EXTICR3_EXTI11_SHIFT)
|
||||
#define AFIO_EXTICR3_EXTI11_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR3_EXTI11_SHIFT)
|
||||
|
||||
/* External interrupt configuration register 4 */
|
||||
|
||||
#define AFIO_EXTICR4_EXTI12_SHIFT (0) /* Bits 3-0: EXTI 12 configuration */
|
||||
#define AFIO_EXTICR4_EXTI12_MASK (0x0f << AFIO_EXTICR4_EXTI12_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI12_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR4_EXTI12_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI13_SHIFT (4) /* Bits 7-4: EXTI 13 configuration */
|
||||
#define AFIO_EXTICR4_EXTI13_MASK (0x0f << AFIO_EXTICR4_EXTI13_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI13_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR4_EXTI13_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI14_SHIFT (8) /* Bits 11-8: EXTI 14 configuration */
|
||||
#define AFIO_EXTICR4_EXTI14_MASK (0x0f << AFIO_EXTICR4_EXTI14_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI14_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR4_EXTI14_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI15_SHIFT (12) /* Bits 15-12: EXTI 15 configuration */
|
||||
#define AFIO_EXTICR4_EXTI15_MASK (0x0f << AFIO_EXTICR4_EXTI15_SHIFT)
|
||||
#define AFIO_EXTICR4_EXTI15_MASK (AFIO_EXTICR_PORT_MASK << AFIO_EXTICR4_EXTI15_SHIFT)
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
|
@ -59,7 +59,7 @@
|
||||
/* Bit-encoded input to stm32_configgpio() *******************************************/
|
||||
|
||||
/* 16-bit Encoding:
|
||||
* OFFS S... VPPP BBBB
|
||||
* OFFS SX.. VPPP BBBB
|
||||
*/
|
||||
|
||||
/* Output mode:
|
||||
@ -99,6 +99,12 @@
|
||||
# define GPIO_MODE_2MHz (2 << GPIO_MODE_SHIFT) /* Output mode, max speed 2 MHz */
|
||||
# define GPIO_MODE_50MHz (3 << GPIO_MODE_SHIFT) /* Output mode, max speed 50 MHz */
|
||||
|
||||
/* External interrupt selection (GPIO inputs only):
|
||||
* .... .X.. .... ....
|
||||
*/
|
||||
|
||||
#define GPIO_EXTI (1 << 10) /* Bit 10: Configure as EXTI interrupt */
|
||||
|
||||
/* If the pin is an GPIO digital output, then this identifies the initial output value:
|
||||
* .... .... V... ....
|
||||
*/
|
||||
|
@ -60,6 +60,7 @@
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader.
|
||||
# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
|
||||
# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture.
|
||||
# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
|
||||
# cause a 100 second delay during boot-up. This 100 second delay
|
||||
# serves no purpose other than it allows you to calibrate
|
||||
@ -83,6 +84,7 @@ CONFIG_ARCH_INTERRUPTSTACK=n
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_BOOTLOADER=n
|
||||
CONFIG_ARCH_LEDS=y
|
||||
CONFIG_ARCH_BUTTONS=n
|
||||
CONFIG_ARCH_CALIBRATION=n
|
||||
|
||||
#
|
||||
|
@ -102,12 +102,51 @@
|
||||
#define LED_ASSERTION 6 /* LED1 + LED2 + LED3 */
|
||||
#define LED_PANIC 7 /* N/C + N/C + N/C + LED4 */
|
||||
|
||||
/* The STM3210E-EVAL supports several buttons
|
||||
*
|
||||
* Reset -- Connected to NRST
|
||||
* Wakeup -- Connected to PA.0
|
||||
* Tamper -- Connected to PC.13
|
||||
* Key -- Connected to PG.8
|
||||
*
|
||||
* And a Joystick
|
||||
*
|
||||
* Joystick center -- Connected to PG.7
|
||||
* Joystick down -- Connected to PD.3
|
||||
* Joystick left -- Connected to PG.14
|
||||
* Joystick right -- Connected to PG.13
|
||||
* Joystick up -- Connected to PG.15
|
||||
*/
|
||||
|
||||
#define BUTTON_WAKEUP (1 << 0)
|
||||
#define BUTTON_TAMPER (1 << 1)
|
||||
#define BUTTON_KEY (1 << 2)
|
||||
|
||||
#define JOYSTICK_SEL (1 << 3)
|
||||
#define JOYSTICK_DOWN (1 << 4)
|
||||
#define JOYSTICK_LEFT (1 << 5)
|
||||
#define JOYSTICK_RIGHT (1 << 6)
|
||||
#define JOYSTICK_UP (1 << 7)
|
||||
|
||||
#define NUM_BUTTONS 8
|
||||
|
||||
/************************************************************************************
|
||||
* Public Function Prototypes
|
||||
* Public Data
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Public Function Prototypes
|
||||
************************************************************************************/
|
||||
/************************************************************************************
|
||||
* Name: stm32_boardinitialize
|
||||
*
|
||||
@ -118,7 +157,28 @@
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
extern void stm32_boardinitialize(void);
|
||||
EXTERN void stm32_boardinitialize(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Button support.
|
||||
*
|
||||
* Description:
|
||||
* up_buttoninit() must be called to initialize button resources. After that,
|
||||
* 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_* and JOYSTICK_* definitions above for the meaning of each bit.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
EXTERN void up_buttoninit(void);
|
||||
EXTERN ubyte up_buttons(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __ARCH_BOARD_BOARD_H */
|
||||
|
@ -60,6 +60,7 @@
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader.
|
||||
# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
|
||||
# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture.
|
||||
# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
|
||||
# cause a 100 second delay during boot-up. This 100 second delay
|
||||
# serves no purpose other than it allows you to calibrate
|
||||
@ -83,6 +84,7 @@ CONFIG_ARCH_INTERRUPTSTACK=n
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_BOOTLOADER=n
|
||||
CONFIG_ARCH_LEDS=y
|
||||
CONFIG_ARCH_BUTTONS=n
|
||||
CONFIG_ARCH_CALIBRATION=n
|
||||
|
||||
#
|
||||
|
@ -60,6 +60,7 @@
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader.
|
||||
# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
|
||||
# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture.
|
||||
# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
|
||||
# cause a 100 second delay during boot-up. This 100 second delay
|
||||
# serves no purpose other than it allows you to calibrate
|
||||
@ -83,6 +84,7 @@ CONFIG_ARCH_INTERRUPTSTACK=n
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_BOOTLOADER=n
|
||||
CONFIG_ARCH_LEDS=y
|
||||
CONFIG_ARCH_BUTTONS=n
|
||||
CONFIG_ARCH_CALIBRATION=n
|
||||
|
||||
#
|
||||
|
@ -39,8 +39,9 @@ CFLAGS += -I$(TOPDIR)/sched
|
||||
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
CSRCS = up_boot.c up_leds.c up_spi.c up_usbdev.c up_extcontext.c \
|
||||
up_selectnor.c up_deselectnor.c up_selectsram.c up_deselectsram.c
|
||||
CSRCS = up_boot.c up_leds.c up_buttons.c up_spi.c up_usbdev.c \
|
||||
up_extcontext.c up_selectnor.c up_deselectnor.c \
|
||||
up_selectsram.c up_deselectsram.c
|
||||
ifeq ($(CONFIG_EXAMPLES_NSH_ARCHINIT),y)
|
||||
CSRCS += up_nsh.c
|
||||
endif
|
||||
|
@ -72,7 +72,26 @@
|
||||
#define GPIO_LED3 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN8)
|
||||
#define GPIO_LED4 (GPIO_OUTPUT|GPIO_CNF_OUTPP|GPIO_MODE_50MHz|\
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN9)
|
||||
GPIO_OUTPUT_CLEAR|GPIO_PORTF|GPIO_PIN9)
|
||||
|
||||
/* BUTTONS -- NOTE that some have EXTI interrupts configured */
|
||||
|
||||
#define GPIO_BTN_WAKEUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_BTN_TAMPER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_PORTA|GPIO_PIN0)
|
||||
#define GPIO_BTN_KEY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
|
||||
#define GPIO_JOY_KEY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTG|GPIO_PIN7)
|
||||
#define GPIO_JOY_DOWN (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTD|GPIO_PIN3)
|
||||
#define GPIO_JOY_LEFT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTG|GPIO_PIN14)
|
||||
#define GPIO_JOY_RIGHT (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTG|GPIO_PIN13)
|
||||
#define GPIO_JOY_UP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
|
||||
GPIO_EXTI|GPIO_PORTG|GPIO_PIN15)
|
||||
|
||||
/* SPI FLASH chip select: PA.4 */
|
||||
|
||||
|
112
configs/stm3210e-eval/src/up_buttons.c
Normal file
112
configs/stm3210e-eval/src/up_buttons.c
Normal file
@ -0,0 +1,112 @@
|
||||
/****************************************************************************
|
||||
* configs/stm3210e-eval/src/up_leds.c
|
||||
*
|
||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* 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 <sys/types.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include "stm3210e-internal.h"
|
||||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const uint16 g_buttons[NUM_BUTTONS] =
|
||||
{
|
||||
GPIO_BTN_WAKEUP, GPIO_BTN_TAMPER, GPIO_BTN_KEY, GPIO_JOY_KEY,
|
||||
GPIO_JOY_DOWN, GPIO_JOY_LEFT, GPIO_JOY_RIGHT, GPIO_JOY_UP
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_buttoninit
|
||||
****************************************************************************/
|
||||
|
||||
void up_buttoninit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Configure the GPIO pins as inputs. NOTE that EXTI interrupts are
|
||||
* configured for some pins but NOT used in this file
|
||||
*/
|
||||
|
||||
for (i = 0; i < NUM_BUTTONS; i++)
|
||||
{
|
||||
stm32_configgpio(g_buttons[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_buttons
|
||||
****************************************************************************/
|
||||
|
||||
ubyte up_buttons(void)
|
||||
{
|
||||
ubyte ret = 0;
|
||||
int i;
|
||||
|
||||
/* Check that state of each key */
|
||||
|
||||
for (i = 0; i < NUM_BUTTONS; i++)
|
||||
{
|
||||
/* A LOW value means that the key is pressed */
|
||||
|
||||
if (!stm32_gpioread(g_buttons[i]))
|
||||
{
|
||||
ret |= (1 << i);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
@ -60,6 +60,7 @@
|
||||
# CONFIG_ARCH_STACKDUMP - Do stack dumps after assertions
|
||||
# CONFIG_ARCH_BOOTLOADER - Set if you are using a bootloader.
|
||||
# CONFIG_ARCH_LEDS - Use LEDs to show state. Unique to board architecture.
|
||||
# CONFIG_ARCH_BUTTONS - Enable support for buttons. Unique to board architecture.
|
||||
# CONFIG_ARCH_CALIBRATION - Enables some build in instrumentation that
|
||||
# cause a 100 second delay during boot-up. This 100 second delay
|
||||
# serves no purpose other than it allows you to calibrate
|
||||
@ -83,6 +84,7 @@ CONFIG_ARCH_INTERRUPTSTACK=n
|
||||
CONFIG_ARCH_STACKDUMP=y
|
||||
CONFIG_ARCH_BOOTLOADER=n
|
||||
CONFIG_ARCH_LEDS=y
|
||||
CONFIG_ARCH_BUTTONS=n
|
||||
CONFIG_ARCH_CALIBRATION=n
|
||||
|
||||
#
|
||||
|
@ -59,7 +59,7 @@ graphics/nxsu
|
||||
single user front-end is selected when CONFIG_NX_MULTIUSER is not defined in the
|
||||
NuttX configuration file.
|
||||
|
||||
graphics/nxsu
|
||||
graphics/nxmu
|
||||
This is the NX multi user "front end". When combined with the generic "back-end"
|
||||
(nxbe), it implements a multi-threaded, multi-user windowing system. The files
|
||||
in this directory present the window APIs described in include/nuttx/nx.h. The
|
||||
|
Loading…
x
Reference in New Issue
Block a user