From c05c319615ed82fba86be398fab11c0bba5ad9d6 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 11 Aug 2019 06:59:23 +0000 Subject: [PATCH] Made bus acquire/release functions in SNOR driver public. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12946 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- .../lib/complex/serial_nor/hal_serial_nor.c | 102 +++++++++--------- .../lib/complex/serial_nor/hal_serial_nor.h | 7 ++ readme.txt | 1 + 3 files changed, 57 insertions(+), 53 deletions(-) diff --git a/os/hal/lib/complex/serial_nor/hal_serial_nor.c b/os/hal/lib/complex/serial_nor/hal_serial_nor.c index 695b0fd32..82d90835e 100644 --- a/os/hal/lib/complex/serial_nor/hal_serial_nor.c +++ b/os/hal/lib/complex/serial_nor/hal_serial_nor.c @@ -66,59 +66,6 @@ static const struct SNORDriverVMT snor_vmt = { /* Driver local functions. */ /*===========================================================================*/ -#if ((SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI) && \ - (SNOR_SHARED_BUS == TRUE)) || defined(__DOXYGEN__) -/** - * @brief Bus acquisition and lock. - * - * @param[in] busp pointer to the bus driver - * @param[in] config bus configuration - * - * @notapi - */ -static void bus_acquire(BUSDriver *busp, const BUSConfig *config) { - - (void)config; - - wspiAcquireBus(busp); - if (busp->config != config) { - wspiStart(busp, config); - } -} - -/** - * @brief Bus release. - * - * @param[in] busp pointer to the bus driver - * - * @notapi - */ -static void bus_release(BUSDriver *busp) { - - wspiReleaseBus(busp); -} - -#elif (SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_SPI) && \ - (SNOR_SHARED_BUS == TRUE) -void bus_acquire(BUSDriver *busp, const BUSConfig *config) { - - spiAcquireBus(busp); - if (busp->config != config) { - spiStart(busp, config); - } -} - -void bus_release(BUSDriver *busp) { - - spiReleaseBus(busp); -} - -#else -/* No bus sharing, empty macros.*/ -#define bus_acquire(busp) -#define bus_release(busp) -#endif - /** * @brief Returns a pointer to the device descriptor. * @@ -358,6 +305,55 @@ static flash_error_t snor_read_sfdp(void *instance, flash_offset_t offset, /* Driver exported functions. */ /*===========================================================================*/ +#if ((SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_WSPI) && \ + (SNOR_SHARED_BUS == TRUE)) || defined(__DOXYGEN__) +/** + * @brief Bus acquisition and lock. + * + * @param[in] busp pointer to the bus driver + * @param[in] config bus configuration + * + * @notapi + */ +void bus_acquire(BUSDriver *busp, const BUSConfig *config) { + + (void)config; + + wspiAcquireBus(busp); + if (busp->config != config) { + wspiStart(busp, config); + } +} + +/** + * @brief Bus release. + * + * @param[in] busp pointer to the bus driver + * + * @notapi + */ +void bus_release(BUSDriver *busp) { + + wspiReleaseBus(busp); +} +#endif + +#if (SNOR_BUS_DRIVER == SNOR_BUS_DRIVER_SPI) && \ + (SNOR_SHARED_BUS == TRUE) +void bus_acquire(BUSDriver *busp, const BUSConfig *config) { + + spiAcquireBus(busp); + if (busp->config != config) { + spiStart(busp, config); + } +} + +void bus_release(BUSDriver *busp) { + + spiReleaseBus(busp); +} +#endif + /** * @brief Stops the underlying bus driver. * diff --git a/os/hal/lib/complex/serial_nor/hal_serial_nor.h b/os/hal/lib/complex/serial_nor/hal_serial_nor.h index a463b52db..d43db214b 100644 --- a/os/hal/lib/complex/serial_nor/hal_serial_nor.h +++ b/os/hal/lib/complex/serial_nor/hal_serial_nor.h @@ -144,6 +144,11 @@ typedef struct { /* Driver macros. */ /*===========================================================================*/ +#if SNOR_SHARED_BUS == FALSE +#define bus_acquire(busp) +#define bus_release(busp) +#endif + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ @@ -151,6 +156,8 @@ typedef struct { #ifdef __cplusplus extern "C" { #endif + void bus_acquire(BUSDriver *busp, const BUSConfig *config); + void bus_release(BUSDriver *busp); void bus_cmd(BUSDriver *busp, uint32_t cmd); void bus_cmd_send(BUSDriver *busp, uint32_t cmd, size_t n, const uint8_t *p); void bus_cmd_receive(BUSDriver *busp, diff --git a/readme.txt b/readme.txt index 2f450d422..b12b223ea 100644 --- a/readme.txt +++ b/readme.txt @@ -74,6 +74,7 @@ ***************************************************************************** *** Next *** +- NEW: Made bus acquire/release functions in SNOR driver public. - NEW: Added mcuconf.h generator for STM32L052/L053/L062/L063. - NEW: Added mcuconf.h generator for STM32L072/L073. - NEW: Initial STM32G0xx support in HAL.