From 3348f11f2c5e5117f9d72f28e259c4db66ee51f6 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 8 Aug 2022 18:42:30 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15715 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/include/hal_sio.h | 23 +++++++++++++++++------ os/hal/src/hal_sio.c | 8 +++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/os/hal/include/hal_sio.h b/os/hal/include/hal_sio.h index 32c7c8637..42bb649e0 100644 --- a/os/hal/include/hal_sio.h +++ b/os/hal/include/hal_sio.h @@ -148,12 +148,23 @@ #if !defined(SIO_USE_SYNCHRONIZATION) || defined(__DOXYGEN__) #define SIO_USE_SYNCHRONIZATION TRUE #endif + +/** + * @brief Support for streams interfacwe. + */ +#if !defined(SIO_USE_STREAMS_INTERFACE) || defined(__DOXYGEN__) +#define SIO_USE_STREAMS_INTERFACE SIO_USE_SYNCHRONIZATION +#endif /** @} */ /*===========================================================================*/ /* Derived constants and error checks. */ /*===========================================================================*/ +#if (SIO_USE_STREAMS_INTERFACE == TRUE) && (SIO_USE_SYNCHRONIZATION == FALSE) +#error "SIO_USE_STREAMS_INTERFACE requires SIO_USE_SYNCHRONIZATION" +#endif + /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ @@ -233,7 +244,7 @@ struct sio_driver_vmt { * architecture dependent, fields. */ struct hal_sio_driver { -#if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__) +#if (SIO_USE_STREAMS_INTERFACE == TRUE) || defined(__DOXYGEN__) /** * @brief Virtual Methods Table. */ @@ -254,12 +265,12 @@ struct hal_sio_driver { /** * @brief Current configuration data. */ - const SIOOperation *operation; + const SIOOperation *operation; #if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__) /** - * @brief Synchronization point for RX. - */ - thread_reference_t sync_rx; + * @brief Synchronization point for RX. + */ + thread_reference_t sync_rx; /** * @brief Synchronization point for RX idle. */ @@ -273,7 +284,7 @@ struct hal_sio_driver { */ thread_reference_t sync_txend; #endif /* SIO_USE_SYNCHRONIZATION == TRUE */ -#if defined(SIO_DRIVER_EXT_FIELDS) +#if defined(SIO_DRIVER_EXT_FIELS) SIO_DRIVER_EXT_FIELDS #endif /* End of the mandatory fields.*/ diff --git a/os/hal/src/hal_sio.c b/os/hal/src/hal_sio.c index 52d667055..20593b8e5 100644 --- a/os/hal/src/hal_sio.c +++ b/os/hal/src/hal_sio.c @@ -46,7 +46,7 @@ static const SIOOperation default_operation = { /* Driver local functions. */ /*===========================================================================*/ -#if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__) +#if (SIO_USE_STREAMS_INTERFACE == TRUE) || defined(__DOXYGEN__) static size_t sync_write(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout) { SIODriver *siop = (SIODriver *)ip; @@ -193,7 +193,7 @@ static const struct sio_driver_vmt vmt = { __putt, __gett, __writet, __readt, __ctl }; -#endif +#endif /* SIO_USE_STREAMS_INTERFACE */ /*===========================================================================*/ /* Driver exported functions. */ @@ -220,8 +220,10 @@ void sioInit(void) { */ void sioObjectInit(SIODriver *siop) { -#if SIO_USE_SYNCHRONIZATION == TRUE +#if SIO_USE_STREAMS_INTERFACE == TRUE siop->vmt = &vmt; +#endif +#if SIO_USE_SYNCHRONIZATION == TRUE siop->sync_rx = NULL; siop->sync_rxidle = NULL; siop->sync_tx = NULL;