From aa05446b2797ab0dfe435f4bbd69fbd48b693dbb Mon Sep 17 00:00:00 2001 From: lorne-maxim <65424047+lorne-maxim@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:58:11 -0500 Subject: [PATCH 1/2] Add PinMux tool supporting functions --- .../Maxim/MAX32520/Source/system_max32520.c | 12 +++++++++ .../Maxim/MAX32570/Source/system_max32570.c | 12 +++++++++ .../Maxim/MAX32572/Source/system_max32572.c | 12 +++++++++ .../Maxim/MAX32650/Source/system_max32650.c | 12 +++++++++ .../Maxim/MAX32655/Source/system_max32655.c | 12 +++++++++ .../Maxim/MAX32660/Source/system_max32660.c | 12 +++++++++ .../Maxim/MAX32662/Source/system_max32662.c | 12 +++++++++ .../Maxim/MAX32665/Source/system_max32665.c | 12 +++++++++ .../Maxim/MAX32670/Source/system_max32670.c | 12 +++++++++ .../Maxim/MAX32672/Source/system_max32672.c | 12 +++++++++ .../Maxim/MAX32675/Source/system_max32675.c | 12 +++++++++ .../Maxim/MAX32680/Source/system_max32680.c | 12 +++++++++ .../Maxim/MAX32690/Source/system_max32690.c | 12 +++++++++ .../Maxim/MAX78000/Source/system_max78000.c | 12 +++++++++ .../Maxim/MAX78002/Source/system_max78002.c | 12 +++++++++ .../PeriphDrivers/Include/MAX32520/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32570/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32572/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32650/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32655/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32660/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32662/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32665/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32670/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32672/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32675/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32680/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX32690/gpio.h | 23 +++++++++++++++++ .../PeriphDrivers/Include/MAX78000/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Include/MAX78002/gpio.h | 22 ++++++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_ai85.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_ai87.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_common.c | 11 ++++++++ .../PeriphDrivers/Source/GPIO/gpio_common.h | 2 ++ .../PeriphDrivers/Source/GPIO/gpio_es17.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me10.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me11.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me12.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me13.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me14.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me15.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me16.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me17.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me18.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me20.c | 25 +++++++++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me21.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_me55.c | 16 ++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_reva.c | 18 +++++++++++++ .../PeriphDrivers/Source/GPIO/gpio_revb.c | 12 +++++++++ 49 files changed, 817 insertions(+) diff --git a/Libraries/CMSIS/Device/Maxim/MAX32520/Source/system_max32520.c b/Libraries/CMSIS/Device/Maxim/MAX32520/Source/system_max32520.c index b1bde766e36..4fdbbe9bca7 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32520/Source/system_max32520.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32520/Source/system_max32520.c @@ -91,6 +91,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -139,5 +150,6 @@ __weak void SystemInit(void) MXC_GPIO1->pdpu_sel0 |= 0xFFFFFFFF; MXC_GPIO1->pdpu_sel1 &= ~(0xFFFFFFFF); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32570/Source/system_max32570.c b/Libraries/CMSIS/Device/Maxim/MAX32570/Source/system_max32570.c index 40d3596fc93..8c0fc6d125d 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32570/Source/system_max32570.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32570/Source/system_max32570.c @@ -97,6 +97,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -138,5 +149,6 @@ __weak void SystemInit(void) MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0); MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32572/Source/system_max32572.c b/Libraries/CMSIS/Device/Maxim/MAX32572/Source/system_max32572.c index eb905848ac3..13d09951ed1 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32572/Source/system_max32572.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32572/Source/system_max32572.c @@ -97,6 +97,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -139,5 +150,6 @@ __weak void SystemInit(void) MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0); MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32650/Source/system_max32650.c b/Libraries/CMSIS/Device/Maxim/MAX32650/Source/system_max32650.c index e50743a909e..567c6ca19d7 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32650/Source/system_max32650.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32650/Source/system_max32650.c @@ -96,6 +96,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -177,6 +188,7 @@ __weak void SystemInit(void) MXC_SYS_ClockDisable(MXC_SYS_PERIPH_CLOCK_I2S); MXC_SYS_ClockDisable(MXC_SYS_PERIPH_CLOCK_SPIXIPR); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32655/Source/system_max32655.c b/Libraries/CMSIS/Device/Maxim/MAX32655/Source/system_max32655.c index 8b058431ce8..d269e39c513 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32655/Source/system_max32655.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32655/Source/system_max32655.c @@ -114,6 +114,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -164,6 +175,7 @@ __weak void SystemInit(void) MXC_SYS_SetClockDiv(MXC_SYS_CLOCK_DIV_1); SystemCoreClockUpdate(); + PinInit(); Board_Init(); PalSysInit(); diff --git a/Libraries/CMSIS/Device/Maxim/MAX32660/Source/system_max32660.c b/Libraries/CMSIS/Device/Maxim/MAX32660/Source/system_max32660.c index 36f669c7b2e..bb818302ff5 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32660/Source/system_max32660.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32660/Source/system_max32660.c @@ -97,6 +97,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -142,6 +153,7 @@ __weak void SystemInit(void) MXC_SYS_ClockDisable(MXC_SYS_PERIPH_CLOCK_TMR2); MXC_SYS_ClockDisable(MXC_SYS_PERIPH_CLOCK_I2C1); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32662/Source/system_max32662.c b/Libraries/CMSIS/Device/Maxim/MAX32662/Source/system_max32662.c index 9053e557baf..1d0fcd037d4 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32662/Source/system_max32662.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32662/Source/system_max32662.c @@ -121,6 +121,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -161,6 +172,7 @@ __weak void SystemInit(void) MXC_SYS_Clock_Select(MXC_SYS_CLOCK_IPO); SystemCoreClockUpdate(); + PinInit(); Board_Init(); __enable_irq(); diff --git a/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c b/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c index ced360ab52a..a7e5bb1411c 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32665/Source/system_max32665.c @@ -120,6 +120,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + // This function can be implemented by the application to initialize the board __weak int Board_Init(void) { @@ -191,6 +202,7 @@ __weak void SystemInit(void) /* Disable fast wakeup due to issues with SIMO in wakeup */ MXC_PWRSEQ->lpcn &= ~MXC_F_PWRSEQ_LPCN_FWKM; + PinInit(); Board_Init(); PalSysInit(); diff --git a/Libraries/CMSIS/Device/Maxim/MAX32670/Source/system_max32670.c b/Libraries/CMSIS/Device/Maxim/MAX32670/Source/system_max32670.c index e75afb56ae4..7b8b644d6c2 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32670/Source/system_max32670.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32670/Source/system_max32670.c @@ -102,6 +102,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -148,6 +159,7 @@ __weak void SystemInit(void) MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0); MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32672/Source/system_max32672.c b/Libraries/CMSIS/Device/Maxim/MAX32672/Source/system_max32672.c index 35991ecc2ca..fbe7fc3b453 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32672/Source/system_max32672.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32672/Source/system_max32672.c @@ -115,6 +115,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -154,5 +165,6 @@ __weak void SystemInit(void) MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0); MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32675/Source/system_max32675.c b/Libraries/CMSIS/Device/Maxim/MAX32675/Source/system_max32675.c index fed7e7dcf51..0b9b117f248 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32675/Source/system_max32675.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32675/Source/system_max32675.c @@ -117,6 +117,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -156,6 +167,7 @@ __weak void SystemInit(void) MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO0); MXC_SYS_ClockEnable(MXC_SYS_PERIPH_CLOCK_GPIO1); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX32680/Source/system_max32680.c b/Libraries/CMSIS/Device/Maxim/MAX32680/Source/system_max32680.c index fe6af4ed518..33191b596dd 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32680/Source/system_max32680.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32680/Source/system_max32680.c @@ -101,6 +101,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -143,6 +154,7 @@ __weak void SystemInit(void) MXC_SYS_SetClockDiv(MXC_SYS_CLOCK_DIV_1); SystemCoreClockUpdate(); + PinInit(); Board_Init(); PalSysInit(); diff --git a/Libraries/CMSIS/Device/Maxim/MAX32690/Source/system_max32690.c b/Libraries/CMSIS/Device/Maxim/MAX32690/Source/system_max32690.c index a5c3297c271..08c66bc3094 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX32690/Source/system_max32690.c +++ b/Libraries/CMSIS/Device/Maxim/MAX32690/Source/system_max32690.c @@ -100,6 +100,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -150,6 +161,7 @@ __weak void SystemInit(void) PalSysInit(); + PinInit(); Board_Init(); __enable_irq(); diff --git a/Libraries/CMSIS/Device/Maxim/MAX78000/Source/system_max78000.c b/Libraries/CMSIS/Device/Maxim/MAX78000/Source/system_max78000.c index 21cbe33328b..2b05de216cc 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX78000/Source/system_max78000.c +++ b/Libraries/CMSIS/Device/Maxim/MAX78000/Source/system_max78000.c @@ -97,6 +97,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -131,5 +142,6 @@ __weak void SystemInit(void) SystemCoreClockUpdate(); + PinInit(); Board_Init(); } diff --git a/Libraries/CMSIS/Device/Maxim/MAX78002/Source/system_max78002.c b/Libraries/CMSIS/Device/Maxim/MAX78002/Source/system_max78002.c index 080d75b42a5..1f153a3bd0b 100644 --- a/Libraries/CMSIS/Device/Maxim/MAX78002/Source/system_max78002.c +++ b/Libraries/CMSIS/Device/Maxim/MAX78002/Source/system_max78002.c @@ -102,6 +102,17 @@ __weak int PreInit(void) return 0; } +/* This function is called before the Board_Init function. This weak + * implementation does nothing, but you may over-ride this function in your + * program if you want to configure the state of all pins prior to the + * application running. This is useful when using external tools (like a + * Pin Mux configuration tool) that generate code to initialize the pins. + */ +__weak void PinInit(void) +{ + /* Do nothing */ +} + /* This function can be implemented by the application to initialize the board */ __weak int Board_Init(void) { @@ -133,5 +144,6 @@ __weak void SystemInit(void) SystemCoreClockUpdate(); + PinInit(); Board_Init(); } diff --git a/Libraries/PeriphDrivers/Include/MAX32520/gpio.h b/Libraries/PeriphDrivers/Include/MAX32520/gpio.h index e4f4eb499c1..9a2b4da6130 100644 --- a/Libraries/PeriphDrivers/Include/MAX32520/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32520/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -373,6 +381,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32570/gpio.h b/Libraries/PeriphDrivers/Include/MAX32570/gpio.h index 16d643f9459..51698a6bc24 100644 --- a/Libraries/PeriphDrivers/Include/MAX32570/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32570/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -373,6 +381,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32572/gpio.h b/Libraries/PeriphDrivers/Include/MAX32572/gpio.h index 6160c4d7007..bedf6886cdb 100644 --- a/Libraries/PeriphDrivers/Include/MAX32572/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32572/gpio.h @@ -191,6 +191,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -374,6 +382,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32650/gpio.h b/Libraries/PeriphDrivers/Include/MAX32650/gpio.h index fe8d78730e5..709ec65afa9 100644 --- a/Libraries/PeriphDrivers/Include/MAX32650/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32650/gpio.h @@ -180,6 +180,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -367,6 +375,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32655/gpio.h b/Libraries/PeriphDrivers/Include/MAX32655/gpio.h index 14d13cf992d..9b51de8d4a7 100644 --- a/Libraries/PeriphDrivers/Include/MAX32655/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32655/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -369,6 +377,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32660/gpio.h b/Libraries/PeriphDrivers/Include/MAX32660/gpio.h index 0ec9e92ef33..abdfbfb0666 100644 --- a/Libraries/PeriphDrivers/Include/MAX32660/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32660/gpio.h @@ -169,6 +169,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -350,6 +358,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32662/gpio.h b/Libraries/PeriphDrivers/Include/MAX32662/gpio.h index d3131883a60..dfe4ff2ffbd 100644 --- a/Libraries/PeriphDrivers/Include/MAX32662/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32662/gpio.h @@ -189,6 +189,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -368,6 +376,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32665/gpio.h b/Libraries/PeriphDrivers/Include/MAX32665/gpio.h index 4931988d60b..8f68f8f0ef0 100644 --- a/Libraries/PeriphDrivers/Include/MAX32665/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32665/gpio.h @@ -189,6 +189,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -372,6 +380,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32670/gpio.h b/Libraries/PeriphDrivers/Include/MAX32670/gpio.h index d8933256ed9..de6ea6efa9e 100644 --- a/Libraries/PeriphDrivers/Include/MAX32670/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32670/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -371,6 +379,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32672/gpio.h b/Libraries/PeriphDrivers/Include/MAX32672/gpio.h index 97b7983436a..496b33f92b0 100644 --- a/Libraries/PeriphDrivers/Include/MAX32672/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32672/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -371,6 +379,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32675/gpio.h b/Libraries/PeriphDrivers/Include/MAX32675/gpio.h index 661becff7a2..dbfe5c0ea22 100644 --- a/Libraries/PeriphDrivers/Include/MAX32675/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32675/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH ///< Interrupt triggers on either edge } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -371,6 +379,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32680/gpio.h b/Libraries/PeriphDrivers/Include/MAX32680/gpio.h index 8b6bbfd3b46..071f6d1bd59 100644 --- a/Libraries/PeriphDrivers/Include/MAX32680/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32680/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -369,6 +377,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX32690/gpio.h b/Libraries/PeriphDrivers/Include/MAX32690/gpio.h index 9f93da57f55..8cc2def4b0d 100644 --- a/Libraries/PeriphDrivers/Include/MAX32690/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32690/gpio.h @@ -191,6 +191,15 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + + /* **** Function Prototypes **** */ /** @@ -370,6 +379,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX78000/gpio.h b/Libraries/PeriphDrivers/Include/MAX78000/gpio.h index 3d33787bd67..b97fd17e7c9 100644 --- a/Libraries/PeriphDrivers/Include/MAX78000/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX78000/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -371,6 +379,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Include/MAX78002/gpio.h b/Libraries/PeriphDrivers/Include/MAX78002/gpio.h index 42203ee4f48..218a7dda19e 100644 --- a/Libraries/PeriphDrivers/Include/MAX78002/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX78002/gpio.h @@ -190,6 +190,14 @@ typedef enum { MXC_GPIO_INT_BOTH /**< Interrupt triggers on either edge */ } mxc_gpio_int_pol_t; +/** + * @brief Enumeration type for the pin configuration lock mechanism. + */ +typedef enum { + MXC_GPIO_CONFIG_UNLOCKED = 0, /**< Allow changing pins' configuration. */ + MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ +} mxc_gpio_config_lock_t; + /* **** Function Prototypes **** */ /** @@ -369,6 +377,20 @@ uint32_t MXC_GPIO_GetWakeEn(mxc_gpio_regs_t *port); */ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask); +/** + * @brief Enables/Disables the lock on all pins' configurations. If + * locked, any changes to a pin's configuration made through the + * MXC_GPIO_Config function will be ignored. + * + * @param locked Determines if changes will be allowed. */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked); + +/** + * @brief Reads the current lock state on pin configuration. + * + * @returns The lock state. */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void); + /**@} end of group gpio */ #ifdef __cplusplus diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c index a6c5c31a9d8..051e6077873 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c @@ -109,6 +109,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -413,3 +419,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c index a6c5c31a9d8..051e6077873 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c @@ -109,6 +109,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -413,3 +419,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_common.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_common.c index fad63225a52..e5717e2aea6 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_common.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_common.c @@ -29,6 +29,7 @@ static void (*callback[MXC_CFG_GPIO_INSTANCES][MXC_CFG_GPIO_PINS_PORT])(void *); static void *cbparam[MXC_CFG_GPIO_INSTANCES][MXC_CFG_GPIO_PINS_PORT]; static uint8_t initialized = 0; +static mxc_gpio_config_lock_t cfg_lock = MXC_GPIO_CONFIG_UNLOCKED; /* **** Functions **** */ int MXC_GPIO_Common_Init(uint32_t portmask) @@ -94,3 +95,13 @@ void MXC_GPIO_Common_Handler(unsigned int port) stat >>= 1; } } + +void MXC_GPIO_Common_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + cfg_lock = locked; +} + +mxc_gpio_config_lock_t MXC_GPIO_Common_GetConfigLock(void) +{ + return cfg_lock; +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_common.h b/Libraries/PeriphDrivers/Source/GPIO/gpio_common.h index ac5cdd5efa6..ecef4865ded 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_common.h +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_common.h @@ -35,6 +35,8 @@ int MXC_GPIO_Common_Init(uint32_t portmask); void MXC_GPIO_Common_RegisterCallback(const mxc_gpio_cfg_t *cfg, mxc_gpio_callback_fn callback, void *cbdata); void MXC_GPIO_Common_Handler(unsigned int port); +void MXC_GPIO_Common_SetConfigLock(mxc_gpio_config_lock_t locked); +mxc_gpio_config_lock_t MXC_GPIO_Common_GetConfigLock(void); /**@} end of group gpio */ diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c index f741c1b6e73..6a9cd34195d 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c @@ -74,6 +74,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -219,3 +225,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c index 83c5bf208ac..53108b13a88 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c @@ -101,6 +101,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int err; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel err = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (err != E_NO_ERROR) { @@ -259,3 +265,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c index 91fb1548dcc..e6cb5e95a06 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c @@ -62,6 +62,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -223,3 +229,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c index 167047828bf..9fcba714223 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c @@ -69,6 +69,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) port = MXC_GPIO_GET_IDX(cfg->port); MXC_GPIO_Init(1 << port); + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -217,3 +223,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c index b3f309284bb..23f47008923 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c @@ -98,6 +98,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -243,3 +249,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c index 7803d5f7d7a..92590a9aec9 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c @@ -78,6 +78,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -236,3 +242,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c index 8d49fc89993..bace1c6c60f 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c @@ -73,6 +73,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure alternate function error = MXC_GPIO_RevA_SetAF((mxc_gpio_reva_regs_t *)gpio, cfg->func, cfg->mask); @@ -197,3 +203,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c index 73e45fc1afe..5bb642ff25c 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c @@ -75,6 +75,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure alternate function error = MXC_GPIO_RevA_SetAF((mxc_gpio_reva_regs_t *)gpio, cfg->func, cfg->mask); if (error != E_NO_ERROR) { @@ -198,3 +204,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c index a6c5c31a9d8..051e6077873 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c @@ -109,6 +109,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -413,3 +419,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c index a7576e73b13..e424f5cba51 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c @@ -138,6 +138,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) // Initialize callback function pointers MXC_GPIO_Init(1 << port); + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel if (port < 4) { error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); @@ -443,3 +449,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c index fc5ddec7be7..bb4217d2a9e 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c @@ -81,6 +81,13 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) port = MXC_GPIO_GET_IDX(cfg->port); if (cfg->port == MXC_GPIO3) { + + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + if (cfg->mask & MXC_GPIO_PIN_0) { switch (cfg->func) { case MXC_GPIO_FUNC_IN: @@ -142,6 +149,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); } + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -368,3 +381,15 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +/* ************************************************************************** */ +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +/* ************************************************************************** */ +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c index afb9ef1f766..683481f15db 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c @@ -76,6 +76,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) port = MXC_GPIO_GET_IDX(cfg->port); MXC_GPIO_Init(1 << port); + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure alternate function error = MXC_GPIO_RevA_SetAF((mxc_gpio_reva_regs_t *)gpio, cfg->func, cfg->mask); if (error != E_NO_ERROR) { @@ -199,3 +205,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c index 009119266ce..65011974e19 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c @@ -76,6 +76,12 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel error = MXC_GPIO_SetVSSEL(gpio, cfg->vssel, cfg->mask); if (error != E_NO_ERROR) { @@ -221,3 +227,13 @@ int MXC_GPIO_SetDriveStrength(mxc_gpio_regs_t *port, mxc_gpio_drvstr_t drvstr, u { return MXC_GPIO_RevA_SetDriveStrength((mxc_gpio_reva_regs_t *)port, drvstr, mask); } + +void MXC_GPIO_SetConfigLock(mxc_gpio_config_lock_t locked) +{ + MXC_GPIO_Common_SetConfigLock(locked); +} + +mxc_gpio_config_lock_t MXC_GPIO_GetConfigLock(void) +{ + return MXC_GPIO_Common_GetConfigLock(); +} diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c index 8455802b6a4..baf64fab7e4 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c @@ -121,6 +121,12 @@ uint32_t MXC_GPIO_RevA_GetFlags(mxc_gpio_reva_regs_t *port) int MXC_GPIO_RevA_SetVSSEL(mxc_gpio_reva_regs_t *port, mxc_gpio_vssel_t vssel, uint32_t mask) { + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel switch (vssel) { case MXC_GPIO_VSSEL_VDDIO: @@ -140,6 +146,12 @@ int MXC_GPIO_RevA_SetVSSEL(mxc_gpio_reva_regs_t *port, mxc_gpio_vssel_t vssel, u int MXC_GPIO_RevA_SetAF(mxc_gpio_reva_regs_t *port, mxc_gpio_func_t func, uint32_t mask) { + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + //This is required for new devices going forward. port->inen |= mask; @@ -226,6 +238,12 @@ uint32_t MXC_GPIO_RevA_GetWakeEn(mxc_gpio_reva_regs_t *port) int MXC_GPIO_RevA_SetDriveStrength(mxc_gpio_reva_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask) { + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the drive strength. switch (drvstr) { case MXC_GPIO_DRVSTR_0: diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c index 7064344a013..0a9c6cc95dc 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c @@ -31,6 +31,12 @@ int MXC_GPIO_RevB_Config(const mxc_gpio_cfg_t *cfg, uint8_t psMask) { mxc_gpio_regs_t *gpio = cfg->port; + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Set the GPIO type switch (cfg->func) { case MXC_GPIO_FUNC_IN: @@ -198,6 +204,12 @@ uint32_t MXC_GPIO_RevB_GetFlags(mxc_gpio_regs_t *port) int MXC_GPIO_RevB_SetVSSEL(mxc_gpio_regs_t *port, mxc_gpio_vssel_t vssel, uint32_t mask) { + if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) + { + // Configuration is locked. Ignore any attempts to change it. + return E_NO_ERROR; + } + // Configure the vssel switch (vssel) { case MXC_GPIO_VSSEL_VDDIO: From c345b86f46700ce6e95b75f28ee8befffc0c156c Mon Sep 17 00:00:00 2001 From: lorne-maxim Date: Fri, 19 Apr 2024 15:57:20 +0000 Subject: [PATCH 2/2] clang-format bot reformatting. --- Libraries/PeriphDrivers/Include/MAX32690/gpio.h | 1 - Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c | 7 ++----- Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c | 3 +-- Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c | 9 +++------ Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c | 6 ++---- 18 files changed, 21 insertions(+), 44 deletions(-) diff --git a/Libraries/PeriphDrivers/Include/MAX32690/gpio.h b/Libraries/PeriphDrivers/Include/MAX32690/gpio.h index 8cc2def4b0d..096bd839f3e 100644 --- a/Libraries/PeriphDrivers/Include/MAX32690/gpio.h +++ b/Libraries/PeriphDrivers/Include/MAX32690/gpio.h @@ -199,7 +199,6 @@ typedef enum { MXC_GPIO_CONFIG_LOCKED, /**< Ignore changes to a pin's configuration. */ } mxc_gpio_config_lock_t; - /* **** Function Prototypes **** */ /** diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c index 051e6077873..e586e496114 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai85.c @@ -109,8 +109,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c index 051e6077873..e586e496114 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_ai87.c @@ -109,8 +109,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c index 6a9cd34195d..96fbd2b118c 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_es17.c @@ -74,8 +74,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c index 53108b13a88..46740343680 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me10.c @@ -101,8 +101,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int err; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c index e6cb5e95a06..b6ed678b9ce 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me11.c @@ -62,8 +62,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c index 9fcba714223..abee1ac3227 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me12.c @@ -69,8 +69,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) port = MXC_GPIO_GET_IDX(cfg->port); MXC_GPIO_Init(1 << port); - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c index 23f47008923..3b684e98083 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me13.c @@ -98,8 +98,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c index 92590a9aec9..2ab67ebb9cb 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me14.c @@ -78,8 +78,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c index bace1c6c60f..09962f49c18 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me15.c @@ -73,8 +73,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c index 5bb642ff25c..3a31217ec40 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me16.c @@ -75,8 +75,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c index 051e6077873..e586e496114 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me17.c @@ -109,8 +109,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c index e424f5cba51..0eedd4f76ec 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me18.c @@ -138,8 +138,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) // Initialize callback function pointers MXC_GPIO_Init(1 << port); - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c index bb4217d2a9e..450a1d26db4 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me20.c @@ -81,9 +81,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) port = MXC_GPIO_GET_IDX(cfg->port); if (cfg->port == MXC_GPIO3) { - - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } @@ -149,8 +147,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) MXC_GPIO_Init(1 << port); } - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c index 683481f15db..01ce3065594 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me21.c @@ -76,8 +76,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) port = MXC_GPIO_GET_IDX(cfg->port); MXC_GPIO_Init(1 << port); - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c index 65011974e19..e760363d7fc 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_me55.c @@ -76,8 +76,7 @@ int MXC_GPIO_Config(const mxc_gpio_cfg_t *cfg) int error; mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c index baf64fab7e4..aeb33c59e83 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_reva.c @@ -121,8 +121,7 @@ uint32_t MXC_GPIO_RevA_GetFlags(mxc_gpio_reva_regs_t *port) int MXC_GPIO_RevA_SetVSSEL(mxc_gpio_reva_regs_t *port, mxc_gpio_vssel_t vssel, uint32_t mask) { - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } @@ -146,8 +145,7 @@ int MXC_GPIO_RevA_SetVSSEL(mxc_gpio_reva_regs_t *port, mxc_gpio_vssel_t vssel, u int MXC_GPIO_RevA_SetAF(mxc_gpio_reva_regs_t *port, mxc_gpio_func_t func, uint32_t mask) { - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } @@ -238,8 +236,7 @@ uint32_t MXC_GPIO_RevA_GetWakeEn(mxc_gpio_reva_regs_t *port) int MXC_GPIO_RevA_SetDriveStrength(mxc_gpio_reva_regs_t *port, mxc_gpio_drvstr_t drvstr, uint32_t mask) { - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } diff --git a/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c b/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c index 0a9c6cc95dc..ab6ed1dd695 100644 --- a/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c +++ b/Libraries/PeriphDrivers/Source/GPIO/gpio_revb.c @@ -31,8 +31,7 @@ int MXC_GPIO_RevB_Config(const mxc_gpio_cfg_t *cfg, uint8_t psMask) { mxc_gpio_regs_t *gpio = cfg->port; - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; } @@ -204,8 +203,7 @@ uint32_t MXC_GPIO_RevB_GetFlags(mxc_gpio_regs_t *port) int MXC_GPIO_RevB_SetVSSEL(mxc_gpio_regs_t *port, mxc_gpio_vssel_t vssel, uint32_t mask) { - if(MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) - { + if (MXC_GPIO_GetConfigLock() == MXC_GPIO_CONFIG_LOCKED) { // Configuration is locked. Ignore any attempts to change it. return E_NO_ERROR; }