Simple test program to get familiar with functionality of MBED RTOS on ST Nucleo-F411RE. Tasks for LED blinking, user button, temperature measurement with DS1620, temperature measurement with internal temperature sensor of ST32F411RE, ultrasonic distance measurement and displaying result on 16x2 TextLCD.
Dependencies: DS1620_improved TextLCD_improved mbed-rtos mbed
tsk_button.cpp@17:94c385ff2641, 2015-12-18 (annotated)
- Committer:
- dzoni
- Date:
- Fri Dec 18 15:23:21 2015 +0000
- Revision:
- 17:94c385ff2641
- Parent:
- 11:e89f89c0920b
- Child:
- 18:be0130c42925
Bugfixes. Works but freezes after some time. Button task requires rewrite (InterruptIn).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dzoni | 9:645f0e517017 | 1 | #include "mbed.h" |
dzoni | 9:645f0e517017 | 2 | #include "rtos.h" |
dzoni | 9:645f0e517017 | 3 | |
dzoni | 9:645f0e517017 | 4 | #include "tsk_button.h" |
dzoni | 9:645f0e517017 | 5 | #include "tsk_led.h" |
dzoni | 9:645f0e517017 | 6 | |
dzoni | 9:645f0e517017 | 7 | static DigitalIn button1(USER_BUTTON); |
dzoni | 9:645f0e517017 | 8 | |
dzoni | 9:645f0e517017 | 9 | |
dzoni | 11:e89f89c0920b | 10 | void button_thread(void const *args) { |
dzoni | 9:645f0e517017 | 11 | static uint32_t last_state = button1; |
dzoni | 9:645f0e517017 | 12 | uint32_t temp; |
dzoni | 9:645f0e517017 | 13 | |
dzoni | 9:645f0e517017 | 14 | while (true) { |
dzoni | 9:645f0e517017 | 15 | if (button1 != last_state) { |
dzoni | 9:645f0e517017 | 16 | temp = led_flash_times.on_time; |
dzoni | 9:645f0e517017 | 17 | led_flash_times.on_time = led_flash_times.off_time; |
dzoni | 9:645f0e517017 | 18 | led_flash_times.off_time = temp; |
dzoni | 9:645f0e517017 | 19 | } |
dzoni | 9:645f0e517017 | 20 | |
dzoni | 17:94c385ff2641 | 21 | Thread::wait(500); |
dzoni | 9:645f0e517017 | 22 | } |
dzoni | 9:645f0e517017 | 23 | } |
dzoni | 9:645f0e517017 | 24 |