kevin eccli / Mbed 2 deprecated Freescale_CupV4

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "main.h"
00002 
00003 
00004 //VOIR LA PRIORITE DES INTERRUPTIONS
00005 //INTERRUPTION SUR LES CLICKS DES CAPTEURS DE VITESSE DOIT AVOIR UNE PRIORITE PLUS IMPORTANTE
00006 //QUE LA CAMERA OU LE RESTE 
00007 
00008 // COMMANDE: 53 43 FF FF FF 0A
00009 // Freescale de merde
00010 
00011 Propulsion propulsion;
00012 DigitalOut led_run(LED_RED);
00013 Camera cam(P_SI,P_CLK,P_AO,5);
00014 Ticker timer;
00015 Timer t;
00016 int begin,end;
00017 int t_int;
00018 bool acquisition;
00019 
00020 unsigned short valeurs[128];
00021 
00022 void call() {
00023     acquisition = true;
00024 }
00025 
00026 void setTIntegration(int t)
00027 {
00028     timer.detach();
00029     timer.attach_us(&call,t);
00030 }
00031 
00032 //TEMPS INTEGRATION 0.065-100 ms
00033 int main()
00034 {
00035    init();
00036    t.start();
00037    acquisition = false;
00038    t_int = 10000;
00039    timer.attach_us(&call,t_int);
00040     /*Attente active !! Argh ! */
00041     
00042     /*Ou est ce que tu vois une attente active, il n'y a qu'un pauvre vieux test a chaque passage*/
00043     /*De plus, je te paie une bière si tu me codes un OS pour Freescale qui me gère la préemption et le réveil de Thread*/
00044     
00045     while (true) {
00046         if(acquisition) {
00047             led_run = !led_run;
00048             
00049             //Lancement acquisition
00050             begin = t.read_us();
00051             cam.capture(valeurs);
00052             end = t.read_us();
00053             
00054             acquisition = false;
00055         }
00056     }
00057 }