DEMONSTRATION OF SIGNAL (EVENT & FLAG) in MBED RTOS. One Thread set particular signal and another thread receive it and proceed according signal state.

Files at this revision

API Documentation at this revision

Comitter:
radhey04ec
Date:
Wed Aug 05 07:15:14 2020 +0000
Child:
1:9dbbb3022957
Commit message:
EVENT , FLAG AND SIGNAL CONCEPT DEMO; PROGRAM CHECKED : SUCCESSFULLY

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
CONTRIBUTING.md Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
resources/official_armmbed_example_badge.png Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Wed Aug 05 07:15:14 2020 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CONTRIBUTING.md	Wed Aug 05 07:15:14 2020 +0000
@@ -0,0 +1,5 @@
+# Contributing to Mbed OS
+
+Mbed OS is an open-source, device software platform for the Internet of Things. Contributions are an important part of the platform, and our goal is to make it as simple as possible to become a contributor.
+
+To encourage productive collaboration, as well as robust, consistent and maintainable code, we have a set of guidelines for [contributing to Mbed OS](https://os.mbed.com/docs/mbed-os/latest/contributing/index.html).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Wed Aug 05 07:15:14 2020 +0000
@@ -0,0 +1,14 @@
+SIGNAL USAGE INSIDE RTOS
+
+
+What is Signal ?  - Answer : Remember these five points
+
+1) Signals are different from all the other types of kernel object in that they are not autonomous (user need to control or set - No automatioc control like semaphore)
+2) signals are associated with tasks/Threads and have no independent existence. 
+3) If signals are configured for an application, each task has a set of eight signal flags.
+
+4) Any task can set the signals of another task. Only the owner task can read the signals. 
+5) The read is destructive – i.e. the signals are cleared by the process of reading. No other task can read or clear a task’s signals.
+
+JAYDEEP SHAH
+radhey04ec@gmail.com
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 05 07:15:14 2020 +0000
@@ -0,0 +1,57 @@
+/* SIGNAL USAGES IN RTOS 
+What is Signal ?  - Answer : Remember these five points
+
+1) Signals are different from all the other types of kernel object in that they are not autonomous (user need to control or set - No automatioc control like semaphore)
+2) signals are associated with tasks/Threads and have no independent existence. 
+3) If signals are configured for an application, each task has a set of eight signal flags.
+
+4) Any task can set the signals of another task. Only the owner task can read the signals. 
+5) The read is destructive – i.e. the signals are cleared by the process of reading. No other task can read or clear a task’s signals.
+
+
+In below example there are two threads 1)main thread and 2)Thread that is connected with onBoard_led functions
+We set the signal from main thread ,  second thread received the signal and toggle the led state.
+
+Program name : LED BLINKING USING RTOS SIGNAL
+PLATFORM : STM NUCLEO 64 L476
+Created by : jaydeep shah
+email : radhey04ec@gmail.com
+*/
+
+/* NOTE : WE ARE GOING TO USE EVENT FLAG CLASS METHOD The EventFlags class is used to control event flags or wait for event flags other threads control.
+*/
+#include "mbed.h"
+#include "rtos.h"
+ 
+DigitalOut led(LED2);  //ON BOARD LED
+ 
+EventFlags event_flags;  // EVESNT FLAG OBJECT CREATED (DOMAIN : SIGNAL)
+
+//TASK which is related to signal 
+void onBoard_led() {
+    uint32_t read = 0;
+    while (true) {
+        // Signal flags that are reported as event are automatically cleared -Autonomous object of Kernal
+        
+        read = event_flags.wait_any(0x1 | 0x2);
+        if(read == 0x1)
+        {
+        led = !led;  //Toggle state
+        }
+        printf("\n Received this flag event 0x%08lx \n\r",read);
+        
+    }
+}
+ 
+int main (void) {
+    Thread thread;  //create threaed
+ 
+    thread.start(callback(onBoard_led));  //Thread start
+ 
+    while (true) {
+        ThisThread::sleep_for(1000); //sleep for 1 sec
+        event_flags.set(0x1);  //set the signal for thread task from main thread  --LED BLINK TASK
+        ThisThread::sleep_for(1000);
+        event_flags.set(0x2); //This signal for print the statement -- use serial terminal
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed Aug 05 07:15:14 2020 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#cf4f12a123c05fcae83fc56d76442015cb8a39e9
Binary file resources/official_armmbed_example_badge.png has changed