git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8614 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2015-12-17 13:21:06 +00:00
parent 56e47668d5
commit 75967a3288
3 changed files with 23 additions and 3 deletions

View File

@ -255,8 +255,10 @@ static void can_lld_rx1_handler(CANDriver *canp) {
static void can_lld_sce_handler(CANDriver *canp) {
uint32_t msr;
/* Clearing IRQ sources.*/
msr = canp->can->MSR;
canp->can->MSR = CAN_MSR_ERRI | CAN_MSR_WKUI | CAN_MSR_SLAKI;
canp->can->MSR = msr;
/* Wakeup event.*/
#if CAN_USE_SLEEP_MODE
if (msr & CAN_MSR_WKUI) {
@ -272,15 +274,17 @@ static void can_lld_sce_handler(CANDriver *canp) {
eventflags_t flags;
uint32_t esr = canp->can->ESR;
canp->can->ESR &= ~CAN_ESR_LEC;
#if STM32_CAN_REPORT_ALL_ERRORS
flags = (eventflags_t)(esr & 7);
if ((esr & CAN_ESR_LEC) > 0)
flags |= CAN_FRAMING_ERROR;
#endif
osalSysLockFromISR();
/* The content of the ESR register is copied unchanged in the upper
half word of the listener flags mask.*/
osalEventBroadcastFlagsI(&canp->error_event, flags | (eventflags_t)(esr << 16));
osalEventBroadcastFlagsI(&canp->error_event,
flags | (eventflags_t)(esr << 16U));
osalSysUnlockFromISR();
}
}
@ -549,10 +553,17 @@ void can_lld_start(CANDriver *canp) {
canp->can->MCR = canp->config->mcr;
/* Interrupt sources initialization.*/
#if STM32_CAN_REPORT_ALL_ERRORS
canp->can->IER = CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_FMPIE1 |
CAN_IER_WKUIE | CAN_IER_ERRIE | CAN_IER_LECIE |
CAN_IER_BOFIE | CAN_IER_EPVIE | CAN_IER_EWGIE |
CAN_IER_FOVIE0 | CAN_IER_FOVIE1;
#else
canp->can->IER = CAN_IER_TMEIE | CAN_IER_FMPIE0 | CAN_IER_FMPIE1 |
CAN_IER_WKUIE | CAN_IER_ERRIE |
CAN_IER_BOFIE | CAN_IER_EPVIE | CAN_IER_EWGIE |
CAN_IER_FOVIE0 | CAN_IER_FOVIE1;
#endif
}
/**

View File

@ -80,6 +80,14 @@
* @name Configuration options
* @{
*/
/**
* @brief CAN pedantic errors report.
* @details Use of this option is IRQ-intensive.
*/
#if !defined(STM32_CAN_REPORT_ALL_ERRORS) || defined(__DOXYGEN__)
#define STM32_CAN_REPORT_ALL_ERRORS FALSE
#endif
/**
* @brief CAN1 driver enable switch.
* @details If set to @p TRUE the support for CAN1 is included.

View File

@ -236,6 +236,7 @@
(backported to 3.0.1).
- HAL: Fixed missing UART7 and UART8 support on STM32F4xx family (bug #612).
- HAL: Fixed outdated CMSIS headers for STM32F1xx devices (bug #609).
- HAL: Fixed CAN errors (bug #387).
- HAL: Fixed USB HS ULPI Support (except board files because patch originally
targeted version 2.6.x)(bug #377).