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 FastPWM USBDevice
Fork of USBHID_TestCase by
Diff: main.cpp
- Revision:
- 6:3d15e8b4d035
- Parent:
- 5:2908292a8cf3
- Child:
- 7:bb6454b72c57
--- a/main.cpp Wed Aug 12 14:58:59 2015 +0000 +++ b/main.cpp Fri Sep 04 08:03:30 2015 +0000 @@ -14,7 +14,7 @@ DigitalOut myled3(LED3); DigitalOut myled4(LED4); -DigitalOut enableEscons(p14,1); +DigitalOut enableEscons(p14,0); InterruptIn encoder0_A(p5); InterruptIn encoder0_B(p7); @@ -23,6 +23,10 @@ InterruptIn encoder2_A(p11); InterruptIn encoder2_B(p13); +Timeout msg_watchdog; + + + Serial pc(USBTX, USBRX); // tx, rx @@ -114,12 +118,31 @@ unsigned int debug; }; +void escon_timeout() { + enableEscons = 0; + myled2 = 0; + + myled3 = 0; + myled4 = 0; + + for(int i=0;i<3;i++){ + pwm[i].write(0); + direction[i]=0; + } +} int main(void) { myled1 = 1; // SETUP + myled2 = 1; + myled3 = 1; + myled4 = 1; + + wait_ms(500); + myled1 = 0; // SETUP myled2 = 0; myled3 = 0; - myled4 = 0; + myled4 = 0; + encoder0_A.rise(&callback_0_A_rise); encoder0_A.fall(&callback_0_A_fall); @@ -136,7 +159,7 @@ encoder2_B.rise(&callback_2_B_rise); encoder2_B.fall(&callback_2_B_fall); - enableEscons = 1; + enableEscons = 0; configuration config = default_woody(); @@ -156,21 +179,24 @@ hid_to_pc.debug = 0; pc_to_hid_message pc_to_hid; - Timer t; - t.start(); +// Timer t; +// t.start(); Timer usb_timer; usb_timer.start(); Timer debug_t; debug_t.start(); + + Timer message_timeout; + message_timeout.start(); pc.printf("Hello World Debug!\n\r"); + while (1) { myled1 = 1; - myled2 = 1; @@ -182,6 +208,16 @@ if(recv_report.length == 8){ // It should always be! + + //message_timeout.reset(); + //enableEscons = 1; + //myled2 = 1; + msg_watchdog.detach(); + msg_watchdog.attach(&escon_timeout,0.5); + enableEscons = 1; + myled2 = 1; + + pc_to_hid = *reinterpret_cast<pc_to_hid_message*>(recv_report.data); //if(debug_t.read() > 0.5){ @@ -204,6 +240,7 @@ else pwm[i].write(0.8*abs_val/3.0+0.1); } + /*