34 #include "esos_pc_stdio.h"
37 #include <sys/select.h>
49 uint32_t randomNumInRange(uint32_t u32_lo, uint32_t u32_hi);
54 volatile uint32_t u32_T2Count;
55 volatile uint32_t u32_T3Count;
56 static uint8_t psz_T2Is[]=
"T2 is ";
57 static uint8_t psz_T3Is[]=
"T3 is ";
58 static uint8_t psz_Enabled[]=
"enabled.";
59 static uint8_t psz_Disabled[]=
"disabled.";
60 static uint8_t psz_CRNL[3]= {0x0D, 0x0A, 0};
64 uint32_t u32_myT1Count = 0;
68 struct stTask* pst_MyTasks[3];
80 static uint32_t u32_count, u32_tick;
86 __esos_tmrSvcsExecute();
93 uint32_t randomNumInRange(uint32_t u32_lo, uint32_t u32_hi) {
94 uint32_t u32_d1, u32_d2, u32_d4, u32_ret;
99 u32_ret = u32_lo + u32_d4;
100 if (u32_ret <= u32_hi)
return u32_ret;
102 U32_temp._uint32_t = u32_d4;
104 u32_ret = u32_lo + u32_d2;
105 if (u32_ret <= u32_hi)
return u32_ret;
108 u32_ret = u32_lo + u32_d1;
109 if (u32_ret <= u32_hi)
return u32_ret;
130 uint32_t u32_cnt1, u32_cnt2, u32_cnt3;
135 printf(
"A:%d\n", u32_cnt1++);
141 printf(
"B:%d\n", u32_cnt2++);
147 printf(
"C:%d\n", u32_cnt3++);
156 u32_rnd = 100*randomNumInRange(1, 30);
157 printf(
"T1 (%d)\n", u32_rnd);
168 u32_rnd = 100*randomNumInRange(1, 30);
169 printf(
"T2 (%d)\n", u32_rnd);
180 u32_rnd = 100*randomNumInRange(1, 30);
181 printf(
"T3 (%d)\n", u32_rnd);
201 static uint32_t u32_RandomNumber;
202 static uint8_t u8_RandomNumber;
203 static uint8_t u8_Count;
211 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
220 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
230 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
239 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
254 static uint32_t u32_RandomNumber;
255 static uint8_t u8_RandomNumber;
256 static uint8_t u8_Count;
266 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
276 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
287 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
297 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
308 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
318 if (tmrhnd_ret == ESOS_TMR_FAILURE) {
320 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
327 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
341 static uint8_t u8_char;
346 ESOS_TASK_SIGNAL_BUSY_IN_COMM();
349 if ((u8_char >=
'a') && (u8_char <=
'z') )
350 u8_char = u8_char -
'a' +
'A';
352 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
361 static uint8_t au8_x[257];
362 static uint8_t au8_y[257];
367 ESOS_TASK_SIGNAL_BUSY_IN_COMM();
372 if ((au8_x[u8_i] >=
'a') && (au8_x[u8_i] <=
'z') )
373 au8_y[u8_i] = au8_x[u8_i] -
'a' +
'A';
375 au8_y[u8_i] = au8_x[u8_i];
376 if (au8_x[u8_i] == 0)
break;
380 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
389 static uint8_t u8_char;
391 static
char* sz_in[257];
392 static char* sz_out[257];
397 ESOS_TASK_SIGNAL_BUSY_IN_COMM();
400 reverseString( sz_in, sz_out );
402 ESOS_TASK_SIGNAL_BUSY_OUT_COMM();
420 void reverseString(
char *psz_s1,
char *psz_s2) {
428 while (*psz_s1end) psz_s1end++;
431 while (psz_s1end != psz_s1) {
432 *psz_s2 = *psz_s1end;
437 *psz_s2 = *psz_s1end;
481 __esos_hw_PutString( HELLO_MSG );