|
/***********************************************************************/
|
|
/* */
|
|
/* FILE :sp4C12.c */
|
|
/* DATE :Wed, Jun 02, 2021 */
|
|
/* DESCRIPTION :main program file. */
|
|
/* CPU GROUP :87B */
|
|
/* */
|
|
/* This file is generated by Renesas Project Generator (Ver.4.18). */
|
|
/* NOTE:THIS IS A TYPICAL EXAMPLE. */
|
|
/***********************************************************************/
|
|
|
|
#include "sfr32c87.h"
|
|
#include "uart0.h"
|
|
|
|
char tram[80];
|
|
char c,c1,c2,t1,t2,check=0,t3,t4;
|
|
int i=0,debut=0,fin_tram=0,validation=0;
|
|
|
|
void main(void)
|
|
{
|
|
|
|
uart0_init();
|
|
pd1_0=1;
|
|
pd1_1=1;
|
|
|
|
/*
|
|
while (1)
|
|
{
|
|
for (i=0;i<26;i++)
|
|
{
|
|
uart0_tx(65+i);
|
|
|
|
}
|
|
|
|
}
|
|
*/
|
|
while (1)
|
|
{
|
|
fin_tram=rectram();
|
|
}
|
|
}
|
|
|
|
void uart0_init(void)
|
|
{
|
|
|
|
u0mr=0x05;
|
|
u0smr=0x00;
|
|
u0smr2=0x00;
|
|
u0smr3=0x00;
|
|
u0smr4=0x00;
|
|
u0c0=0x11;
|
|
u0brg=0x20;
|
|
u0c1=0x00;
|
|
pd6_0=0;
|
|
pd6_1=0;
|
|
pd6_2=0;
|
|
pd6_3=1;
|
|
ps0_0=0;
|
|
ps0_1=0;
|
|
ps0_2=0;
|
|
ps0_3=1;
|
|
u0c1=0x05;
|
|
}
|
|
|
|
void uart0_tx(char c)
|
|
{
|
|
while (ti_u0c1!=1);
|
|
u0tb=c;
|
|
}
|
|
|
|
|
|
char uart0_rx(void)
|
|
{
|
|
while (!ri_u0c1);
|
|
return u0rb;
|
|
}
|
|
|
|
|
|
|
|
|
|
int decode_int(char ch)
|
|
{
|
|
char res;
|
|
if (ch>=0x30 && ch<=0x39){
|
|
res=ch-48;
|
|
}
|
|
if (ch>=0x41 && ch<=0x46){
|
|
res=ch-55;
|
|
}
|
|
return (res);
|
|
}
|
|
|
|
int rectram(char * Buffer){
|
|
fin_tram=0;
|
|
c=uart0_rx();
|
|
if (c=='\n' || c=='\r'){
|
|
return 1;
|
|
}
|
|
if (c=='*'){
|
|
/*p1_1=1;
|
|
while (i!=10000){i++;}
|
|
p1_1=0;*/
|
|
c1=uart0_rx();
|
|
c2=uart0_rx();
|
|
debut=0;
|
|
i=0;
|
|
t1=(check&0xf0)>>4;//decode_int(c1);decode_int(c1);
|
|
t2=check&0x0f;//decode_int(c2);decode_int(c2);
|
|
t3=decode_int(c1);
|
|
t4=decode_int(c2);
|
|
if (t1==t3 && t2==t4 ){
|
|
validation=1;}
|
|
}
|
|
if (debut==1){
|
|
i++;
|
|
tram[i]=c;
|
|
*(Buffer+i)=c;
|
|
check=check^c;
|
|
}
|
|
if (c=='$'){
|
|
/*p1_0=1;
|
|
while (i!=10000){i++;}
|
|
p1_0=0;*/
|
|
debut=1;
|
|
fin_tram=0;
|
|
tram[0]=c;
|
|
}
|
|
}
|