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.
main.cpp
- Committer:
- demayer
- Date:
- 2020-04-11
- Revision:
- 1:b36bbc1c6d27
- Parent:
- 0:6bf0743ece18
- Child:
- 2:c7897a3f5f11
File content as of revision 1:b36bbc1c6d27:
#include "mbed.h" #include "mbed_events.h" #include "MPU9250.h" #define SAMPLE_TIME 100 DigitalOut led1(LED1); InterruptIn sw(USER_BUTTON); Thread eventthread; Thread imuthread; bool read_imu_isrunning; // Pin defines DigitalOut led_green(D4); //----------------------------------------------------- //IMU //----------------------------------------------------- void rise_handler(void) { printf("rise_handler in context %p\r\n", Thread::gettid()); // Toggle LED led1 = !led1; for (int i = 0; i<10; i++) { led_green = !led_green; wait(0.5); } } void fall_handler(void) { printf("fall_handler in context %p\r\n", Thread::gettid()); // Toggle LED led1 = !led1; } int main() { //pc.baud(9600); //imuSetup(); //imuthread.start(readIMU); // Request the shared queue EventQueue *queue = mbed_event_queue(); //printf("Starting in context %p\r\n", Thread::gettid()); // The 'rise' handler will execute in IRQ context sw.rise(queue->event(rise_handler)); // The 'fall' handler will execute in the context of the shared queue (actually the main thread) sw.fall(queue->event(fall_handler)); // Setup complete, so we now dispatch the shared queue from main queue->dispatch_forever(); }