From 568ed8d0ee46b3ada7bdf13cbb6b1a94f185d788 Mon Sep 17 00:00:00 2001 From: marcoveeneman Date: Sun, 30 Oct 2016 12:27:54 +0100 Subject: Some improvements. --- os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.c | 29 +++++++++++++---------------- os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.h | 18 +++++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) (limited to 'os/hal') diff --git a/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.c b/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.c index 09076c5..9adbf11 100644 --- a/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.c +++ b/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.c @@ -223,9 +223,6 @@ GPION_AHB_BIT | GPIOP_AHB_BIT | GPIOQ_AHB_BIT | \ GPIOR_AHB_BIT | GPIOS_AHB_BIT | GPIOT_AHB_BIT) -/* GPIO lock password.*/ -#define TIVA_GPIO_LOCK_PWD 0x4C4F434B - #define GPIOC_JTAG_MASK (0x0F) #define GPIOD_NMI_MASK (0x80) #define GPIOF_NMI_MASK (0x01) @@ -275,7 +272,7 @@ static void gpio_init(ioportid_t port, const tiva_gpio_setup_t *config) static void gpio_unlock(ioportid_t port, ioportmask_t mask) { - HWREG(port + GPIO_O_LOCK) = TIVA_GPIO_LOCK_PWD; + HWREG(port + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(port + GPIO_O_CR) = mask; } @@ -403,18 +400,18 @@ void _pal_lld_setgroupmode(ioportid_t port, ioportmask_t mask, iomode_t mode) uint32_t bit_mask = (1 << bit); if ((mask & 1) != 0) { - HWREG((port) + GPIO_O_DIR) = (HWREG((port) + GPIO_O_DIR) & ~bit_mask) | dir; - HWREG((port) + GPIO_O_AFSEL) = (HWREG((port) + GPIO_O_AFSEL) & ~bit_mask) | afsel; - HWREG((port) + GPIO_O_DR2R) = (HWREG((port) + GPIO_O_DR2R) & ~bit_mask) | dr2r; - HWREG((port) + GPIO_O_DR4R) = (HWREG((port) + GPIO_O_DR4R) & ~bit_mask) | dr4r; - HWREG((port) + GPIO_O_DR8R) = (HWREG((port) + GPIO_O_DR8R) & ~bit_mask) | dr8r; - HWREG((port) + GPIO_O_ODR) = (HWREG((port) + GPIO_O_ODR) & ~bit_mask) | odr; - HWREG((port) + GPIO_O_PUR) = (HWREG((port) + GPIO_O_PUR) & ~bit_mask) | pur; - HWREG((port) + GPIO_O_PDR) = (HWREG((port) + GPIO_O_PDR) & ~bit_mask) | pdr; - HWREG((port) + GPIO_O_SLR) = (HWREG((port) + GPIO_O_SLR) & ~bit_mask) | slr; - HWREG((port) + GPIO_O_DEN) = (HWREG((port) + GPIO_O_DEN) & ~bit_mask) | den; - HWREG((port) + GPIO_O_AMSEL) = (HWREG((port) + GPIO_O_AMSEL) & ~bit_mask) | amsel; - HWREG((port) + GPIO_O_PCTL) = (HWREG((port) + GPIO_O_PCTL) & ~pctl_mask) | pctl; + HWREG(port + GPIO_O_DIR) = (HWREG(port + GPIO_O_DIR) & ~bit_mask) | dir; + HWREG(port + GPIO_O_AFSEL) = (HWREG(port + GPIO_O_AFSEL) & ~bit_mask) | afsel; + HWREG(port + GPIO_O_DR2R) = (HWREG(port + GPIO_O_DR2R) & ~bit_mask) | dr2r; + HWREG(port + GPIO_O_DR4R) = (HWREG(port + GPIO_O_DR4R) & ~bit_mask) | dr4r; + HWREG(port + GPIO_O_DR8R) = (HWREG(port + GPIO_O_DR8R) & ~bit_mask) | dr8r; + HWREG(port + GPIO_O_ODR) = (HWREG(port + GPIO_O_ODR) & ~bit_mask) | odr; + HWREG(port + GPIO_O_PUR) = (HWREG(port + GPIO_O_PUR) & ~bit_mask) | pur; + HWREG(port + GPIO_O_PDR) = (HWREG(port + GPIO_O_PDR) & ~bit_mask) | pdr; + HWREG(port + GPIO_O_SLR) = (HWREG(port + GPIO_O_SLR) & ~bit_mask) | slr; + HWREG(port + GPIO_O_DEN) = (HWREG(port + GPIO_O_DEN) & ~bit_mask) | den; + HWREG(port + GPIO_O_AMSEL) = (HWREG(port + GPIO_O_AMSEL) & ~bit_mask) | amsel; + HWREG(port + GPIO_O_PCTL) = (HWREG(port + GPIO_O_PCTL) & ~pctl_mask) | pctl; } mask >>= 1; diff --git a/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.h b/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.h index 60af102..8f7a1f6 100644 --- a/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.h +++ b/os/hal/ports/TIVA/LLD/GPIO/hal_pal_lld.h @@ -421,55 +421,55 @@ typedef uint32_t ioportid_t; /* Derived constants and error checks. */ /*===========================================================================*/ -#if TIVA_GPIO_GPIOA_USE_AHB +#if TIVA_GPIO_GPIOA_USE_AHB && defined(TM4C123x) #define GPIOA GPIO_PORTA_AHB_BASE #else #define GPIOA GPIO_PORTA_BASE #endif -#if TIVA_GPIO_GPIOB_USE_AHB +#if TIVA_GPIO_GPIOB_USE_AHB && defined(TM4C123x) #define GPIOB GPIO_PORTB_AHB_BASE #else #define GPIOB GPIO_PORTB_BASE #endif -#if TIVA_GPIO_GPIOC_USE_AHB +#if TIVA_GPIO_GPIOC_USE_AHB && defined(TM4C123x) #define GPIOC GPIO_PORTC_AHB_BASE #else #define GPIOC GPIO_PORTC_BASE #endif -#if TIVA_GPIO_GPIOD_USE_AHB +#if TIVA_GPIO_GPIOD_USE_AHB && defined(TM4C123x) #define GPIOD GPIO_PORTD_AHB_BASE #else #define GPIOD GPIO_PORTD_BASE #endif -#if TIVA_GPIO_GPIOE_USE_AHB +#if TIVA_GPIO_GPIOE_USE_AHB && defined(TM4C123x) #define GPIOE GPIO_PORTE_AHB_BASE #else #define GPIOE GPIO_PORTE_BASE #endif -#if TIVA_GPIO_GPIOF_USE_AHB +#if TIVA_GPIO_GPIOF_USE_AHB && defined(TM4C123x) #define GPIOF GPIO_PORTF_AHB_BASE #else #define GPIOF GPIO_PORTF_BASE #endif -#if TIVA_GPIO_GPIOG_USE_AHB +#if TIVA_GPIO_GPIOG_USE_AHB && defined(TM4C123x) #define GPIOG GPIO_PORTG_AHB_BASE #else #define GPIOG GPIO_PORTG_BASE #endif -#if TIVA_GPIO_GPIOH_USE_AHB +#if TIVA_GPIO_GPIOH_USE_AHB && defined(TM4C123x) #define GPIOH GPIO_PORTH_AHB_BASE #else #define GPIOH GPIO_PORTH_BASE #endif -#if TIVA_GPIO_GPIOJ_USE_AHB +#if TIVA_GPIO_GPIOJ_USE_AHB && defined(TM4C123x) #define GPIOJ GPIO_PORTJ_AHB_BASE #else #define GPIOJ GPIO_PORTJ_BASE -- cgit v1.2.3