Exemplo n.º 1
0
__interrupt void USCI_A3_ISR(void)
{
  switch(__even_in_range(UCA3IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:break;                             // Vector 2 - RXIFG
  case 4:                                   // Vector 4 - TXIFG
    
    if ( TxCount == 0 )
    {
      UCA3IFG = 0;
      TxBusy = 0;
      
      /* start the countdown to disable SMCLK */
      DisableSmClkCounter = 0;  
      EnableRtcPrescaleInterruptUser(RTC_TIMER_USER_DEBUG_UART);
     
    }
    else
    {
      /* send a character */
      UCA3TXBUF = TxBuffer[ReadIndex];
      IncrementReadIndex();
      TxCount--;  
    }
    break;
    
  default: break;
  }
  
}
Exemplo n.º 2
0
/* Handle the message from the host that starts a vibration event */
void SetVibrateModeHandler(tHostMsg* pMsg)
{

  // overlay a structure pointer on the data section
  tSetVibrateModePayload* pMsgData;
  pMsgData = (tSetVibrateModePayload*) pMsg->pPayload;

  // set it active or cancel it
  VibeEventActive = pMsgData->Enable;

  // save the parameters from the message
  motorOn = pMsgData->Enable;

  tWordByteUnion temp;
  temp.byte0 = pMsgData->OnDurationLsb; 
  temp.byte1 = pMsgData->OnDurationMsb;
  timeOn = temp.word / RTC_TIMER_MS_PER_TICK;

  temp.byte0 = pMsgData->OffDurationLsb; 
  temp.byte1 = pMsgData->OffDurationMsb;
  timeOff = temp.word / RTC_TIMER_MS_PER_TICK;

  cycleCount = pMsgData->NumberOfCycles;

  // Start or stop the RTC PS timer based on whether the motor is being turned
  // on or off
  if ( VibeEventActive )
  {
    EnableRtcPrescaleInterruptUser(RTC_TIMER_VIBRATION);
    EnableVibratorPwm();
  }
  else
  {
    DisableRtcPrescaleInterruptUser(RTC_TIMER_VIBRATION);
    DisableVibratorPwm();
  }

  // Use a separate timer that counts Rtc_Prescale_Timer_Static messages to
  // get the time for the vibe motor.
  if(VibeEventActive)
  {
    VibeEventTimerCount = 0;
    timeStart =  0;
  }

  // the next event is to turn
  nextActionTime =  timeStart + timeOn;

  // Set/clear  the port bit that controls the motor
  SetVibeMotorState(motorOn);

}