00001 /* 00002 * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")" 00003 * All rights reserved. 00004 * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University) 00005 * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University) 00006 * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University) 00007 * 00008 * Permission to use, copy, modify, and distribute this software and its 00009 * documentation for any purpose, without fee, and without written agreement is 00010 * hereby granted, provided that the above copyright notice, the following 00011 * two paragraphs and the authors appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS" 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00021 * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00023 * 00024 * Please maintain this header in its entirety when copying/modifying 00025 * these files. 00026 * 00027 * 00028 */ 00029 00030 #define ESOS_USE_IRQS 00031 00032 // INCLUDEs go here (First include the main esos.h file) 00033 // After that, the user can include what they need 00034 #include "esos.h" 00035 #include "esos_pc.h" 00036 #include "esos_pc_stdio.h" 00037 00038 00039 // DEFINEs go here 00040 00041 /* 00042 * PROTOTYPEs go here 00043 * 00044 */ 00045 00046 // GLOBALs go here 00047 // Generally, the user-created semaphores will be defined/allocated here 00048 volatile uint32 u32_T2Count; 00049 volatile uint32 u32_T3Count; 00050 static uint8 psz_T2Is[]="T2 is "; 00051 static uint8 psz_T3Is[]="T3 is "; 00052 static uint8 psz_Enabled[]="enabled."; 00053 static uint8 psz_Disabled[]="disabled."; 00054 static uint8 psz_CRNL[3]= {0x0D, 0x0A, 0}; 00055 00056 struct stTask* pst_MyTasks[3]; 00057 00058 /************************************************************************ 00059 * User supplied functions 00060 ************************************************************************ 00061 */ 00062 00063 /****************************************************************************** 00064 * Function: upper_case 00065 * 00066 * PreConditions: This ESOS task has been registered with ESOS properly 00067 * 00068 * Input: None 00069 * 00070 * Output: None 00071 * 00072 * Side Effects: 00073 * 00074 * Overview: A task to read the data buffers, convert them to upper case 00075 * and send the data right back out. 00076 * 00077 * Notes: 00078 * 00079 *****************************************************************************/ 00080 ESOS_USER_TASK( upper_case ) { 00081 static uint8 u8_Char; 00082 00083 ESOS_TASK_BEGIN(pstTask); 00084 while (TRUE) { 00085 ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM(); 00086 ESOS_TASK_SIGNAL_BUSY_IN_COMM(); 00087 ESOS_TASK_WAIT_ON_GET_UINT8( u8_Char ); 00088 ESOS_TASK_RELEASE_IN_COMM(); 00089 if ((u8_Char >= 'a') && (u8_Char <= 'z') ) 00090 u8_Char = u8_Char - 'a' + 'A'; 00091 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00092 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00093 ESOS_TASK_WAIT_ON_SEND_UINT8( u8_Char); 00094 ESOS_TASK_RELEASE_OUT_COMM(); 00095 } // endof while(TRUE) 00096 ESOS_TASK_END(pstTask); 00097 } 00098 00099 /****************************************************************************** 00100 * Function: echo 00101 * 00102 * PreConditions: This ESOS task has been registered with ESOS properly 00103 * 00104 * Input: None 00105 * 00106 * Output: None 00107 * 00108 * Side Effects: 00109 * 00110 * Overview: A task to read the data buffers, and echo it write back out 00111 * 00112 * Notes: 00113 * 00114 *****************************************************************************/ 00115 ESOS_USER_TASK( echo ) { 00116 static uint8 u8_Char; 00117 00118 ESOS_TASK_BEGIN(pstTask); 00119 while (TRUE) { 00120 ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM(); 00121 ESOS_TASK_SIGNAL_BUSY_IN_COMM(); 00122 ESOS_TASK_WAIT_ON_GET_UINT8( u8_Char ); 00123 ESOS_TASK_RELEASE_IN_COMM(); 00124 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00125 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00126 ESOS_TASK_WAIT_ON_SEND_UINT8( u8_Char); 00127 ESOS_TASK_RELEASE_OUT_COMM(); 00128 } // endof while(TRUE) 00129 ESOS_TASK_END(pstTask); 00130 } 00131 00132 // user task to talk to child task RX/TX tasks --- bypasses the 00133 // ESOS comm system. Requires that you "disable" the 00134 // ESOS comm system task in the main ESOS code. 00135 // 00136 // USED ONLY FOR DEVELOPMENT AND TESTING! 00137 ESOS_USER_TASK( child_echo_buffers ) { 00138 00139 #define LOCAL_BUFFER_LEN 16 00140 00141 static uint8 u8_i; 00142 static uint8 au8_Char[LOCAL_BUFFER_LEN+4]; 00143 00144 ESOS_TASK_BEGIN(pstTask); 00145 while (TRUE) { 00146 ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM(); 00147 ESOS_TASK_SIGNAL_BUSY_IN_COMM(); 00148 ESOS_TASK_WAIT_ON_GET_U8BUFFER( &au8_Char[0], LOCAL_BUFFER_LEN); 00149 ESOS_TASK_RELEASE_IN_COMM(); 00150 for (u8_i=0; u8_i<LOCAL_BUFFER_LEN; u8_i++) { 00151 if ((au8_Char[u8_i] >= 'A') && (au8_Char[u8_i] <= 'Z') ) 00152 au8_Char[u8_i] = au8_Char[u8_i] - 'A' + 'a'; 00153 } // end for 00154 00155 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00156 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00157 ESOS_TASK_WAIT_ON_SEND_U8BUFFER( &au8_Char[0], LOCAL_BUFFER_LEN ); 00158 ESOS_TASK_RELEASE_OUT_COMM(); 00159 } // endof while(TRUE) 00160 ESOS_TASK_END(pstTask); 00161 } // end child_task 00162 00163 // user task to transmit a 32bit random number 00164 // 00165 // USED ONLY FOR DEVELOPMENT AND TESTING! 00166 ESOS_USER_TASK( random_xmit ) { 00167 static uint32 u32_RandomNumber; 00168 static uint32 u32_count; 00169 UINT32 U32_Temp; 00170 00171 ESOS_TASK_BEGIN(pstTask); 00172 u32_RandomNumber = 0; 00173 while (TRUE) { 00174 u32_RandomNumber = 245 + (esos_GetRandomUint32() & 0xFF); 00175 U32_Temp._uint32 = u32_RandomNumber; 00176 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00177 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00178 #if FALSE 00179 ESOS_TASK_WAIT_ON_SEND_UINT8( U32_Temp.u8LoLsb ); 00180 ESOS_TASK_WAIT_ON_SEND_UINT8( U32_Temp.u8LoMsb ); 00181 ESOS_TASK_WAIT_ON_SEND_UINT8( U32_Temp.u8HiLsb ); 00182 ESOS_TASK_WAIT_ON_SEND_UINT8( U32_Temp.u8HiMsb ); 00183 #else 00184 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( u32_RandomNumber ); 00185 #endif 00186 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00187 ESOS_TASK_RELEASE_OUT_COMM(); 00188 00189 ESOS_TASK_WAIT_TICKS( pstTask, u32_RandomNumber ); 00190 } // endof while(TRUE) 00191 ESOS_TASK_END(pstTask); 00192 } // end child_task 00193 00194 00195 // user task to transmit a 32bit random number 00196 // 00197 // USED ONLY FOR DEVELOPMENT AND TESTING! 00198 ESOS_USER_TASK( random_1 ) { 00199 static uint32 u32_RandomNumber; 00200 static uint8 u8_RandomNumber; 00201 static uint8 u8_Count; 00202 UINT32 U32_Temp; 00203 00204 ESOS_TASK_BEGIN(pstTask); 00205 while (TRUE) { 00206 u8_Count = 0x13; 00207 while (u8_Count--) { 00208 u32_RandomNumber = esos_GetRandomUint32(); 00209 U32_Temp._uint32 = u32_RandomNumber; 00210 u8_RandomNumber = U32_Temp.u8LoLsb ^ U32_Temp.u8LoMsb ^ U32_Temp.u8HiLsb ^ U32_Temp.u8HiMsb; 00211 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00212 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00213 ESOS_TASK_WAIT_ON_SEND_STRING( "R1: "); 00214 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( u8_RandomNumber ); 00215 ESOS_TASK_WAIT_ON_SEND_UINT8( ' '); 00216 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( u8_Count ); 00217 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00218 ESOS_TASK_RELEASE_OUT_COMM(); 00219 ESOS_TASK_WAIT_TICKS(pstTask, 10+4*u8_RandomNumber ); 00220 } // endof while (u8_Count) 00221 ESOS_TASK_SLEEP( pstTask ); 00222 } // endof while(TRUE) 00223 ESOS_TASK_END(pstTask); 00224 } // end child_task 00225 00226 // user task to transmit a 32bit random number 00227 // 00228 // USED ONLY FOR DEVELOPMENT AND TESTING! 00229 ESOS_USER_TASK( random_2 ) { 00230 static uint32 u32_RandomNumber; 00231 static uint8 u8_RandomNumber; 00232 static uint8 u8_Count; 00233 UINT32 U32_Temp; 00234 00235 ESOS_TASK_BEGIN(pstTask); 00236 //while(TRUE) { 00237 u8_Count = 0x16 ; 00238 while (u8_Count--) { 00239 u32_RandomNumber = esos_GetRandomUint32(); 00240 U32_Temp._uint32 = u32_RandomNumber; 00241 u8_RandomNumber = U32_Temp.u8LoLsb ^ U32_Temp.u8LoMsb ^ U32_Temp.u8HiLsb ^ U32_Temp.u8HiMsb; 00242 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00243 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00244 ESOS_TASK_WAIT_ON_SEND_STRING( "R2: "); 00245 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( u8_RandomNumber ); 00246 ESOS_TASK_WAIT_ON_SEND_UINT8( ' '); 00247 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( u8_Count ); 00248 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00249 ESOS_TASK_RELEASE_OUT_COMM(); 00250 ESOS_TASK_WAIT_TICKS(pstTask, 10+4*u8_RandomNumber ); 00251 00252 } // endof while (u8_Count) 00253 // uncomment the line below to have the task SLEEP when finished, 00254 // else, it will just die 00255 //ESOS_TASK_SLEEP( pstTask ); 00256 //ESOS_TASK_SLEEP( pstTask ); 00257 //} // endof while(TRUE) 00258 ESOS_TASK_END(pstTask); 00259 } // end child_task 00260 00261 // user task to transmit a 32bit random number 00262 // 00263 // USED ONLY FOR DEVELOPMENT AND TESTING! 00264 ESOS_USER_TASK( random_3 ) { 00265 static uint32 u32_RandomNumber; 00266 static uint8 u8_RandomNumber; 00267 static uint8 u8_Count; 00268 UINT32 U32_Temp; 00269 00270 ESOS_TASK_BEGIN(pstTask); 00271 while (TRUE) { 00272 u8_Count = 0x11; 00273 while (u8_Count--) { 00274 u32_RandomNumber = esos_GetRandomUint32(); 00275 U32_Temp._uint32 = u32_RandomNumber; 00276 u8_RandomNumber = U32_Temp.u8LoLsb; 00277 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00278 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00279 ESOS_TASK_WAIT_ON_SEND_STRING( "R3: "); 00280 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( u8_RandomNumber ); 00281 ESOS_TASK_WAIT_ON_SEND_UINT8( ' '); 00282 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( u8_Count ); 00283 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00284 ESOS_TASK_RELEASE_OUT_COMM(); 00285 ESOS_TASK_WAIT_TICKS(pstTask, 10+4*u8_RandomNumber ); 00286 } // endof while (u8_Count) 00287 ESOS_TASK_SLEEP( pstTask ); 00288 } // endof while(TRUE) 00289 ESOS_TASK_END(pstTask); 00290 } // end child_task 00291 00292 00293 /****************************************************************************** 00294 * Function: task_ctrl 00295 * 00296 * PreConditions: This ESOS task has been registered with ESOS properly 00297 * 00298 * Input: None 00299 * 00300 * Output: None 00301 * 00302 * Side Effects: 00303 * 00304 * Overview: A task to sleep, wake, kill, restart, and re-register 00305 * a few other tasks 00306 * 00307 * Notes: 00308 * 00309 *****************************************************************************/ 00310 ESOS_USER_TASK( task_ctrl ) { 00311 static uint8 u8_Char; 00312 static uint8 u8_i; 00313 00314 ESOS_TASK_BEGIN(pstTask); 00315 while (TRUE) { 00316 ESOS_TASK_WAIT_ON_AVAILABLE_IN_COMM(); 00317 ESOS_TASK_SIGNAL_BUSY_IN_COMM(); 00318 ESOS_TASK_WAIT_ON_GET_UINT8( u8_Char ); 00319 ESOS_TASK_RELEASE_IN_COMM(); 00320 00321 // do NOT wait for permission... Just seize control of 00322 // the output communications system. Release it when 00323 // we are done so an errant task can be overcome. 00324 //ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00325 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00326 00327 if ( u8_Char == '1') { 00328 ESOS_TASK_WAIT_ON_SEND_STRING( "Registering Task 1" ); 00329 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00330 pst_MyTasks[0] = esos_RegisterTask( random_1 ); 00331 } else if (u8_Char == '2') { 00332 ESOS_TASK_WAIT_ON_SEND_STRING( "Registering Task 2" ); 00333 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00334 pst_MyTasks[1] = esos_RegisterTask( random_2 ); 00335 } else if (u8_Char == '3') { 00336 ESOS_TASK_WAIT_ON_SEND_STRING( "Registering Task 3" ); 00337 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00338 pst_MyTasks[2] = esos_RegisterTask( random_3 ); 00339 } else if (u8_Char == 'Q') { 00340 ESOS_TASK_WAIT_ON_SEND_STRING( "Killing Task 1" ); 00341 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00342 ESOS_TASK_KILL(pst_MyTasks[0] ); 00343 } else if (u8_Char == 'W') { 00344 ESOS_TASK_WAIT_ON_SEND_STRING( "Killing Task 2" ); 00345 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00346 ESOS_TASK_KILL(pst_MyTasks[1] ); 00347 } else if (u8_Char == 'E') { 00348 ESOS_TASK_WAIT_ON_SEND_STRING( "Killing Task 3" ); 00349 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00350 ESOS_TASK_KILL(pst_MyTasks[2] ); 00351 } else if (u8_Char == 'A') { 00352 ESOS_TASK_WAIT_ON_SEND_STRING( "Restarting Task 1" ); 00353 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00354 ESOS_TASK_INIT( pst_MyTasks[0] ); 00355 } else if (u8_Char == 'S') { 00356 ESOS_TASK_WAIT_ON_SEND_STRING( "Restarting Task 2" ); 00357 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00358 ESOS_TASK_INIT( pst_MyTasks[1] ); 00359 } else if (u8_Char == 'D') { 00360 ESOS_TASK_WAIT_ON_SEND_STRING( "Restarting Task 3" ); 00361 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00362 ESOS_TASK_INIT( pst_MyTasks[2] ); 00363 } else if (u8_Char == 'Z') { 00364 ESOS_TASK_WAIT_ON_SEND_STRING( "Waking Task 1" ); 00365 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00366 ESOS_TASK_WAKE(pst_MyTasks[0] ); 00367 } else if (u8_Char == 'X') { 00368 ESOS_TASK_WAIT_ON_SEND_STRING( "Waking Task 2" ); 00369 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00370 ESOS_TASK_WAKE(pst_MyTasks[1] ); 00371 } else if (u8_Char == 'C') { 00372 ESOS_TASK_WAIT_ON_SEND_STRING( "Waking Task 3" ); 00373 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00374 ESOS_TASK_WAKE(pst_MyTasks[2] ); 00375 } else if (u8_Char == ' ') { 00376 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00377 ESOS_TASK_WAIT_ON_SEND_STRING( "Status:" ); 00378 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00379 ESOS_TASK_WAIT_ON_SEND_STRING( "=======" ); 00380 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00381 for (u8_i=0; u8_i<3; u8_i++) { 00382 ESOS_TASK_WAIT_ON_SEND_STRING( "Task#" ); 00383 ESOS_TASK_WAIT_ON_SEND_UINT8_AS_HEX_STRING( 1+u8_i ); 00384 ESOS_TASK_WAIT_ON_SEND_STRING( " is " ); 00385 if (ESOS_TASK_IS_SLEEPING(pst_MyTasks[u8_i])) { 00386 ESOS_TASK_WAIT_ON_SEND_STRING( "sleeping." ); 00387 } 00388 if (ESOS_TASK_IS_KILLED(pst_MyTasks[u8_i])) { 00389 ESOS_TASK_WAIT_ON_SEND_STRING( "killed." ); 00390 } 00391 if (__ESOS_TASK_IS_CALLED(pst_MyTasks[u8_i])) { 00392 ESOS_TASK_WAIT_ON_SEND_STRING( "called." ); 00393 } 00394 if (ESOS_TASK_IS_ENDED(pst_MyTasks[u8_i])) { 00395 ESOS_TASK_WAIT_ON_SEND_STRING( "ended." ); 00396 } 00397 if (ESOS_TASK_IS_WAITING(pst_MyTasks[u8_i])) { 00398 ESOS_TASK_WAIT_ON_SEND_STRING( "waiting." ); 00399 } 00400 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00401 } // endof for() 00402 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00403 } else { 00404 ESOS_TASK_WAIT_ON_SEND_UINT8( u8_Char ); 00405 } 00406 ESOS_TASK_RELEASE_OUT_COMM(); 00407 } 00408 ESOS_TASK_END(pstTask); 00409 } 00410 00411 /****************************************************************************** 00412 * Function: watchdog 00413 * 00414 * PreConditions: This ESOS task has been registered with ESOS properly 00415 * 00416 * Input: None 00417 * 00418 * Output: None 00419 * 00420 * Side Effects: 00421 * 00422 * Overview: A task to alert me when tasks are no longer located where 00423 * they should be 00424 * 00425 * Notes: 00426 * 00427 *****************************************************************************/ 00428 ESOS_USER_TASK( watchdog ) { 00429 static uint8 u8_i; 00430 00431 u8_i = FALSE; 00432 ESOS_TASK_BEGIN(pstTask); 00433 while (TRUE) { 00434 if (pst_MyTasks[0]->pfn != random_1 ) u8_i |= BIT0; 00435 if (pst_MyTasks[1]->pfn != random_2 ) u8_i |= BIT1; 00436 if (pst_MyTasks[2]->pfn != random_3 ) u8_i |= BIT2; 00437 if (u8_i) { 00438 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00439 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00440 00441 if ( u8_i && BIT0 ) { 00442 ESOS_TASK_WAIT_ON_SEND_STRING( "pstTasks[0] is now " ); 00443 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( (uint32) pst_MyTasks[0]->pfn ); 00444 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00445 } 00446 if ( u8_i && BIT1 ) { 00447 ESOS_TASK_WAIT_ON_SEND_STRING( "pstTasks[1] is now" ); 00448 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( (uint32) pst_MyTasks[1]->pfn ); 00449 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00450 } 00451 if ( u8_i && BIT2 ) { 00452 ESOS_TASK_WAIT_ON_SEND_STRING( "pstTasks[2] is now" ); 00453 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( (uint32) pst_MyTasks[2]->pfn ); 00454 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00455 } 00456 ESOS_TASK_RELEASE_OUT_COMM(); 00457 } //end of if(u8_i) 00458 ESOS_TASK_YIELD( pstTask ); 00459 } //endof while(TRUE) 00460 ESOS_TASK_END(pstTask); 00461 } // endof watchdog() task 00462 00463 00464 /****************************************************************************** 00465 * Function: watchdog 00466 * 00467 * PreConditions: This ESOS task has been registered with ESOS properly 00468 * 00469 * Input: None 00470 * 00471 * Output: None 00472 * 00473 * Side Effects: 00474 * 00475 * Overview: A task to alert me when tasks are no longer located where 00476 * they should be 00477 * 00478 * Notes: 00479 * 00480 *****************************************************************************/ 00481 ESOS_USER_TASK( init_print ) { 00482 00483 ESOS_TASK_BEGIN(pstTask); 00484 ESOS_TASK_WAIT_ON_AVAILABLE_OUT_COMM(); 00485 ESOS_TASK_SIGNAL_BUSY_OUT_COMM(); 00486 ESOS_TASK_WAIT_ON_SEND_STRING( "pstTasks[0] is " ); 00487 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( (uint32) pst_MyTasks[0]->pfn ); 00488 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00489 ESOS_TASK_WAIT_ON_SEND_STRING( "pstTasks[1] is " ); 00490 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( (uint32) pst_MyTasks[1]->pfn ); 00491 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00492 ESOS_TASK_WAIT_ON_SEND_STRING( "pstTasks[2] is " ); 00493 ESOS_TASK_WAIT_ON_SEND_UINT32_AS_HEX_STRING( (uint32) pst_MyTasks[2]->pfn ); 00494 ESOS_TASK_WAIT_ON_SEND_STRING( psz_CRNL ); 00495 ESOS_TASK_RELEASE_OUT_COMM(); 00496 ESOS_TASK_END(pstTask); 00497 00498 } // endof init_print() task 00499 00500 00501 00502 00503 /****************************************************************************** 00504 * Function: void user_init(void) 00505 * 00506 * PreCondition: None 00507 * 00508 * Input: None 00509 * 00510 * Output: None 00511 * 00512 * Side Effects: None 00513 * 00514 * Overview: user_init is a centralized initialization routine where 00515 * the user can setup their application. It is called 00516 * automagically by ES_OS during the operating system 00517 * initialization. 00518 * 00519 * Note: The user should set up any state machines and init 00520 * all application variables. They can also turn on 00521 * any needed peripherals here. 00522 * 00523 * The user SHALL NOT mess with the interrupt hardware 00524 * directly!!! The ES_OS must be aware of the interrupts 00525 * and provides osXXXXXXX functions for the user to use. 00526 * Using these ES_OS-provided functions, the user may 00527 * (and probably should) initialize, register, and enable 00528 * interrupts in this routine. 00529 * 00530 * Furthermore, the user should register AT LEAST one 00531 * user application task here (via esos_RegisterTask) or 00532 * the ES_OS scheduler will have nothing to schedule 00533 * to run when this function returns. 00534 * 00535 *****************************************************************************/ 00536 void user_init(void) { 00537 uint16* pu16_ptr; 00538 uint16 u16_junk; 00539 00540 __esos_hw_PutString( HELLO_MSG ); 00541 00542 /* 00543 * Now, let's get down and dirty with ESOS and our user tasks 00544 * 00545 * Once tasks are registered, they will start executing in 00546 * the ESOS scheduler. 00547 */ 00548 00549 00550 // here are several combinations of tasks that should work together 00551 #if 0 00552 esos_RegisterTask( upper_case ); 00553 #endif 00554 00555 #if 0 00556 esos_RegisterTask( child_echo_buffers ); 00557 #endif 00558 00559 #if 1 00560 esos_RegisterTask( random_xmit ); 00561 #endif 00562 00563 #if 0 00564 esos_RegisterTask( check_timers ); 00565 #endif 00566 00567 #if 0 00568 esos_RegisterTask( child_echo_buffers ); 00569 esos_RegisterTask( random_xmit ); 00570 #endif 00571 00572 #if 0 00573 esos_RegisterTask( random_1 ); 00574 esos_RegisterTask( random_2 ); 00575 esos_RegisterTask( random_3 ); 00576 #endif 00577 00578 #if 0 00579 esos_RegisterTask( echo ); 00580 esos_RegisterTask( random_1 ); 00581 esos_RegisterTask( random_2 ); 00582 esos_RegisterTask( random_3 ); 00583 #endif 00584 00585 #if 0 00586 esos_RegisterTask( child_echo_buffers ); 00587 esos_RegisterTask( random_1 ); 00588 esos_RegisterTask( random_2 ); 00589 esos_RegisterTask( random_3 ); 00590 #endif 00591 00592 #if 0 00593 esos_RegisterTask( upper_case ); 00594 esos_RegisterTask( random_1 ); 00595 esos_RegisterTask( random_2 ); 00596 esos_RegisterTask( random_3 ); 00597 #endif 00598 00599 #if 0 00600 pst_MyTasks[0] = esos_RegisterTask( random_1 ); 00601 pst_MyTasks[1] = esos_RegisterTask( random_2 ); 00602 pst_MyTasks[2] = esos_RegisterTask( random_3 ); 00603 esos_RegisterTask( task_ctrl ); 00604 #endif 00605 00606 #if 0 00607 pst_MyTasks[0] = esos_RegisterTask( random_1 ); 00608 pst_MyTasks[1] = esos_RegisterTask( random_2 ); 00609 pst_MyTasks[2] = esos_RegisterTask( random_3 ); 00610 esos_RegisterTask( task_ctrl ); 00611 esos_RegisterTask( init_print ); 00612 esos_RegisterTask( watchdog ); 00613 #endif 00614 00615 00616 } // end user_init()