|
/***********************************************************************/
|
|
/* */
|
|
/* FILE :uart0.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"
|
|
|
|
|
|
void uart0_init(void)
|
|
{
|
|
u0mr = 0x05;
|
|
|
|
//Param?trage des modes sp?ciaux
|
|
u0smr = 0x00;
|
|
u0smr2 = 0x00;
|
|
u0smr3 = 0x00;
|
|
u0smr4 = 0x00;
|
|
|
|
u0c0 = 0x11;
|
|
|
|
//Param?trage des bauds
|
|
u0brg = 32;
|
|
|
|
u0c1 = 0x00;
|
|
pd6_0 =1;
|
|
pd6_1 =0;
|
|
pd6_2 =0;
|
|
pd6_3 =1;
|
|
|
|
ps0_0 =1;
|
|
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()
|
|
{
|
|
while (ri_u0c1 !=1);
|
|
return u0rb;
|
|
|
|
}
|
|
|
|
|
|
char alphabet(void)
|
|
{
|
|
int c = 65;
|
|
uart0_init();
|
|
|
|
while(1)
|
|
{
|
|
uart0_tx((char) c);
|
|
c = (int)c +1;
|
|
if (c==91)
|
|
{
|
|
c = (int) 65;
|
|
}
|
|
}
|
|
}
|
|
|
|
int hex2int( char*c)
|
|
{
|
|
}
|
|
|
|
short recTrame (char *Buffer)
|
|
{
|
|
int i=0;
|
|
char CS =0;
|
|
char a;
|
|
char CS_reel[1];
|
|
|
|
while (uart0_rx() !='$');
|
|
|
|
while (a = uart0_rx() != '*')
|
|
{
|
|
|
|
Buffer[i] = a;
|
|
CS = Buffer[i] + CS;
|
|
i++;
|
|
}
|
|
|
|
|
|
|
|
CS_reel[0] = uart0_rx();
|
|
CS_reel[1] = uart0_rx();
|
|
if (CS_reel[0] + CS_reel[1] == CS)
|
|
{
|
|
uart0_tx('Y');
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
|
|
void main(void)
|
|
{
|
|
char nb1;
|
|
char nb2;
|
|
char trame[100];
|
|
uart0_init();
|
|
|
|
while (1)
|
|
{
|
|
nb1 = (char) (recTrame(trame))/10;
|
|
nb2 = (char) (recTrame(trame))%10;
|
|
|
|
uart0_tx(nb1+48);
|
|
uart0_tx(nb2+48);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|