Esempio n. 1
0
/*! LCD Task Main Loop */
static void DisplayTask(void *pvParameters)
{
  static tMessage Msg;
  
  Init();

  for(;;)
  {
    if (xQueueReceive(QueueHandles[DISPLAY_QINDEX], &Msg, portMAX_DELAY))
    {
      PrintMessageType(&Msg);
      DisplayQueueMessageHandler(&Msg);
      SendToFreeQueue(&Msg);
      CheckStackUsage(DisplayHandle, "~DspStk ");
      CheckQueueUsage(QueueHandles[DISPLAY_QINDEX]);
    }
  }
}
Esempio n. 2
0
/*! Function to implement the BackgroundTask loop
 *
 * \param pvParameters not used
 *
 */
static void BackgroundTask(void *pvParameters)
{
  if ( QueueHandles[BACKGROUND_QINDEX] == 0 )
  {
    PrintString("Background Queue not created!\r\n");
  }

  PrintString(SPP_DEVICE_NAME);
  PrintString2("\r\nSoftware Version ",VERSION_STRING);
  PrintString("\r\n\r\n");

  InitializeRstNmiConfiguration();

  /*
   * check on the battery
   */
  ConfigureBatteryPins();
  BatteryChargingControl();
  BatterySenseCycle();

  /*
   * now set up a timer that will cause the battery to be checked at
   * a regular frequency.
   */
  BatteryMonitorTimerId = AllocateOneSecondTimer();

  InitializeBatteryMonitorInterval();

  SetupOneSecondTimer(BatteryMonitorTimerId,
                      nvBatteryMonitorIntervalInSeconds,
                      REPEAT_FOREVER,
                      BACKGROUND_QINDEX,
                      BatteryChargeControl,
                      NO_MSG_OPTIONS);

  StartOneSecondTimer(BatteryMonitorTimerId);

  /*
   * Setup a timer to use with the LED for the LCD.
   */
  LedTimerId = AllocateOneSecondTimer();

  SetupOneSecondTimer(LedTimerId,
                      ONE_SECOND*3,
                      NO_REPEAT,
                      BACKGROUND_QINDEX,
                      LedChange,
                      LED_OFF_OPTION);

  // Allocate a timer for wake-up iOS background BLE app
  CallbackTimerId = AllocateOneSecondTimer();

  /****************************************************************************/

#ifdef RAM_TEST

  RamTestTimerId = AllocateOneSecondTimer();

  SetupOneSecondTimer(RamTestTimerId,
                      ONE_SECOND*20,
                      NO_REPEAT,
                      DISPLAY_QINDEX,
                      RamTestMsg,
                      NO_MSG_OPTIONS);

  StartOneSecondTimer(RamTestTimerId);

#endif

  /****************************************************************************/

  InitializeAccelerometer();

#ifdef ACCELEROMETER_DEBUG

  SetupMessageAndAllocateBuffer(&BackgroundMsg,
                                AccelerometerSetupMsg,
                                ACCELEROMETER_SETUP_INTERRUPT_CONTROL_OPTION);

  BackgroundMsg.pBuffer[0] = INTERRUPT_CONTROL_ENABLE_INTERRUPT;
  BackgroundMsg.Length = 1;
  RouteMsg(&BackgroundMsg);

  /* don't call AccelerometerEnable() directly use a message*/
  SetupMessage(&BackgroundMsg,AccelerometerEnableMsg,NO_MSG_OPTIONS);
  RouteMsg(&BackgroundMsg);

#endif

  /****************************************************************************/

#ifdef RATE_TEST

  StartCrystalTimer(CRYSTAL_TIMER_ID3,RateTestCallback,RATE_TEST_INTERVAL_MS);

#endif

  /****************************************************************************/

  for(;;)
  {
    if( pdTRUE == xQueueReceive(QueueHandles[BACKGROUND_QINDEX],
                                &BackgroundMsg, portMAX_DELAY ) )
    {
      PrintMessageType(&BackgroundMsg);

      BackgroundMessageHandler(&BackgroundMsg);

      SendToFreeQueue(&BackgroundMsg);

      CheckStackUsage(xBkgTaskHandle,"Background Task");

      CheckQueueUsage(QueueHandles[BACKGROUND_QINDEX]);

    }

  }

}