git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15715 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2022-08-08 18:42:30 +00:00
parent 4699ee33fb
commit 3348f11f2c
2 changed files with 22 additions and 9 deletions

View File

@ -148,12 +148,23 @@
#if !defined(SIO_USE_SYNCHRONIZATION) || defined(__DOXYGEN__) #if !defined(SIO_USE_SYNCHRONIZATION) || defined(__DOXYGEN__)
#define SIO_USE_SYNCHRONIZATION TRUE #define SIO_USE_SYNCHRONIZATION TRUE
#endif #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. */ /* 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. */ /* Driver data structures and types. */
/*===========================================================================*/ /*===========================================================================*/
@ -233,7 +244,7 @@ struct sio_driver_vmt {
* architecture dependent, fields. * architecture dependent, fields.
*/ */
struct hal_sio_driver { struct hal_sio_driver {
#if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__) #if (SIO_USE_STREAMS_INTERFACE == TRUE) || defined(__DOXYGEN__)
/** /**
* @brief Virtual Methods Table. * @brief Virtual Methods Table.
*/ */
@ -254,12 +265,12 @@ struct hal_sio_driver {
/** /**
* @brief Current configuration data. * @brief Current configuration data.
*/ */
const SIOOperation *operation; const SIOOperation *operation;
#if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__) #if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
/** /**
* @brief Synchronization point for RX. * @brief Synchronization point for RX.
*/ */
thread_reference_t sync_rx; thread_reference_t sync_rx;
/** /**
* @brief Synchronization point for RX idle. * @brief Synchronization point for RX idle.
*/ */
@ -273,7 +284,7 @@ struct hal_sio_driver {
*/ */
thread_reference_t sync_txend; thread_reference_t sync_txend;
#endif /* SIO_USE_SYNCHRONIZATION == TRUE */ #endif /* SIO_USE_SYNCHRONIZATION == TRUE */
#if defined(SIO_DRIVER_EXT_FIELDS) #if defined(SIO_DRIVER_EXT_FIELS)
SIO_DRIVER_EXT_FIELDS SIO_DRIVER_EXT_FIELDS
#endif #endif
/* End of the mandatory fields.*/ /* End of the mandatory fields.*/

View File

@ -46,7 +46,7 @@ static const SIOOperation default_operation = {
/* Driver local functions. */ /* 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, static size_t sync_write(void *ip, const uint8_t *bp, size_t n,
sysinterval_t timeout) { sysinterval_t timeout) {
SIODriver *siop = (SIODriver *)ip; SIODriver *siop = (SIODriver *)ip;
@ -193,7 +193,7 @@ static const struct sio_driver_vmt vmt = {
__putt, __gett, __writet, __readt, __putt, __gett, __writet, __readt,
__ctl __ctl
}; };
#endif #endif /* SIO_USE_STREAMS_INTERFACE */
/*===========================================================================*/ /*===========================================================================*/
/* Driver exported functions. */ /* Driver exported functions. */
@ -220,8 +220,10 @@ void sioInit(void) {
*/ */
void sioObjectInit(SIODriver *siop) { void sioObjectInit(SIODriver *siop) {
#if SIO_USE_SYNCHRONIZATION == TRUE #if SIO_USE_STREAMS_INTERFACE == TRUE
siop->vmt = &vmt; siop->vmt = &vmt;
#endif
#if SIO_USE_SYNCHRONIZATION == TRUE
siop->sync_rx = NULL; siop->sync_rx = NULL;
siop->sync_rxidle = NULL; siop->sync_rxidle = NULL;
siop->sync_tx = NULL; siop->sync_tx = NULL;