1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #15639 from dylad/pr/saml11/fix_iobus_gpio

cpu/saml11: fix GPIO/IOBUS management
This commit is contained in:
Kevin "Tristate Tom" Weiss 2020-12-15 20:52:29 +01:00 committed by GitHub
commit 5a1dabc025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -73,12 +73,18 @@ typedef uint32_t gpio_t;
* @brief Macro for accessing GPIO pins
* @{
*/
#ifdef CPU_FAM_SAML11
#define GPIO_PIN(x, y) (((gpio_t)(&PORT_SEC->Group[x])) | y)
#elif defined(PORT_IOBUS) /* Use IOBUS access when available */
#ifdef MODULE_PERIPH_GPIO_FAST_READ
#ifdef PORT_IOBUS_SEC
#define GPIO_PIN(x, y) (((gpio_t)(&PORT_IOBUS_SEC->Group[x])) | y)
#else /* Use IOBUS access when available */
#define GPIO_PIN(x, y) (((gpio_t)(&PORT_IOBUS->Group[x])) | y)
#endif /* PORT_IOBUS_SEC */
#else
#ifdef PORT_SEC
#define GPIO_PIN(x, y) (((gpio_t)(&PORT_SEC->Group[x])) | y)
#else
#define GPIO_PIN(x, y) (((gpio_t)(&PORT->Group[x])) | y)
#endif /* PORT_IOBUS_SEC */
#endif
/**

View File

@ -109,12 +109,17 @@ static inline PortGroup *_port_iobus(gpio_t pin)
static inline PortGroup *_port(gpio_t pin)
{
#ifdef PORT_IOBUS
#ifdef MODULE_PERIPH_GPIO_FAST_READ
/* Shift the PortGroup address back from the IOBUS region to the peripheral
* region
*/
#ifdef PORT_IOBUS_SEC
return (PortGroup *)((uintptr_t)_port_iobus(pin) -
(uintptr_t)PORT_IOBUS_SEC + (uintptr_t)PORT_SEC);
#else
return (PortGroup *)((uintptr_t)_port_iobus(pin) -
(uintptr_t)PORT_IOBUS + (uintptr_t)PORT);
#endif /* PORT_IOBUS_SEC */
#else
return _port_iobus(pin);
#endif