Пример #1
0
void idle_tick_isr(void) 
{

	ACTIVE_EVENT_STRUCT *a;
	
	LIST *head;
	LIST *iter;
	LIST *iter_temp;

	head = &raw_idle_tick_head;
	iter = head->next;

	/*if list is not empty*/
 	while (iter != head) {

		a =  raw_list_entry(iter, ACTIVE_EVENT_STRUCT, idle_tick_list);
		iter_temp =  iter->next;

		if (a->tick_ctr) {
			--a->tick_ctr;
			
			if (a->tick_ctr == 0) {
				list_delete(iter);
				idle_event_end_post(a, STM_TIMEOUT_SIG, 0);
			}
		}
		
		iter = iter_temp;
 	}

	
}
Пример #2
0
void test_event_task2(void * pParam)
{
	/*check whether MAX_IDLE_EVENT_TASK is valid*/
	RAW_ASSERT((ARRAY_SIZE(active_idle_task)) == MAX_IDLE_EVENT_TASK);
	
	idle_event_init();

	Bomb4_ctor(&l_bomb22, 0xd);       /* the secret defuse code, 1101 binary */

	l_bomb22.internal_priority = 1;
	
	fsm_init(&l_bomb22.a1.super, 0); 
	
	idle_tick_start = 1;
	
	 vc_port_printf("Time Bomb (raw os fsm case)\n"
           "Press 'u'   for UP   event\n"
           "Press 'd'   for DOWN event\n"
           "Press 'a'   for ARM  event\n"
           "Press <Esc> to quit.\n");
	
	while (1) {
	
		 if (_kbhit()) {
            static STATE_EVENT  up_evt   = { UP_SIG,   0, 0 };
            static STATE_EVENT  down_evt = { DOWN_SIG, 0, 0 };
            static STATE_EVENT  arm_evt  = { ARM_SIG,  0, 0 };
            STATE_EVENT  *e = 0;

            switch (_getch()) {
                case 'u': {                                     /* UP event */
                    vc_port_printf("\nUP  : ");
                    e = &up_evt;                   /* generate the UP event */
                    break;
                }
                case 'd': {                                   /* DOWN event */
                    vc_port_printf("\nDOWN: ");
                    e = &down_evt;               /* generate the DOWN event */
                    break;
                }
                case 'a': {                                    /* ARM event */
                    vc_port_printf("\nARM : ");
                    e = &arm_evt;                 /* generate the ARM event */
                    break;
                }
                case '\33': {                                  /* <Esc> key */
                    vc_port_printf("\nESC : Bye! Bye!");
                    exit(0);
                    break;
                }
            }
            if (e != 0) {            /* keyboard event available? */
               
				idle_event_end_post(&l_bomb22.a1, e->sig, &tick_evt);
            }
			
		 	}

		 raw_sleep(10);
		 
	}


}