diff --git a/os/hal/include/hal_sio.h b/os/hal/include/hal_sio.h index 533afa865..c45d98f12 100644 --- a/os/hal/include/hal_sio.h +++ b/os/hal/include/hal_sio.h @@ -618,7 +618,9 @@ extern "C" { void sioObjectInit(SIODriver *siop); msg_t sioStart(SIODriver *siop, const SIOConfig *config); void sioStop(SIODriver *siop); + void sioStartOperationI(SIODriver *siop, const SIOOperation *operation); void sioStartOperation(SIODriver *siop, const SIOOperation *operation); + void sioStopOperationI(SIODriver *siop); void sioStopOperation(SIODriver *siop); void sioWriteEnableFlags(SIODriver *siop, sioflags_t flags); void sioSetEnableFlags(SIODriver *siop, sioflags_t flags); diff --git a/os/hal/lib/complex/buffered_sio/hal_buffered_sio.c b/os/hal/lib/complex/buffered_sio/hal_buffered_sio.c index ab9a601fb..43c25baff 100644 --- a/os/hal/lib/complex/buffered_sio/hal_buffered_sio.c +++ b/os/hal/lib/complex/buffered_sio/hal_buffered_sio.c @@ -156,7 +156,6 @@ msg_t bsdStart(BufferedSIODriver *bsdp, const BufferedSIOConfig *config) { osalDbgCheck(bsdp != NULL); - osalSysLock(); osalDbgAssert((bsdp->state == BS_STOP) || (bsdp->state == BS_READY), "invalid state"); @@ -167,15 +166,16 @@ msg_t bsdStart(BufferedSIODriver *bsdp, const BufferedSIOConfig *config) { msg = sioStart(bsdp->siop, config); if (msg == HAL_RET_SUCCESS) { - sioStartOperation(bsdp->siop, &bs_default_operation); + osalSysLock(); + sioStartOperationI(bsdp->siop, &bs_default_operation); + sioWriteEnableFlagsI(bsdp->siop, SIO_FL_ALL); bsdp->state = BS_READY; + osalSysUnlock(); } else { bsdp->state = BS_STOP; } - osalSysUnlock(); - return msg; } @@ -192,8 +192,6 @@ void bsdStop(BufferedSIODriver *bsdp) { osalDbgCheck(bsdp != NULL); - osalSysLock(); - osalDbgAssert((bsdp->state == BS_STOP) || (bsdp->state == BS_READY), "invalid state"); @@ -205,10 +203,10 @@ void bsdStop(BufferedSIODriver *bsdp) { bsdp->state = BS_STOP; - oqResetI(&bsdp->oqueue); + osalSysLock(); + oqResetI(&bsdp->oqueue); /* TODO should go in the upper class.*/ iqResetI(&bsdp->iqueue); osalOsRescheduleS(); - osalSysUnlock(); } diff --git a/os/hal/src/hal_sio.c b/os/hal/src/hal_sio.c index 20593b8e5..d6bccb68d 100644 --- a/os/hal/src/hal_sio.c +++ b/os/hal/src/hal_sio.c @@ -304,13 +304,12 @@ void sioStop(SIODriver *siop) { * be @p NULL if callbacks are not required * encoding the operation to be performed * - * @api + * @iclass */ -void sioStartOperation(SIODriver *siop, const SIOOperation *operation) { +void sioStartOperationI(SIODriver *siop, const SIOOperation *operation) { osalDbgCheck(siop != NULL); - - osalSysLock(); + osalDbgCheckClassI(); osalDbgAssert((siop->state == SIO_READY) || (siop->state == SIO_ACTIVE), "invalid state"); @@ -326,7 +325,7 @@ void sioStartOperation(SIODriver *siop, const SIOOperation *operation) { if (siop->state == SIO_READY) { sio_lld_start_operation(siop); - siop->state = SIO_ACTIVE; + siop->state = SIO_ACTIVE; #if SIO_USE_SYNCHRONIZATION == TRUE /* If synchronization is enabled then some events are enforced by @@ -335,7 +334,22 @@ void sioStartOperation(SIODriver *siop, const SIOOperation *operation) { SIO_FL_ALL_DATA | SIO_FL_ALL_ERRORS | SIO_FL_ALL_PROTOCOL); #endif } +} +/** + * @brief Starts a SIO operation. + * + * @param[in] siop pointer to an @p SIODriver structure + * @param[in] operation pointer to an @p SIOOperation structure, can + * be @p NULL if callbacks are not required + * encoding the operation to be performed + * + * @api + */ +void sioStartOperation(SIODriver *siop, const SIOOperation *operation) { + + osalSysLock(); + sioStartOperationI(siop, operation); osalSysUnlock(); } @@ -344,13 +358,12 @@ void sioStartOperation(SIODriver *siop, const SIOOperation *operation) { * * @param[in] siop pointer to an @p SIODriver structure * - * @api + * @iclass */ -void sioStopOperation(SIODriver *siop) { +void sioStopOperationI(SIODriver *siop) { osalDbgCheck(siop != NULL); - - osalSysLock(); + osalDbgCheckClassI(); osalDbgAssert((siop->state == SIO_READY) || (siop->state == SIO_ACTIVE), "invalid state"); @@ -369,7 +382,21 @@ void sioStopOperation(SIODriver *siop) { siop->operation = NULL; siop->state = SIO_READY; } +} +/** + * @brief Stops an ongoing SIO operation, if any. + * + * @param[in] siop pointer to an @p SIODriver structure + * + * @api + */ +void sioStopOperation(SIODriver *siop) { + + osalDbgCheck(siop != NULL); + + osalSysLock(); + sioStopOperationI(siop); osalSysUnlock(); }