Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch 2 #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions components/can/CAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
#include "CAN_config.h"


static void CAN_read_frame();
static void CAN_read_frame(BaseType_t* pfYieldRequired);
static void CAN_isr(void *arg_p);


static void CAN_isr(void *arg_p){

BaseType_t fYieldRequired = pdFALSE;
//Interrupt flag buffer
__CAN_IRQ_t interrupt;

Expand All @@ -61,7 +62,7 @@ static void CAN_isr(void *arg_p){

// Handle RX frame available interrupt
if ((interrupt & __CAN_IRQ_RX) != 0)
CAN_read_frame();
CAN_read_frame(&fYieldRequired);

// Handle error interrupts.
if ((interrupt & (__CAN_IRQ_ERR //0x4
Expand All @@ -73,9 +74,11 @@ static void CAN_isr(void *arg_p){
)) != 0) {
/*handler*/
}
if (fYieldRequired == pdTRUE)
portYIELD_FROM_ISR();
}

static void CAN_read_frame(){
static void CAN_read_frame(BaseType_t* pfYieldRequired){

//byte iterator
uint8_t __byte_i;
Expand All @@ -87,6 +90,7 @@ static void CAN_read_frame(){
if (CAN_cfg.rx_queue == NULL){
// Let the hardware know the frame has been read.
MODULE_CAN->CMR.B.RRB=1;
*pfYieldRequired = pdFALSE;
return;
}

Expand Down Expand Up @@ -118,7 +122,7 @@ static void CAN_read_frame(){
}

//send frame to input queue
xQueueSendFromISR(CAN_cfg.rx_queue,&__frame,0);
xQueueSendFromISR(CAN_cfg.rx_queue,&__frame, pfYieldRequired);

//Let the hardware know the frame has been read.
MODULE_CAN->CMR.B.RRB=1;
Expand Down