Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed tsi_sensor MMA8451Q
Diff: main.cpp
- Revision:
- 0:6ab157599e7f
diff -r 000000000000 -r 6ab157599e7f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 14 07:38:57 2020 +0000 @@ -0,0 +1,54 @@ +#include "func.h" + +//Timer +Ticker ticker; +//UART +RawSerial pc(USBTX, USBRX); + +int main ( void ) +{ + printf("INICIO PROGRAMA\r\n"); + //Inicializo interrupts + ticker.attach(&interrupcion_timer,0.001); //Timer 1ms + pc.attach(&interrupcion_UART); //UART + + while ( 1 ) { + MaquinaDeEstados(); + } +} + +//Interrupts + +void interrupcion_UART() { + unsigned char dato; + dato = pc.getc(); + CargarDatoAlBufferCircular (dato); +} + +void interrupcion_timer() +{ + static int tickMuestreo = 0; + static int tickLr = 500; + static int tickLg = 1000; + tickMuestreo --; + if ( tickMuestreo <= 0 ) { + fMuestras= TRUE; + tickMuestreo = TiempoDeMuestreo * 1000; + } + tickLr--; + if ( tickLr<= 0 ) { + if(fLr) + fLr = FALSE; + else + fLr = TRUE; + tickLr = 500; + } + tickLg--; + if ( tickLg<= 0 ) { + if(fLg) + fLg = FALSE; + else + fLg = TRUE; + tickLg = 1000; + } +} \ No newline at end of file