Révision 905
Ajouté par ahkurklu il y a environ 4 ans
branch/KURKLU/sp4c12/sp4c12/sp4c12/rectrame.c | ||
---|---|---|
|
||
#include"sfr32c87.h"
|
||
#include <stdlib.h>
|
||
#include "rectrame.h"
|
||
#include "uart0.h"
|
||
|
||
|
||
|
||
int rectrame(char * Buffer){
|
||
int i=0;
|
||
char c1,c2;
|
||
int b = 0;
|
||
char c[2];
|
||
while(uart0_rx()!='$');
|
||
while(uart0_rx()!='*'){
|
||
Buffer[i]= uart0_rx() ;
|
||
i=i+1;
|
||
}
|
||
c1 = uart0_rx();
|
||
c2 = uart0_rx();
|
||
c[0] = uart0_rx();
|
||
c[1] = uart0_rx();
|
||
|
||
b= hex2int(c);
|
||
if (b=122){
|
||
uart0_tx('X');
|
||
uart0_tx('X');
|
||
}
|
||
|
||
return i;
|
||
}
|
||
|
||
int hex2int(char * c){
|
||
int c1;
|
||
int c2;
|
||
int resultat =0;
|
||
|
||
if(c[0]>=48 && c[0]<=57){
|
||
c1 = c[0]-48;
|
||
}
|
||
else if(c[0]>=10 && c[0]<=15){
|
||
c1 = c[0];
|
||
}
|
||
|
||
if(c[1]>=48 && c[1]<=57){
|
||
c2 = c[1]-48;
|
||
}
|
||
else if(c[1]>=10 && c[1]<=15){
|
||
c2 = c[1];
|
||
}
|
||
|
||
resultat = c2+16*c1;
|
||
return resultat;
|
||
}
|
Formats disponibles : Unified diff
Ajout fonction hex2int et test