Fabien Lepoutre
/
ProjetMbed
Diff: main.cpp
- Revision:
- 0:5fccc8628275
- Child:
- 1:e184fce6da0d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jan 23 12:55:16 2012 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +Timeout timeout; +AnalogIn voltage(p20); + + +typedef struct CHAINECH{ + float fValEch; + struct CHAINECH* suivant; + }ChainEch; + + +typedef struct HEADECH{ + ChainEch *FirstEch; + int NbEch; + }HeadEch; + + +HeadEch Head; + + +int main() { +} + + +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 + ValEch->suivant = NULL; + if(Head->NbEch == 0){ // Test si Premier maillon + Head->FirstEch = ValEch; // Atribu. premier maillon + Head->NbEch++; + } + else{ + 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++; + } +} + + + +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; + + + timeout.attach(&vTimeoutEch, time); // Init Timeout + } + + + + +