main.cpp 501 B

1234567891011121314151617181920212223
  1. #include "mbed.h"
  2. #include "cmsis_os.h"
  3. DigitalOut led(LED1);
  4. void led_thread(void const *argument) {
  5. while (true) {
  6. // Signal flags that are reported as event are automatically cleared.
  7. osSignalWait(0x1, osWaitForever);
  8. led = !led;
  9. }
  10. }
  11. osThreadDef(led_thread, osPriorityNormal, DEFAULT_STACK_SIZE);
  12. int main (void) {
  13. osThreadId tid = osThreadCreate(osThread(led_thread), NULL);
  14. while (true) {
  15. osDelay(1000);
  16. osSignalSet(tid, 0x1);
  17. }
  18. }