Ejemplo n.º 1
0
/*----------------------------------------------------------------------------
 * switch LED off
 *---------------------------------------------------------------------------*/
void LED_Off (unsigned char led) {
  LED_off(led);
  os_mut_wait(mut_GLCD, 0xffff);
  GLCD_SetBackColor(White);                         /* Set the Back Color */
  GLCD_SetTextColor(Green);                         /* Set the Text Color */
  GLCD_DisplayChar(4, 5+led, 1, 0x80+0);            /* Circle Empty       */
  os_mut_release(mut_GLCD);
}
Ejemplo n.º 2
0
/*----------------------------------------------------------------------------
 *  Task 2: RTX Kernel starts this task with os_tsk_create (consumer_task, 0)
 *---------------------------------------------------------------------------*/
__task void consumer_task (void) {

	OS_TID consumer_tskid;                          /* assigned identification for consumer */
	
	consumer_tskid = os_tsk_self();									/* get it's own task ID */
	
	T_NUM *random_num_rx;

	while( msg_counter_rec < N )
	{
		os_mbx_wait (MsgBox, (void **)&random_num_rx, 0xffff); /* wait for the message    */
		
		os_mut_wait(g_mut_uart, 0xFFFF);
		printf("[consumer_task [pid:(%d)] ]: Received %u\n", consumer_tskid, random_num_rx->number);
		msg_counter_rec += 1;
		os_mut_release(g_mut_uart);
		
		if( _free_box (mpool, random_num_rx) )           /* free memory allocated for message  */
		{
			os_mut_wait(g_mut_uart, 0xFFFF);
			printf("_free_box failed because memory couldn't be freed\n");
			os_mut_release(g_mut_uart);
			exit(1);
			
		}
	}


	//Get Time C 
	time_c = os_time_get();
	
	os_mut_wait(g_mut_uart, 0xFFFF);
	printf("Time to initialize system: %0.6f\n", (float)(((float)time_b - time_a)/1000000) );
	printf("Time to transmit data: %0.6f\n", (float)(((float)time_c - time_b)/1000000) );
	os_mut_release(g_mut_uart);

	// os_dly_wait(10);
	os_tsk_delete_self ();              /* We are done here, delete this task  */
}
Ejemplo n.º 3
0
/*----------------------------------------------------------------------------
 *        Task 6 'lcd': LCD Control task
 *---------------------------------------------------------------------------*/
__task void lcd (void) {

  for (;;) {
    os_mut_wait(mut_GLCD, 0xffff);
    GLCD_SetBackColor(Blue);                           /* Set the Text Color */
    GLCD_SetTextColor(White);                          /* Set the Text Color */
    GLCD_DisplayString(0, 0, 1, "  MCB1700 RL-ARM    ");
    GLCD_DisplayString(1, 0, 1, "    RTX Blinky      ");
    GLCD_DisplayString(2, 0, 1, "   www.keil.com     ");
    os_mut_release(mut_GLCD);
    os_dly_wait (400);

    os_mut_wait(mut_GLCD, 0xffff);
    GLCD_SetBackColor(Blue);                           /* Set the Text Color */
    GLCD_SetTextColor(Red);                            /* Set the Text Color */
    GLCD_DisplayString(0, 0, 1, "  MCB1700 RL-ARM    ");
    GLCD_DisplayString(1, 0, 1, "    RTX Blinky      ");
    GLCD_DisplayString(2, 0, 1, "   www.keil.com     ");
    os_mut_release(mut_GLCD);
    os_dly_wait (400);
  }
}
Ejemplo n.º 4
0
/*---------------------------------------------------------------------*/
__task void task4(void)
{
	for(;;){
	U8 i=1;
  RL_TASK_INFO task_info;
  
  os_mut_wait(g_mut_uart, 0xFFFF);
	printf("TID\tNAME\t\tPRIO\tSTATE   \t%%STACK\n");
	os_mut_release(g_mut_uart);
    
  for(i = 0; i <7; i++) { // this is a lazy way of doing loop.
    if (os_tsk_get(i+1, &task_info) == OS_R_OK) {
      os_mut_wait(g_mut_uart, 0xFFFF);  
		  printf("%d\t%s\t\t%d\t%s\t%d%%\n", \
             task_info.task_id, \
             fp2name(task_info.ptask, g_tsk_name), \
             task_info.prio, \
             state2str(task_info.state, g_str),  \
             task_info.stack_usage);
		  os_mut_release(g_mut_uart);
    } 
  }
    
  if (os_tsk_get(0xFF, &task_info) == OS_R_OK) {
    os_mut_wait(g_mut_uart, 0xFFFF);  
	  printf("%d\t%s\t%d\t%s\t%d%%\n", \
           task_info.task_id, \
           fp2name(task_info.ptask, g_tsk_name), \
           task_info.prio, \
           state2str(task_info.state, g_str),  \
           task_info.stack_usage);
		os_mut_release(g_mut_uart);
  }
	 os_dly_wait(20);	
	}
	
}
Ejemplo n.º 5
0
/*---------------------------------------------------------------------*/
__task void init(void)
{
	//Initialize the memory pool
	_init_box(box_mem, sizeof(box_mem), 4);
	
  os_mut_init(&g_mut_uart);
  
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: TID = %d\n", os_tsk_self());
  os_mut_release(g_mut_uart);
  
	g_tid = os_tsk_create(task1, 1);  /* task 1 at priority 1 */
	os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task1 with TID %d\n", g_tid);
  os_mut_release(g_mut_uart);
  
  g_tid = os_tsk_create(task2, 4);  /* task 2 at priority 2 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task2 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
	g_tid = os_tsk_create(task3, 3);  /* task 3 at priority 3 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task3 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
	g_tid = os_tsk_create(task4, 4);  /* task 4 at priority 4 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task4 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
	g_tid = os_tsk_create(task5, 1);  /* task 5 at priority 1 */
  os_mut_wait(g_mut_uart, 0xFFFF);
  printf("init: created task5 with TID %d\n", g_tid);
	os_mut_release(g_mut_uart);
	
  os_tsk_delete_self();     /* task MUST delete itself before exiting */
}
Ejemplo n.º 6
0
 int LockMutex(wolfSSL_Mutex* m)
 {
     os_mut_wait (m, 0xffff);
     return(0) ;
 }
Ejemplo n.º 7
0
static void sync_lock(void)
{
    os_mut_wait(&sync_mutex, 0xFFFF);
}
Ejemplo n.º 8
0
/****************************************************************************************************
 * @fn      EnterCriticalSection/ ExitCriticalSection
 *          Helper routines for thread-safe operation of the FreeMotion Library
 *
 ***************************************************************************************************/
__inline void EnterCriticalSection(void)
{
    os_mut_wait( mutexCritSection, OS_WAIT_FOREVER );
}
Ejemplo n.º 9
0
/*----------------------------------------------------------------------------
 *  Task Producer:  RTX Kernel starts this task with os_sys_init (producer_task)
 *---------------------------------------------------------------------------*/
__task void producer_task (void) {
  
	OS_TID producer_tskid;                          /* assigned identification for producer  */

	T_NUM *random_num_tx;
	
	//Get Time A
	//time_a = os_time_get();
	
	//Get current task ID
	producer_tskid = os_tsk_self ();
	
	// fork the child process
	os_tsk_create (consumer_task, 0); /* start task 2                        */
  
	os_mut_wait(procon, 0xFFFF);
	if(cur_producer == 0)
	{
		os_mbx_init (MsgBox, sizeof(MsgBox));/* initialize the mailbox             */
 
		os_mut_wait(g_mut_uart, 0xFFFF);
		printf("[producer_task [pid:(%d)] ]: Mailbox Created\n", producer_tskid);
		os_mut_release(g_mut_uart);
		
		cur_producer = 1;
	}
	os_mut_release(procon);
		
	//Get Time B
	//time_b = os_time_get() ;

	// Check if the number is the required one
	// .. And also make sure that we still have to send numbers.
	while (msg_counter_send < N && ( (msg_counter_send % P) == producer_tskid ) )
	{
		random_num_tx = _alloc_box(mpool);			/* Allocate a memory for the message   */
	
		if( random_num_tx == NULL )
		{
			os_mut_wait(g_mut_uart, 0xFFFF);
			printf("_alloc_box failed because of no mem available!\n");
			os_mut_release(g_mut_uart);
			exit(1);
		}
		
		random_num_tx->number = (U32) ( msg_counter_send );
		
		os_mbx_send (MsgBox, random_num_tx, 0xffff); /* Send the message to the mailbox     */
		
		os_mut_wait(g_mut_uart, 0xFFFF);
		printf("[producer_task [pid:(%d)] ]: Sent %u\n", producer_tskid, random_num_tx->number);
		msg_counter_send++;
		os_mut_release(g_mut_uart);
		
		
		// os_dly_wait (100);
	}
	
	//msg_counter_send = 0;
		
	os_tsk_delete_self ();              /* We are done here, delete this task  */
}
Ejemplo n.º 10
0
osStatus_t osMutexAcquire(osMutexId_t mutex_id, uint32_t timeout)
{
    os_mut_wait((OS_ID)mutex_id, timeout);
    return osOK;
}