57 #if (defined(PDL_PERIPHERAL_CAN_ACTIVE))
70 #define CAN_INSTANCE_COUNT (uint32_t)(sizeof(m_astcCanInstanceDataLut) / sizeof(m_astcCanInstanceDataLut[0]))
73 #define CAN_STATUS_INTERRUPT (1 << 15)
77 #define CAN_NO_LEC_CHANGE 7
79 #define CAN_MSG_DIR_RX 0
80 #define CAN_MSG_DIR_TX 1
81 #define CAN_MSG_ID_EXTENDED 1
90 #if (PDL_PERIPHERAL_ENABLE_CAN0 == PDL_ON)
96 #if (PDL_PERIPHERAL_ENABLE_CAN1 == PDL_ON)
135 uint32_t u32Instance;
139 if (pstcCan == m_astcCanInstanceDataLut[u32Instance].pstcInstance)
159 NVIC_ClearPendingIRQ(CAN0_IRQn);
160 NVIC_EnableIRQ(CAN0_IRQn);
165 NVIC_ClearPendingIRQ(CAN1_IRQn);
166 NVIC_EnableIRQ(CAN1_IRQn);
185 NVIC_ClearPendingIRQ(CAN0_IRQn);
186 NVIC_DisableIRQ(CAN0_IRQn);
191 NVIC_ClearPendingIRQ(CAN1_IRQn);
192 NVIC_DisableIRQ(CAN1_IRQn);
228 uint16_t u16MessageBufferNumber ;
235 while( bDone ==
FALSE )
237 u16MessageBufferNumber = pstcCan->
INTR ;
239 switch ( u16MessageBufferNumber )
249 unCanStatusRegister = pstcCan->
STATR_f;
255 if (unCanStatusRegister.
BOFF != 0)
262 if (unCanStatusRegister.
EWARN != 0)
287 unCanIf2Cmsk.
MASK = 1;
288 unCanIf2Cmsk.
ARB = 1;
290 unCanIf2Cmsk.
CIP = 1;
292 unCanIf2Cmsk.
DATAA = 1;
293 unCanIf2Cmsk.
DATAB = 1;
299 pstcCan->
IF2CREQ = u16MessageBufferNumber ;
309 uint16_t* pu16Data = (uint16_t*)&pstcMsgBuffer->
stcData.
au8Data[0] ;
351 pstcCan->
IF2CREQ = u16MessageBufferNumber;
433 uint8_t u8MessageNumber;
442 if ( pstcCan == NULL ||
463 if (pstcCanInternData == NULL)
509 if (((__HCLK * u8HclkMul) / u8HclkDiv) >
CAN_MAX_CLK)
567 pstcCan->
BTR_f = unBTR ;
575 pstcCan->
STATR = 0x0000;
592 pstcCan->
IF1CREQ = u8MessageNumber ;
637 uint8_t u8MessageNumber;
640 if ( pstcCan == NULL )
649 if (pstcCanInternData == NULL)
657 pstcCan->
CTRLR = 0x0000;
669 pstcCan->
BRPER = 0x00;
675 pstcCan->
STATR = 0x00;
678 pstcCan->
TESTR = 0x00;
685 pstcCan->
IF1MSK = UINT32_MAX ;
686 pstcCan->
IF2MSK = UINT32_MAX ;
742 uint16_t u16CmpMask ;
750 u16CmpMask <<= (u8MsgBuf % 16) ;
759 switch ( u8MsgBuf >> 3 )
762 if ( pstcCan->
TREQR1 & u16CmpMask )
769 if ( pstcCan->
TREQR2 & u16CmpMask )
825 if ( pstcCan == NULL ||
842 if (pstcCanInternData == NULL)
860 pstcCan->
IF1CREQ = u8MsgBuf + 1 ;
890 pstcCan->
IF1CREQ = u8MsgBuf + 1 ;
927 uint8_t u8DataLengthCode;
930 if ( pstcCan == NULL ||
947 if ( pstcCanInternData == NULL )
962 pstcCan->
IF1CREQ = u8MsgBuf + 1 ;
983 pstcCan->
IF1CREQ = u8MsgBuf + 1 ;
1013 switch (u8DataLengthCode)
1016 u16Data = pstcMsgData->
au8Data[7] << 8;
1019 u16Data |= pstcMsgData->
au8Data[6] ;
1023 u16Data = pstcMsgData->
au8Data[5] << 8;
1026 u16Data |= pstcMsgData->
au8Data[4];
1030 u16Data = pstcMsgData->
au8Data[3] << 8;
1033 u16Data |= pstcMsgData->
au8Data[2];
1037 u16Data = pstcMsgData->
au8Data[1] << 8;
1040 u16Data |= pstcMsgData->
au8Data[0];
1061 pstcCan->
IF1CREQ = u8MsgBuf + 1 ;
1098 if ( pstcCan == NULL ||
1109 if ( pstcCanInternData == NULL )
1122 return enFuncResult;
1174 uint32_t u32MsgIdMask,
1186 if ( pstcCan == NULL ||
1187 pstcMsgBuffer == NULL
1203 if ( pstcCanInternData == NULL )
1265 pstcCan->
IF1CREQ = u8MsgBuf + 1 ;
1294 uint32_t u32MsgIdMask,
1303 if ( pstcCan == NULL ||
1304 pstcMsgBuffer == NULL
1314 if ( pstcCanInternData == NULL )
1327 return enFuncResult;
1353 if ( pstcCan == NULL )
1368 if ( pstcCanInternData == NULL )
1389 #endif // #if (defined(PDL_PERIPHERAL_CAN_ACTIVE))