main.c

来自「博创2410的实验代码」· C语言 代码 · 共 56 行

C
56
字号
#include "../inc/drivers.h"
#include "../inc/lib.h"
#include <string.h>
#include <stdio.h>
#include "../inc/MCP2510.h"
#include "../inc/myuart.h"
#include "inc/lcd.h"
#include "inc/keyboard.h"

#pragma import(__use_no_semihosting_swi)  // ensure no functions that use semihosting 
extern unsigned short mcukey1;
int main(void)
{
	int n;
	unsigned int id;
	int length;
	BOOL rxRTR, isExt;
	U8 data[8]={0,};
  
 unsigned char KeyBoard_Map[]={0,0,10,0,0,7,4,1,0,0,11
								,14,0,8,5,2,0,13,12,0,0
								,9,6,3,16,0,0,0,0,14,0
								,15,0,1,0,0,17,2,0,0,0
								,4,0,6,0,5,0,0,0,7,0
								,9,15,8,0,0,0,0,0,0,0
								,0,0,0
								}; //64,键值映射表	  
	ARMTargetInit();	//开发版初始化
    LCD_Init();
	LCD_Cls(); 	
	Key_init();	
	init_MCP2510(BandRate_250kbps);//可在该函数内设置成回环模式
                                  //从而只用一台设备完成实验
	canSetup();

	Uart_SendByte(0,0xa);//换行
	Uart_SendByte(0,0xd);//回车

	for(;;)
	{
        if(mcukey1!=0){           
			canWrite(0x7ff, (U8 *)&KeyBoard_Map[mcukey1], 8, FALSE, FALSE);
			Uart_Printf(0,"\nthe character sended is %d",KeyBoard_Map[mcukey1]);
			LCD_printf("\nthe character sended is %d ",KeyBoard_Map[mcukey1]);
			mcukey1=0;
		}

		if((n=canPoll())!=-1){//CAN总线收到数据,则发送到串口
			canRead(n, &id, data, &length,  &rxRTR, &isExt);          
             Uart_Printf(0,"\nreceiving is %x",data[0]);
             LCD_printf("\nthe character received is %x ",data[0]);
					
		}
	}
	return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?