diff options
-rw-r--r-- | os/hal/hal.dox | 70 | ||||
-rw-r--r-- | os/hal/platforms/STM32/can_lld.c | 5 | ||||
-rw-r--r-- | os/hal/src/can.c | 31 |
3 files changed, 55 insertions, 51 deletions
diff --git a/os/hal/hal.dox b/os/hal/hal.dox index 0af849111..308477567 100644 --- a/os/hal/hal.dox +++ b/os/hal/hal.dox @@ -440,44 +440,54 @@ digraph example {
size="5, 7";
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
- uninit [label="CAN_UNINIT", style="bold"];
+
stop [label="CAN_STOP\nLow Power"];
+ uninit [label="CAN_UNINIT", style="bold"];
+ starting [label="CAN_STARTING\nInitializing"];
ready [label="CAN_READY\nClock Enabled"];
sleep [label="CAN_SLEEP\nLow Power"];
- uninit -> stop [label="canInit()"];
- stop -> stop [label="canStop()"];
- stop -> ready [label="canStart()"];
- ready -> stop [label="canStop()"];
- ready -> ready [label="canReceive()\ncanTransmit()"];
- ready -> ready [label="canStart()"];
- ready -> sleep [label="canSleep()"];
- sleep -> sleep [label="canSleep()"];
- sleep -> ready [label="canWakeup()"];
- sleep -> ready [label="wakeup event"];
+
+ uninit -> stop [label=" canInit()", constraint=false];
+ stop -> stop [label="\ncanStop()"];
+ stop -> ready [label="\ncanStart()\n(fast implementation)"];
+ stop -> starting [label="\ncanStart()\n(slow implementation)"];
+ starting -> starting [label="\ncanStart()\n(other thread)"];
+ starting -> ready [label="\ninitialization complete\n(all threads)"];
+ ready -> stop [label="\ncanStop()"];
+ ready -> ready [label="\ncanStart()\ncanReceive()\ncanTransmit()"];
+ ready -> sleep [label="\ncanSleep()"];
+ sleep -> sleep [label="\ncanSleep()"];
+ sleep -> ready [label="\ncanWakeup()"];
+ sleep -> ready [label="\nhardware\nwakeup event"];
}
* @enddot
* @else
* @dot
digraph example {
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
- uninit [label="CAN_UNINIT", style="bold"];
+
stop [label="CAN_STOP\nLow Power"];
+ uninit [label="CAN_UNINIT", style="bold"];
+ starting [label="CAN_STARTING\nInitializing"];
ready [label="CAN_READY\nClock Enabled"];
sleep [label="CAN_SLEEP\nLow Power"];
- uninit -> stop [label="canInit()"];
- stop -> stop [label="canStop()"];
- stop -> ready [label="canStart()"];
- ready -> stop [label="canStop()"];
- ready -> ready [label="canReceive()\ncanTransmit()"];
- ready -> ready [label="canStart()"];
- ready -> sleep [label="canSleep()"];
- sleep -> sleep [label="canSleep()"];
- sleep -> ready [label="canWakeup()"];
- sleep -> ready [label="wakeup event"];
+
+ uninit -> stop [label=" canInit()", constraint=false];
+ stop -> stop [label="\ncanStop()"];
+ stop -> ready [label="\ncanStart()\n(fast implementation)"];
+ stop -> starting [label="\ncanStart()\n(slow implementation)"];
+ starting -> starting [label="\ncanStart()\n(other thread)"];
+ starting -> ready [label="\ninitialization complete\n(all threads)"];
+ ready -> stop [label="\ncanStop()"];
+ ready -> ready [label="\ncanStart()\ncanReceive()\ncanTransmit()"];
+ ready -> sleep [label="\ncanSleep()"];
+ sleep -> sleep [label="\ncanSleep()"];
+ sleep -> ready [label="\ncanWakeup()"];
+ sleep -> ready [label="\nhardware\nwakeup event"];
}
* @enddot
* @endif
@@ -510,7 +520,7 @@ * @dot
digraph example {
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
uninit [label="PWM_UNINIT", style="bold"];
stop [label="PWM_STOP\nLow Power"];
@@ -592,7 +602,7 @@ digraph example {
size="5, 7";
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
any [label="Any State"];
@@ -632,7 +642,7 @@ * @dot
digraph example {
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
any [label="Any State"];
@@ -711,7 +721,7 @@ * @dot
digraph example {
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
uninit [label="UART_UNINIT", style="bold"];
@@ -734,7 +744,7 @@ * @dot
digraph example {
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
tx_idle [label="TX_IDLE", style="bold"];
@@ -760,7 +770,7 @@ * @dot
digraph example {
rankdir="LR";
- node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.8", height="0.8"];
+ node [shape=circle, fontname=Helvetica, fontsize=8, fixedsize="true", width="0.9", height="0.9"];
edge [fontname=Helvetica, fontsize=8];
rx_idle [label="RX_IDLE", style="bold"];
diff --git a/os/hal/platforms/STM32/can_lld.c b/os/hal/platforms/STM32/can_lld.c index 526ecb98e..d8e12af9e 100644 --- a/os/hal/platforms/STM32/can_lld.c +++ b/os/hal/platforms/STM32/can_lld.c @@ -236,11 +236,10 @@ void can_lld_start(CANDriver *canp) { cfp->FR1 = 0;
cfp->FR2 = 0;
}
- cfp++;
- fmask <<= 1;
/* Gives a chance for preemption since this is a rather long loop.*/
chSysUnlock();
- chThdYield();
+ cfp++;
+ fmask <<= 1;
chSysLock();
}
}
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;
|