ESOS32
ESOSOn32-bitProcessors
esos.c
Go to the documentation of this file.
1 /*
2  * "Copyright (c) 2019 J. W. Bruce ("AUTHOR(S)")"
3  * All rights reserved.
4  * (J. W. Bruce, jwbruce_AT_tntech.edu, Tennessee Tech University)
5  *
6  * Permission to use, copy, modify, and distribute this software and its
7  * documentation for any purpose, without fee, and without written agreement is
8  * hereby granted, provided that the above copyright notice, the following
9  * two paragraphs and the authors appear in all copies of this software.
10  *
11  * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR
12  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
13  * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS"
14  * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15  *
16  * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES,
17  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
18  * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
19  * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO
20  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
21  *
22  * Please maintain this header in its entirety when copying/modifying
23  * these files.
24  *
25  *
26  */
27 
28 
29 // Documentation for this file. If the \file tag isn't present,
30 // this file won't be documented.
82 #include "esos.h"
83 
84 //**********************************************************
85 // GLOBAL variables for ESOS to use/maintain
86 //**********************************************************
87 
88 // Tasks management variables
89 struct stTask __astUserTaskPool[MAX_NUM_USER_TASKS];
90 uint8_t __au8UserTaskStructIndex[MAX_NUM_USER_TASKS];
91 struct stTask __astChildTaskPool[MAX_NUM_CHILD_TASKS];
92 uint8_t __u8UserTasksRegistered;
93 uint8_t __u8ChildTasksRegistered;
94 uint16_t __u16NumTasksEverCreated;
95 
96 // ESOS timer managmentment variables
97 struct stTimer __astTmrSvcs[MAX_NUM_TMRS];
98 uint8_t __esos_u8TmrSvcsRegistered;
99 uint32_t __esos_u32TmrActiveFlags;
100 
101 #ifdef ESOS_USE_BULK_CDC_USB
102 static struct stTask __stUsbCommSystem;
103 #endif
104 
105 // ESOS task mail services
106 MAILBOX __astMailbox[MAX_NUM_USER_TASKS];
107 uint8_t __au8_MBData[MAX_NUM_USER_TASKS][MAX_SIZE_TASK_MAILBOX];
108 CBUFFER __astCircularBuffers[MAX_NUM_USER_TASKS];
109 
110 
111 // misc ESOS variables
112 uint32_t __esos_u32UserFlags, __esos_u32SystemFlags;
113 
114 /****************************************************************
115 ** Embedded Systems Operating System (ESOS) code
116 ****************************************************************/
126 ESOS_TASK_HANDLE esos_RegisterTask( uint8_t (*taskname)(ESOS_TASK_HANDLE pstTask) ) {
127  uint8_t u8_i;
128  uint8_t u8_FoundFcn = FALSE;
129  uint8_t u8_IndexFcn;
130  uint8_t u8_IndexFree=0;
131  uint8_t u8_FoundFree = FALSE;
132 
133  if (__u8UserTasksRegistered < MAX_NUM_USER_TASKS) {
134  /* First, we will look to see if the request task
135  has already been allocated to a task from the pool.
136  If so, then let's just reactivate/reset/etc the task.
137  */
138  for (u8_i=0; u8_i<MAX_NUM_USER_TASKS; u8_i++) {
139  if (__astUserTaskPool[u8_i].pfn == taskname) {
140  u8_FoundFcn = TRUE;
141  u8_IndexFcn = u8_i;
142  break;
143  } // endof if()
144  /* While we are looping through, take note of the first unused task
145  we find in the pool. We will assign this slot to the new task if
146  we can't find it already allocated a (dead) slot
147  */
148  if ((!u8_FoundFree) && (__astUserTaskPool[u8_i].pfn == NULLPTR)) {
149  u8_FoundFree = TRUE;
150  u8_IndexFree = u8_i;
151  } // endof if()
152  } // endof for()
153 
154  /* OK. We looked at all the tasks in the pool. We either
155  * found the new task already allocated (u8_FoundFcn),
156  OR
157  * we did not. In this case, there are two cases:
158  # We found a dead/free task slot in our search (u8_FoundFree),
159  OR
160  # we did not. (All slots are already being used. WE ARE IN TROUBLE!)
161 
162  If we found the new task already (dead but allocated) in the pool, then we need to
163  1) initialize the task, its flags, and its mailbox, and
164  2) add the task to the task rotation
165  */
166  if (u8_FoundFcn) {
167  __ESOS_INIT_TASK( &__astUserTaskPool[u8_IndexFcn]); // reset the task state
168  __astUserTaskPool[u8_IndexFcn].flags = 0; // reset the task flags
169  ESOS_TASK_FLUSH_TASK_MAILBOX(&__astUserTaskPool[u8_IndexFcn]); // reset the task mailbox
170  __au8UserTaskStructIndex[__u8UserTasksRegistered] = u8_IndexFcn;
171  __u8UserTasksRegistered++;
172  // make sure this task has a non-zero task identifier
173  if ( __astUserTaskPool[u8_IndexFree].u16_taskID == 0 ) {
174  // we will simply assign a sequential task ID number (sorta like unix does for PIDs)
175  __u16NumTasksEverCreated++;
176  __astUserTaskPool[u8_IndexFree].u16_taskID = __u16NumTasksEverCreated;
177  } // endif
178  return &__astUserTaskPool[u8_IndexFcn];
179  } // endof if
180  /* We did NOT find our task already in the pool, so allocate a new struct
181  It has never been registered before, or it's location was garbage collected at some
182  point.
183 
184  If we found a free task slot in the pool, then give this free slot to the new task.
185  */
186  if (u8_FoundFree) {
187  __astUserTaskPool[u8_IndexFree].pfn = taskname; // attach task to the free slot
188  __ESOS_INIT_TASK(&__astUserTaskPool[u8_IndexFree]); // reset the task state
189  __astUserTaskPool[u8_IndexFree].flags = 0; // reset the task flags
190  ESOS_TASK_FLUSH_TASK_MAILBOX(&__astUserTaskPool[u8_IndexFree]); // reset the task mailbox
191  __au8UserTaskStructIndex[__u8UserTasksRegistered] = u8_IndexFree;
192  __u8UserTasksRegistered++;
193  // Since this is a "new" task, give it a new task ID number
194  __u16NumTasksEverCreated++;
195  __astUserTaskPool[u8_IndexFree].u16_taskID = __u16NumTasksEverCreated;
196  return &__astUserTaskPool[u8_IndexFree];
197  } // endof if
198  /* we did NOT find our function in the pool OR a free struct to use, so
199  we will return a NULLPTR for now. In the future, maybe the garbage can be called here
200  to find some space by looking for killed/dead tasks. (Current dead tasks are garbaged
201  at the end of a complete pool rotation. Possibly we can do an early garbage collection
202  here, but it will only help in very rare circumstances.)
203  */
204  return NULLPTR;
205  } else {
206  return NULLPTR;
207  } //end of if-else
208 }// end esos_RegisterTask()
209 
218 uint8_t esos_UnregisterTask( uint8_t (*taskname)(ESOS_TASK_HANDLE pstTask) ) {
219  uint8_t u8Status=FALSE;
220  uint8_t u8_i, u8_z;
221  ESOS_TASK_HANDLE pstNowTask;
222 
223  /* Search through the pool and find out where the task needing unregistering
224  is residing in the pool. Then, we will mark this slot as needing removal
225  and setting a flag for task pool repacking at the end of the current
226  rotation through the pool.
227  */
228  for (u8_i=0; u8_i<__u8UserTasksRegistered; u8_i++) {
229  // get next index from array so we can get the task handle
230  u8_z = __au8UserTaskStructIndex[u8_i];
231  /* check tasks that have been allocated (not a NULLIDX) and
232  not been garbage collected (not REMOVE_IDX) yet. If our
233  task is among them, the mark it to be garbaged collected
234  (REMOVE_IDX) at the next opportunity
235  */
236  if ((u8_z != NULLIDX) & (u8_z != REMOVE_IDX)) {
237  pstNowTask = &__astUserTaskPool[u8_z];
238  // If we find our task, mark it and signal ESOS to repack task pool
239  if (pstNowTask->pfn == taskname) {
240  __au8UserTaskStructIndex[u8_i] = REMOVE_IDX;
241  __esos_SetSystemFlag( __ESOS_SYS_FLAG_PACK_TASKS );
242  u8Status=TRUE;
243  break;
244  } // end if (pfn == taskname)
245  } // end if (!NULLIDX)
246  } // end for
247  return u8Status;
248 }// end esos_UnregisterTask()
249 
259 ESOS_TASK_HANDLE esos_GetTaskHandle( uint8_t (*taskname)(ESOS_TASK_HANDLE pstTask) ) {
260  uint8_t u8_i, u8_z;
261  ESOS_TASK_HANDLE pst_NowTask;
262  ESOS_TASK_HANDLE pst_ReturnTask = (ESOS_TASK_HANDLE) NULLPTR;
263 
264  /* Scan through the pool of "registered" tasks and see
265  if we can find the task function name requested
266  */
267  for (u8_i=0; u8_i<__u8UserTasksRegistered; u8_i++) {
268  // get next index from array so we can get the task handle
269  u8_z = __au8UserTaskStructIndex[u8_i];
270  /* check tasks that have been allocated (not a NULLIDX) and
271  not been garbage collected (not REMOVE_IDX) yet. If our
272  task is among them, then return the handle to the caller
273  */
274  if ((u8_z != NULLIDX) & (u8_z != REMOVE_IDX)) {
275  pst_NowTask = &__astUserTaskPool[u8_z];
276  // If we find our task, save the pstXXX so we can return it
277  if (pst_NowTask->pfn == taskname) {
278  pst_ReturnTask = pst_NowTask;
279  break;
280  } // end if (pfn == taskname)
281  } // end if (!NULLIDX)
282  } //end for
283  return pst_ReturnTask;
284 } //end esos_GetTaskHandle()
285 
296  uint8_t u8_i, u8_z;
297  ESOS_TASK_HANDLE pst_NowTask;
298  ESOS_TASK_HANDLE pst_ReturnTask = (ESOS_TASK_HANDLE) NULLPTR;
299 
300  /* Scan through the pool of "registered" tasks and see
301  if we can find the task function name requested
302  */
303  for (u8_i=0; u8_i<__u8UserTasksRegistered; u8_i++) {
304  // get next index from array so we can get the task handle
305  u8_z = __au8UserTaskStructIndex[u8_i];
306  /* check tasks that have been allocated (not a NULLIDX) and
307  not been garbage collected (not REMOVE_IDX) yet. If our
308  task is among them, then return the handle to the caller
309  */
310  if ((u8_z != NULLIDX) & (u8_z != REMOVE_IDX)) {
311  pst_NowTask = &__astUserTaskPool[u8_z];
312  // If we find our task, save the pstXXX so we can return it
313  if (pst_NowTask->u16_taskID == u16_TaskID) {
314  pst_ReturnTask = pst_NowTask;
315  break;
316  } // end if (pfn == taskname)
317  } // end if (!NULLIDX)
318  } //end for
319  return pst_ReturnTask;
320 } //end esos_GetTaskHandleFromID()
321 
322 
323 
324 // TODO: I DONT THINK I NEED TO STORE THE ACTUAL PFNs SINCE THE PARENT'S
325 // WAIT FUNCTION WILL DECOMPOSE INTO A CALL TO THE CHILD TASK AUTOMATICALLY.
326 //
327 // INVESTIGATE MORE!
328 //
329 // TODO: make sure childs get restarted if they yield and some other task
330 // executes in the meantime!
331 
339  uint16_t u16_i = 0;
340 
341  while (u16_i < MAX_NUM_CHILD_TASKS) {
342  if (ESOS_IS_TASK_INITED( &__astChildTaskPool[u16_i]) )
343  return &__astChildTaskPool[u16_i];
344  u16_i++;
345  }
346  return NULLPTR;
347 }// end esos_u16GetFreeChildTaskStruct()
348 
349 /********************************************************************************/
350 
355 uint8_t esos_GetMaxNumberTasks(void) {
356  return MAX_NUM_USER_TASKS;
357 } // end osGetMaxNumberTasks()
358 
359 /*
360 * Determine whether a period of time has elapsed. Users
361 * have no need to call this function. It is used by ESOS
362 * internally.
363 * \param u32_startTick system tick count when timer was created
364 * \param u32_period duration of period in system ticks
365 * \retval TRUE if the period of time has elapsed
366 * \retval FALSE if the period of time has not yet elapsed
367 */
368 uint16_t __esos_hasTickDurationPassed(uint32_t u32_startTick, uint32_t u32_period) {
369  uint32_t u32_delta, u32_current;
370 
371  u32_current = esos_GetSystemTick();
372  u32_delta = u32_current - u32_startTick;
373  if (u32_current < u32_startTick)
374  u32_delta += 0xFFFFFFFF; // account for rollover (DELTA=0xFFFFFFF-start+current)
375  if (u32_delta > u32_period)
376  return TRUE;
377  else
378  return FALSE;
379 } // end __esos_hasSystemTickDurationPassed()
380 
381 /*
382 * ESOS timer services callback function. HW-specific code
383 * that creates the system tick must call this function at
384 * every ESOS system tick.
385 */
386 void __esos_tmrSvcsExecute(void) {
387  uint8_t u8_cnt, u8_index;
388 
389  u8_cnt = __esos_u8TmrSvcsRegistered;
390  u8_index = 0;
391  while (u8_cnt) {
392  // if timer is running, update its structure and call it if necessary
393  if (esos_IsTimerRunning(u8_index)) {
394  __astTmrSvcs[u8_index].u32_cntDown--;
395  if (__astTmrSvcs[u8_index].u32_cntDown == 0 ) {
396  __astTmrSvcs[u8_index].u32_cntDown = __astTmrSvcs[u8_index].u32_period;
397  __astTmrSvcs[u8_index].pfn();
398  } //endif timer has expired
399  u8_cnt--; // denote we've serviced one of the active timers
400  } // endif IsTimerRunning
401  u8_index++; // move index to next timer in array
402  } // end while(u8_cnt)
403 } //end __esos_tmrSvcsExecute()
404 
422 ESOS_TMR_HANDLE esos_RegisterTimer( void (*timername)(void), uint32_t u32_period ) {
423  uint8_t u8_i;
424 
425  if ( esos_GetNumberRunningTimers() < MAX_NUM_TMRS) {
426  for (u8_i=0; u8_i<MAX_NUM_TMRS; u8_i++ ) {
427  if (!esos_IsTimerRunning(u8_i)) {
428  __astTmrSvcs[u8_i].pfn = timername;
429  __astTmrSvcs[u8_i].u32_period = u32_period;
430  __astTmrSvcs[u8_i].u32_cntDown = u32_period;
431  __esos_u8TmrSvcsRegistered++;
432  __esos_MarkTimerRunning( u8_i );
433  return u8_i;
434  } // endif IsTimerRunning
435  } // endfor
436  return ESOS_TMR_FAILURE;
437  } // endif
438  else
439  return ESOS_TMR_FAILURE;
440 } // end esos_RegisterTimer
441 
451 uint8_t esos_UnregisterTimer( ESOS_TMR_HANDLE hnd_timer ) {
452 
453  if ( esos_IsTimerRunning(hnd_timer) ) {
454  __astTmrSvcs[hnd_timer].pfn = NULLPTR;
455  __esos_u8TmrSvcsRegistered--;
456  __esos_MarkTimerStopped(hnd_timer);
457  return TRUE;
458  } else
459  return FALSE;
460 } //end esos_UnregisterTimer()
461 
472 ESOS_TMR_HANDLE esos_GetTimerHandle( void (*pfnTmrFcn)(void) ) {
473  uint8_t u8_i=0;
474  uint8_t u8_cnt;
475 
476  u8_cnt = esos_GetNumberRunningTimers();
477  while (u8_cnt) {
478  if (esos_IsTimerRunning(u8_i) ) {
479  if ( __astTmrSvcs[u8_i].pfn == pfnTmrFcn ) return u8_i;
480  u8_cnt--;
481  } //endif
482  u8_i++;
483  } // endwhile
484  return ESOS_TMR_FAILURE;
485 } //end esos_GetTimerHandle()
486 
487 
499 uint8_t esos_ChangeTimerPeriod( ESOS_TMR_HANDLE hnd_timer, uint32_t u32_period ) {
500 
501  if (esos_IsTimerRunning(hnd_timer) ) {
502  __astTmrSvcs[hnd_timer].u32_period = u32_period;
503  return TRUE;
504  } else return FALSE;
505 } //end esos_geTimerHandle()
506 
507 void __esosInit(void) {
508  uint8_t u8_i;
509 
510  // initialize the pool of available user tasks
511  for (u8_i=0; u8_i<MAX_NUM_USER_TASKS; u8_i++) {
512  __astUserTaskPool[u8_i].pfn = NULLPTR;
513  __au8UserTaskStructIndex[u8_i] = NULLIDX;
514  __astChildTaskPool[u8_i].pfn = NULLPTR;
515  // assign each possible user task a mailbox and initialize it
516  __astUserTaskPool[u8_i].pst_Mailbox = &__astMailbox[u8_i];
517  (__astUserTaskPool[u8_i].pst_Mailbox)->pst_CBuffer = &__astCircularBuffers[u8_i];
518  __esos_InitMailbox(__astUserTaskPool[u8_i].pst_Mailbox, &__au8_MBData[u8_i][0]);
519  }
520  __esos_u32TmrActiveFlags = 0;
521  for (u8_i=0; u8_i<MAX_NUM_TMRS; u8_i++) {
522  __astTmrSvcs[u8_i].pfn = NULLPTR;
523  }
524 
525  // no user tasks are currently registered
526  __u8UserTasksRegistered = 0;
527  // no child tasks are active
528  __u8ChildTasksRegistered = 0;
529  // no timer services are active
530  __esos_u8TmrSvcsRegistered = 0;
531 
532  // initialize the ESOS pseudo-random number generator
533  // see value, in case the hardware-functions don't..
534  // Also, some internal ESOS functions may use the SW PRNG
535  // in ESOS via the hidden function, so let's make sure it
536  // is seed. We will use MAX_NUM_USER_TASKS for now.
537  __esos_set_PRNG_U32Seed( MAX_NUM_USER_TASKS );
538  // call the config routine for the hardware PRNG.
539  __esos_hw_config_PRNG();
540 
541  /* Call the user provided function to initialize the
542  * and start the ESOS system tick..
543  */
545 
546  // initialize the HW interrupts
547  // (This routine is considered HW specific, because
548  // we don't know the number of HW interrupts on the
549  // CPU at this point....)
550 #ifdef ESOS_USE_IRQS
551  _esos_hw_InitUserInterrupts();
552 #endif
553  /*
554  * Now, initialize one of the communication systems if
555  * the user has requested it in user_config.h
556  *
557  * TODO: At some point, I want to be able to run both comm
558  * systems independently so we can use USB and debug via
559  * RS232 or vice-versa. I'll worry about that later.
560  */
561 #ifdef ESOS_USE_BULK_CDC_USB
562  __esos_InitCommSystem();
563 #endif
564 #ifdef ESOS_USE_SERIAL_PORT
565  __esos_InitCommSystem();
566 #endif
567 
568 #ifdef ESOS_USE_LCD
569  // Initialize LCD services
570  __esos_lcd44780_init();
571 #endif
572 
573 
574  user_init();
575 
576 #ifdef ESOS_USE_SUI
577  // must be called **AFTER** user_init() because we expect the user
578  // to "register" their SUI elements before we try to initialize the
579  // devices
580  __esos_InitSUI();
581 #endif
582 
583 #if defined (ESOS_USE_I2C_100KBPS) || defined (ESOS_USE_I2C) || defined (ESOS_USE_I2C_400KBPS)
584  // Cal **AFTER** user_init() because the user might have set
585  // pin directions and peripheral functions in their user_init()
586  // ESOS will call the specific __esos_i2c_hw_config( u32_i2cbps)
587  // as well.
588 #ifdef ESOS_USE_I2C_400KBPS
589  #warning Using 400kbps I2C service.... Can your I2C slaves handle it?
590  __esos_i2c_config(400000UL);
591 #else
592  __esos_i2c_config(100000UL);
593 #endif
594 #endif
595 
596 // Call **AFTER** user_init() because the user might have set
597 // pin directions and peripheral functions in their user_init()
598 // ESOS will call the specific __esos_spi_hw_config( u32_spibps)
599 // as well.
600 #ifdef ESOS_USE_SPI
601  __esos_spi_config(1000000UL);
602 #endif
603 
604 #ifdef ESOS_USE_WATCHDOG
605  // must be called at the very end so that watchdog doesnt reset
606  // us before the user gets around to feeding the watchdog
607  // We will use a 1000 ms = 1 second watchdog period for now....
608  _esos_wdog_initWatchdog( 1000 );
609 #endif
610 
611 } // end osInit()
612 
613 main_t main(void) {
614  uint8_t u8TaskReturnedVal=0;
615  uint8_t u8i,u8j, u8NumRegdTasksTemp;
616  ESOS_TASK_HANDLE pstNowTask;
617 
618  __esosInit();
619  /* Keep a running counter of number of tasks we've created
620  ** to serve as stupid/simple task identifier
621  */
622  __u16NumTasksEverCreated = 0;
623  while (TRUE) {
624  /* First, let ESOS get something done.....
625  * service communications, garbage collection, etc.
626  * Whatever a nice little OS needs to do.
627  */
628 
629  u8i = 0;
630  /* get the number of currently registered tasks.... we must make
631  * a local copy, because the tasks themselves may unregister and
632  * change the variable __u8UserTasksRegistered as they go!
633  */
634  u8NumRegdTasksTemp = __u8UserTasksRegistered;
635 
636  // if there are registered tasks, let them run (call them)
637  while ( u8i < u8NumRegdTasksTemp ) {
638  /* Get the next task up for execution. Call it and catch
639  its state (returned value) when it gives focus back.
640  We may need to do something depending on its new state,
641  e.g. if it has ended, we need to remove it from the rotation
642  */
643  pstNowTask = &__astUserTaskPool[__au8UserTaskStructIndex[u8i]];
644  u8TaskReturnedVal = pstNowTask->pfn( pstNowTask );
645  if (u8TaskReturnedVal == ESOS_TASK_ENDED) {
646  //printf ("Unregistering an ENDED protothread\n");
647  esos_UnregisterTask( pstNowTask->pfn );
648  } // endif
649  u8i++;
650  OS_ITERATE;
651  } //end while()
652 
653  /* we have completed a rotation through the set of active tasks
654  Now repack the pool (if necessary) to keep everything nice and
655  tight.
656  */
657  if (__esos_IsSystemFlagSet( __ESOS_SYS_FLAG_PACK_TASKS) ) {
658  /* Now, loop over the UserTasks and pack them into
659  the beginning of our arrays. We loop through the list
660  backwards.....
661 
662  Loop over the original number of registered tasks and
663  look for NULLPTRs. If you find one, scoot all the following
664  tasks down by one and make the last one a NULLPTR. Reduce
665  our count of tasks by one to make the next search shorter.
666 
667  NOTE: we can't "break" the for-loop search because there
668  may be more than one unregistered tasks in the pool
669  */
670  u8i = __u8UserTasksRegistered;
671  // TODO: CHANGE THIS TO A do{}while(u8i)
672  while(TRUE) {
673  pstNowTask = &__astUserTaskPool[u8i];
674  if (__au8UserTaskStructIndex[u8i] == REMOVE_IDX) {
675  for ( u8j=u8i+1; u8j<u8NumRegdTasksTemp; u8j++) {
676  __au8UserTaskStructIndex[u8j-1] = __au8UserTaskStructIndex[u8j];
677  } // end for
678  __au8UserTaskStructIndex[u8NumRegdTasksTemp-1] = NULLIDX;
679  u8NumRegdTasksTemp--;
680  } // end if
681  /* Have we hit the beginning of the task pool yet?
682  If not, decrement (do another).
683  If so, we are done (break)
684  */
685  if (u8i)
686  u8i--;
687  else
688  break;
689  } // end while
690  /* We have repacked the task pool (possibly multiple times), so update
691  the new number of registered tasks and clear the task PACK flag
692  */
693  __u8UserTasksRegistered=u8NumRegdTasksTemp; // set record the new number of registered tasks
694  __esos_ClearSystemFlag( __ESOS_SYS_FLAG_PACK_TASKS );
695  } // end if
696  } //end while
697 
698  OS_END;
699 
700 } //end main()
esos_GetTaskHandleFromID
ESOS_TASK_HANDLE esos_GetTaskHandleFromID(uint16_t u16_TaskID)
Definition: esos.c:295
__ESOS_INIT_TASK
#define __ESOS_INIT_TASK(TaskHandle)
Definition: esos_task.h:142
esos_UnregisterTask
uint8_t esos_UnregisterTask(uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
Definition: esos.c:218
esos_RegisterTimer
ESOS_TMR_HANDLE esos_RegisterTimer(void(*timername)(void), uint32_t u32_period)
Definition: esos.c:422
__esos_set_PRNG_U32Seed
void __esos_set_PRNG_U32Seed(uint32_t u32_seed)
Definition: esos_utils.c:70
__esos_hw_InitSystemTick
void __esos_hw_InitSystemTick(void)
Definition: esos_hwxxx_tick.c:102
esos_GetTaskHandle
ESOS_TASK_HANDLE esos_GetTaskHandle(uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
Definition: esos.c:259
NULLPTR
#define NULLPTR
Definition: all_generic.h:435
esos_IsTimerRunning
#define esos_IsTimerRunning(hndl)
Definition: esos.h:568
esos_GetSystemTick
#define esos_GetSystemTick()
Definition: esos.h:418
__stMAILBOX
Definition: esos_mail.h:60
esos_GetTimerHandle
ESOS_TMR_HANDLE esos_GetTimerHandle(void(*pfnTmrFcn)(void))
Definition: esos.c:472
__stCIRCBUFF
Definition: esos_cb.h:56
ESOS_TASK_HANDLE
ESOS_TASK_FLUSH_TASK_MAILBOX
#define ESOS_TASK_FLUSH_TASK_MAILBOX(pstTask)
Definition: esos_mail.h:228
__esos_i2c_config
void __esos_i2c_config(uint32_t u32_i2cbps)
Definition: esos_i2c.c:65
__esos_spi_config
void __esos_spi_config(uint32_t u32_spibps)
Definition: esos_spi.c:70
user_init
void user_init(void)
Definition: app_timer.c:476
esos.h
_esos_wdog_initWatchdog
void _esos_wdog_initWatchdog(uint32_t u32_msBetweenWatchdogResets)
Definition: esos_wdog.c:66
esos_ChangeTimerPeriod
uint8_t esos_ChangeTimerPeriod(ESOS_TMR_HANDLE hnd_timer, uint32_t u32_period)
Definition: esos.c:499
MAX_NUM_CHILD_TASKS
#define MAX_NUM_CHILD_TASKS
Definition: esos.h:149
ESOS_IS_TASK_INITED
#define ESOS_IS_TASK_INITED(TaskHandle)
Definition: esos_task.h:166
stTimer
Definition: esos.h:175
TRUE
@ TRUE
Definition: all_generic.h:410
__esos_InitSUI
void __esos_InitSUI(void)
Definition: esos_sui.c:741
FALSE
@ FALSE
Definition: all_generic.h:408
stTask
Definition: esos_task.h:54
esos_GetMaxNumberTasks
uint8_t esos_GetMaxNumberTasks(void)
Definition: esos.c:355
esos_UnregisterTimer
uint8_t esos_UnregisterTimer(ESOS_TMR_HANDLE hnd_timer)
Definition: esos.c:451
NULLIDX
#define NULLIDX
Definition: all_generic.h:437
ESOS_TMR_HANDLE
uint8_t ESOS_TMR_HANDLE
Definition: esos.h:337
main_t
int main_t
Definition: esos.h:128
esos_GetFreeChildTaskStruct
ESOS_TASK_HANDLE esos_GetFreeChildTaskStruct()
Definition: esos.c:338
esos_RegisterTask
ESOS_TASK_HANDLE esos_RegisterTask(uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
Definition: esos.c:126
esos_GetNumberRunningTimers
#define esos_GetNumberRunningTimers()
Definition: esos.h:555