[PATCH rtems-examples 10/23] led/event_server/init.c: Use names for events to reflect application intent

Joel Sherrill joel at rtems.org
Wed Feb 23 22:21:38 UTC 2022


---
 led/event_server/init.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/led/event_server/init.c b/led/event_server/init.c
index 90b0360..e9225d1 100644
--- a/led/event_server/init.c
+++ b/led/event_server/init.c
@@ -13,7 +13,11 @@
 
 #include "../led.h"
 
-rtems_task Test_task(
+/* Rename to something meaningful to the application */
+#define EVENT_LED_OFF RTEMS_EVENT_1
+#define EVENT_LED_ON  RTEMS_EVENT_2
+
+rtems_task LED_Server_Thread(
   rtems_task_argument unused
 )
 {
@@ -22,15 +26,15 @@ rtems_task Test_task(
   for ( ; ; ) {
     events = 0;
     (void) rtems_event_receive(
-      (RTEMS_EVENT_1 | RTEMS_EVENT_2),
+      (EVENT_LED_OFF | EVENT_LED_ON),
       RTEMS_EVENT_ANY,
       RTEMS_NO_TIMEOUT,
       &events
     );
 
-    if ( events == RTEMS_EVENT_1 ) {
+    if ( events == EVENT_LED_OFF ) {
       LED_OFF();
-    } else if ( events == RTEMS_EVENT_2 ) {
+    } else if ( events == EVENT_LED_ON ) {
       LED_ON();
     } else {
       fprintf( stderr, "Incorrect event set 0x%08" PRIx32 "\n", events );
@@ -59,11 +63,11 @@ rtems_task Init(
     RTEMS_DEFAULT_ATTRIBUTES, &task_id
   );
 
-  (void) rtems_task_start( task_id, Test_task, 1 );
+  (void) rtems_task_start( task_id, LED_Server_Thread, 1 );
 
   for (count=0; ; count++) {
 
-    events = ( (count % 2) == 0 ) ?  RTEMS_EVENT_1 : RTEMS_EVENT_2;
+    events = ( (count % 2) == 0 ) ?  EVENT_LED_OFF : EVENT_LED_ON;
     status = rtems_event_send( task_id, events );
     if ( status != RTEMS_SUCCESSFUL )
       fputs( "send did not work\n", stderr );
-- 
1.8.3.1



More information about the devel mailing list