drivers/hcs12/canOpenDriver.c
changeset 365 9b76e0881beb
parent 7 126e37bcca0f
child 384 83793fc7ce48
equal deleted inserted replaced
364:17edd8a028fa 365:9b76e0881beb
   420   }
   420   }
   421   else{
   421   else{
   422     /* Selecting a buffer */
   422     /* Selecting a buffer */
   423     IO_PORTS_8(adrCAN + CANTBSEL) = cantflg;
   423     IO_PORTS_8(adrCAN + CANTBSEL) = cantflg;
   424     /* We put ide = 0 because id is on 11 bits only */
   424     /* We put ide = 0 because id is on 11 bits only */
   425      IO_PORTS_8(adrCAN + CANTRSID) = (UNS8)(msg.cob_id.w >> 3);
   425      IO_PORTS_8(adrCAN + CANTRSID) = (UNS8)(msg.cob_id >> 3);
   426     IO_PORTS_8(adrCAN + CANTRSID + 1) = (UNS8)((msg.cob_id.w << 5)|
   426     IO_PORTS_8(adrCAN + CANTRSID + 1) = (UNS8)((msg.cob_id << 5)|
   427     (msg.rtr << 4));
   427     (msg.rtr << 4));
   428    
   428    
   429     IO_PORTS_8(adrCAN + CANTRSLEN) = msg.len & 0X0F;
   429     IO_PORTS_8(adrCAN + CANTRSLEN) = msg.len & 0X0F;
   430     /* For the priority, we put the highter bits of the cob_id */
   430     /* For the priority, we put the highter bits of the cob_id */
   431     IO_PORTS_8(adrCAN + CANTRSPRI) = IO_PORTS_8(adrCAN + CANTRSID);
   431     IO_PORTS_8(adrCAN + CANTRSPRI) = IO_PORTS_8(adrCAN + CANTRSID);
   531      ptrMsgRcv[j].r = 0;
   531      ptrMsgRcv[j].r = 0;
   532   else
   532   else
   533     ptrMsgRcv[j].r ++;
   533     ptrMsgRcv[j].r ++;
   534 
   534 
   535   /* Store the message from the stack*/
   535   /* Store the message from the stack*/
   536   msgRcv->cob_id.w = stackMsgRcv[j][ptrMsgRcv[j].r].cob_id.w;
   536   msgRcv->cob_id = stackMsgRcv[j][ptrMsgRcv[j].r].cob_id;
   537   msgRcv->len = stackMsgRcv[j][ptrMsgRcv[j].r].len;
   537   msgRcv->len = stackMsgRcv[j][ptrMsgRcv[j].r].len;
   538   msgRcv->rtr = stackMsgRcv[j][ptrMsgRcv[j].r].rtr;
   538   msgRcv->rtr = stackMsgRcv[j][ptrMsgRcv[j].r].rtr;
   539   for (i = 0 ; i < stackMsgRcv[j][ptrMsgRcv[j].r].len ; i++)
   539   for (i = 0 ; i < stackMsgRcv[j][ptrMsgRcv[j].r].len ; i++)
   540     msgRcv->data[i] = stackMsgRcv[j][ptrMsgRcv[j].r].data[i];
   540     msgRcv->data[i] = stackMsgRcv[j][ptrMsgRcv[j].r].data[i];
   541   return 0xFF;
   541   return 0xFF;
   570   }
   570   }
   571   else
   571   else
   572     ptrMsgRcv[0].w = NewPtrW;
   572     ptrMsgRcv[0].w = NewPtrW;
   573   
   573   
   574   /* Store the message */
   574   /* Store the message */
   575   stackMsgRcv[0][ptrMsgRcv[0].w].cob_id.w = IO_PORTS_16(CAN0 + CANRCVID) >> 5;
   575   stackMsgRcv[0][ptrMsgRcv[0].w].cob_id = IO_PORTS_16(CAN0 + CANRCVID) >> 5;
   576   stackMsgRcv[0][ptrMsgRcv[0].w].len = IO_PORTS_8(CAN0 + CANRCVLEN) & 0x0F;
   576   stackMsgRcv[0][ptrMsgRcv[0].w].len = IO_PORTS_8(CAN0 + CANRCVLEN) & 0x0F;
   577   stackMsgRcv[0][ptrMsgRcv[0].w].rtr = (IO_PORTS_8(CAN0 + CANRCVID + 1) >> 4) & 0x01;
   577   stackMsgRcv[0][ptrMsgRcv[0].w].rtr = (IO_PORTS_8(CAN0 + CANRCVID + 1) >> 4) & 0x01;
   578   for (i = 0 ; i < stackMsgRcv[0][ptrMsgRcv[0].w].len ; i++)
   578   for (i = 0 ; i < stackMsgRcv[0][ptrMsgRcv[0].w].len ; i++)
   579     stackMsgRcv[0][ptrMsgRcv[0].w].data[i] = IO_PORTS_8(CAN0 + CANRCVDTA + i);
   579     stackMsgRcv[0][ptrMsgRcv[0].w].data[i] = IO_PORTS_8(CAN0 + CANRCVDTA + i);
   580   
   580   
   621   }
   621   }
   622   else
   622   else
   623     ptrMsgRcv[1].w = NewPtrW;
   623     ptrMsgRcv[1].w = NewPtrW;
   624   
   624   
   625   /* Store the message */
   625   /* Store the message */
   626   stackMsgRcv[1][ptrMsgRcv[1].w].cob_id.w = IO_PORTS_16(CAN1 + CANRCVID) >> 5;
   626   stackMsgRcv[1][ptrMsgRcv[1].w].cob_id = IO_PORTS_16(CAN1 + CANRCVID) >> 5;
   627   stackMsgRcv[1][ptrMsgRcv[1].w].len = IO_PORTS_8(CAN1 + CANRCVLEN) & 0x0F;
   627   stackMsgRcv[1][ptrMsgRcv[1].w].len = IO_PORTS_8(CAN1 + CANRCVLEN) & 0x0F;
   628   stackMsgRcv[0][ptrMsgRcv[0].w].rtr = (IO_PORTS_8(CAN1 + CANRCVID + 1) >> 4) & 0x01;
   628   stackMsgRcv[0][ptrMsgRcv[0].w].rtr = (IO_PORTS_8(CAN1 + CANRCVID + 1) >> 4) & 0x01;
   629   for (i = 0 ; i < stackMsgRcv[1][ptrMsgRcv[1].w].len ; i++)
   629   for (i = 0 ; i < stackMsgRcv[1][ptrMsgRcv[1].w].len ; i++)
   630     stackMsgRcv[1][ptrMsgRcv[1].w].data[i] = IO_PORTS_8(CAN1 + CANRCVDTA + i);
   630     stackMsgRcv[1][ptrMsgRcv[1].w].data[i] = IO_PORTS_8(CAN1 + CANRCVDTA + i);
   631   
   631