git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2255 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2010-10-14 12:16:41 +00:00
parent 4fab7c06d1
commit a122640ac6
3 changed files with 55 additions and 51 deletions

View File

@ -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"];

View File

@ -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();
}
}

View File

@ -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;