William Singleton
/
595_Lab_8_Part_I_Thread
Libraries required to run 595 lab 8
main.cpp@13:f8cee8ecb4f0, 2020-05-03 (annotated)
- Committer:
- wssingle
- Date:
- Sun May 03 19:09:23 2020 +0000
- Revision:
- 13:f8cee8ecb4f0
- Parent:
- 12:4e3f46e615d9
Part one of Lab 8 (595)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wssingle | 13:f8cee8ecb4f0 | 1 | #include "mbed.h" |
wssingle | 13:f8cee8ecb4f0 | 2 | #include "rtos.h" |
wssingle | 13:f8cee8ecb4f0 | 3 | |
wssingle | 13:f8cee8ecb4f0 | 4 | DigitalOut led1(LED1); |
wssingle | 13:f8cee8ecb4f0 | 5 | DigitalOut led2(LED2); |
wssingle | 13:f8cee8ecb4f0 | 6 | Thread thread; |
wssingle | 13:f8cee8ecb4f0 | 7 | |
wssingle | 13:f8cee8ecb4f0 | 8 | void led2_thread() { |
wssingle | 13:f8cee8ecb4f0 | 9 | while (true) { |
wssingle | 13:f8cee8ecb4f0 | 10 | led2 = !led2; |
wssingle | 13:f8cee8ecb4f0 | 11 | Thread::wait(1000); |
wssingle | 13:f8cee8ecb4f0 | 12 | } |
wssingle | 13:f8cee8ecb4f0 | 13 | } |
wssingle | 13:f8cee8ecb4f0 | 14 | |
wssingle | 13:f8cee8ecb4f0 | 15 | int main() { |
wssingle | 13:f8cee8ecb4f0 | 16 | thread.start(led2_thread); |
wssingle | 13:f8cee8ecb4f0 | 17 | |
wssingle | 13:f8cee8ecb4f0 | 18 | while (true) { |
wssingle | 13:f8cee8ecb4f0 | 19 | led1 = !led1; |
wssingle | 13:f8cee8ecb4f0 | 20 | Thread::wait(500); |
wssingle | 13:f8cee8ecb4f0 | 21 | } |
wssingle | 13:f8cee8ecb4f0 | 22 | } |