Esempio n. 1
0
void APL_TaskHandler(void)
{
	static int init_done = 0;
	if(init_done == 0)
	{	
		/* Init Led */
		init_led();
		
		/* Init Serial Interface for debug */ 
		initSerialInterface();          	
		
		
		DDRD = 0x0F;
		PORTD = 0x0F;
		
		bouttonsTimer.interval = 400L;
		bouttonsTimer.mode     = TIMER_REPEAT_MODE;
		bouttonsTimer.callback = bouttons_task;
		HAL_StartAppTimer(&bouttonsTimer);
		
		init_done = 1;
		uprintf("test_bouttons : init done\r\n");
	}
	SYS_PostTask(APL_TASK_ID);
}
Esempio n. 2
0
/* This function starts the calibration task */
void calibration_start_manual_task(void)
{
	calibrationTimer.interval = CALIBRATION_MANUAL_PERIOD;
	calibrationTimer.mode     = TIMER_REPEAT_MODE;
	calibrationTimer.callback = calibration_manual_task;
	HAL_StartAppTimer(&calibrationTimer);
}
Esempio n. 3
0
/* This function start the codewheel timer task */
void start_codewheel_timer_task(void)
{
	codewheel.time = 0;
	codewheelTimer.interval = CODEWHEEL_TIMER_TASK_PERIOD;
	codewheelTimer.mode     = TIMER_REPEAT_MODE;
	codewheelTimer.callback = codewheel_timer_task;
	HAL_StartAppTimer(&codewheelTimer);
}
Esempio n. 4
0
/* This function restarts the calibration task changing its frequency */
void calibration_change_task_frequency(uint32_t frequency)
{
	HAL_StopAppTimer(&calibrationTimer);
	calibrationTimer.interval = frequency;
	calibrationTimer.mode     = TIMER_REPEAT_MODE;
	calibrationTimer.callback = calibration_task;
	HAL_StartAppTimer(&calibrationTimer);
}
Esempio n. 5
0
/* This function starts the calibration task */
void calibration_start_task(void)
{
	calibration.state = CALIBRATION_INIT;
	calibrationTimer.interval = CALIBRATION_FAST_TASK_PERIOD;
	calibrationTimer.mode     = TIMER_REPEAT_MODE;
	calibrationTimer.callback = calibration_task;
	calibration_init_structure();
	servo_structure_init();
	motor_start();
	HAL_StartAppTimer(&calibrationTimer);
}
/**************************************************************************//**
  \brief Router application subtask handler.

  \param  None.

  \return None.
******************************************************************************/
static void appRouterTaskHandler(void)
{
  switch (appDeviceState)
  {
    case READING_SENSORS_STATE:
    {
      appNwkInfo.parentShortAddr = NWK_GetNextHop(0x0000);
      appReadLqiRssi();
      appStartSensorManager();
      appDeviceState = WAITING_DEVICE_STATE; // need to put here in a case if run context isn't broken
      appGetSensorData(appSensorsGot);
    }
    break;

    case SENDING_DEVICE_STATE:
    {
      AppCommand_t *pCommand = NULL;

      if (appCreateCommand(&pCommand))
      {
        pCommand->id = APP_NETWORK_INFO_COMMAND_ID;
        memcpy(&pCommand->payload.nwkInfo, &appNwkInfo, sizeof(AppNwkInfoCmdPayload_t));
      }

      appDeviceState = STARTING_TIMER_STATE;
      appPostSubTaskTask();
    }
    break;

    case STARTING_TIMER_STATE:
    {
      HAL_StartAppTimer(&deviceTimer);
      appDeviceState = WAITING_DEVICE_STATE;
    }
    break;

    case INITIAL_DEVICE_STATE:
    {
      HAL_StopAppTimer(&deviceTimer); // Have to be stopped before start
      deviceTimer.interval = APP_TIMER_SENDING_PERIOD;
      deviceTimer.mode     = TIMER_ONE_SHOT_MODE;
      deviceTimer.callback = deviceTimerFired;

      appDeviceState = READING_SENSORS_STATE;
      appPostSubTaskTask();
    }
    break;

    default:
      break;
  }
}
Esempio n. 7
0
/* This function starts the debug task */
void debug_start_stop_task(void)
{
	static bool debug_task_running = 0;
	if(debug_task_running == 0)
	{
		debugTimer.interval = DEBUG_TASK_PERIOD;
		debugTimer.mode     = TIMER_REPEAT_MODE;
		debugTimer.callback = debug_task;
		HAL_StartAppTimer(&debugTimer);
		debug_task_running = 1;
	}
	else
	{
		HAL_StopAppTimer(&debugTimer);
		debug_task_running = 0;
	}
}