Removed flags handling in CAN driver, now it is done using the new event flags.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4672 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2012-09-16 09:26:46 +00:00
parent f90a0f3790
commit c145c837da
5 changed files with 9 additions and 36 deletions

View File

@ -137,7 +137,6 @@ extern "C" {
void canStop(CANDriver *canp);
msg_t canTransmit(CANDriver *canp, const CANTxFrame *ctfp, systime_t timeout);
msg_t canReceive(CANDriver *canp, CANRxFrame *crfp, systime_t timeout);
canstatus_t canGetAndClearFlags(CANDriver *canp);
#if CAN_USE_SLEEP_MODE
void canSleep(CANDriver *canp);
void canWakeup(CANDriver *canp);

View File

@ -95,9 +95,8 @@ CH_IRQ_HANDLER(STM32_CAN1_RX0_HANDLER) {
if ((rf0r & CAN_RF0R_FOVR0) > 0) {
/* Overflow events handling.*/
CAN1->RF0R = CAN_RF0R_FOVR0;
canAddFlagsI(&CAND1, CAN_OVERFLOW_ERROR);
chSysLockFromIsr();
chEvtBroadcastI(&CAND1.error_event);
chEvtBroadcastFlagsI(&CAND1.error_event, CAN_OVERFLOW_ERROR);
chSysUnlockFromIsr();
}
@ -138,16 +137,18 @@ CH_IRQ_HANDLER(STM32_CAN1_SCE_HANDLER) {
}
/* Error event.*/
if (msr & CAN_MSR_ERRI) {
canstatus_t flags;
flagsmask_t flags;
uint32_t esr = CAN1->ESR;
CAN1->ESR &= ~CAN_ESR_LEC;
flags = (canstatus_t)(esr & 7);
flags = (flagsmask_t)(esr & 7);
if ((esr & CAN_ESR_LEC) > 0)
flags |= CAN_FRAMING_ERROR;
chSysLockFromIsr();
canAddFlagsI(&CAND1, flags | (canstatus_t)(flags < 16));
chEvtBroadcastI(&CAND1.error_event);
/* The content of the ESR register is copied unchanged in the upper
half word of the listener flags mask.*/
chEvtBroadcastFlagsI(&CAND1.error_event, flags | (flagsmask_t)(esr < 16));
chSysUnlockFromIsr();
}

View File

@ -111,11 +111,6 @@
/* Driver data structures and types. */
/*===========================================================================*/
/**
* @brief CAN status flags.
*/
typedef uint32_t canstatus_t;
/**
* @brief CAN transmission frame.
* @note Accessing the frame data as word16 or word32 is not portable because
@ -273,10 +268,6 @@ typedef struct {
* @brief A CAN bus error happened.
*/
EventSource error_event;
/**
* @brief Error flags set when an error event is broadcasted.
*/
canstatus_t status;
#if CAN_USE_SLEEP_MODE || defined (__DOXYGEN__)
/**
* @brief Entering sleep state event.

View File

@ -79,7 +79,6 @@ void canObjectInit(CANDriver *canp) {
chEvtInit(&canp->rxfull_event);
chEvtInit(&canp->txempty_event);
chEvtInit(&canp->error_event);
canp->status = 0;
#if CAN_USE_SLEEP_MODE
chEvtInit(&canp->sleep_event);
chEvtInit(&canp->wakeup_event);
@ -136,7 +135,6 @@ void canStop(CANDriver *canp) {
chSemResetI(&canp->txsem, 0);
chSchRescheduleS();
canp->state = CAN_STOP;
canp->status = 0;
chSysUnlock();
}
@ -219,24 +217,6 @@ msg_t canReceive(CANDriver *canp, CANRxFrame *crfp, systime_t timeout) {
return RDY_OK;
}
/**
* @brief Returns the current status mask and clears it.
*
* @param[in] canp pointer to the @p CANDriver object
* @return The status flags mask.
*
* @api
*/
canstatus_t canGetAndClearFlags(CANDriver *canp) {
canstatus_t status;
chSysLock();
status = canp->status;
canp->status = 0;
chSysUnlock();
return status;
}
#if CAN_USE_SLEEP_MODE || defined(__DOXYGEN__)
/**
* @brief Enters the sleep mode.

View File

@ -85,6 +85,8 @@
*** 2.5.1 ***
- FIX: Fixed Data available event not generated in serial_usb driver (bug
3567992).
- NEW: Modified the CAN drivers to use the new event flags mechanism, the
previous flags handling has been removed.
- NEW: Modified serial and serial_usb drivers to use the new event flags
mechanism, the previous flags handling in BaseAsynchronousChannel has
been removed.