Exemple #1
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);
}
/**************************************************************************//**
  \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;
  }
}
Exemple #3
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;
	}
}
Exemple #4
0
/* This function stop the codewheel timer task */
void stop_codewheel_timer_task(void)
{
	HAL_StopAppTimer(&codewheelTimer);
}
Exemple #5
0
/* This function stops the calibration task */
void calibration_stop_task(void)
{
	HAL_StopAppTimer(&calibrationTimer);
	motor_stop();
}