From c328f805c2cceca386985193c964c36b13884e32 Mon Sep 17 00:00:00 2001 From: Alex Lewontin Date: Mon, 15 Feb 2021 11:35:01 -0500 Subject: [PATCH] NUC123: Added CONFIG enabling switch --- .../ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.h | 4 ++++ os/hal/ports/NUMICRO/NUC123/hal_lld.c | 8 +++++-- os/hal/ports/NUMICRO/NUC123/hal_lld.h | 24 +++++++++++++++++-- .../NUTINY-SDK-NUC123-V2.0/EFL/cfg/mcuconf.h | 1 + 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/os/hal/ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.h b/os/hal/ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.h index 200955c2..c49c1499 100644 --- a/os/hal/ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.h +++ b/os/hal/ports/NUMICRO/LLD/FLASHv1/hal_efl_lld.h @@ -96,6 +96,10 @@ /* Derived constants and error checks. */ /*===========================================================================*/ +#if (NUC123_EFL_ACCESS_DATAFLASH == TRUE) && (NUC123_CONFIG_ENABLED == FALSE) +#error "EFL driver data flash access requires NUC123_CONFIG_ENABLED to be set to TRUE" +#endif + /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ diff --git a/os/hal/ports/NUMICRO/NUC123/hal_lld.c b/os/hal/ports/NUMICRO/NUC123/hal_lld.c index 32862515..32548cb0 100644 --- a/os/hal/ports/NUMICRO/NUC123/hal_lld.c +++ b/os/hal/ports/NUMICRO/NUC123/hal_lld.c @@ -50,8 +50,12 @@ uint32_t SystemCoreClock = __HSI; /* System Clock Frequency (Core Clock)*/ uint32_t CyclesPerUs = (__HSI / 1000000); /* Cycles per micro second */ uint32_t PllClock = __HSI; /*!< PLL Clock Frequency */ -volatile const uint32_t config0 __attribute__((used, unused, section(".nuc123_config0"))) = NUC123_CONFIG0; -volatile const uint32_t config1 __attribute__((used, unused, section(".nuc123_config1"))) = NUC123_CONFIG1; +#if (NUC123_CONFIG_ENABLED == TRUE) + +static volatile const uint32_t config0 __attribute__((used, unused, section(".nuc123_config0"))) = NUC123_CONFIG0; +static volatile const uint32_t config1 __attribute__((used, unused, section(".nuc123_config1"))) = NUC123_CONFIG1; + +#endif /*===========================================================================*/ /* Driver local functions. */ diff --git a/os/hal/ports/NUMICRO/NUC123/hal_lld.h b/os/hal/ports/NUMICRO/NUC123/hal_lld.h index 7154ff55..7892c701 100644 --- a/os/hal/ports/NUMICRO/NUC123/hal_lld.h +++ b/os/hal/ports/NUMICRO/NUC123/hal_lld.h @@ -183,6 +183,13 @@ #define NUC123_HCLK 72000000UL #endif +/** + * @brief Enables the use of the CONFIG0/1 registers + */ +#if !defined(NUC123_CONFIG_ENABLED) || defined(__DOXYGEN__) +#define NUC123_CONFIG_ENABLED FALSE +#endif + /** * @brief Enables or disables data flash * @warning If data this is set to @p TRUE, the data flash @@ -191,10 +198,10 @@ * that the combination of the data flash & the text section still fit * into ROM. - * @note The default is @p FALSE. + * @note The default is @p TRUE. */ #if !defined(NUC123_DATAFLASH_ENABLED) || defined(__DOXYGEN__) -#define NUC123_DATAFLASH_ENABLED FALSE +#define NUC123_DATAFLASH_ENABLED TRUE #endif /** @@ -237,6 +244,19 @@ /* * Persistant configuration settings. */ + +#if (NUC123_CONFIG_ENABLED == FALSE) + +#if (NUC123_DATAFLASH_ENABLED == FALSE) +#error "Setting NUC123_DATAFLASH_ENABLED to FALSE requires NUC123_CONFIG_ENABLED to be TRUE" +#endif + +#if (NUC123_DATAFLASH_SIZE != 4096) +#error "Setting NUC123_DATAFLASH_SIZE to a value other than 4096 requires NUC123_CONFIG_ENABLED to be TRUE" +#endif + +#endif + #if (NUC123_DATAFLASH_ENABLED == TRUE) #if (NUC123_DATAFLASH_SIZE == 4096) diff --git a/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/cfg/mcuconf.h b/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/cfg/mcuconf.h index b7e52f87..08642c6b 100644 --- a/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/cfg/mcuconf.h +++ b/testhal/NUMICRO/NUC123/NUTINY-SDK-NUC123-V2.0/EFL/cfg/mcuconf.h @@ -29,6 +29,7 @@ #define NUC123_SERIAL_CLKSRC NUC123_SERIAL_CLKSRC_HSI +#define NUC123_CONFIG_ENABLED TRUE #define NUC123_DATAFLASH_ENABLED TRUE #define NUC123_DATAFLASH_SIZE 4096 #define NUC123_EFL_ACCESS_APROM TRUE