From 90f32c35466c9edbd59716de66903b3f537f5abb Mon Sep 17 00:00:00 2001 From: Fabien Poussin Date: Tue, 29 Oct 2019 20:16:08 +0100 Subject: Updating FSMC driver (SRAM part) --- os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.c | 2 +- os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.h | 2 +- os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.c | 61 +++----------- os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.h | 97 ++-------------------- 4 files changed, 20 insertions(+), 142 deletions(-) (limited to 'os/hal/ports/STM32') diff --git a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.c b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.c index 5934f88..1b0c0db 100644 --- a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.c +++ b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.c @@ -34,7 +34,7 @@ defined(STM32F769xx) || defined(STM32F777xx) || \ defined(STM32F779xx)) -#if (STM32_FSMC_USE_SDRAM1 == TRUE) || (STM32_FSMC_USE_SDRAM2 == TRUE) || defined(__DOXYGEN__) +#if (HAL_USE_FSMC_SDRAM == TRUE) || defined(__DOXYGEN__) #include "hal_fsmc_sdram_lld.h" diff --git a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.h b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.h index 0e533b6..1fc7993 100644 --- a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.h +++ b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sdram_lld.h @@ -37,7 +37,7 @@ #include "hal_fsmc.h" -#if (STM32_FSMC_USE_SDRAM1 == TRUE) || (STM32_FSMC_USE_SDRAM2 == TRUE) || defined(__DOXYGEN__) +#if (HAL_USE_FSMC_SDRAM == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver constants. */ diff --git a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.c b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.c index da13ca5..49b7826 100644 --- a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.c +++ b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.c @@ -22,9 +22,10 @@ * @{ */ #include "hal.h" -#include "hal_fsmc_sram.h" -#if (STM32_USE_FSMC_SRAM == TRUE) || defined(__DOXYGEN__) +#if (HAL_USE_FSMC_SRAM == TRUE) || defined(__DOXYGEN__) + +#include "hal_fsmc_sram_lld.h" /*===========================================================================*/ /* Driver local definitions. */ @@ -36,28 +37,28 @@ /** * @brief SRAM1 driver identifier. */ -#if STM32_SRAM_USE_FSMC_SRAM1 || defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM1 || defined(__DOXYGEN__) SRAMDriver SRAMD1; #endif /** * @brief SRAM2 driver identifier. */ -#if STM32_SRAM_USE_FSMC_SRAM2 || defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM2 || defined(__DOXYGEN__) SRAMDriver SRAMD2; #endif /** * @brief SRAM3 driver identifier. */ -#if STM32_SRAM_USE_FSMC_SRAM3 || defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM3 || defined(__DOXYGEN__) SRAMDriver SRAMD3; #endif /** * @brief SRAM4 driver identifier. */ -#if STM32_SRAM_USE_FSMC_SRAM4 || defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM4 || defined(__DOXYGEN__) SRAMDriver SRAMD4; #endif @@ -81,36 +82,6 @@ SRAMDriver SRAMD4; /* Driver exported functions. */ /*===========================================================================*/ -/** - * @brief Low level SRAM driver initialization. - * - * @notapi - */ -void fsmcSramInit(void) { - - fsmc_init(); - -#if STM32_SRAM_USE_FSMC_SRAM1 - SRAMD1.sram = FSMCD1.sram1; - SRAMD1.state = SRAM_STOP; -#endif /* STM32_SRAM_USE_FSMC_SRAM1 */ - -#if STM32_SRAM_USE_FSMC_SRAM2 - SRAMD2.sram = FSMCD1.sram2; - SRAMD2.state = SRAM_STOP; -#endif /* STM32_SRAM_USE_FSMC_SRAM2 */ - -#if STM32_SRAM_USE_FSMC_SRAM3 - SRAMD3.sram = FSMCD1.sram3; - SRAMD3.state = SRAM_STOP; -#endif /* STM32_SRAM_USE_FSMC_SRAM3 */ - -#if STM32_SRAM_USE_FSMC_SRAM4 - SRAMD4.sram = FSMCD1.sram4; - SRAMD4.state = SRAM_STOP; -#endif /* STM32_SRAM_USE_FSMC_SRAM4 */ -} - /** * @brief Configures and activates the SRAM peripheral. * @@ -119,20 +90,11 @@ void fsmcSramInit(void) { * * @notapi */ -void fsmcSramStart(SRAMDriver *sramp, const SRAMConfig *cfgp) { - - if (FSMCD1.state == FSMC_STOP) - fsmc_start(&FSMCD1); - - osalDbgAssert((sramp->state == SRAM_STOP) || (sramp->state == SRAM_READY), - "invalid state"); +void lld_sram_start(SRAMDriver *sramp, const SRAMConfig *cfgp) { - if (sramp->state == SRAM_STOP) { sramp->sram->BTR = cfgp->btr; sramp->sram->BWTR = cfgp->bwtr; sramp->sram->BCR = cfgp->bcr | FSMC_BCR_MBKEN; - sramp->state = SRAM_READY; - } } /** @@ -142,9 +104,8 @@ void fsmcSramStart(SRAMDriver *sramp, const SRAMConfig *cfgp) { * * @notapi */ -void fsmcSramStop(SRAMDriver *sramp) { +void lld_sram_stop(SRAMDriver *sramp) { - if (sramp->state == SRAM_READY) { uint32_t mask = FSMC_BCR_MBKEN; #if (defined(STM32F427xx) || defined(STM32F437xx) || \ defined(STM32F429xx) || defined(STM32F439xx) || \ @@ -155,11 +116,9 @@ void fsmcSramStop(SRAMDriver *sramp) { mask |= FSMC_BCR_CCLKEN; #endif sramp->sram->BCR &= ~mask; - sramp->state = SRAM_STOP; - } } -#endif /* STM32_USE_FSMC_SRAM */ +#endif /* STM32_FSMC_USE_SRAM */ /** @} */ diff --git a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.h b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.h index 5e749a8..bfd878f 100644 --- a/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.h +++ b/os/hal/ports/STM32/LLD/FSMCv1/hal_fsmc_sram_lld.h @@ -27,7 +27,7 @@ #include "hal_fsmc.h" -#if (STM32_USE_FSMC_SRAM == TRUE) || defined(__DOXYGEN__) +#if (HAL_USE_FSMC_SRAM == TRUE) || defined(__DOXYGEN__) /*===========================================================================*/ /* Driver constants. */ @@ -41,95 +41,15 @@ * @{ */ -/** - * @brief SRAM driver enable switch. - * @details If set to @p TRUE the support for SRAM1 is included. - */ -#if !defined(STM32_SRAM_USE_FSMC_SRAM1) || defined(__DOXYGEN__) -#define STM32_SRAM_USE_FSMC_SRAM1 FALSE -#endif - -/** - * @brief SRAM driver enable switch. - * @details If set to @p TRUE the support for SRAM2 is included. - */ -#if !defined(STM32_SRAM_USE_FSMC_SRAM2) || defined(__DOXYGEN__) -#define STM32_SRAM_USE_FSMC_SRAM2 FALSE -#endif - -/** - * @brief SRAM driver enable switch. - * @details If set to @p TRUE the support for SRAM3 is included. - */ -#if !defined(STM32_SRAM_USE_FSMC_SRAM3) || defined(__DOXYGEN__) -#define STM32_SRAM_USE_FSMC_SRAM3 FALSE -#endif - -/** - * @brief SRAM driver enable switch. - * @details If set to @p TRUE the support for SRAM4 is included. - */ -#if !defined(STM32_SRAM_USE_FSMC_SRAM4) || defined(__DOXYGEN__) -#define STM32_SRAM_USE_FSMC_SRAM4 FALSE -#endif - /** @} */ /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ -#if !STM32_SRAM_USE_FSMC_SRAM1 && !STM32_SRAM_USE_FSMC_SRAM2 && \ - !STM32_SRAM_USE_FSMC_SRAM3 && !STM32_SRAM_USE_FSMC_SRAM4 -#error "SRAM driver activated but no SRAM peripheral assigned" -#endif - -#if (STM32_SRAM_USE_FSMC_SRAM1 || STM32_SRAM_USE_FSMC_SRAM2 || \ - STM32_SRAM_USE_FSMC_SRAM3 || STM32_SRAM_USE_FSMC_SRAM4) && !STM32_HAS_FSMC -#error "FSMC not present in the selected device" -#endif - /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ -/** - * @brief Driver state machine possible states. - */ -typedef enum { - SRAM_UNINIT = 0, /**< Not initialized. */ - SRAM_STOP = 1, /**< Stopped. */ - SRAM_READY = 2, /**< Ready. */ -} sramstate_t; - -/** - * @brief Type of a structure representing an NAND driver. - */ -typedef struct SRAMDriver SRAMDriver; - -/** - * @brief Driver configuration structure. - * @note It could be empty on some architectures. - * @note Some bits in BCR register will be forced by driver. - */ -typedef struct { - uint32_t bcr; - uint32_t btr; - uint32_t bwtr; -} SRAMConfig; - -/** - * @brief Structure representing an NAND driver. - */ -struct SRAMDriver { - /** - * @brief Driver state. - */ - sramstate_t state; - /** - * @brief Pointer to the FSMC SRAM registers block. - */ - FSMC_SRAM_NOR_TypeDef *sram; -}; /*===========================================================================*/ /* Driver macros. */ @@ -139,33 +59,32 @@ struct SRAMDriver { /* External declarations. */ /*===========================================================================*/ -#if STM32_SRAM_USE_FSMC_SRAM1 && !defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM1 && !defined(__DOXYGEN__) extern SRAMDriver SRAMD1; #endif -#if STM32_SRAM_USE_FSMC_SRAM2 && !defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM2 && !defined(__DOXYGEN__) extern SRAMDriver SRAMD2; #endif -#if STM32_SRAM_USE_FSMC_SRAM3 && !defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM3 && !defined(__DOXYGEN__) extern SRAMDriver SRAMD3; #endif -#if STM32_SRAM_USE_FSMC_SRAM4 && !defined(__DOXYGEN__) +#if STM32_FSMC_USE_SRAM4 && !defined(__DOXYGEN__) extern SRAMDriver SRAMD4; #endif #ifdef __cplusplus extern "C" { #endif - void fsmcSramInit(void); - void fsmcSramStart(SRAMDriver *sramp, const SRAMConfig *cfgp); - void fsmcSramStop(SRAMDriver *sramp); + void lld_sram_start(SRAMDriver *sramp, const SRAMConfig *cfgp); + void lld_sram_stop(SRAMDriver *sramp); #ifdef __cplusplus } #endif -#endif /* STM32_USE_FSMC_SRAM */ +#endif /* STM32_FSMC_USE_SRAM */ #endif /* HAL_FSMC_SRAM_H_ */ -- cgit v1.2.3