|
TransmitMailbox = CAN_Transmit(CAN1,&TxMessage);
/* CAN FIFO0 message pending interrupt enable */
//CAN_ITConfig(CAN1,CAN_IT_FMP0, ENABLE);
/* disable interrupt handling */
// CAN_ITConfig(CAN1,CAN_IT_FMP0, DISABLE);
if(CAN_NO_MB == TransmitMailbox)
{
//发送失败,没有空邮箱
PUT("Mail box is nok\r\n");
return 0;
}
else
{
PUT("Mail box is ok\r\n");
CAN_msg_num[TransmitMailbox] = 1;
}
do
{
message_tx_status = CAN_TransmitStatus(CAN1, TransmitMailbox);
if(message_tx_status == CANTXOK)
{
PUT("message send ok\r\n");
}
else if(message_tx_status == CANTXPENDING)
{
PUT("message send pending\r\n");
}
else if(message_tx_status == CANTXFAILED)
{
PUT("message send failed\r\n");
}
delay_GSM(10000);
retry_time++;
Status_sign = CAN_GetFlagStatus(CAN1,CAN_FLAG_BOF);
if(Status_sign == SET)
{
PUT("CAN_FLAG_BOF = SET \r\n");
CAN1->MCR|=1;
CAN1->MCR&=0xfffffffe;
}
else
{
PUT("CAN_FLAG_BOF = RESET \r\n");
}
Status_sign = CAN_GetFlagStatus(CAN1,CAN_FLAG_EWG);
if(Status_sign == SET)
{
PUT("CAN_FLAG_EWG = SET \r\n");
}
else
{
PUT("CAN_FLAG_EWG = RESET \r\n");
}
Status_sign = CAN_GetFlagStatus(CAN1,CAN_FLAG_EPV);
if(Status_sign == SET)
{
PUT("CAN_FLAG_EPV = SET \r\n");
}
else
{
PUT("CAN_FLAG_EPV = RESET \r\n");
}
}while((message_tx_status != CANTXOK)&&(retry_time <3)); |
|