Révision 911
Ajouté par dgmbadinga il y a environ 4 ans
uart0.c | ||
---|---|---|
#include "sfr32c87.h"
|
||
|
||
void uart0_init(void)
|
||
{
|
||
smd0_u0mr=1;
|
||
smd1_u0mr=0;
|
||
smd2_u0mr=1;
|
||
ckdir_u0mr=0;
|
||
stps_u0mr=0;
|
||
prye_u0mr=0;
|
||
iopol_u0mr=0;
|
||
u0smr=0x00;
|
||
u0smr2=0x00;
|
||
u0smr3=0x00;
|
||
u0smr4=0x00;
|
||
|
||
|
||
clk0_u0c0=0;
|
||
clk1_u0c0=0;
|
||
crd_u0c0=1;
|
||
crs_u0c0=0;
|
||
nch_u0c0=0;
|
||
ckpol_u0c0=0;
|
||
uform_u0c0=0;
|
||
txept_u0c0=0;
|
||
|
||
u0brg=255;
|
||
|
||
te_u0c1=0;
|
||
re_u0c1=0;
|
||
ti_u0c1=1;
|
||
ri_u0c1=0;
|
||
u0rrm_u0c1=0;
|
||
u0lch_u0c1=0;
|
||
|
||
//bit 7=0
|
||
u0c1=u0c1 & 0x7f;
|
||
|
||
pd6_0=0;
|
||
pd6_1=0;
|
||
pd6_2=0;
|
||
pd6_3=1;
|
||
|
||
ps0_0=0;
|
||
ps0_1=0;
|
||
ps0_2=0;
|
||
ps0_3=1;
|
||
psl0_0=0;
|
||
|
||
}
|
||
|
||
void uart0_init (void)
|
||
{
|
||
|
||
//initialisation des ports
|
||
pd6_1 = 0 ;
|
||
pd6_2 = 0;
|
||
pd6_3 = 1;
|
||
ps0_1 = 0;
|
||
ps0_2 = 0;
|
||
ps0_3 = 1;
|
||
|
||
//initialisation des registres
|
||
u0mr = 0x05;
|
||
u0brg = 0x20;
|
||
u0c0 = 0x11;
|
||
u0c1 = 0x05;
|
||
}
|
||
|
||
void uart0_tx(char c)
|
||
{
|
||
ti_u0c1=0;
|
||
while(ri_u0c1!=1);
|
||
u0tb=c;
|
||
|
||
}
|
||
|
||
char uart0_rx(void)
|
||
{
|
||
psl0_0=1;
|
||
while(ri_u0c1!=1);
|
||
return u0rb;
|
||
|
||
|
||
}
|
||
{
|
||
while(ti_u0c1 !=1);
|
||
u0tb=c;
|
||
}
|
||
|
||
char uart0_rx()
|
||
{
|
||
char c;
|
||
while(ri_u0c1!=1);
|
||
c=u0rb;
|
||
uart0_tx(c);
|
||
return c;
|
||
}
|
Formats disponibles : Unified diff
tpsp4 c12 non terminé