diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-10-14 12:16:41 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2010-10-14 12:16:41 +0000 |
commit | a122640ac69ce3fb8ae5c6e83d9e3a912bb96c98 (patch) | |
tree | d7a15aacae11cc871036ed1c7c5c33982377c038 /os/hal/src/can.c | |
parent | 4fab7c06d1b0c9e61f6106b5b2a5c2c0b5694c34 (diff) | |
download | ChibiOS-a122640ac69ce3fb8ae5c6e83d9e3a912bb96c98.tar.gz ChibiOS-a122640ac69ce3fb8ae5c6e83d9e3a912bb96c98.tar.bz2 ChibiOS-a122640ac69ce3fb8ae5c6e83d9e3a912bb96c98.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2255 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/can.c')
-rw-r--r-- | os/hal/src/can.c | 31 |
1 files changed, 13 insertions, 18 deletions
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;
|