eecs-bsp-test-code-2/2-2/main.c

34 lines
779 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// receiver
#include "STC15F2K60S2.H"
#include "displayer.h"
#include "sys.h"
#include "uart2.h"
code unsigned long SysClock = 11059200; //必须。定义系统工作时钟频率(Hz),用户必须修改成与实际工作频率(下载时选择的)一致
char buffer[10], *match;
int sum;
void sendBack()
{
int i;
for (i = 0; i < 5; i++)
{
sum += buffer[i];
}
// print least 8 bits
LedPrint(sum & 0xFF);
}
void main()
{
Uart2Init(1200, Uart2Usedfor485); //初始化串口2波特率为2400
DisplayerInit();
SetUart2Rxd(buffer, 5, match, 0); //设置串口2接收缓冲区接收5个字节匹配0个字节
SetEventCallBack(enumEventUart2Rxd, sendBack);
MySTC_Init();
while (1)
{
MySTC_OS();
}
}