aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src/can.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-02 16:24:32 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-12-02 16:24:32 +0000
commitc2ad39132395d52a3894c13f978da2349f650201 (patch)
tree84ba493fbde95a6a2fb2057cdd9d60a0498b3ab3 /os/hal/src/can.c
parent3d182788ee7386b0fa53b4aee08fe8146d67d3b0 (diff)
downloadChibiOS-c2ad39132395d52a3894c13f978da2349f650201.tar.gz
ChibiOS-c2ad39132395d52a3894c13f978da2349f650201.tar.bz2
ChibiOS-c2ad39132395d52a3894c13f978da2349f650201.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1370 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src/can.c')
-rw-r--r--os/hal/src/can.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/os/hal/src/can.c b/os/hal/src/can.c
index 7c6cdd656..e4258050e 100644
--- a/os/hal/src/can.c
+++ b/os/hal/src/can.c
@@ -69,12 +69,18 @@ void canStart(CANDriver *canp, const CANConfig *config) {
chDbgCheck((canp != NULL) && (config != NULL), "canStart");
chSysLock();
- chDbgAssert((canp->cd_state == CAN_STOP) || (canp->cd_state == CAN_READY),
+ chDbgAssert((canp->cd_state == CAN_STOP) ||
+ (canp->cd_state == CAN_STARTING) ||
+ (canp->cd_state == CAN_READY),
"canStart(), #1",
"invalid state");
- canp->cd_config = config;
- can_lld_start(canp);
- canp->cd_state = CAN_READY;
+ while (canp->cd_state == CAN_STARTING)
+ chThdSleepS(1);
+ if (canp->cd_state == CAN_STOP) {
+ canp->cd_config = config;
+ can_lld_start(canp);
+ canp->cd_state = CAN_READY;
+ }
chSysUnlock();
}
@@ -145,12 +151,15 @@ msg_t canTransmit(CANDriver *canp, const CANFrame *cfp, systime_t timeout) {
* @param[out] cfp pointer to the buffer where the CAN frame is copied
* @param[in] timeout the number of ticks before the operation timeouts,
* the following special values are allowed:
- * - @a TIME_IMMEDIATE immediate timeout.
+ * - @a TIME_IMMEDIATE immediate timeout (useful in an
+ * event driven scenario where a thread never blocks
+ * for I/O).
* - @a TIME_INFINITE no 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.
+ * @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.
*/
msg_t canReceive(CANDriver *canp, CANFrame *cfp, systime_t timeout) {