Exemple #1
0
/**
  * @brief  Toggle LED1 thread
  * @param  Thread not used
  * @retval None
  */
static void LED_Thread1(void const *argument)
{
  (void) argument;
  uint32_t PreviousWakeTime = osKernelSysTick();
  
  for(;;)
  {
/* osDelayUntil function differs from osDelay() in one important aspect:  osDelay () will
 * cause a thread to block for the specified time in ms from the time osDelay () is
 * called.  It is therefore difficult to use osDelay () by itself to generate a fixed
 * execution frequency as the time between a thread starting to execute and that thread
 * calling osDelay () may not be fixed [the thread may take a different path though the
 * code between calls, or may get interrupted or preempted a different number of times
 * each time it executes].
 *
 * Whereas osDelay () specifies a wake time relative to the time at which the function
 * is called, osDelayUntil () specifies the absolute (exact) time at which it wishes to
 * unblock.
 * PreviousWakeTime must be initialised with the current time prior to its first use 
 * (PreviousWakeTime = osKernelSysTick() )   
 */  
    osDelayUntil (&PreviousWakeTime, 200);
    BSP_LED_Toggle(LED1);
  }
}
Exemple #2
0
static void _prog_loop(void const * argument)
{
	ticks = osKernelSysTick();

	while (1)
	{
		update_common_values();

		io_execute_in();
		program_execute();
		io_execute_out();

		osDelayUntil(&ticks, PROG_LOOP_PERIOD_MS);
	}
}
void detect_task(void const *argu)
{
  uint32_t detect_wake_time = osKernelSysTick();
  while(1)
  {
    detect_time_ms = HAL_GetTick() - detect_time_last;
    detect_time_last = HAL_GetTick();
    
    /* module offline detect */
    module_offline_detect();

    
    if (glb_err_exit == 1)
    {
      if (pc_glb_cnt++ > 50)
        pc_glb_cnt = 0;
      
      if (pc_glb_cnt < 15)
        g_err.beep_ctrl = g_err.beep_tune/2;
      else
        g_err.beep_ctrl = 0;
    }
    else
    {
      if (g_err.err_now != NULL)
      {
        //LED_G_OFF;
        module_offline_callback();
      }
      else
      {
        g_err.beep_ctrl = 0;
        //LED_G_ON;
      }
    }
    
    beep_ctrl(g_err.beep_tune, g_err.beep_ctrl);
    
    detect_stack_surplus = uxTaskGetStackHighWaterMark(NULL);
    
    osDelayUntil(&detect_wake_time, DETECT_TASK_PERIOD);
  }
}