]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Forgot os_simple
authormahi <devnull@localhost>
Thu, 26 May 2011 19:42:23 +0000 (21:42 +0200)
committermahi <devnull@localhost>
Thu, 26 May 2011 19:42:23 +0000 (21:42 +0200)
examples/os_simple/example_info.txt [new file with mode: 0644]
examples/os_simple/os_simple.c [new file with mode: 0644]

diff --git a/examples/os_simple/example_info.txt b/examples/os_simple/example_info.txt
new file mode 100644 (file)
index 0000000..e0e0c74
--- /dev/null
@@ -0,0 +1,11 @@
+\r
+DESCRIPTION\r
+  This is a very simple example just to demonstrate some basic OS functionally\r
+  \r
+WHAT IT DOES\r
+   1. An alarm sets Event1 in eTask1\r
+   2. eTask1 sets Event2 in eTask2 and waits for a new Event1\r
+   3. eTask2 activates bTask3 and waits for a new Event2\r
+   4. Back to 1\r
+  \r
+  
\ No newline at end of file
diff --git a/examples/os_simple/os_simple.c b/examples/os_simple/os_simple.c
new file mode 100644 (file)
index 0000000..e0fa8c2
--- /dev/null
@@ -0,0 +1,98 @@
+/* -------------------------------- Arctic Core ------------------------------
+ * Arctic Core - the open source AUTOSAR platform http://arccore.com
+ *
+ * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
+ *
+ * This source code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ * -------------------------------- Arctic Core ------------------------------*/
+
+
+#include "Os.h"
+#include "Mcu.h"
+#include "arc.h"
+
+//#define USE_LDEBUG_PRINTF // Uncomment this to turn debug statements on.
+#include "debug.h"
+
+// How many errors to keep in error log.
+#define ERROR_LOG_SIZE 20
+
+
+/**
+ * Just an example of a basic task.
+ */
+
+void bTask3( void ) {
+       StackInfoType si;
+       TaskType currTask;
+       LDEBUG_PRINTF("[%08u] bTask3 start\n", (unsigned)GetOsTick() );
+
+       GetTaskID(&currTask);
+       Os_Arc_GetStackInfo(currTask,&si);
+       LDEBUG_PRINTF("bTask3: %u%% stack usage\n",
+                       (unsigned)OS_STACK_USAGE(&si));
+
+       TerminateTask();
+}
+
+/**
+ * An extended task is auto-started and is also triggered by an alarm
+ * that sets event 2.
+ */
+
+void eTask1( void ) {
+       volatile float tryFloatingPoint = 0.0F;
+       StackInfoType si;
+       TaskType currTask;
+
+       LDEBUG_FPUTS("eTask1 start\n");
+       for(;;) {
+               SetEvent(TASK_ID_eTask2,EVENT_MASK_Event1);
+               WaitEvent(EVENT_MASK_Event2);
+               ClearEvent(EVENT_MASK_Event2);
+               tryFloatingPoint += 1.0F;
+               GetTaskID(&currTask);
+               Os_Arc_GetStackInfo(currTask,&si);
+               LDEBUG_PRINTF("eTask1: %u%% stack usage\n",
+                               (unsigned)OS_STACK_USAGE(&si));
+
+       }
+}
+
+/**
+ * An extended task that receives events from someone
+ * and activates task: bTask3.
+ */
+void eTask2( void ) {
+       LDEBUG_FPUTS("eTask2 start\n");
+
+       for(;;) {
+               WaitEvent(EVENT_MASK_Event1);
+               ClearEvent(EVENT_MASK_Event1);
+               ActivateTask(TASK_ID_bTask3);
+               {
+                       StackInfoType si;
+                       TaskType currTask;
+                       GetTaskID(&currTask);
+                       Os_Arc_GetStackInfo(currTask,&si);
+                       LDEBUG_PRINTF("eTask2: %u%% stack usage\n",
+                                       (unsigned)OS_STACK_USAGE(&si));
+               }
+       }
+}
+
+
+/*
+ * Functions that must be supplied by the example
+ */
+
+void OsIdle( void ) {
+       for(;;);
+}