periph: generalized button macros

This commit is contained in:
smlng 2017-06-20 21:11:34 +02:00
parent 30be4f7673
commit de948189c3
39 changed files with 179 additions and 100 deletions

View File

@ -16,6 +16,7 @@
* @brief Board specific configuration for the Calliope mini * @brief Board specific configuration for the Calliope mini
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -61,7 +62,9 @@ extern "C" {
* @{ * @{
*/ */
#define BTN0_PIN GPIO_PIN(0, 17) #define BTN0_PIN GPIO_PIN(0, 17)
#define BTN0_MODE GPIO_IN
#define BTN1_PIN GPIO_PIN(0, 26) #define BTN1_PIN GPIO_PIN(0, 26)
#define BTN1_MODE GPIO_IN
/** @} */ /** @} */
/** /**

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -33,13 +34,13 @@ static const saul_gpio_params_t saul_gpio_params[] =
{ {
{ {
.name = "Button A", .name = "Button A",
.pin = BTN0_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
}, },
{ {
.name = "Button B", .name = "Button B",
.pin = BTN1_PIN, .pin = BTN1_PIN,
.mode = GPIO_IN .mode = BTN1_MODE
}, },
}; };

View File

@ -16,6 +16,7 @@
* @brief Board configuration for the CC2650STK * @brief Board configuration for the CC2650STK
* *
* @author Leon M. George <leon@georgemail.eu> * @author Leon M. George <leon@georgemail.eu>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -38,8 +39,10 @@ extern "C" {
* @name On-board button configuration * @name On-board button configuration
* @{ * @{
*/ */
#define BUTTON1_DIO GPIO_PIN(0, 4) #define BTN0_PIN GPIO_PIN(0, 4)
#define BUTTON2_DIO GPIO_PIN(0, 0) #define BTN0_MODE GPIO_IN
#define BTN1_PIN GPIO_PIN(0, 0)
#define BTN1_MODE GPIO_IN
/** @} */ /** @} */
/** /**

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the maple-mini board * @brief Board specific definitions for the maple-mini board
* *
* @author Frits Kuipers <frits.kuipers@gmail.com> * @author Frits Kuipers <frits.kuipers@gmail.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -49,8 +50,11 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_B, 8) #define BTN0_PIN GPIO_PIN(PORT_B, 8)
#define BTN0_MODE GPIO_IN
/** @} */
/** /**
* @brief Use the USART1 for STDIO on this board * @brief Use the USART1 for STDIO on this board

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Frits Kuipers <frits.kuipers@gmail.com> * @author Frits Kuipers <frits.kuipers@gmail.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -38,8 +39,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "BUTTON", .name = "BUTTON",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
} }
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific configuration for the BBC micro:bit * @brief Board specific configuration for the BBC micro:bit
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -61,7 +62,9 @@ extern "C" {
* @{ * @{
*/ */
#define BTN0_PIN GPIO_PIN(0, 17) #define BTN0_PIN GPIO_PIN(0, 17)
#define BTN0_MODE GPIO_IN
#define BTN1_PIN GPIO_PIN(0, 26) #define BTN1_PIN GPIO_PIN(0, 26)
#define BTN1_MODE GPIO_IN
/** @} */ /** @} */
/** /**

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -33,13 +34,13 @@ static const saul_gpio_params_t saul_gpio_params[] =
{ {
{ {
.name = "Button A", .name = "Button A",
.pin = BTN0_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
}, },
{ {
.name = "Button B", .name = "Button B",
.pin = BTN1_PIN, .pin = BTN1_PIN,
.mode = GPIO_IN .mode = BTN1_MODE
}, },
}; };

View File

@ -15,7 +15,7 @@
* @brief Board specific configuration for the nRF52840 DK * @brief Board specific configuration for the nRF52840 DK
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -63,10 +63,14 @@ extern "C" {
* @name Button pin configuration * @name Button pin configuration
* @{ * @{
*/ */
#define BUTTON1_PIN (GPIO_PIN(0, 11)) #define BTN0_PIN GPIO_PIN(0, 11)
#define BUTTON2_PIN (GPIO_PIN(0, 12)) #define BTN0_MODE GPIO_IN_PU
#define BUTTON3_PIN (GPIO_PIN(0, 24)) #define BTN1_PIN GPIO_PIN(0, 12)
#define BUTTON4_PIN (GPIO_PIN(0, 25)) #define BTN1_MODE GPIO_IN_PU
#define BTN2_PIN GPIO_PIN(0, 24)
#define BTN2_MODE GPIO_IN_PU
#define BTN3_PIN GPIO_PIN(0, 25)
#define BTN3_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -14,7 +14,7 @@
* @brief Configuration of SAUL mapped GPIO pins * @brief Configuration of SAUL mapped GPIO pins
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -54,23 +54,23 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button 1", .name = "Button 1",
.pin = BUTTON1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
{ {
.name = "Button 2", .name = "Button 2",
.pin = BUTTON2_PIN, .pin = BTN1_PIN,
.mode = GPIO_IN_PU .mode = BTN1_MODE
}, },
{ {
.name = "Button 3", .name = "Button 3",
.pin = BUTTON3_PIN, .pin = BTN2_PIN,
.mode = GPIO_IN_PU .mode = BTN2_MODE
}, },
{ {
.name = "Button 4", .name = "Button 4",
.pin = BUTTON4_PIN, .pin = BTN3_PIN,
.mode = GPIO_IN_PU .mode = BTN3_MODE
} }
}; };

View File

@ -15,7 +15,7 @@
* @brief Board specific configuaration for the nRF52 DK * @brief Board specific configuaration for the nRF52 DK
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -62,10 +62,14 @@ extern "C" {
* @name Button pin configuration * @name Button pin configuration
* @{ * @{
*/ */
#define BUTTON1_PIN (GPIO_PIN(0, 13)) #define BTN0_PIN GPIO_PIN(0, 13)
#define BUTTON2_PIN (GPIO_PIN(0, 14)) #define BTN0_MODE GPIO_IN_PU
#define BUTTON3_PIN (GPIO_PIN(0, 15)) #define BTN1_PIN GPIO_PIN(0, 14)
#define BUTTON4_PIN (GPIO_PIN(0, 16)) #define BTN1_MODE GPIO_IN_PU
#define BTN2_PIN GPIO_PIN(0, 15)
#define BTN2_MODE GPIO_IN_PU
#define BTN3_PIN GPIO_PIN(0, 16)
#define BTN3_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -14,7 +14,7 @@
* @brief Configuration of SAUL mapped GPIO pins * @brief Configuration of SAUL mapped GPIO pins
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -54,23 +54,23 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button 1", .name = "Button 1",
.pin = BUTTON1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
{ {
.name = "Button 2", .name = "Button 2",
.pin = BUTTON2_PIN, .pin = BTN1_PIN,
.mode = GPIO_IN_PU .mode = BTN1_MODE
}, },
{ {
.name = "Button 3", .name = "Button 3",
.pin = BUTTON3_PIN, .pin = BTN2_PIN,
.mode = GPIO_IN_PU .mode = BTN2_MODE
}, },
{ {
.name = "Button 4", .name = "Button 4",
.pin = BUTTON4_PIN, .pin = BTN3_PIN,
.mode = GPIO_IN_PU .mode = BTN3_MODE
} }
}; };

View File

@ -16,6 +16,7 @@
* @brief Common pin definitions and board configuration options * @brief Common pin definitions and board configuration options
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_COMMON_H #ifndef BOARD_COMMON_H
@ -48,8 +49,11 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) #define BTN0_PIN GPIO_PIN(PORT_C, 13)
#define BTN0_MODE GPIO_IN_PU
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Alexandre Abadie <alexandre.abadie@inria.fr> * @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -40,8 +41,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
#endif #endif
{ {
.name = "Button(B1 User)", .name = "Button(B1 User)",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
}; };

View File

@ -18,6 +18,7 @@
* *
* @author Alexandre Abadie <alexandre.abadie@inria.fr> * @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Vincent Dupont <vincent@otakeys.com> * @author Vincent Dupont <vincent@otakeys.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_COMMON_H #ifndef BOARD_COMMON_H
@ -56,8 +57,11 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) #define BTN0_PIN GPIO_PIN(PORT_C, 13)
#define BTN0_MODE GPIO_IN_PD
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Alexandre Abadie <alexandre.abadie@inria.fr> * @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -48,8 +49,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "B1(User button)", .name = "B1(User button)",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PD .mode = BTN0_MODE
} }
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the OpenCM9.04 board * @brief Board specific definitions for the OpenCM9.04 board
* *
* @author Loïc Dauphin <loic.dauphin@inria.fr> * @author Loïc Dauphin <loic.dauphin@inria.fr>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -49,8 +50,11 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_C, 15) #define BTN0_PIN GPIO_PIN(PORT_C, 15)
#define BTN0_MODE GPIO_IN
/** @} */
/** /**
* @brief Pin used to switch RX and TX mode for the Dynamixel TTL bus * @brief Pin used to switch RX and TX mode for the Dynamixel TTL bus

View File

@ -17,6 +17,7 @@
* @brief Board specific definitions for the phyWAVE evaluation board * @brief Board specific definitions for the phyWAVE evaluation board
* *
* @author Johann Fischer <j.fischer@phytec.de> * @author Johann Fischer <j.fischer@phytec.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -59,18 +60,18 @@ extern "C"
* @name Macro for button S1/S2. * @name Macro for button S1/S2.
* @{ * @{
*/ */
#define BUTTON_PORT PORTD #define BTN0_PORT PORTD
#define BUTTON_PIN 1 #define BTN0_PIN GPIO_PIN(PORT_D, 1)
#define BUTTON_GPIO GPIO_PIN(PORT_D, BUTTON_PIN) #define BTN0_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**
* @name Macro for capacitive sensor button. * @name Macro for capacitive sensor button.
* @{ * @{
*/ */
#define CS_BUTTON_PORT PORTC #define BTN1_PORT PORTC
#define CS_BUTTON_PIN 6 #define BTN1_PIN GPIO_PIN(PORT_C, 6)
#define CS_BUTTON_GPIO GPIO_PIN(PORT_C, CS_BUTTON_PIN) #define BTN1_MODE GPIO_IN
/** @} */ /** @} */
/** /**

View File

@ -48,13 +48,13 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button(SW0)", .name = "Button(SW0)",
.pin = BUTTON_GPIO, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
{ {
.name = "Button(CS0)", .name = "Button(CS0)",
.pin = CS_BUTTON_GPIO, .pin = BTN1_PIN,
.mode = GPIO_IN .mode = BTN1_MODE
}, },
}; };

View File

@ -17,7 +17,8 @@
* @brief Board specific definitions for the Re-Mote board prototype A * @brief Board specific definitions for the Re-Mote board prototype A
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* Antonio Lignan <alinan@zolertia.com> * @author Antonio Lignan <alinan@zolertia.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -60,6 +61,7 @@
* @{ * @{
*/ */
#define BTN0_PIN GPIO_PIN(0, 3) #define BTN0_PIN GPIO_PIN(0, 3)
#define BTN0_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -13,7 +13,7 @@
* @file * @file
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author smlng <s@mlng.net> * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -48,8 +48,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button(User)", .name = "Button(User)",
.pin = BTN0_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
}; };

View File

@ -17,7 +17,8 @@
* @brief Board specific definitions for the RE-Mote board Revision A * @brief Board specific definitions for the RE-Mote board Revision A
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* Antonio Lignan <alinan@zolertia.com> * @author Antonio Lignan <alinan@zolertia.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -60,6 +61,7 @@
* @{ * @{
*/ */
#define BTN0_PIN GPIO_PIN(0, 3) #define BTN0_PIN GPIO_PIN(0, 3)
#define BTN0_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -13,7 +13,7 @@
* @file * @file
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author smlng <s@mlng.net> * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -48,8 +48,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button(User)", .name = "Button(User)",
.pin = BTN0_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
}; };

View File

@ -17,7 +17,8 @@
* @brief Board specific definitions for the RE-Mote board Revision B * @brief Board specific definitions for the RE-Mote board Revision B
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* Antonio Lignan <alinan@zolertia.com> * @author Antonio Lignan <alinan@zolertia.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -60,6 +61,7 @@
* @{ * @{
*/ */
#define BTN0_PIN GPIO_PIN(0, 3) #define BTN0_PIN GPIO_PIN(0, 3)
#define BTN0_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -13,7 +13,7 @@
* @file * @file
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author smlng <s@mlng.net> * @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -48,8 +48,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button(User)", .name = "Button(User)",
.pin = BTN0_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
}; };

View File

@ -17,7 +17,7 @@
* *
* @author Travis Griggs <travisgriggs@gmail.com> * @author Travis Griggs <travisgriggs@gmail.com>
* @author Dan Evans <photonthunder@gmail.com> * @author Dan Evans <photonthunder@gmail.com>
* * @author Sebastian Meiling <s@mlng.net>
* @} * @}
*/ */
@ -30,7 +30,7 @@ void board_init(void)
gpio_init(LED0_PIN, GPIO_OUT); gpio_init(LED0_PIN, GPIO_OUT);
/* initialize the on-board button */ /* initialize the on-board button */
gpio_init(BUTTON_GPIO, GPIO_IN_PU); gpio_init(BTN0_PIN, BTN0_MODE);
/* initialize the CPU */ /* initialize the CPU */
cpu_init(); cpu_init();

View File

@ -19,6 +19,7 @@
* *
* @author Travis Griggs <travisgriggs@gmail.com> * @author Travis Griggs <travisgriggs@gmail.com>
* @author Dan Evans <photonthunder@gmail.com> * @author Dan Evans <photonthunder@gmail.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -58,9 +59,9 @@ extern "C" {
* @name SW0 (Button) pin definitions * @name SW0 (Button) pin definitions
* @{ * @{
*/ */
#define BUTTON_PORT PORT->Group[PA] #define BTN0_PORT PORT->Group[PA]
#define BUTTON_PIN (15) #define BTN0_PIN GPIO_PIN(PA, 15)
#define BUTTON_GPIO GPIO_PIN(PA, BUTTON_PIN) #define BTN0_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -16,6 +16,7 @@
* *
* @author Travis Griggs <travisgriggs@gmail.com> * @author Travis Griggs <travisgriggs@gmail.com>
* @author Dan Evans <photonthunder@gmail.com> * @author Dan Evans <photonthunder@gmail.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -40,8 +41,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button(SW0)", .name = "Button(SW0)",
.pin = BUTTON_GPIO, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the Atmel SAM L21 Xplained Pro board. * @brief Board specific definitions for the Atmel SAM L21 Xplained Pro board.
* *
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -42,9 +43,14 @@ extern "C" {
/** @} */ /** @} */
/** /**
* @brief User button pin * @name SW0 (Button) pin definitions
* @{
*/ */
#define SW0_PIN GPIO_PIN(PA, 2) #define BTN0_PORT PORT->Group[PA]
#define BTN0_PIN GPIO_PIN(PA, 2)
#define BTN0_MODE GPIO_IN_PU
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -17,6 +17,7 @@
* board * board
* *
* @author Thomas Eichinger <thomas.eichinger@fu-berlin.de> * @author Thomas Eichinger <thomas.eichinger@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -68,9 +69,9 @@ extern "C" {
* @name SW0 (Button) pin definitions * @name SW0 (Button) pin definitions
* @{ * @{
*/ */
#define BUTTON_PORT PORT->Group[0] #define BTN0_PORT PORT->Group[0]
#define BUTTON_PIN (28) #define BTN0_PIN GPIO_PIN(0, 28)
#define BUTTON_GPIO GPIO_PIN(0, BUTTON_PIN) #define BTN0_MODE GPIO_IN_PU
/** @} */ /** @} */
/** /**

View File

@ -16,6 +16,7 @@
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Kaspar Schleiser <kaspar@schleiser.de> * @author Kaspar Schleiser <kaspar@schleiser.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -40,8 +41,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "Button(SW0)", .name = "Button(SW0)",
.pin = BUTTON_GPIO, .pin = BTN0_PIN,
.mode = GPIO_IN_PU .mode = BTN0_MODE
}, },
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the STM32F0Discovery evaluation board. * @brief Board specific definitions for the STM32F0Discovery evaluation board.
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -49,8 +50,11 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) #define BTN0_PIN GPIO_PIN(PORT_A, 0)
#define BTN0_MODE GPIO_IN
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -16,6 +16,7 @@
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Alexandre Abadie <alexandre.abadie@inria.fr> * @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -45,8 +46,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "BTN USER", .name = "BTN USER",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
}, },
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the STM32F3Discovery evaluation board * @brief Board specific definitions for the STM32F3Discovery evaluation board
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -85,8 +86,12 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) #define BTN0_PIN GPIO_PIN(PORT_A, 0)
#define BTN0_MODE GPIO_IN
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -73,8 +74,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "BTN USER", .name = "BTN USER",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
}, },
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the STM32F4Discovery evaluation board * @brief Board specific definitions for the STM32F4Discovery evaluation board
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -78,8 +79,12 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) #define BTN0_PIN GPIO_PIN(PORT_A, 0)
#define BTN0_MODE GPIO_IN
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -16,6 +16,7 @@
* *
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> * @author Hauke Petersen <hauke.petersen@fu-berlin.de>
* @author Alexandre Abadie <alexandre.abadie@inria.fr> * @author Alexandre Abadie <alexandre.abadie@inria.fr>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -55,8 +56,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "BTN USER", .name = "BTN USER",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
}, },
}; };

View File

@ -16,6 +16,7 @@
* @brief Board specific definitions for the stm32f769 Discovery board * @brief Board specific definitions for the stm32f769 Discovery board
* *
* @author Vincent Dupont <vincent@otakeys.com> * @author Vincent Dupont <vincent@otakeys.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef BOARD_H #ifndef BOARD_H
@ -65,8 +66,12 @@ extern "C" {
/** /**
* @brief User button * @brief User button
* @{
*/ */
#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) #define BTN0_PIN GPIO_PIN(PORT_A, 0)
#define BTN0_MODE GPIO_IN
/** @} */
/** /**
* @brief Initialize board specific hardware, including clock, LEDs and std-IO * @brief Initialize board specific hardware, including clock, LEDs and std-IO

View File

@ -14,6 +14,7 @@
* @brief Board specific configuration of direct mapped GPIOs * @brief Board specific configuration of direct mapped GPIOs
* *
* @author Vincent Dupont <vincent@otakeys.com> * @author Vincent Dupont <vincent@otakeys.com>
* @author Sebastian Meiling <s@mlng.net>
*/ */
#ifndef GPIO_PARAMS_H #ifndef GPIO_PARAMS_H
@ -53,8 +54,8 @@ static const saul_gpio_params_t saul_gpio_params[] =
}, },
{ {
.name = "BTN USER", .name = "BTN USER",
.pin = BTN_B1_PIN, .pin = BTN0_PIN,
.mode = GPIO_IN .mode = BTN0_MODE
}, },
}; };

View File

@ -98,11 +98,12 @@ extern "C" {
* @name User button configuration * @name User button configuration
* @{ * @{
*/ */
#define USER_BTN_PxIN P2IN #define BTN0_PIN P2IN
#define USER_BTN_MASK 0x20 #define BTN0_MASK (0x20)
#define BTN0_MODE GPIO_IN
#define USER_BTN_PRESSED ((USER_BTN_PxIN & USER_BTN_MASK) == 0) #define BTN0_PRESSED ((BTN0_PIN & BTN0_MASK) == 0)
#define USER_BTN_RELEASED ((USER_BTN_PxIN & USER_BTN_MASK) != 0) #define BTN0_RELEASED ((BTN0_PIN & BTN0_MASK) != 0)
/** @} */ /** @} */
/** /**