void SaveLinkAlarmEnable(void)
{
  OsalNvWrite(NVID_LINK_ALARM_ENABLE,
              NV_ZERO_OFFSET,
              sizeof(nvLinkAlarmEnable),
              &nvLinkAlarmEnable);
}
void SaveRstNmiConfiguration(void)
{
  OsalNvWrite(NVID_RSTNMI_CONFIGURATION,
              NV_ZERO_OFFSET,
              sizeof(nvRstNmiConfiguration),
              &nvRstNmiConfiguration);
}
static void NvalOperationHandler(tMessage* pMsg)
{
  /* overlay */
  tNvalOperationPayload* pNvPayload = (tNvalOperationPayload*)pMsg->pBuffer;

  /* create the outgoing message */
  tMessage OutgoingMsg;
  SetupMessageAndAllocateBuffer(&OutgoingMsg,
                                NvalOperationResponseMsg,
                                NV_FAILURE);

  /* add identifier to outgoing message */
  tWordByteUnion Identifier;
  Identifier.word = pNvPayload->NvalIdentifier;
  OutgoingMsg.pBuffer[0] = Identifier.Bytes.byte0;
  OutgoingMsg.pBuffer[1] = Identifier.Bytes.byte1;
  OutgoingMsg.Length = 2;

  /* option byte in return message is status */
  switch (pMsg->Options)
  {

  case NVAL_INIT_OPERATION:
    /* may allow access to a specific range of nval ids that
     * the phone can initialize and use
     */
    break;

  case NVAL_READ_OPERATION:

    /* read the value and update the length */
    OutgoingMsg.Options = OsalNvRead(pNvPayload->NvalIdentifier,
                                     NV_ZERO_OFFSET,
                                     pNvPayload->Size,
                                     &OutgoingMsg.pBuffer[2]);

    OutgoingMsg.Length += pNvPayload->Size;

    break;

  case NVAL_WRITE_OPERATION:

    /* check that the size matches (otherwise NV_FAILURE is sent) */
    if ( OsalNvItemLength(pNvPayload->NvalIdentifier) == pNvPayload->Size )
    {
      OutgoingMsg.Options = OsalNvWrite(pNvPayload->NvalIdentifier,
                                        NV_ZERO_OFFSET,
                                        pNvPayload->Size,
                                        (void*)(&pNvPayload->DataStartByte));
    }

    /* update the copy in ram */
    NvUpdater(pNvPayload->NvalIdentifier);
    break;

  default:
    break;
  }

  RouteMsg(&OutgoingMsg);

}
Exemple #4
0
void WatchdogTimeoutHandler(unsigned char ResetSource)
{
  /* always print information about the number of watchdogs that have occured */
  unsigned char nvWatchdogCount = 0;
  OsalNvItemInit(NVID_WATCHDOG_RESET_COUNT,
                 sizeof(nvWatchdogCount),
                 &nvWatchdogCount);

  PrintStringAndDecimal("Total Watchdogs: ",nvWatchdogCount);
   
  if ( ResetSource == SYSRSTIV_WDTTO || ResetSource == SYSRSTIV_WDTKEY )
  {
    if ( ResetSource == SYSRSTIV_WDTTO )
    {
      PrintString("## Watchdog Failsafe\r\n");
    }
    else
    {
      PrintString("## Forced Watchdog Timeout\r\n");
    }
    
    PrintStringAndDecimal("SppReadyToSleep ",WatchdogInfo.SppReadyToSleep);
    
    PrintStringAndDecimal("TaskDelayLockCount ",
                          WatchdogInfo.TaskDelayLockCount);
    
    PrintStringAndDecimal("DisplayMessagesWaiting ",
                          WatchdogInfo.DisplayMessagesWaiting);
    
    PrintStringAndDecimal("SppMessagesWaiting ",
                          WatchdogInfo.SppMessagesWaiting);
    
    /* 
     * now save the information
     */

    /* If a watchdog is occurring over and over we don't want to ruin the flash.
     * Limit to 255 writes until code is reflashed or phone clears value
     */
#if WATCHDOG_TEST_MODE == 0
    if ( nvWatchdogCount < 0xFF )
#else
    if ( nvWatchdogCount < 0x01 )
#endif
    {
      nvWatchdogCount++;
      OsalNvWrite(NVID_WATCHDOG_RESET_COUNT,
                  NV_ZERO_OFFSET,
                  sizeof(nvWatchdogCount),
                  &nvWatchdogCount);
    
      OsalNvItemInit(NVID_WATCHDOG_INFORMATION,
                     sizeof(WatchdogInfo),
                     &WatchdogInfo);
    
      OsalNvWrite(NVID_WATCHDOG_INFORMATION,
                  NV_ZERO_OFFSET,
                  sizeof(WatchdogInfo),
                  &WatchdogInfo);
    }
  }
  
}