Skip to content

Commit 40123f0

Browse files
committed
correct bxcan drive errors
1 parent c3e4fd0 commit 40123f0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

bsp/stm32f10x/drivers/bxcan.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void bxcan2_filter_init(struct rt_can_device *can)
139139
CAN1->FMR |= FMR_FINIT;
140140
mask = 0x01 << (i + 0);
141141
off = i - BX_CAN2_FMRSTART;
142-
if(i < pbxcan->fifo1filteroff) {
142+
if(off < pbxcan->fifo1filteroff) {
143143
if(pbxcan->filtermap[0].id32mask_cnt && off < pbxcan->filtermap[0].id32mask_cnt) {
144144
CAN1->FS1R |= mask;
145145
CAN1->FM1R &= ~mask;
@@ -586,7 +586,7 @@ static rt_int32_t bxcanfindfilter(struct stm_bxcan *pbxcan,struct rt_can_filter_
586586
if(pitem->rtr) {
587587
thisid |= CAN_RTR_REMOTE;
588588
}
589-
if((off == 0 && pfilterreg->FR1 == thisid) ||
589+
if((*off == 0 && pfilterreg->FR1 == thisid) ||
590590
(*off == 1 && pfilterreg->FR2 == thisid)
591591
) {
592592
found = 1;
@@ -959,14 +959,14 @@ static rt_err_t control(struct rt_can_device *can, int cmd, void *arg)
959959
break;
960960
case RT_CAN_CMD_SET_BAUD:
961961
argval = (rt_uint32_t) arg;
962-
if(argval != CAN1MBaud ||
963-
argval != CAN800kBaud ||
964-
argval != CAN500kBaud ||
965-
argval != CAN250kBaud ||
966-
argval != CAN125kBaud ||
967-
argval != CAN100kBaud ||
968-
argval != CAN50kBaud ||
969-
argval != CAN20kBaud ||
962+
if(argval != CAN1MBaud &&
963+
argval != CAN800kBaud &&
964+
argval != CAN500kBaud &&
965+
argval != CAN250kBaud &&
966+
argval != CAN125kBaud &&
967+
argval != CAN100kBaud &&
968+
argval != CAN50kBaud &&
969+
argval != CAN20kBaud &&
970970
argval != CAN10kBaud ) {
971971
return RT_ERROR;
972972
}
@@ -1063,7 +1063,7 @@ static int recvmsg(struct rt_can_device *can, void* buf, rt_uint32_t boxno)
10631063
pmsg->id = (uint32_t)0x1FFFFFFF & (pbxcan->sFIFOMailBox[boxno].RIR >> 3);
10641064
}
10651065

1066-
pmsg->rtr = ((uint8_t)0x02 & pbxcan->sFIFOMailBox[boxno].RIR) >> 1;
1066+
pmsg->rtr = (uint8_t) ((0x02 & pbxcan->sFIFOMailBox[boxno].RIR) >> 1);
10671067
pmsg->len = (uint8_t)0x0F & pbxcan->sFIFOMailBox[boxno].RDTR;
10681068
pmsg->data[0] = (uint8_t)0xFF & pbxcan->sFIFOMailBox[boxno].RDLR;
10691069
pmsg->data[1] = (uint8_t)0xFF & (pbxcan->sFIFOMailBox[boxno].RDLR >> 8);
@@ -1127,7 +1127,7 @@ static struct stm_bxcan bxcan1data =
11271127
struct rt_can_device bxcan1;
11281128
void CAN1_RX0_IRQHandler(void)
11291129
{
1130-
while(CAN1->RF0R & 0x11)
1130+
if(CAN1->RF0R & 0x11)
11311131
{
11321132
if ((CAN1->RF0R & CAN_RF0R_FOVR0) != 0)
11331133
{
@@ -1141,7 +1141,7 @@ void CAN1_RX0_IRQHandler(void)
11411141
}
11421142
void CAN1_RX1_IRQHandler(void)
11431143
{
1144-
while(CAN1->RF1R & 0x11)
1144+
if(CAN1->RF1R & 0x11)
11451145
{
11461146
if ((CAN1->RF1R & CAN_RF1R_FOVR1) != 0)
11471147
{
@@ -1262,7 +1262,7 @@ static struct stm_bxcan bxcan2data =
12621262
struct rt_can_device bxcan2;
12631263
void CAN2_RX0_IRQHandler(void)
12641264
{
1265-
while(CAN2->RF0R & 0x11)
1265+
if(CAN2->RF0R & 0x11)
12661266
{
12671267
if ((CAN2->RF0R & CAN_RF0R_FOVR0) != 0)
12681268
{
@@ -1276,7 +1276,7 @@ void CAN2_RX0_IRQHandler(void)
12761276
}
12771277
void CAN2_RX1_IRQHandler(void)
12781278
{
1279-
while(CAN2->RF1R & 0x11)
1279+
if(CAN2->RF1R & 0x11)
12801280
{
12811281
if ((CAN2->RF1R & CAN_RF1R_FOVR1) != 0)
12821282
{

0 commit comments

Comments
 (0)