Projet APP5 comm Zumo avec mbed

Dependencies:   mbed PowerControl

main.cpp

Committer:
bouaziz
Date:
2022-01-10
Revision:
3:f12fee4182d3
Parent:
2:d5dd5e731d4a

File content as of revision 3:f12fee4182d3:

#include "zumo.h"
#include "PowerControl/PowerControl.h"

DigitalOut myled(LED1);
zumo myzumo;
Timer t1;
long v1,v2;
unsigned short i;
int meandist;
int main() {
    char v[3];
    Peripheral_PowerDown(LPC1768_PCONP_PCENET|LPC1768_PCONP_PCSPI|LPC1768_PCONP_PCRTC|LPC1768_PCONP_PCI2C2|
                          LPC1768_PCONP_PCI2S|LPC1768_PCONP_PCQEI|LPC1768_PCONP_PCI2C1|LPC1768_PCONP_PCCAN1|LPC1768_PCONP_PCCAN2);
    //and turn off the PHY OSC
    LPC_GPIO1->FIODIR |= 0x8000000;
    LPC_GPIO1->FIOCLR = 0x8000000;
    wait(1.0);
    t1.reset();
    t1.start();
    t1.stop();
    //printf("INIT= %u\r\n",t1.read_us());
    t1.reset();
    myled=0;
    
    while(1) {
        myzumo.speed(140,140);
        do{
            myzumo.read_data_wait(DATA_SENSOR_MEANDIST, (char*)&meandist);
        }while(meandist<50);
        myzumo.stop();
        myled=1;
        while(1);
    }
}