[rtems-examples commit] led/event_server/init.c: Use names for events to reflect application intent
Joel Sherrill
joel at rtems.org
Thu Feb 24 23:04:33 UTC 2022
Module: rtems-examples
Branch: master
Commit: 24ce5a343fe2efd04c0a2a3af75ed399c4d4c99d
Changeset: http://git.rtems.org/rtems-examples/commit/?id=24ce5a343fe2efd04c0a2a3af75ed399c4d4c99d
Author: Joel Sherrill <joel at rtems.org>
Date: Tue Feb 22 13:20:49 2022 -0600
led/event_server/init.c: Use names for events to reflect application intent
---
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 );
More information about the vc
mailing list