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

Files at this revision

API Documentation at this revision

Comitter:
dzoni
Date:
Mon Dec 14 18:15:57 2015 +0000
Parent:
11:e89f89c0920b
Child:
13:f62b10a6e1c5
Commit message:
Compiles OK. Testing fails (display).

Changed in this revision

tsk_display.cpp Show annotated file Show diff for this revision Revisions of this file
tsk_display.h Show annotated file Show diff for this revision Revisions of this file
tsk_main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/tsk_display.cpp	Mon Dec 14 17:15:29 2015 +0000
+++ b/tsk_display.cpp	Mon Dec 14 18:15:57 2015 +0000
@@ -10,16 +10,31 @@
 
 static TextLCD lcd(PA_8, PA_7, PA_9, PA_1, PB_5, PA_10, TextLCD::LCD16x2);
 
+uint32_t initDisplay(void const *args) {
+    
+        lcd.cls();
+//        lcd.printf("Raw:%3u % 5.0f mm", temp_data.temp_raw, dist_data.distance);
+        lcd.printf("Row 1");
+        lcd.locate(0, 1);    
+//        lcd.printf("Float: %3.2f%cC", temp_data.temperature, 0xdf);
+        lcd.printf("Row 2");
+    
+    return 1;
+}
+
+
 void disp_thread(void const *args) {
 
     while (true) {
         lcd.cls();
-        lcd.printf("Raw:%3u % 5.0f mm", temp_data.temp_raw, dist_data.distance);
+//        lcd.printf("Raw:%3u % 5.0f mm", temp_data.temp_raw, dist_data.distance);
+        lcd.printf("Row 1");
         uiCnt += 2;
         lcd.locate(0, 1);    
-        lcd.printf("Float: %3.2f%cC", temp_data.temperature, 0xdf);
-        
-        Thread::wait(1900);
+//        lcd.printf("Float: %3.2f%cC", temp_data.temperature, 0xdf);
+        lcd.printf("Row 2");
+
+        Thread::wait(5000);
     }
 }
 
--- a/tsk_display.h	Mon Dec 14 17:15:29 2015 +0000
+++ b/tsk_display.h	Mon Dec 14 18:15:57 2015 +0000
@@ -1,6 +1,7 @@
 #ifndef TSK_DISPLAY_H
 #define TSK_DISPLAY_H
 
+extern uint32_t initDisplay(void const *args);
 extern void disp_thread(void const *args);
 
 #endif
--- a/tsk_main.cpp	Mon Dec 14 17:15:29 2015 +0000
+++ b/tsk_main.cpp	Mon Dec 14 18:15:57 2015 +0000
@@ -9,7 +9,6 @@
 
 #define TASKS_NUMBER    (sizeof(taskList)/sizeof(taskList[0]))
 
-
 uint32_t uiCnt = 0;
 
 struct task_definition_struct {
@@ -26,19 +25,21 @@
 };
 
 static struct task_definition_struct taskList[] = {
-    { button_thread, NULL,           NULL, NULL, osPriorityAboveNormal, 0, NULL, 0 },
-    { disp_thread,   NULL,           NULL, NULL, osPriorityLow, 0, NULL, 0 },
-    { dist_thread,   NULL,           NULL, NULL, osPriorityRealtime, 0, NULL, 0 },
-    { temp_thread,   &initDS1620Temp, NULL, NULL, osPriorityLow, 0, NULL, 0 },
-    { led_thread,    NULL,           NULL, NULL, osPriorityNormal, 0, NULL, 0 },
+    { dist_thread,   NULL,            NULL, NULL, osPriorityRealtime,    0, NULL, 0 },
+    { temp_thread,   &initDS1620Temp, NULL, NULL, osPriorityLow,         0, NULL, 0 },
+    { button_thread, NULL,            NULL, NULL, osPriorityAboveNormal, 0, NULL, 0 },
+    { led_thread,    NULL,            NULL, NULL, osPriorityNormal,      0, NULL, 0 },
+    { disp_thread,   NULL,            NULL, NULL, osPriorityLow,         0, NULL, 0 },
 };
 
 static uint32_t initTasks(void) {
-    uint32_t    i;
+    uint32_t i;
+    uint32_t retval = 1;
     
     for (i = 0; i < TASKS_NUMBER; i++) {
-        if (taskList[i].init) {
-            taskList[i].retVal = ((*taskList[i].init)(taskList[i].init_args));
+        if (taskList[i].init != NULL) {
+            if ((taskList[i].retVal = ((*taskList[i].init)(taskList[i].init_args))) == 0)
+                retval = 0;
         }
     }
             
@@ -50,24 +51,25 @@
         }
     }
     
-    return 0;
+    return retval;
 }
 
 
 int main() {
     
-    Thread::wait(1000);
-/*
-    initDS1620Temp(NULL);
-    
-    Thread dispThread(disp_thread, NULL, osPriorityLow);
-    Thread tempThread(temp_thread, NULL, osPriorityLow);
-    Thread distThread(dist_thread, NULL, osPriorityRealtime);
-    Thread led2Thread(led_thread, NULL, osPriorityNormal);
-    Thread ubuttonThread(button_thread, NULL, osPriorityAboveNormal);
-*/
+//    Thread::wait(1000);
 
-    initTasks();
+//    initDS1620Temp(NULL);
+      initDisplay(NULL);
+      
+//    Thread tempThread(temp_thread, NULL, osPriorityLow);
+//    Thread distThread(dist_thread, NULL, osPriorityRealtime);
+//    Thread ledThread(led_thread, NULL, osPriorityNormal);
+//    Thread buttonThread(button_thread, NULL, osPriorityAboveNormal);
+//    Thread dispThread(disp_thread, NULL, osPriorityNormal);
+
+
+//    initTasks();
 
     Thread::wait(osWaitForever);
 }