Beispiel #1
0
void EnableDebugUart(unsigned char Enable)
{
  if (!UartMutex)
  {
    UCA3CTL1 = UCSWRST;
    
    /* set the baud rate to 115200 (from table 32-5 in slau208j) */
    UCA3CTL1 |= UCSSEL__SMCLK;
    UCA3BR0 = 145;
    UCA3MCTL = UCBRS_5 + UCBRF_0;
    
    /* configure tx and rx pins */
    P10SEL |= BIT4;
    P10SEL |= BIT5;
    
    /* clear status */
    UCA3STAT = 0;
    
    /* take uart out of reset */
    UCA3CTL1 &= ~UCSWRST; 
    
    /* prime transmitter */
    UCA3IE = 0;
    UCA3IFG = 0; //UCTXIFG;
    
    UartMutex = xSemaphoreCreateMutex();
    xSemaphoreGive(UartMutex);
    
    DebugEnabled = TRUE;
    PrintR(); PrintC(STAR); PrintC(STAR); PrintC(STAR); PrintR();
  }
  
  DebugEnabled = Enable;
  EnableTermMode(Enable);
}
Beispiel #2
0
void Print4R(__m128i R1,
			__m128i R2,
			__m128i R3,
			__m128i R4)
{
	PrintR(R1) ;
	PrintR(R2) ;
	PrintR(R3) ;
	PrintR(R4) ;
}
Beispiel #3
0
void ShowStateInfo(void)
{
  if (!pStateLog) return;
  State_t *pState = (State_t *)pStateLog;

  PrintS("---- State before reset ----");
  if (pState->ResetSource > 0x22) pState->ResetSource = 0x22;
  PrintS(ResetReason[pState->ResetSource >> 1]);

  PrintF("ResetCode:%s %u", ResetCode[pState->ResetCode], pState->ResetValue);
  PrintF("RadioIdle:%u", pState->RadioReadyToSleep);
  PrintF("DisplayQueue:%u", pState->DisplayQueue);
  PrintF("WrapperQueue:%u", pState->WrapperQueue);

  if (pState->ResetSource == SYSRSTIV_WDTTO || pState->ResetSource == SYSRSTIV_WDTKEY)
  {
    PrintF("# WDT %s", pState->ResetSource == SYSRSTIV_WDTTO ? "Failsafe" : "Forced");
    pState->WdtNum ++;
  }

  PrintF("Total WDT:%u", pState->WdtNum);
  PrintF("MuxMode:%s", MuxMode[pState->MuxMode]);

  unsigned char i;

  PrintW("Property:");
  for (i = 0; i < 7; ++i)
  {
    if (pState->Property & (1 << i))
      {PrintW(Property[i]); PrintC(SPACE);}
  }
  PrintR();
  
  PrintF("State:%s", Bluetooth[pState->Bluetooth]);

  PrintW("Conn:");
  for (i = 0; i < 7; ++i)
  {
    if (pState->ConnType & (1 << i))
      {PrintW(ConnType[i]); PrintC(SPACE);}
  }
  PrintR();

  PrintF("Dscnn:%u", pState->Disconnects);
  PrintF("Battery:%u%c", pState->Battery, PERCENT);
  PrintF("SrvChgdHandle:%u", pState->SrvChgdHandle);
  PrintS("-------- State end --------");
}
/* Send interrupt notification to the phone or 
 * read data from the accelerometer and send it to the phone
 */
static void AccelerometerSendDataHandler(void)
{
  tMessage Msg;

  SetupMessageWithBuffer(&Msg, AccelIndMsg, MSG_OPT_NONE);
  if (Msg.pBuffer != NULL)
  {
    if (Control & WUF_ENABLE)
    {
      AccelerometerRead(KIONIX_XOUT_HPF_L, Data, XYZ_DATA_LENGTH);
      AccelerometerRead(KIONIX_INT_REL, Data, ONE_BYTE); //clear int
    }
    else AccelerometerRead(KIONIX_XOUT_L, Data, XYZ_DATA_LENGTH);

    Msg.pBuffer[0] = CONVERT_TO_8_BIT(0);
    Msg.pBuffer[1] = CONVERT_TO_8_BIT(2);
    Msg.pBuffer[2] = CONVERT_TO_8_BIT(4);
    Msg.Length = 3;
    RouteMsg(&Msg);

    PrintH(Msg.pBuffer[0]); PrintC(SPACE);
    PrintH(Msg.pBuffer[1]); PrintC(SPACE);
    PrintH(Msg.pBuffer[2]); PrintR();
  }
}
/* Send interrupt notification to the phone or 
 * read data from the accelerometer and send it to the phone
 */
static void AccelerometerSendDataHandler(void)
{
  tMessage Msg = {3, AccelIndMsg, MSG_OPT_NONE, NULL};

  if (CreateMessage(&Msg))
  {
    if (Control & DRDYE_DATA_AVAILABLE || (Control & WUF_ENABLE))
    {
      AccelerometerRead(Control & DRDYE_DATA_AVAILABLE ? KIONIX_XOUT_L : KIONIX_XOUT_HPF_L,
        Data, XYZ_DATA_LENGTH);

      Msg.pBuffer[0] = Data[1];
      Msg.pBuffer[1] = Data[3];
      Msg.pBuffer[2] = Data[5];
      RouteMsg(&Msg);

//      PrintQ(Msg.pBuffer, 3);
    }
    else if (Control & TILT_ENABLE_TPE)
    {
      AccelerometerRead(KIONIX_TILT_POS_CUR, Msg.pBuffer, ONE_BYTE);
      Msg.Length = 1;
      RouteMsg(&Msg);
      PrintH(Msg.pBuffer[0]); PrintR();
    }

    AccelerometerRead(KIONIX_INT_REL, Data, ONE_BYTE); //clear int
  }
}
Beispiel #6
0
void Print8R(__m128i R1,
			__m128i R2,
			__m128i R3,
			__m128i R4,
			__m128i R5,
			__m128i R6,
			__m128i R7,
			__m128i R8)
{
	PrintR(R1) ;
	PrintR(R2) ;
	PrintR(R3) ;
	PrintR(R4) ;
	PrintR(R5) ;
	PrintR(R6) ;
	PrintR(R7) ;
	PrintR(R8) ;
}
Beispiel #7
0
void PrintQ(unsigned char const *pHex, unsigned char const Len)
{
  unsigned char i;
  for (i = 0; i < Len; ++i) PrintH(*pHex++);
  PrintR();
}
Beispiel #8
0
void SetWidgetList(tMessage *pMsg)
{
  static Widget_t *pCurrWidget = NULL; // point to Widget in current Widget[]
  static Widget_t *pNextWidget = NULL; // point to Widget in new Widget[]
  static unsigned char ChangedClockWidget = INVALID_ID;

  xSemaphoreTake(SramMutex, portMAX_DELAY);

  WidgetList_t *pMsgWgtLst = (WidgetList_t *)pMsg->pBuffer;
  unsigned char WidgetNum = pMsg->Length / WIDGET_HEADER_LEN;

  unsigned char i = 0;
  PrintF(">SetWLst I:%d %s %d %s %d", WGTLST_INDEX(pMsg->Options), "T:", WGTLST_TOTAL(pMsg->Options), "Num:", WidgetNum);
  for(; i<WidgetNum; ++i) {PrintH(pMsgWgtLst[i].Id); PrintH(pMsgWgtLst[i].Layout);} PrintR();

  if (pNextWidget == NULL) // first time call, only add widgets
  {
    pCurrWidget = pCurrWidgetList;
    pNextWidget = &Widget[0];
  }
  else
  {
    if (WGTLST_INDEX(pMsg->Options) == 0 &&
      (pCurrWidget != pCurrWidgetList || (pNextWidget != &Widget[0] && pNextWidget != &Widget[MAX_WIDGET_NUM])))
    { // last SetWLst failed in the middle.Clean up whole list
      PrintS("# Last SetWgtLst broken!");

      pCurrWidget = pCurrWidgetList;
      pNextWidget = &Widget[0] + (&Widget[MAX_WIDGET_NUM] - pCurrWidgetList);
    }
  }

  while (WidgetNum) // number of list items
  {
      /* old clock widgets */
    if (!IS_CLOCK_WIDGET(pMsgWgtLst->Layout) && pMsgWgtLst->Id <= CLOCK_WIDGET_ID_RANGE) TestFaceId(pMsgWgtLst);
    unsigned char Change = GetWidgetChange(pCurrWidget->Id, pCurrWidget->Layout, pMsgWgtLst->Id, pMsgWgtLst->Layout);
    
    switch (Change)
    {
    case WGT_CHG_CLK_FACE:
      PrintS("Chg ClkFce");
      if (ON_CURRENT_PAGE(pMsgWgtLst->Layout)) ChangedClockWidget = pMsgWgtLst->Id;
      
    case WGT_CHG_SETTING:
     //cpy layout to curr; cpy curr to next; msg, curr, next ++
      PrintF("=%02X", pCurrWidget->Id);
      pCurrWidget->Id = pMsgWgtLst->Id;
      pCurrWidget->Layout = pMsgWgtLst->Layout;
      *pNextWidget++ = *pCurrWidget++;
      pMsgWgtLst ++;
      WidgetNum --;
      break;

    case WGT_CHG_CLK_ADD:
      PrintS("+Clk");
      if (ON_CURRENT_PAGE(pMsgWgtLst->Layout)) ChangedClockWidget = pMsgWgtLst->Id;

    case WGT_CHG_ADD: //pCurrWidget->Id > pMsgWgtLst->Id)
     // add new widget: cpy msg to next; msg and next ++; curr stays
      PrintF("+%02X", pMsgWgtLst->Id);

      pNextWidget->Id = pMsgWgtLst->Id;
      pNextWidget->Layout = pMsgWgtLst->Layout;
      AssignWidgetBuffer(pNextWidget);

      pNextWidget ++;
      pMsgWgtLst ++;
      WidgetNum --;
      break;
      
    case WGT_CHG_REMOVE:
    // remove widget: curr ++
      PrintF("-%02X", pCurrWidget->Id);
      FreeWidgetBuffer(pCurrWidget);
      pCurrWidget ++;
      break;
      
    default: break;
    }
  }
  PrintR();

  // if part index + 1 == parts, SetWidgetList complete
  if (WGTLST_TOTAL(pMsg->Options) == WGTLST_INDEX(pMsg->Options) + 1)
  {
//    PrintS("C:");
//    for (i=0; pCurrWidgetList[i].Id != INVALID_ID && i < MAX_WIDGET_NUM; ++i) PrintH(pCurrWidgetList[i].Id);
//    PrintR();

    while (pCurrWidget->Id != INVALID_ID && pCurrWidget < &pCurrWidgetList[MAX_WIDGET_NUM])
    {
      FreeWidgetBuffer(pCurrWidget);
      pCurrWidget->Id = INVALID_ID;
      pCurrWidget ++;
    }

    for (i = 0; i < MAX_WIDGET_NUM; ++i)
    {
      if (pCurrWidgetList[i].Id != INVALID_ID)
      { // clear the widget id in the curr list
        pCurrWidgetList[i].Id = INVALID_ID;
      }
    }

    pNextWidget = pCurrWidgetList;
    pCurrWidgetList = &Widget[0] + (&Widget[MAX_WIDGET_NUM] - pCurrWidgetList);
    pCurrWidget = pCurrWidgetList;

//    PrintS("N:");
//    for (i=0; pCurrWidgetList[i].Id != INVALID_ID; ++i) PrintH(pCurrWidgetList[i].Id);
//    PrintR();
    PrintF("Tg:%04X", BufTag);

    if (ChangedClockWidget != INVALID_ID)
    {
      CreateAndSendMessage(DrawClockWidgetMsg, ChangedClockWidget);
      ChangedClockWidget = INVALID_ID;
    }
  }
  xSemaphoreGive(SramMutex);
}