Fabien Lepoutre
/
ProjetMbed
Revision 1:e184fce6da0d, committed 2012-01-23
- Comitter:
- fabienlepoutre
- Date:
- Mon Jan 23 13:08:52 2012 +0000
- Parent:
- 0:5fccc8628275
- Commit message:
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5fccc8628275 -r e184fce6da0d main.cpp --- a/main.cpp Mon Jan 23 12:55:16 2012 +0000 +++ b/main.cpp Mon Jan 23 13:08:52 2012 +0000 @@ -14,6 +14,7 @@ typedef struct HEADECH{ ChainEch *FirstEch; int NbEch; + ChainEch *LastEch; }HeadEch; @@ -25,30 +26,31 @@ void vTimeoutEch(){ - ChainEch* ValEch = (ChainEch*)malloc(sizeof(ChainEch)); //Cr�ation maillon valeur CAN - ValEch->fValEch = voltage; // R�cup�ration valeur -> ?!: valeur entre 0 et 1 -->> CONVERTIR + ChainEch* ValEch = (ChainEch*)malloc(sizeof(ChainEch)); //Cr�ation maillon valeur CAN + ValEch->fValEch = voltage; // R�cup�ration valeur -> ?!: valeur entre 0 et 1 -->> CONVERTIR ValEch->suivant = NULL; - if(Head->NbEch == 0){ // Test si Premier maillon - Head->FirstEch = ValEch; // Atribu. premier maillon - Head->NbEch++; + if(Head.NbEch == 0){ // Test si Premier maillon + Head.FirstEch = ValEch; // Atribu. premier maillon + Head.NbEch++; + Head.LastEch = ValEch; } else{ - ChainEch* maillon = Head->FirstEch; // On va au bou de la chaine + ChainEch* maillon = Head.FirstEch; // On va au bou de la chaine while(maillon->suivant !=NULL){ maillon = maillon->suivant; } maillon->suivant = ValEch; // Ajout a la chaine - Head->NbEch++; + Head.NbEch++; + Head.LastEch = ValEch; } } HeadEch* Echantillonnage(int freq){ - float time = 1/freq; // periode echantillonnage - HeadEch* Echanti = (HeadEch*)malloc(sizeof(HeadEch)); // Cr�ation t�te maillon - Echanti->NbEch =0; // Initialisation - Echanti->FirstEch = NULL; + float time = 1/freq; // periode echantillonnage + Head.NbEch =0; // Initialisation + Head.FirstEch = NULL; timeout.attach(&vTimeoutEch, time); // Init Timeout