?? main.c
字號:
#include"uhal.h"
#include"myuart.h"
#include"MCP2510.h"
#pragma import(__use_no_semihosting_swi) // ensure no functions that use semihosting
int main(void)
{
int n;
unsigned int id;
int length;
BOOL rxRTR, isExt;
U8 data[8]={0,};
ARMTargetInit(); //開發版初始化
init_MCP2510(BandRate_250kbps);//可在該函數內設置成回環模式
//從而只用一臺設備完成實驗
canSetup();
Uart_SendByte(0,0xa);//換行
Uart_SendByte(0,0xd);//回車
for(;;)
{
if(Uart_Poll(0)){ //串口收到數據,則發送到CAN總線
Uart_Getch((char*)data,0,0);
canWrite(0x123, data, 8, FALSE, FALSE);
}
if((n=canPoll())!=-1){//CAN總線收到數據,則發送到串口
canRead(n, &id, data, &length, &rxRTR, &isExt);
Uart_SendByte(0,data[0]); //顯示采集的數據
if(data[0]=='\r') //發送換行
Uart_SendByte(0,'\n');
}
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -