From fe01e7759ffe4c19c1adbf7aedce0c738fee1190 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 24 Aug 2022 08:38:02 +0000 Subject: [PATCH] Fixed some redundant code. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15735 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/ports/RP/LLD/UARTv1/hal_sio_lld.c | 7 --- os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c | 7 --- os/hal/ports/STM32/LLD/USARTv3/hal_sio_lld.c | 7 --- os/hal/ports/sandbox/hal_sio_lld.c | 62 ++++++++------------ os/hal/ports/sandbox/hal_sio_lld.h | 17 ++---- 5 files changed, 30 insertions(+), 70 deletions(-) diff --git a/os/hal/ports/RP/LLD/UARTv1/hal_sio_lld.c b/os/hal/ports/RP/LLD/UARTv1/hal_sio_lld.c index 6673a2f9c..f32e9c9da 100644 --- a/os/hal/ports/RP/LLD/UARTv1/hal_sio_lld.c +++ b/os/hal/ports/RP/LLD/UARTv1/hal_sio_lld.c @@ -197,13 +197,6 @@ msg_t sio_lld_start(SIODriver *siop) { else { osalDbgAssert(false, "invalid SIO instance"); } - - /* Driver object low level initializations.*/ -#if SIO_USE_SYNCHRONIZATION - siop->sync_rx = NULL; - siop->sync_tx = NULL; - siop->sync_txend = NULL; -#endif } /* Configures the peripheral.*/ diff --git a/os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c b/os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c index 57ae4af9e..baba49564 100644 --- a/os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c +++ b/os/hal/ports/STM32/LLD/USARTv2/hal_sio_lld.c @@ -361,13 +361,6 @@ msg_t sio_lld_start(SIODriver *siop) { else { osalDbgAssert(false, "invalid SIO instance"); } - - /* Driver object low level initializations.*/ -#if SIO_USE_SYNCHRONIZATION - siop->sync_rx = NULL; - siop->sync_tx = NULL; - siop->sync_txend = NULL; -#endif } /* Configures the peripheral.*/ diff --git a/os/hal/ports/STM32/LLD/USARTv3/hal_sio_lld.c b/os/hal/ports/STM32/LLD/USARTv3/hal_sio_lld.c index 1f0f871d9..ccdc6de4a 100644 --- a/os/hal/ports/STM32/LLD/USARTv3/hal_sio_lld.c +++ b/os/hal/ports/STM32/LLD/USARTv3/hal_sio_lld.c @@ -403,13 +403,6 @@ msg_t sio_lld_start(SIODriver *siop) { else { osalDbgAssert(false, "invalid SIO instance"); } - - /* Driver object low level initializations.*/ -#if SIO_USE_SYNCHRONIZATION - siop->sync_rx = NULL; - siop->sync_tx = NULL; - siop->sync_txend = NULL; -#endif } /* Configures the peripheral.*/ diff --git a/os/hal/ports/sandbox/hal_sio_lld.c b/os/hal/ports/sandbox/hal_sio_lld.c index 52a930cd6..65793e44d 100644 --- a/os/hal/ports/sandbox/hal_sio_lld.c +++ b/os/hal/ports/sandbox/hal_sio_lld.c @@ -63,6 +63,20 @@ static const SIOConfig default_config = { /* Driver local functions. */ /*===========================================================================*/ +__attribute__((always_inline)) +static inline uint32_t __sio_vuart_init(uint32_t nvuart, uint32_t ncfg) { + + __syscall3r(201, SB_VUART_INIT, nvuart, ncfg); + return (uint32_t)r0; +} + +__attribute__((always_inline)) +static inline uint32_t __sio_vuart_deinit(uint32_t nvuart) { + + __syscall2r(201, SB_VUART_INIT, nvuart); + return (uint32_t)r0; +} + /*===========================================================================*/ /* Driver interrupt handlers. */ /*===========================================================================*/ @@ -116,6 +130,7 @@ void sio_lld_init(void) { * @notapi */ msg_t sio_lld_start(SIODriver *siop) { + msg_t msg = HAL_RET_SUCCESS; /* Using the default configuration if the application passed a NULL pointer.*/ @@ -125,30 +140,27 @@ msg_t sio_lld_start(SIODriver *siop) { if (siop->state == SIO_STOP) { - /* Enables the peripheral.*/ + /* Enables the peripheral.*/ if (false) { } #if SB_SIO_USE_VUART1 == TRUE else if (&SIOD1 == siop) { + msg = (msg_t)__sio_vuart_init(siop->nvuart, siop->config->ncfg); } #endif #if SB_SIO_USE_VUART2 == TRUE else if (&SIOD2 == siop) { + msg = (msg_t)__sio_vuart_init(siop->nvuart, siop->config->ncfg); } #endif else { osalDbgAssert(false, "invalid SIO instance"); } - - /* Driver object low level initializations.*/ -#if SIO_USE_SYNCHRONIZATION - siop->sync_rx = NULL; - siop->sync_tx = NULL; - siop->sync_txend = NULL; -#endif } - return HAL_RET_SUCCESS; + /* Configures the peripheral.*/ + + return msg; } /** @@ -161,17 +173,17 @@ msg_t sio_lld_start(SIODriver *siop) { void sio_lld_stop(SIODriver *siop) { if (siop->state == SIO_READY) { - /* Resets the peripheral.*/ - /* Disables the peripheral.*/ if (false) { } #if SB_SIO_USE_VUART1 == TRUE else if (&SIOD1 == siop) { + (void) __sio_vuart_deinit(siop->nvuart); } #endif #if SB_SIO_USE_VUART2 == TRUE else if (&SIOD2 == siop) { + (void) __sio_vuart_deinit(siop->nvuart); } #endif else { @@ -180,30 +192,6 @@ void sio_lld_stop(SIODriver *siop) { } } -/** - * @brief Starts a SIO operation. - * - * @param[in] siop pointer to an @p SIODriver structure - * - * @api - */ -void sio_lld_start_operation(SIODriver *siop) { - - (void)siop; -} - -/** - * @brief Stops an ongoing SIO operation, if any. - * - * @param[in] siop pointer to an @p SIODriver structure - * - * @api - */ -void sio_lld_stop_operation(SIODriver *siop) { - - (void)siop; -} - /** * @brief Enable flags change notification. * @@ -212,7 +200,7 @@ void sio_lld_stop_operation(SIODriver *siop) { void sio_lld_update_enable_flags(SIODriver *siop) { (void)siop; -} + } /** * @brief Get and clears SIO error event flags. @@ -344,7 +332,7 @@ msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg) { } /** - * @brief Serves an USART interrupt. + * @brief Serves an VUART interrupt. * * @param[in] siop pointer to the @p SIODriver object * diff --git a/os/hal/ports/sandbox/hal_sio_lld.h b/os/hal/ports/sandbox/hal_sio_lld.h index bb3d3611b..4704a59f1 100644 --- a/os/hal/ports/sandbox/hal_sio_lld.h +++ b/os/hal/ports/sandbox/hal_sio_lld.h @@ -92,11 +92,6 @@ /* Driver macros. */ /*===========================================================================*/ -/** - * @brief Type of a SIO events mask. - */ -typedef uint32_t sio_events_mask_t; - /** * @brief Low level fields of the SIO driver structure. */ @@ -121,11 +116,11 @@ typedef uint32_t sio_events_mask_t; * * @notapi */ -#define sio_lld_is_rx_empty(siop) true +#define sio_lld_is_rx_empty(siop) false /** * @brief Determines the activity state of the receiver. - *(bool)(((siop)->uart->UARTFR & UART_UARTFR_RXFE) != 0U) + * * @param[in] siop pointer to the @p SIODriver object * @return The RX activity state. * @retval false if RX is in active state. @@ -133,7 +128,7 @@ typedef uint32_t sio_events_mask_t; * * @notapi */ -#define sio_lld_is_rx_idle(siop) true +#define sio_lld_is_rx_idle(siop) false /** * @brief Determines if RX has pending error events to be read and cleared. @@ -159,7 +154,7 @@ typedef uint32_t sio_events_mask_t; * * @notapi */ -#define sio_lld_is_tx_full(siop) true +#define sio_lld_is_tx_full(siop) false /** * @brief Determines the transmission state. @@ -171,7 +166,7 @@ typedef uint32_t sio_events_mask_t; * * @notapi */ -#define sio_lld_is_tx_ongoing(siop) true +#define sio_lld_is_tx_ongoing(siop) false /*===========================================================================*/ /* External declarations. */ @@ -191,8 +186,6 @@ extern "C" { void sio_lld_init(void); msg_t sio_lld_start(SIODriver *siop); void sio_lld_stop(SIODriver *siop); - void sio_lld_start_operation(SIODriver *siop); - void sio_lld_stop_operation(SIODriver *siop); void sio_lld_update_enable_flags(SIODriver *siop); sioevents_t sio_lld_get_and_clear_errors(SIODriver *siop); sioevents_t sio_lld_get_and_clear_events(SIODriver *siop);