Dependents:   rtest LeonardoMbos OS_test Labo_TRSE_Drone ... more

Revision:
1:b453bba9c5c0
Parent:
0:1dafafe7d505
Child:
2:af930cdf7cce
--- a/mbos.h	Sat Dec 04 16:51:52 2010 +0000
+++ b/mbos.h	Sun Dec 05 10:34:48 2010 +0000
@@ -46,23 +46,23 @@
  * #include "mbed.h"
  * #include "mbos.h"
  *
- * #define TASK1_ID			    1		// defines to make the code more readable
- * #define TASK1_PRIO			50
- * #define TASK1_STACK_SZ		32
- * #define TASK2_ID			    2
- * #define TASK2_PRIO			60
- * #define TASK2_STACK_SZ		32
- * #define TIMER0_ID			0
- * #define TIMER0_PERIOD		1000
- * #define TIMER0_EVENT		    1
- * #define T1_TO_T2_EVENT		2
+ * #define TASK1_ID                1        // defines to make the code more readable
+ * #define TASK1_PRIO            50
+ * #define TASK1_STACK_SZ        32
+ * #define TASK2_ID                2
+ * #define TASK2_PRIO            60
+ * #define TASK2_STACK_SZ        32
+ * #define TIMER0_ID            0
+ * #define TIMER0_PERIOD        1000
+ * #define TIMER0_EVENT            1
+ * #define T1_TO_T2_EVENT        2
  *
- * void task1(void);					// task function prototypes
+ * void task1(void);                    // task function prototypes
  * void task2(void);
  *
  * DigitalOut led1(LED1);
  * DigitalOut led2(LED2);
- * mbos os(2, 1);						// 2 tasks, 1 timer
+ * mbos os(2, 1);                        // 2 tasks, 1 timer
  *
  * int main(void)
  * {
@@ -76,27 +76,26 @@
  * {
  *     os.SetTimer(TIMER0_ID, TIMER0_PERIOD, TIMER0_PERIOD);
  *     while(1){
- *     		os.WaitEvent(TIMER0_EVENT);
- *     		led1 = !led1;
- * 			os.SetEvent(T1_TO_T2_EVENT, TASK2_ID);
- *	   }
+ *             os.WaitEvent(TIMER0_EVENT);
+ *             led1 = !led1;
+ *             os.SetEvent(T1_TO_T2_EVENT, TASK2_ID);
+ *       }
  * }
  * void task2(void)
  * {
- * 		while(1){
- * 			os.WaitEvent(T1_TO_T2_EVENT);
- * 			led2 = 1;
- * 			wait_ms(100);
- * 			led2 = 0;
- * 		}
+ *         while(1){
+ *             os.WaitEvent(T1_TO_T2_EVENT);
+ *             led2 = 1;
+ *             wait_ms(100);
+ *             led2 = 0;
+ *         }
  * }
  * @endcode
  */
 
 class mbos {
 public:
-    /** Create an mbos object
-     * Instantiate mbos and define the number of tasks, timers and resources. Must be called first. 
+    /** Create an mbos object. Instantiate mbos and define the number of tasks, timers and resources. 
      *
      * @param ntasks The number of user tasks (1 .. 99) in the application. 
      * @param ntimers Optional number of timers (0 ..  100) in the application.
@@ -104,20 +103,19 @@
      */
     mbos(uint ntasks, uint ntimers = 0, uint nresources = 0);
 
-    /** Start mbos
-     * Optionally specify the size of the stack for a user-written idle task. All tasks, timers and resources must be created before calling Start. 
+    /** Start mbos. Optionally specify the size of the stack for a user-written idle task. All tasks, 
+     * timers and resources must be created before calling Start. 
      *
      * @param idlestacksize Size in words (≥32) of the user-written idle stack, if present. 
      * @returns Never returns
      */
     void Start(uint idlestacksize = 0);
 
-    /** Create a mboss task
-     * Allocates and initialises the Task Control Block and task’s private stack.
+    /** Create a mboss task. Allocates and initialises the Task Control Block and task's private stack.
      *
      * @param taskid Unique ID (1 .. number specified in the constructor) for the task.
      * @param priority Priority (0 .. 99) of the task. Tasks may share the same priority.
-     * @param stacksize Size in words (≥32) of the task’s stack.
+     * @param stacksize Size in words (>= 32) of the task'sstack.
      * @param fun Pointer to the task function. Function must be static, of type void, returning  void.
      */
     void CreateTask(uint taskid, uint priority, uint stacksz, void (*fun)(void));
@@ -129,24 +127,21 @@
      */
     uint GetTask(void);
 
-    /** Set the priority of the current task
-     * Sets the priority of the calling task.Does not force a context switch. May not be called from the idle task.
+    /** Set the priority of the current task. Does not force a context switch. Does nothing if called from the idle task.
      *
      * @param priority Priority (0 .. 99) to apply to the calling task.
      */
     void SetPriority(uint priority);
 
-    /** Get the priority of the current task
-     * Returns the priority of the calling task
+    /** Get the priority of the current task.
      *
      * @returns The priority (0 .. 99) of the calling task
      */
     uint GetPriority(void);
 
-    /** Wait for an event or events
-     * Causes the current task to block, waiting for the specified event. May not be called from the idle task.
+    /** Wait for an event or events. Causes the current task to block, waiting for the specified event. Does nothing if called from the idle task, or if event is NULL.
      *
-     * @param event Event flag(s) to wait for.  May not be NULL.
+     * @param event Event flag(s) to wait for.
      */
     void WaitEvent(uint event);
 
@@ -199,7 +194,7 @@
     void CreateResource(uint resourceid, uint priority);
 
     /** Lock a resource
-     *Locks a mbos resource by temporarily allocating the resource’s priority to the calling task. This priority should be higher than that of any other task potentially accessing the resource. Does nothing if the resource is already locked, or if called from the idle task.
+     *Locks a mbos resource by temporarily allocating the resource's priority to the calling task. This priority should be higher than that of any other task potentially accessing the resource. Does nothing if the resource is already locked, or if called from the idle task.
      *
      * @param resourceid Unique ID (0 .. the number specified in the constructor - 1) of the resource. 
      * @returns Zero, if the resource was locked successfully or the id of the task locking the resource, if not.
@@ -216,7 +211,7 @@
     uint TestResource(uint resourceid);
 
     /** Frees a resource
-     * Frees an mbos resource and restores the calling task’s original priority. Does nothing if the resource is already free, if called from the idle task, or the resource was locked by a different task..
+     * Frees an mbos resource and restores the calling task's original priority. Does nothing if the resource is already free, if called from the idle task, or the resource was locked by a different task..
      *
      * @param resourceid Unique ID (0 .. the number specified in the constructor - 1) of the resource. 
      * @returns Zero, if the resource was freed successfully or the id of the task locking the resource if not.