Projet

Général

Profil

« Précédent | Suivant » 

Révision 858

Ajouté par gasacco il y a presque 4 ans

Fonction uart0_rx, codage de rectrame et checksum à continuer

Voir les différences:

branch/sacco/sp4c12/SP4c1/SP4c1/uart0.c
}
}
}
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)
{
uart0_init();
while(1)
char nb1;
char nb2;
char trame[100];
uart0_init();
while (1)
{
uart0_tx(uart0_rx() +1);
nb1 = (char) (recTrame(trame))/10;
nb2 = (char) (recTrame(trame))%10;
uart0_tx(nb1+48);
uart0_tx(nb2+48);
}
}

Formats disponibles : Unified diff