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.
Diff: DO/DO.cpp
- Revision:
- 4:e0ca69606fdf
- Parent:
- 1:5c0ca9bdf810
- Child:
- 5:19a7a0f972cb
--- a/DO/DO.cpp Mon Oct 23 18:45:55 2017 +0000 +++ b/DO/DO.cpp Mon Oct 23 20:39:18 2017 +0000 @@ -7,6 +7,7 @@ Queue <char,16> queueCharReception; extern Serial pc; +Timer timer; void receiveChar() { @@ -19,6 +20,7 @@ res = res | (((char)evt.value.p)<<i); } } + queueCharReception.put((char*)res); } @@ -26,29 +28,28 @@ void receiveBit() { - Timer timer; + timer.start(); int oldTime; - bool bitType=false; - Thread::signal_wait(0x02); + bool bitType=true; oldTime = timer.read_ms(); - //TODO SYNCHRONISATION + printf("\n %d \n ",oldTime); while(1) { Thread::signal_wait(0x01); - if(timer.read_ms()-oldTime<T) { - Thread::signal_wait(0x01); - } else { + //printf("\n %d",timer.read_ms()-oldTime); + if(timer.read_ms()-oldTime<(T-(T*0.15))*1000){ + Thread::signal_wait(0x01); + } + else { bitType=!bitType; } - - timer.reset(); - oldTime=timer.read_ms(); - - if(bitType) { queueBitReception.put((void*)0x01); + pc.putc(0x31); } else { queueBitReception.put((void*)0x00); + pc.putc(0x30); } + oldTime=timer.read_ms(); } } @@ -85,7 +86,6 @@ if(evt.status == osEventMessage) { reception = (char)evt.value.p; pc.putc(reception); - //TODO remplacer le putc par la fabrication d'un trame propre + calcul du crc16 avec cette derniere } }while(reception!=STOP); }