mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
689 lines
28 KiB
C
689 lines
28 KiB
C
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: SWM320_can.c
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: SWM320<EFBFBD><EFBFBD>Ƭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CANģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD><EFBFBD>: http://www.synwit.com.cn/e/tool/gbook/?bid=1
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
|||
|
* <EFBFBD>汾<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: V1.1.0 2017<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD>25<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼:
|
|||
|
*
|
|||
|
*
|
|||
|
*******************************************************************************************************************************************
|
|||
|
* @attention
|
|||
|
*
|
|||
|
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
|
|||
|
* REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
|
|||
|
* FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
|
|||
|
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
|
|||
|
* -ECTION WITH THEIR PRODUCTS.
|
|||
|
*
|
|||
|
* COPYRIGHT 2012 Synwit Technology
|
|||
|
*******************************************************************************************************************************************/
|
|||
|
#include "SWM320.h"
|
|||
|
#include "SWM320_can.h"
|
|||
|
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_Init()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CAN<EFBFBD>ӿڳ<EFBFBD>ʼ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* CAN_InitStructure * initStruct <EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN<EFBFBD>ӿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>趨ֵ<EFBFBD>Ľṹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_Init(CAN_TypeDef * CANx, CAN_InitStructure * initStruct)
|
|||
|
{
|
|||
|
switch((uint32_t)CANx)
|
|||
|
{
|
|||
|
case ((uint32_t)CAN):
|
|||
|
SYS->CLKEN |= (0x01 << SYS_CLKEN_CAN_Pos);
|
|||
|
break;
|
|||
|
}
|
|||
|
|
|||
|
CAN_Close(CANx); //һЩ<D2BB>ؼ<EFBFBD><D8BC>Ĵ<EFBFBD><C4B4><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD>CAN<41>ر<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
CANx->CR &= ~(CAN_CR_LOM_Msk | CAN_CR_STM_Msk | CAN_CR_AFM_Msk);
|
|||
|
CANx->CR |= (initStruct->Mode << CAN_CR_LOM_Pos) |
|
|||
|
(initStruct->FilterMode << CAN_CR_AFM_Pos);
|
|||
|
|
|||
|
CANx->FILTER.AMR[3] = initStruct->FilterMask32b & 0xFF;
|
|||
|
CANx->FILTER.AMR[2] = (initStruct->FilterMask32b >> 8) & 0xFF;
|
|||
|
CANx->FILTER.AMR[1] = (initStruct->FilterMask32b >> 16) & 0xFF;
|
|||
|
CANx->FILTER.AMR[0] = (initStruct->FilterMask32b >> 24) & 0xFF;
|
|||
|
|
|||
|
CANx->FILTER.ACR[3] = initStruct->FilterCheck32b & 0xFF;
|
|||
|
CANx->FILTER.ACR[2] = (initStruct->FilterCheck32b >> 8) & 0xFF;
|
|||
|
CANx->FILTER.ACR[1] = (initStruct->FilterCheck32b >> 16) & 0xFF;
|
|||
|
CANx->FILTER.ACR[0] = (initStruct->FilterCheck32b >> 24) & 0xFF;
|
|||
|
|
|||
|
CANx->BT1 = (0 << CAN_BT1_SAM_Pos) |
|
|||
|
(initStruct->CAN_BS1 << CAN_BT1_TSEG1_Pos) |
|
|||
|
(initStruct->CAN_BS2 << CAN_BT1_TSEG2_Pos);
|
|||
|
|
|||
|
CANx->BT0 = (initStruct->CAN_SJW << CAN_BT0_SJW_Pos) |
|
|||
|
((SystemCoreClock/2/initStruct->Baudrate/(1 + (initStruct->CAN_BS1 + 1) + (initStruct->CAN_BS2 + 1)) - 1) << CAN_BT0_BRP_Pos);
|
|||
|
|
|||
|
CANx->RXERR = 0; //ֻ<><D6BB><EFBFBD>ڸ<EFBFBD>λģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
CANx->TXERR = 0;
|
|||
|
|
|||
|
CANx->IE = (initStruct->RXNotEmptyIEn << CAN_IE_RXDA_Pos) |
|
|||
|
(initStruct->RXOverflowIEn << CAN_IE_RXOV_Pos) |
|
|||
|
(initStruct->ArbitrLostIEn << CAN_IE_ARBLOST_Pos) |
|
|||
|
(initStruct->ErrPassiveIEn << CAN_IE_ERRPASS_Pos);
|
|||
|
|
|||
|
switch((uint32_t)CANx)
|
|||
|
{
|
|||
|
case ((uint32_t)CAN):
|
|||
|
if(initStruct->RXNotEmptyIEn | initStruct->RXOverflowIEn | initStruct->ArbitrLostIEn | initStruct->ErrPassiveIEn)
|
|||
|
{
|
|||
|
NVIC_EnableIRQ(CAN_IRQn);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
NVIC_DisableIRQ(CAN_IRQn);
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_Open()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CAN<EFBFBD>ӿڴ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_Open(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->CR &= ~(0x01 << CAN_CR_RST_Pos); //<2F>˳<EFBFBD><CBB3><EFBFBD>λģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD><EBB9A4>ģʽ
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_Close()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CAN<EFBFBD>ӿڹر<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_Close(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->CR |= (0x01 << CAN_CR_RST_Pos); //<2F><><EFBFBD>븴λģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><DCB7>ͺͽ<CDBA><CDBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_Transmit()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CAN<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* uint32_t format CAN_FRAME_STD <EFBFBD><EFBFBD>֡ CAN_FRAME_EXT <EFBFBD><EFBFBD>չ֡
|
|||
|
* uint32_t id <EFBFBD><EFBFBD>ϢID
|
|||
|
* uint8_t data[] Ҫ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* uint32_t size Ҫ<EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĸ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* uint32_t once ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD>ٲö<EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NAK<EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_Transmit(CAN_TypeDef * CANx, uint32_t format, uint32_t id, uint8_t data[], uint32_t size, uint32_t once)
|
|||
|
{
|
|||
|
uint32_t i;
|
|||
|
|
|||
|
if(format == CAN_FRAME_STD)
|
|||
|
{
|
|||
|
CANx->TXFRAME.INFO = (0 << CAN_INFO_FF_Pos) |
|
|||
|
(0 << CAN_INFO_RTR_Pos) |
|
|||
|
(size << CAN_INFO_DLC_Pos);
|
|||
|
|
|||
|
CANx->TXFRAME.DATA[0] = id >> 3;
|
|||
|
CANx->TXFRAME.DATA[1] = id << 5;
|
|||
|
|
|||
|
for(i = 0; i < size; i++)
|
|||
|
{
|
|||
|
CANx->TXFRAME.DATA[i+2] = data[i];
|
|||
|
}
|
|||
|
}
|
|||
|
else //if(format == CAN_FRAME_EXT)
|
|||
|
{
|
|||
|
CANx->TXFRAME.INFO = (1 << CAN_INFO_FF_Pos) |
|
|||
|
(0 << CAN_INFO_RTR_Pos) |
|
|||
|
(size << CAN_INFO_DLC_Pos);
|
|||
|
|
|||
|
CANx->TXFRAME.DATA[0] = id >> 21;
|
|||
|
CANx->TXFRAME.DATA[1] = id >> 13;
|
|||
|
CANx->TXFRAME.DATA[2] = id >> 5;
|
|||
|
CANx->TXFRAME.DATA[3] = id << 3;
|
|||
|
|
|||
|
for(i = 0; i < size; i++)
|
|||
|
{
|
|||
|
CANx->TXFRAME.DATA[i+4] = data[i];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if(CANx->CR & CAN_CR_STM_Msk)
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_SRR_Pos);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if(once == 0)
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_TXREQ_Pos);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_TXREQ_Pos) | (1 << CAN_CMD_ABTTX_Pos);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_TransmitRequest()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CAN<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>̽ڵ㷢<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* uint32_t format CAN_FRAME_STD <EFBFBD><EFBFBD>֡ CAN_FRAME_EXT <EFBFBD><EFBFBD>չ֡
|
|||
|
* uint32_t id <EFBFBD><EFBFBD>ϢID
|
|||
|
* uint32_t once ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>Σ<EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD>ٲö<EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>NAK<EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_TransmitRequest(CAN_TypeDef * CANx, uint32_t format, uint32_t id, uint32_t once)
|
|||
|
{
|
|||
|
if(format == CAN_FRAME_STD)
|
|||
|
{
|
|||
|
CANx->TXFRAME.INFO = (0 << CAN_INFO_FF_Pos) |
|
|||
|
(1 << CAN_INFO_RTR_Pos) |
|
|||
|
(0 << CAN_INFO_DLC_Pos);
|
|||
|
|
|||
|
CANx->TXFRAME.DATA[0] = id >> 3;
|
|||
|
CANx->TXFRAME.DATA[1] = id << 5;
|
|||
|
}
|
|||
|
else //if(format == CAN_FRAME_EXT)
|
|||
|
{
|
|||
|
CANx->TXFRAME.INFO = (1 << CAN_INFO_FF_Pos) |
|
|||
|
(1 << CAN_INFO_RTR_Pos) |
|
|||
|
(0 << CAN_INFO_DLC_Pos);
|
|||
|
|
|||
|
CANx->TXFRAME.DATA[0] = id >> 21;
|
|||
|
CANx->TXFRAME.DATA[1] = id >> 13;
|
|||
|
CANx->TXFRAME.DATA[2] = id >> 5;
|
|||
|
CANx->TXFRAME.DATA[3] = id << 3;
|
|||
|
}
|
|||
|
|
|||
|
if(once == 0)
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_TXREQ_Pos);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_TXREQ_Pos) | (1 << CAN_CMD_ABTTX_Pos);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_Receive()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: CAN<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* CAN_RXMessage *msg <EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>洢<EFBFBD>ڴ˽ṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_Receive(CAN_TypeDef * CANx, CAN_RXMessage *msg)
|
|||
|
{
|
|||
|
uint32_t i;
|
|||
|
msg->format = (CANx->RXFRAME.INFO & CAN_INFO_FF_Msk) >> CAN_INFO_FF_Pos;
|
|||
|
|
|||
|
msg->remote = (CANx->RXFRAME.INFO & CAN_INFO_RTR_Msk) >> CAN_INFO_RTR_Pos;
|
|||
|
msg->size = (CANx->RXFRAME.INFO & CAN_INFO_DLC_Msk) >> CAN_INFO_DLC_Pos;
|
|||
|
|
|||
|
if(msg->format == CAN_FRAME_STD)
|
|||
|
{
|
|||
|
msg->id = (CANx->RXFRAME.DATA[0] << 3) | (CANx->RXFRAME.DATA[1] >> 5);
|
|||
|
|
|||
|
for(i = 0; i < msg->size; i++)
|
|||
|
{
|
|||
|
msg->data[i] = CANx->RXFRAME.DATA[i+2];
|
|||
|
}
|
|||
|
}
|
|||
|
else //if(msg->format == CAN_FRAME_EXT)
|
|||
|
{
|
|||
|
msg->id = (CANx->RXFRAME.DATA[0] << 21) | (CANx->RXFRAME.DATA[1] << 13) | (CANx->RXFRAME.DATA[2] << 5) | (CANx->RXFRAME.DATA[3] >> 3);
|
|||
|
|
|||
|
for(i = 0; i < msg->size; i++)
|
|||
|
{
|
|||
|
msg->data[i] = CANx->RXFRAME.DATA[i+4];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
CANx->CMD = (1 << CAN_CMD_RRB_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_TXComplete()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 <EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD>AbortҲ<EFBFBD>ᴥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ᴥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳɹ<EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_TXComplete(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->SR & CAN_SR_TXBR_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_TXSuccess()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD><EFBFBD><EFBFBD>ͳɹ<EFBFBD> 0 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_TXSuccess(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->SR & CAN_SR_TXOK_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_AbortTransmit()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><EFBFBD>еķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܲ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_AbortTransmit(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_ABTTX_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_TXBufferReady()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TX Buffer<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_TXBufferReady(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->SR & CAN_SR_TXBR_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_RXDataAvailable()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: RX FIFO<EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿɶ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿɶ<EFBFBD><EFBFBD><EFBFBD> 0 û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_RXDataAvailable(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->SR & CAN_SR_RXDA_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_SetBaudrate()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* uint32_t baudrate <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* uint32_t CAN_BS1 CAN_BS1_1tq<EFBFBD><EFBFBD>CAN_BS1_2tq<EFBFBD><EFBFBD>... ... <EFBFBD><EFBFBD>CAN_BS1_16tq
|
|||
|
* uint32_t CAN_BS2 CAN_BS2_1tq<EFBFBD><EFBFBD>CAN_BS2_2tq<EFBFBD><EFBFBD>... ... <EFBFBD><EFBFBD>CAN_BS2_8tq
|
|||
|
* uint32_t CAN_SJW CAN_SJW_1tq<EFBFBD><EFBFBD>CAN_SJW_2tq<EFBFBD><EFBFBD>CAN_SJW_3tq<EFBFBD><EFBFBD>CAN_SJW_4tq
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD>CAN_Close()<EFBFBD>ر<EFBFBD>CANģ<EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_SetBaudrate(CAN_TypeDef * CANx, uint32_t baudrate, uint32_t CAN_BS1, uint32_t CAN_BS2, uint32_t CAN_SJW)
|
|||
|
{
|
|||
|
CANx->BT1 = (0 << CAN_BT1_SAM_Pos) |
|
|||
|
(CAN_BS1 << CAN_BT1_TSEG1_Pos) |
|
|||
|
(CAN_BS2 << CAN_BT1_TSEG2_Pos);
|
|||
|
|
|||
|
CANx->BT0 = (CAN_SJW << CAN_BT0_SJW_Pos) |
|
|||
|
((SystemCoreClock/2/baudrate/(1 + (CAN_BS1 + 1) + (CAN_BS2 + 1)) - 1) << CAN_BT0_BRP_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_SetFilter32b()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>32λ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* uint32_t check <EFBFBD><EFBFBD>maskһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>Message<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ģ<EFBFBD>check & (~mask) == ID & (~mask)<EFBFBD><EFBFBD>Messageͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* uint32_t mask
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD>CAN_Close()<EFBFBD>ر<EFBFBD>CANģ<EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_SetFilter32b(CAN_TypeDef * CANx, uint32_t check, uint32_t mask)
|
|||
|
{
|
|||
|
CANx->CR &= ~CAN_CR_AFM_Msk;
|
|||
|
CANx->CR |= (CAN_FILTER_32b << CAN_CR_AFM_Pos);
|
|||
|
|
|||
|
CANx->FILTER.AMR[3] = mask & 0xFF;
|
|||
|
CANx->FILTER.AMR[2] = (mask >> 8) & 0xFF;
|
|||
|
CANx->FILTER.AMR[1] = (mask >> 16) & 0xFF;
|
|||
|
CANx->FILTER.AMR[0] = (mask >> 24) & 0xFF;
|
|||
|
|
|||
|
CANx->FILTER.ACR[3] = check & 0xFF;
|
|||
|
CANx->FILTER.ACR[2] = (check >> 8) & 0xFF;
|
|||
|
CANx->FILTER.ACR[1] = (check >> 16) & 0xFF;
|
|||
|
CANx->FILTER.ACR[0] = (check >> 24) & 0xFF;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_SetFilter16b()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ý<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>16λ<EFBFBD>˲<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* uint16_t check1 <EFBFBD><EFBFBD>maskһ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˽<EFBFBD><EFBFBD>յ<EFBFBD><EFBFBD><EFBFBD>Message<EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ģ<EFBFBD>check & (~mask) == ID & (~mask)<EFBFBD><EFBFBD>Messageͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* uint16_t mask1
|
|||
|
* uint16_t check2
|
|||
|
* uint16_t mask2
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>Ҫ<EFBFBD>ȵ<EFBFBD><EFBFBD><EFBFBD>CAN_Close()<EFBFBD>ر<EFBFBD>CANģ<EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_SetFilter16b(CAN_TypeDef * CANx, uint16_t check1, uint16_t mask1, uint16_t check2, uint16_t mask2)
|
|||
|
{
|
|||
|
CANx->CR &= ~CAN_CR_AFM_Msk;
|
|||
|
CANx->CR |= (CAN_FILTER_16b << CAN_CR_AFM_Pos);
|
|||
|
|
|||
|
CANx->FILTER.AMR[3] = mask1 & 0xFF;
|
|||
|
CANx->FILTER.AMR[2] = (mask1 >> 8) & 0xFF;
|
|||
|
CANx->FILTER.AMR[1] = mask2 & 0xFF;
|
|||
|
CANx->FILTER.AMR[0] = (mask2 >> 8) & 0xFF;
|
|||
|
|
|||
|
CANx->FILTER.ACR[3] = check1 & 0xFF;
|
|||
|
CANx->FILTER.ACR[2] = (check1 >> 8) & 0xFF;
|
|||
|
CANx->FILTER.ACR[1] = check2 & 0xFF;
|
|||
|
CANx->FILTER.ACR[0] = (check2 >> 8) & 0xFF;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXNotEmptyEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>RX FIFO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTRXNotEmptyEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_RXDA_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXNotEmptyDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>RX FIFO<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ǿգ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTRXNotEmptyDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_RXDA_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXNotEmptyStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: RX FIFO<EFBFBD>ǿ<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTRXNotEmptyStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_RXDA_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTTXBufEmptyEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>TX Buffer<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTTXBufEmptyEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_TXBR_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTTXBufEmptyDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>TX Buffer<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTTXBufEmptyDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_TXBR_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTTXBufEmptyStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TX Buffer<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTTXBufEmptyStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_TXBR_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTErrWarningEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TXERR/RXERR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ﵽError Warning Limitʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTErrWarningEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_ERRWARN_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTErrWarningDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TXERR/RXERR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ﵽError Warning Limitʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTErrWarningDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_ERRWARN_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTErrWarningStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TXERR/RXERR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ﵽError Warning Limit<EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTErrWarningStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_ERRWARN_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXOverflowEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: RX FIFO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTRXOverflowEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_RXOV_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXOverflowDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: RX FIFO <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTRXOverflowDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_RXOV_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXOverflowStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: RX FIFO <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTRXOverflowStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_RXOV_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTRXOverflowClear()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: RX FIFO <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTRXOverflowClear(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->CMD = (1 << CAN_CMD_CLROV_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTWakeupEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTWakeupEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_WKUP_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTWakeupDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTWakeupDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_WKUP_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTWakeupStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTWakeupStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_WKUP_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTErrPassiveEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TXERR/RXERR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ﵽ127ʱ<EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTErrPassiveEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_ERRPASS_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTErrPassiveDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TXERR/RXERR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ﵽ127ʱ<EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTErrPassiveDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_ERRPASS_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTErrPassiveStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: TXERR/RXERR<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ﵽ127<EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTErrPassiveStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_ERRPASS_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTArbitrLostEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ٲ<EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTArbitrLostEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_ARBLOST_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTArbitrLostDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ٲ<EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTArbitrLostDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_ARBLOST_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTArbitrLostStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD>ٲ<EFBFBD>ʧ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTArbitrLostStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_ARBLOST_Msk) ? 1 : 0;
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTBusErrorEn()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTBusErrorEn(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE |= (1 << CAN_IE_BUSERR_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTBusErrorDis()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϽ<EFBFBD>ֹ
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
void CAN_INTBusErrorDis(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
CANx->IE &= ~(1 << CAN_IE_BUSERR_Pos);
|
|||
|
}
|
|||
|
|
|||
|
/******************************************************************************************************************************************
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: CAN_INTBusErrorStat()
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD>ߴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: CAN_TypeDef * CANx ָ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>CAN<EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD>Чֵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CAN
|
|||
|
* <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>: uint32_t 1 <EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD> 0 δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD>
|
|||
|
******************************************************************************************************************************************/
|
|||
|
uint32_t CAN_INTBusErrorStat(CAN_TypeDef * CANx)
|
|||
|
{
|
|||
|
return (CANx->IF & CAN_IF_BUSERR_Msk) ? 1 : 0;
|
|||
|
}
|