예제 #1
0
/*-----------------------------------------------------------------------------
 * High priority job used for priority inversion test
 *----------------------------------------------------------------------------*/
void Th_HighPrioJob (void const *arg) {
  osThreadId *ctrl_id = (osThreadId *)arg;
  uint32_t    i;
  osStatus    stat;
  
  /* Allow control thread to be executed while this thread waits */
  osSignalSet (*ctrl_id, 0x01);
  
  /* Wait for a mutex object */
  stat = osMutexWait (G_MutexId, 200);
  ASSERT_TRUE (stat == osOK);
  
  if (stat == osOK) {
    /* Set mark into execution array */
    for (i = 0; i < 3; i++) {
      if (G_ExecArr[i] == 0) {
        G_ExecArr[i] = 'H';             /* H as High priority job             */

        /* Inform control thread */
        osSignalSet (*ctrl_id, (1 << 3));
        break;
      }
    }
  }
}
static void gimbal_cali_msg_hook(uint8_t cur_type, uint8_t last_type)
{
  gimbal_cali_hook(moto_pit.ecd, moto_yaw.ecd);
  
  if ((last_type == GIMBAL_CALI_START) && (cur_type == GIMBAL_CALI_END))
  {
    cali_param.gim_cali_data[CALI_GIMBAL_CENTER].cali_cmd = 1;
    gimbal_cali_hook(moto_pit.ecd, moto_yaw.ecd);
    
    pc_send_mesg.cali_response_data.type = 0x01;
    pc_send_mesg.cali_response_data.pitch_offset = moto_pit.ecd;
    pc_send_mesg.cali_response_data.yaw_offset   = moto_yaw.ecd;
    data_packet_pack(CALI_RESPONSE_ID, (uint8_t *)&pc_send_mesg.cali_response_data,
                     sizeof(cali_response_t), UP_REG_ID);
    osSignalSet(pc_unpack_task_t, PC_UART_TX_SIGNAL);
  }
  
  if ((last_type == CAMERA_CALI_START) && (cur_type == CAMERA_CALI_END))
  {
    cali_param.gim_cali_data[CALI_CAMERA_CENTER].cali_cmd = 1;
    gimbal_cali_hook(moto_pit.ecd, moto_yaw.ecd);
    
    pc_send_mesg.cali_response_data.type = 0x02;
    pc_send_mesg.cali_response_data.pitch_offset = moto_pit.ecd;
    pc_send_mesg.cali_response_data.yaw_offset   = moto_yaw.ecd;
    data_packet_pack(CALI_RESPONSE_ID, (uint8_t *)&pc_send_mesg.cali_response_data,
                     sizeof(cali_response_t), UP_REG_ID);
    osSignalSet(pc_unpack_task_t, PC_UART_TX_SIGNAL);
  }
}
예제 #3
0
/*-----------------------------------------------------------------------------
 * Low priority job used for priority inversion test
 *----------------------------------------------------------------------------*/
void Th_LowPrioJob (void const *arg) {
  osThreadId *ctrl_id = (osThreadId *)arg;
  osStatus    stat;
  uint32_t    i;

  /* Obtain a mutex object */
  stat = osMutexWait (G_MutexId, 0);
  ASSERT_TRUE (stat == osOK);

  if (stat == osOK) {
    /* Mutex acquired, inform control thread */
    osSignalSet (*ctrl_id, (1 << 0));
    
    /* Set mark into execution array */
    for (i = 0; i < 3; i++) {
      if (G_ExecArr[i] == 0) {
        G_ExecArr[i] = 'L';             /* L as Low priority job              */

        /* Inform control thread */
        osSignalSet (*ctrl_id, (1 << 1));
        break;
      }
    }
    ASSERT_TRUE (osMutexRelease (G_MutexId) == osOK);
  }
}
예제 #4
0
/**
  * @brief  The period elapsed callback is called when the counter underflows (UEV Update event).
  * @param  TIM_HandleTypeDef *htim: handle to TIM configuration struct
  * @retval None
  */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
    if (htim->Instance == TIM3) {
        osSignalSet(tid_Thread_SEGMENT, SEGMENT_SIGNAL);
    } else if (htim->Instance == TIM4) {
        osSignalSet(tid_Thread_TEMPERATURE, TEMPERATURE_SIGNAL);
    }
}
예제 #5
0
/*----------------------------------------------------------------------------
  Function 'signal_func' called from multiple tasks
 *---------------------------------------------------------------------------*/
void signal_func (osThreadId tid) {
  osSignalSet(tid_clock, 0x0100);           /* set signal to clock thread    */
  osDelay(500);                             /* delay 500ms                   */
  osSignalSet(tid_clock, 0x0100);           /* set signal to clock thread    */
  osDelay(500);                             /* delay 500ms                   */
  osSignalSet(tid, 0x0001);                 /* set signal to thread 'thread' */
  osDelay(500);                             /* delay 500ms                   */
}
예제 #6
0
static void sigio_handler(SInfo *info)
{
    if (info->getReceiverThreadId()) {
        osSignalSet(info->getReceiverThreadId(), SIGNAL_SIGIO);
    }
    if (info->getSenderThreadId()) {
        osSignalSet(info->getSenderThreadId(), SIGNAL_SIGIO);
    }
}
예제 #7
0
void TIM3_IRQHandler(void) {
	TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
	
	static int count = FREQ_RATIO;
	if (count <= 1) {
		count = FREQ_RATIO;
		osSignalSet(tempThread_ID, 0x1);
	} else
		count--;	
	
	osSignalSet(accThread_ID, 0x1);
}
예제 #8
0
파일: main.c 프로젝트: dazuo78/TBall
/**
  * @brief  Signal generator thread
  * @param  Thread not used
  * @retval None
  */
static void Signal_Gen_Thread(void const *argument)
{
  (void) argument;
  
  for(;;)
  {
    osSignalSet( LED1_ThreadId, BIT_0 );
    osDelay(500);
    osSignalSet( LED2_ThreadId, BIT_1 | BIT_2 );
    osDelay(500);     
  }
}
void uart_idle_interrupt_signal(UART_HandleTypeDef *huart)
{
  if (huart == &JUDGE_HUART)
  {
    err_detector_hook(JUDGE_SYS_OFFLINE);
    osSignalSet(judge_unpack_task_t, JUDGE_UART_IDLE_SIGNAL);
  }
  else if (huart == &COMPUTER_HUART)
  {
    err_detector_hook(PC_SYS_OFFLINE);
    osSignalSet(pc_unpack_task_t, PC_UART_IDLE_SIGNAL);
  }
}
예제 #10
0
	void DispatcherPrivate::task_main_imp(volatile PROCESS_ENTRY_STATE* process)
	{
		const PROCESS_ENTRY_DATA* pdata = process->data;
		PROCESS_ENTRY* pcb = process->process;

		TRACE(("[%s] task_main_imp(): starting\r\n", process->data->name));
		process->thread->mutex.lock();
		if (pcb->process_start != NULL)
			pcb->process_start(pcb);

		STATE_ENTRY* state = pdata->initstate;
		enter_state(process, state);
		process->state = ProcessRunning;
		process->thread->mutex.unlock();
		osSignalSet(_dispid, SIGNAL_CHANGED);

		for (;;)
		{
			//TRACE(("[%s] task_main_imp(): waiting for signal.\r\n", process->data->name));
			process->state = ProcessWaiting;
			DelayedThread::signal_wait(SIGNAL_RUN_TASKS);
			process->state = ProcessRunning;
			//TRACE(("[%s] task_main_imp(): woken up.\r\n", process->data->name));

			process->thread->mutex.lock();
			//TRACE(("DispatcherPrivate::run_tasks(): locked\r\n"));

			do
			{
				//TRACE(("[%s:%s] task_main_imp(): current state type is %i.\r\n", process->data->name, process->current->data->name, process->current->data->mode));
				TRANSITION_ENTRY* transition = find_valid_transition(process);
				if (transition != NULL)
				{
					take_transition(process, transition);
				}
				else
				{
					process->stepped = false;
					//TRACE(("[%s:%s] task_main_imp(): no transitions found.\r\n", process->data->name, process->current->data->name));
					break;
				}

			} while (process->current->data->mode == StateCommited);

			//TRACE(("DispatcherPrivate::run_tasks(): unlocking\r\n"));
			process->thread->mutex.unlock();
			osSignalSet(_dispid, SIGNAL_CHANGED);
		}

	}
예제 #11
0
/**
  * @brief  Toggles LEDs to show user input state.
  * @param  None
  * @retval None
  */
void Toggle_Leds(void)
{
   static uint32_t ticks = 0;
   if(ticks == 400) 
   {
     osSignalSet( LED_ThreadId, BIT_1); 
   }
   else if(ticks == 1000) 
   {
     osSignalSet( LED_ThreadId, BIT_1 | BIT_2 );
     ticks = 0; 
   } 
   ticks++;
 }
예제 #12
0
/*----------------------------------------------------------------------------
  Task 1 'ledOn': switches the LED on
 *---------------------------------------------------------------------------*/
 void ledOn (void const *argument) {
  for (;;) {
    LED_On(0);                          /* Turn LED On                       */
    osSignalSet(t_ledOff, 0x0001);      /* send event to task 'ledoff'       */
    osDelay(500);                       /* delay 500ms                       */
  }
}
예제 #13
0
/**
\brief Test case: TC_MutexTimeout
\details
- Create and initialize a mutex object
- Create a thread that acquires a mutex but never release it
- Wait for mutex release until timeout
*/
void TC_MutexTimeout (void) {
  osThreadId ctrl_id, lock_id;
  osEvent    evt;

  /* Get control thread id */
  ctrl_id = osThreadGetId ();
  ASSERT_TRUE (ctrl_id != NULL);
  
  if (ctrl_id != NULL) {
    /* - Create and initialize a mutex object */
    G_MutexId = osMutexCreate (osMutex (MutexTout));
    ASSERT_TRUE (G_MutexId != NULL);
    
    if (G_MutexId != NULL) {
      /* - Create a thread that acquires a mutex but never release it */
      lock_id = osThreadCreate (osThread (Th_MutexLock), &ctrl_id);
      ASSERT_TRUE (lock_id != NULL);
      
      if (lock_id != NULL) {
        /* - Wait for mutex release until timeout */
        ASSERT_TRUE (osMutexWait (G_MutexId, 10) == osErrorTimeoutResource);
        /* - Release a mutex */
        osSignalSet (lock_id, 0x01);
        evt = osSignalWait (0x01, 100);
        ASSERT_TRUE (evt.status == osEventSignal);
        /* - Terminate locking thread */
        ASSERT_TRUE (osThreadTerminate (lock_id)  == osOK);
      }
      /* Delete mutex object */
      ASSERT_TRUE (osMutexDelete (G_MutexId)  == osOK);
    }
  }
}
예제 #14
0
// This function is called by the DNS client when dns event occurs.
static void dnsCBack (dnsClientEvent event, const uint8_t *ip_addr)
{
  switch (event)
	{
    case dnsClientSuccess:
      // Host Address successfully resolved.
			ntpHostIP[0] = ip_addr[0];
			ntpHostIP[1] = ip_addr[1];
			ntpHostIP[2] = ip_addr[2];
			ntpHostIP[3] = ip_addr[3];
      break;
		/*
    case dnsClientNotResolved:
      // Host Name does not exist in DNS record database.
      break;
    case dnsClientTimeout:
      // All DNS Resolver retries used up and timeouts expired.
      break;
    case dnsClientError:
      // DNS Protocol Error, invalid or corrupted reply received.
      break;
		*/
		default:
			ntpHostIP[0] = 0;
			ntpHostIP[1] = 0;
			ntpHostIP[2] = 0;
			ntpHostIP[3] = 0;
			break;
  }
	osSignalSet (netTaskId, FLAG_DNS_RESOLVED);
}
예제 #15
0
/** \brief  LPC EMAC interrupt handler.
 *
 *  This function handles the transmit, receive, and error interrupt of
 *  the LPC177x_8x. This is meant to be used when NO_SYS=0.
 */
void ENET_IRQHandler(void)
{
#if NO_SYS == 1
	/* Interrupts are not used without an RTOS */
    NVIC_DisableIRQ(ENET_IRQn);
#else
	uint32_t ints;

	/* Interrupts are of 2 groups - transmit or receive. Based on the
	   interrupt, kick off the receive or transmit (cleanup) task */

	/* Get pending interrupts */
	ints = LPC_EMAC->IntStatus;

	if (ints & RXINTGROUP) {
        /* RX group interrupt(s): Give signal to wakeup RX receive task.*/
        osSignalSet(lpc_enetdata.RxThread->id, RX_SIGNAL);
    }

    if (ints & TXINTGROUP) {
        /* TX group interrupt(s): Give semaphore to wakeup TX cleanup task. */
        sys_sem_signal(&lpc_enetdata.TxCleanSem);
    }

	/* Clear pending interrupts */
	LPC_EMAC->IntClear = ints;
#endif
}
예제 #16
0
파일: Traffic.c 프로젝트: EnergyMicro/RTX
/*----------------------------------------------------------------------------
  Thread 5 'get_escape': check if ESC (escape character) was entered
 *---------------------------------------------------------------------------*/
void get_escape (void const *argument) {
  while (1)  {                                /* endless loop                */
    if (SER_GetChar () == ESC) {              /* If ESC entered, set flag    */ 
      escape = true;                          /* 'escape', set event flag of */
      osSignalSet(tid_command, 0x0002);       /* thread 'command'            */
    }
  }
}
예제 #17
0
파일: xbee.c 프로젝트: kevarek/CanFireWall
void XB_USART_IRQH(void){
	if( __HAL_USART_GET_IT(&xb_ComPort, UART_IT_CM ) ){														//If character match interrupt is pending
		__HAL_UART_CLEAR_IT(&xb_ComPort, UART_CLEAR_CMF);													//Clear interrupt pending bit

		xb_RxCmdCnt++;																						//Increment counter of received commands in buffer
		osSignalSet(xb_ReceiveTaskId, XB_SIG_DATARECEIVED);													//Set signal to receiving task
	}
}
예제 #18
0
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* AdcHandle)
{	
	HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);
	HAL_ADC_Stop_DMA(&g_AdcHandle);
	osSignalSet(tid_TH_GUI,DMA_ConvCpltSig);
	HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_9);
	//GPIOB->ODR ^= GPIO_PIN_9; // this is just for test of DMA speed
}
예제 #19
0
/**
  * @brief  Interrupt Service Routine for EXTI12_IRQHandler
  */
void EXTI15_10_IRQHandler(void) {
	if(EXTI_GetITStatus(EXTI_Line12) != RESET)
    {
			osSignalSet(Rx_thread, RX_PKT);
		}	
	// clear EXTI inruppt pending bit.
	EXTI_ClearITPendingBit(EXTI_Line12);
}
예제 #20
0
void timer_1s (void const *argument)  {
	char i;
	if(is_initialized == false)
		return;	
	for(i = 0; i < MAX_SUBSCRIBERS_COUNT; i++)
	if(mail_lists[TIMER_1S] & 1 << i)
		osSignalSet(subscribers[i], 0x0001);
}
예제 #21
0
/**
  * @brief  Interrupt handler for Tim5
  * @param  None 
  * @retval None
  */
void TIM5_IRQHandler(void) {
    if (TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET)
    {
		//if interrupt then set hard_interrupt flag
        TIM_ClearITPendingBit(TIM5, TIM_IT_Update);
        osSignalSet(proxThread, PROX_SIGNAL);
    }
}
예제 #22
0
파일: Traffic.c 프로젝트: EnergyMicro/RTX
/*----------------------------------------------------------------------------
  Thread 4 'keyread': process key stroke from pedestrian push button
 *---------------------------------------------------------------------------*/
void keyread (void const *argument) {
  while (1) {                                 /* endless loop                */
    if (INT0_Get() == 0) {                    /* if key pressed              */
      osSignalSet(tid_lights, 0x0010);        /* set signal to lights thread */
    }
    osDelay(50);                              /* wait for timeout: 50ms      */
  }
}
예제 #23
0
/**
* @brief  EXTI4 Interrupt Handler
* @param  No input
* @retval No return
*/
void EXTI4_IRQHandler(void) {
	//When the interrupt is raised, send a signal to the wireless thread
	if(EXTI_GetITStatus(CC2500_SPI_INT_EXTI_LINE) != RESET){
			osSignalSet(Rx_thread, RX_PKT);
		}	
	//Clear EXTI inruppt pending bit.
	EXTI_ClearITPendingBit(CC2500_SPI_INT_EXTI_LINE);
}
예제 #24
0
void button2PressEvent()
{
	utcOffset++;
	if (utcOffset > 12)
		utcOffset = -12;
	osSignalSet (displayThreadId, FLAG_UPDATE_DISPLAY);
	saveUtcOffsetToFlash();
}
예제 #25
0
void ADC1_2_IRQHandler (void)
{
	
	if(ADC1->SR & ADC_SR_EOC)
  {
		osSignalSet(osAlarmTask, 0x03);
		ADC1->SR &= ~ADC_SR_EOC;
  }
}
예제 #26
0
void TIM5_IRQHandler(void)
{
	if (TIM_GetITStatus(TIM5, TIM_IT_Update) != RESET)
  {
		// send a data ready signal to the temperature detection that calculates temperature and wake up the thread
		osSignalSet(temperatureGetId, SIGNAL_TEMPERATURE_READY);
     TIM_ClearITPendingBit(TIM5, TIM_IT_Update);
  }
}
예제 #27
0
/**
  * @brief  Interrupt handler for Tim3
  * @param  None 
  * @retval None
  */
void TIM3_IRQHandler(void)
{
    if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
    {
		//if interrupt then set hard_interrupt flag
        TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
		osSignalSet(detectionSystem_thread, DISPLAY_SIGNAL);
    }
}
예제 #28
0
파일: RTX_ex2.c 프로젝트: 32bitmicro/RTX
/*----------------------------------------------------------------------------
 *   Thread 2: 'job2'
 *---------------------------------------------------------------------------*/
void job2 (void const *argument) {
  while (1)  {                        /* endless loop                        */
    counter2++;                       /* increment counter 2                 */
    if (counter2 == 0) {              /* signal overflow of counter 2        */
      osSignalSet(thread3_id, 0x0001);/* to thread 3                         */
      osThreadYield();
    }
  }
}
예제 #29
0
void tskNTP(void const * argument)
{
	/*
	* Wait Signal(from Ethernet manager)
	* DNS request.
	* 	NTP Run() -> X: N Retry using the other NTP Server(DNS retry) || O: Time Update();
	*/
	time_t now;
	uint8_t NTPServerNum;
	uint8_t temp;
#if defined(NTP_SERVER_LIST)
	NTPServerNum = NTP_SERVER_NUM;
	uint8_t* NTPServerList[] = NTP_SERVER_LIST;
#else
	NTPServerNum = NTP_SERVER_NUM_DEFAULT;
	uint8_t* NTPServerList[] = NTP_SERVER_LIST_DEFAULT;
#endif

	while(1)
	{
		if(!isLinked() || (NetInfo.dhcp == NETINFO_DHCP && leaseTime == 0))
			continue;
		temp = 0;
		do{
			now = NTPTimeOut(NTPServerList[temp],NETINFO_NTP_TIMEOUT);
			if(now > 0)
			{
				DHCPLeasedTime = now - 2208988800 - time(NULL) + DHCPLeasedTime;
				time_dat = now - 2208988800;
				srand(now^randomKey);
#if WIZSYSTEM_DEBUG
				printf("NTP Time updated.\r\n");
				printfTime(9);
#endif
				osSignalSet(userTaskId,0x0001);
				osDelay(1000*60);//NETINFO_NTP_PERIODIC);
				break;
			}
			else
			{
#if WIZSYSTEM_DEBUG
				printf("Retry update time using other NTP Server. Retry Count = %d\r\n",temp);
#endif
				if(++temp == NETINFO_NTP_RETRY)
				{
				/*todo*/
				//Signal transmit to ethernet manager?
#if WIZSYSTEM_DEBUG
					printf("NTP Failed. Retry NTP time update after 10 minutes.\r\n");
#endif
					osDelay(600000);//Retry NTP time update after 10 minutes.
				}
			}
		}while(temp < NTPServerNum);
	}
}
void TIM3_IRQHandler() {
	
	if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)
	{
		TIM_ClearITPendingBit(TIM3, TIM_IT_Update);
		osSignalSet(TemperatureSensor_thread, 0x10);

	}

}