Projet APP5 comm Zumo avec mbed

Dependencies:   mbed PowerControl

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "zumo.h"
00002 #include "PowerControl/PowerControl.h"
00003 
00004 DigitalOut myled(LED1);
00005 zumo myzumo;
00006 Timer t1;
00007 long v1,v2;
00008 unsigned short i;
00009 int meandist;
00010 int main() {
00011     char v[3];
00012     Peripheral_PowerDown(LPC1768_PCONP_PCENET|LPC1768_PCONP_PCSPI|LPC1768_PCONP_PCRTC|LPC1768_PCONP_PCI2C2|
00013                           LPC1768_PCONP_PCI2S|LPC1768_PCONP_PCQEI|LPC1768_PCONP_PCI2C1|LPC1768_PCONP_PCCAN1|LPC1768_PCONP_PCCAN2);
00014     //and turn off the PHY OSC
00015     LPC_GPIO1->FIODIR |= 0x8000000;
00016     LPC_GPIO1->FIOCLR = 0x8000000;
00017     wait(1.0);
00018     t1.reset();
00019     t1.start();
00020     t1.stop();
00021     //printf("INIT= %u\r\n",t1.read_us());
00022     t1.reset();
00023     myled=0;
00024     
00025     while(1) {
00026         myzumo.speed(140,140);
00027         do{
00028             myzumo.read_data_wait(DATA_SENSOR_MEANDIST, (char*)&meandist);
00029         }while(meandist<50);
00030         myzumo.stop();
00031         myled=1;
00032         while(1);
00033     }
00034 }