mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
cpu/nrf5x_common: make GPIO_PIN macro model independent
We can use the `GPIO_COUNT` vendor macro to check if there is more than one GPIO port on nRF52. This is the case for nRF52840 and nRF52833.
This commit is contained in:
parent
5a11fd2c66
commit
eb89482a75
@ -46,7 +46,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* The port definition is used (and zeroed) to suppress compiler warnings
|
* The port definition is used (and zeroed) to suppress compiler warnings
|
||||||
*/
|
*/
|
||||||
#if !defined(CPU_MODEL_NRF52832XXAA) && !defined(CPU_FAM_NRF51)
|
#if GPIO_COUNT > 1
|
||||||
#define GPIO_PIN(x,y) ((x << 5) | y)
|
#define GPIO_PIN(x,y) ((x << 5) | y)
|
||||||
#else
|
#else
|
||||||
#define GPIO_PIN(x,y) ((x & 0) | y)
|
#define GPIO_PIN(x,y) ((x & 0) | y)
|
||||||
|
|||||||
@ -86,7 +86,7 @@ static inline NRF_GPIO_Type *port(gpio_t pin)
|
|||||||
*/
|
*/
|
||||||
static inline int pin_num(gpio_t pin)
|
static inline int pin_num(gpio_t pin)
|
||||||
{
|
{
|
||||||
#if !defined(CPU_MODEL_NRF52832XXAA) && !defined(CPU_FAM_NRF51)
|
#if GPIO_COUNT > 1
|
||||||
return (pin & PIN_MASK);
|
return (pin & PIN_MASK);
|
||||||
#else
|
#else
|
||||||
return (int)pin;
|
return (int)pin;
|
||||||
@ -184,7 +184,7 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
|
|||||||
/* configure the GPIOTE channel: set even mode, pin and active flank */
|
/* configure the GPIOTE channel: set even mode, pin and active flank */
|
||||||
NRF_GPIOTE->CONFIG[_pin_index] = (GPIOTE_CONFIG_MODE_Event |
|
NRF_GPIOTE->CONFIG[_pin_index] = (GPIOTE_CONFIG_MODE_Event |
|
||||||
(pin_num(pin) << GPIOTE_CONFIG_PSEL_Pos) |
|
(pin_num(pin) << GPIOTE_CONFIG_PSEL_Pos) |
|
||||||
#if !defined(CPU_MODEL_NRF52832XXAA) && !defined(CPU_FAM_NRF51)
|
#if GPIO_COUNT > 1
|
||||||
((pin & PORT_BIT) << 8) |
|
((pin & PORT_BIT) << 8) |
|
||||||
#endif
|
#endif
|
||||||
(flank << GPIOTE_CONFIG_POLARITY_Pos));
|
(flank << GPIOTE_CONFIG_POLARITY_Pos));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user