From a122640ac69ce3fb8ae5c6e83d9e3a912bb96c98 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 14 Oct 2010 12:16:41 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2255 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/can.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'os/hal/src') diff --git a/os/hal/src/can.c b/os/hal/src/can.c index a1fb237f3..ec907de97 100644 --- a/os/hal/src/can.c +++ b/os/hal/src/can.c @@ -81,6 +81,9 @@ void canObjectInit(CANDriver *canp) { /** * @brief Configures and activates the CAN peripheral. + * @note Activating the CAN bus can be a slow operation this this function + * is not atomic, it waits internally for the initialization to + * complete. * * @param[in] canp pointer to the @p CANDriver object * @param[in] config pointer to the @p CANConfig object @@ -95,8 +98,7 @@ void canStart(CANDriver *canp, const CANConfig *config) { chDbgAssert((canp->cd_state == CAN_STOP) || (canp->cd_state == CAN_STARTING) || (canp->cd_state == CAN_READY), - "canStart(), #1", - "invalid state"); + "canStart(), #1", "invalid state"); while (canp->cd_state == CAN_STARTING) chThdSleepS(1); if (canp->cd_state == CAN_STOP) { @@ -120,8 +122,7 @@ void canStop(CANDriver *canp) { chSysLock(); chDbgAssert((canp->cd_state == CAN_STOP) || (canp->cd_state == CAN_READY), - "canStop(), #1", - "invalid state"); + "canStop(), #1", "invalid state"); can_lld_stop(canp); chSemResetI(&canp->cd_rxsem, 0); chSemResetI(&canp->cd_txsem, 0); @@ -146,8 +147,8 @@ void canStop(CANDriver *canp) { * . * @return The operation result. * @retval RDY_OK the frame has been queued for transmission. - * @retval RDY_TIMEOUT operation not finished within the specified time. - * @retval RDY_RESET driver stopped while waiting. + * @retval RDY_TIMEOUT The operation has timed out. + * @retval RDY_RESET The driver has been stopped while waiting. * * @api */ @@ -157,8 +158,7 @@ msg_t canTransmit(CANDriver *canp, const CANTxFrame *ctfp, systime_t timeout) { chSysLock(); chDbgAssert((canp->cd_state == CAN_READY) || (canp->cd_state == CAN_SLEEP), - "canTransmit(), #1", - "invalid state"); + "canTransmit(), #1", "invalid state"); while ((canp->cd_state == CAN_SLEEP) || !can_lld_can_transmit(canp)) { msg_t msg = chSemWaitTimeoutS(&canp->cd_txsem, timeout); if (msg != RDY_OK) { @@ -187,10 +187,8 @@ msg_t canTransmit(CANDriver *canp, const CANTxFrame *ctfp, systime_t timeout) { * . * @return The operation result. * @retval RDY_OK a frame has been received and placed in the buffer. - * @retval RDY_TIMEOUT operation not finished within the specified time or - * frame not immediately available if invoked using - * @p TIME_IMMEDIATE. - * @retval RDY_RESET driver stopped while waiting. + * @retval RDY_TIMEOUT The operation has timed out. + * @retval RDY_RESET The driver has been stopped while waiting. * * @api */ @@ -200,8 +198,7 @@ msg_t canReceive(CANDriver *canp, CANRxFrame *crfp, systime_t timeout) { chSysLock(); chDbgAssert((canp->cd_state == CAN_READY) || (canp->cd_state == CAN_SLEEP), - "canReceive(), #1", - "invalid state"); + "canReceive(), #1", "invalid state"); while ((canp->cd_state == CAN_SLEEP) || !can_lld_can_receive(canp)) { msg_t msg = chSemWaitTimeoutS(&canp->cd_rxsem, timeout); if (msg != RDY_OK) { @@ -251,8 +248,7 @@ void canSleep(CANDriver *canp) { chSysLock(); chDbgAssert((canp->cd_state == CAN_READY) || (canp->cd_state == CAN_SLEEP), - "canSleep(), #1", - "invalid state"); + "canSleep(), #1", "invalid state"); if (canp->cd_state == CAN_READY) { can_lld_sleep(canp); canp->cd_state = CAN_SLEEP; @@ -275,8 +271,7 @@ void canWakeup(CANDriver *canp) { chSysLock(); chDbgAssert((canp->cd_state == CAN_READY) || (canp->cd_state == CAN_SLEEP), - "canWakeup(), #1", - "invalid state"); + "canWakeup(), #1", "invalid state"); if (canp->cd_state == CAN_SLEEP) { can_lld_wakeup(canp); canp->cd_state = CAN_READY; -- cgit v1.2.3