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

Committer:
dzoni
Date:
Mon Dec 14 19:38:24 2015 +0000
Revision:
13:f62b10a6e1c5
Parent:
12:1de8b271e292
Child:
15:a627638edd9c
Now works. Too big fluctuations in distance measurement values. Change to RTOS interrupt on EDGE pin change.

Who changed what in which revision?

UserRevisionLine numberNew 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 "TextLCD.h"
dzoni 9:645f0e517017 5
dzoni 9:645f0e517017 6 #include "tsk_display.h"
dzoni 9:645f0e517017 7 #include "tsk_temp.h"
dzoni 9:645f0e517017 8 #include "tsk_dist.h"
dzoni 9:645f0e517017 9 #include "tsk_main.h"
dzoni 9:645f0e517017 10
dzoni 13:f62b10a6e1c5 11 static TextLCD *lcd = NULL;
dzoni 9:645f0e517017 12
dzoni 12:1de8b271e292 13 uint32_t initDisplay(void const *args) {
dzoni 13:f62b10a6e1c5 14
dzoni 13:f62b10a6e1c5 15 lcd = new TextLCD(PA_8, PA_7, PA_9, PA_1, PB_5, PA_10, TextLCD::LCD16x2);
dzoni 13:f62b10a6e1c5 16
dzoni 13:f62b10a6e1c5 17 lcd->cls();
dzoni 13:f62b10a6e1c5 18 lcd->printf("Row 1");
dzoni 13:f62b10a6e1c5 19 lcd->locate(0, 1);
dzoni 13:f62b10a6e1c5 20 lcd->printf("Row 2");
dzoni 13:f62b10a6e1c5 21
dzoni 13:f62b10a6e1c5 22 return 1;
dzoni 13:f62b10a6e1c5 23 }
dzoni 13:f62b10a6e1c5 24
dzoni 13:f62b10a6e1c5 25 uint32_t disposeDisplay(void const *args) {
dzoni 13:f62b10a6e1c5 26
dzoni 13:f62b10a6e1c5 27 delete lcd;
dzoni 13:f62b10a6e1c5 28 lcd = NULL;
dzoni 13:f62b10a6e1c5 29
dzoni 12:1de8b271e292 30 return 1;
dzoni 12:1de8b271e292 31 }
dzoni 12:1de8b271e292 32
dzoni 12:1de8b271e292 33
dzoni 9:645f0e517017 34 void disp_thread(void const *args) {
dzoni 9:645f0e517017 35
dzoni 9:645f0e517017 36 while (true) {
dzoni 13:f62b10a6e1c5 37 lcd->cls();
dzoni 13:f62b10a6e1c5 38 lcd->printf("Raw:%3u % 5.0f mm", temp_data.temp_raw, dist_data.distance);
dzoni 9:645f0e517017 39 uiCnt += 2;
dzoni 13:f62b10a6e1c5 40 lcd->locate(0, 1);
dzoni 13:f62b10a6e1c5 41 lcd->printf("Float: %3.2f%cC", temp_data.temperature, 0xdf);
dzoni 12:1de8b271e292 42
dzoni 13:f62b10a6e1c5 43 Thread::wait(2000);
dzoni 9:645f0e517017 44 }
dzoni 13:f62b10a6e1c5 45 }