コード例 #1
0
ファイル: sb_main.c プロジェクト: sdhczw/ACGatewayDemo
/**************************************************************************************************
 * @fn          main
 *
 * @brief       ISR for the reset vector.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void main(void)
{
  uint8 time_spent_validating;
  uint8 bootloaderForcedByMainApp = FALSE;
  uint32 mainAppCommandLocal = mainAppCommand;

  mainAppCommand = MAIN_APP_CMD_NONE;
    
  if (mainAppCommandLocal == MAIN_APP_CMD_FORCE_BOOTLOADER)
  {
    bootloaderForcedByMainApp = TRUE;
  }
  else if ((mainAppCommandLocal == MAIN_APP_CMD_PASS_THROUGH) || ((SLEEPSTA & LRESET) == RESETWD))
  /* If reset due to WatchDog Timer - Transfer control to the main application immediately.
     WatchDog Timer reset causes the hardware to disconnect the USB. Without this jump here,
     the SBL code will try to initiaize the CDC too early, which causes undesired behavior
     on the host (e.g. on beaglebone black - the host gets stuck) */
  {
    asm("LJMP 0x2000\n");
  }

  sblInit();

  if ((!bootloaderForcedByMainApp) && sbImgValid(&time_spent_validating))
  {
    if (sblWait(SBL_WAIT_TIME > time_spent_validating ? SBL_WAIT_TIME - time_spent_validating : 0))
    {
      if (znpCfg1 == ZNP_CFG1_SPI)
      {
        HalUARTUnInitSPI();
      }
      else
      {
        sbReportState(SB_STATE_EXECUTING_IMAGE);
		
        while(sblIsUartTxPending())
        {
          sbUartPoll();
        }
        
        SLEEP(0x2600); //Give the last bytes in the HW TX fifo (if any) enough time to be transmitted

        HalUARTUnInitISR();
      }
      magicByte = SB_STACK_VALUE;

      // Simulate a reset for the Application code by an absolute jump to location 0x2000.
      asm("LJMP 0x2000\n");
      HAL_SYSTEM_RESET();
    }
  }

  sblExec();
  HAL_SYSTEM_RESET();
}
コード例 #2
0
ファイル: sb_main.c プロジェクト: Zmarkteam/zmarkt
/**************************************************************************************************
 * @fn          main
 *
 * @brief       ISR for the reset vector.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void main(void)
{
  sblInit();

  if (sbImgValid())
  {
    if (sblWait())
    {
      HalUARTUnInitUSB();
      // Simulate a reset for the Application code by an absolute jump to location 0x2000.
      asm("LJMP 0x2000\n");
      HAL_SYSTEM_RESET();
    }
  }

  sblExec();
  HAL_SYSTEM_RESET();
}
コード例 #3
0
ファイル: sb_main.c プロジェクト: niuniu500w/led_gprs
/**************************************************************************************************
 * @fn          main
 *
 * @brief       C-code main functionality.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void main(void)
{
  vddWait(VDD_MIN_RUN);
  HAL_BOARD_INIT();

  // make sure the DMA channel is selected before we attempt to
  // to write anything to flash.
  sblInit();
  
  if (sbImgValid())
  {
    if ((SB_UART_DELAY == 0) || ResetWasWatchDog)
    {
      sblJump();
    }

    sblWait();
  }

  vddWait(VDD_MIN_NV);
  sblExec();
  HAL_SYSTEM_RESET();
}
コード例 #4
0
ファイル: sb_main.c プロジェクト: jphome/zigbee_2.5.1
/**************************************************************************************************
 * @fn          main
 *
 * @brief       C-code main functionality.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void main(void)
{
  vddWait(VDD_MIN_RUN);
  HAL_BOARD_INIT();

  if (sbImgValid())
  {
    if ((SB_UART_DELAY == 0) || ResetWasWatchDog)
    {
      sblJump();
    }

    sblInit();
    sblWait();
  }
  else
  {
    sblInit();
  }

  vddWait(VDD_MIN_NV);
  sblExec();
  HAL_SYSTEM_RESET();
}
コード例 #5
0
ファイル: sb_main.c プロジェクト: Lieubk/SmartLife
/**************************************************************************************************
 * @fn          main
 *
 * @brief       C-code main functionality.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
void main(void)
{
  uint8 time_spent_validating;
  uint8 bootloaderForcedByMainApp = FALSE;
  uint32 mainAppCommandLocal = mainAppCommand;

  vddWait(VDD_MIN_RUN);

  mainAppCommand = MAIN_APP_CMD_NONE;
    
  if (mainAppCommandLocal == MAIN_APP_CMD_FORCE_BOOTLOADER)
  {
    bootloaderForcedByMainApp = TRUE;
  }
  else if ((mainAppCommandLocal == MAIN_APP_CMD_PASS_THROUGH) || ((SLEEPSTA & LRESET) == RESETWD))
  {
    // If reset due to WatchDog Timer - Transfer control to the main application immediately.
    // WatchDog Timer reset causes the hardware to disconnect the USB. Withought this jump here,
    // the SBL code will try to initiaize the CDC too early, which causes undesired behavior on the host
    // (e.g. on beaglebone black - the host gets stuck)
    asm("LJMP 0x2000\n");
  }

  sblInit(bootloaderForcedByMainApp);
  
  HAL_TURN_ON_LED1();
  HAL_TURN_ON_LED2();
  
  if ((!bootloaderForcedByMainApp) && (sbImgValid(&time_spent_validating)))
  {
    HAL_TURN_OFF_LED2();
    
    if (sblWait(SBL_WAIT_TIME > time_spent_validating ? SBL_WAIT_TIME - time_spent_validating : 0))
    {
      HAL_TURN_OFF_LED1();
      
      sbReportState(SB_STATE_EXECUTING_IMAGE);
      
      while(sblIsUartTxPending())
      {
        sbUartPoll();
      }
      
      SLEEP(0x2600); //Give the last bytes in the HW TX fifo (if any) enough time to be transmitted

      while (SB1_PRESS || SB2_PRESS);
      
      sblUnInit();
      
      // Simulate a reset for the Application code by an absolute jump to location 0x2000.
      asm("LJMP 0x2000\n");
    }
  }
  
  HAL_TURN_OFF_LED1();
  HAL_TURN_ON_LED2();
  
  vddWait(VDD_MIN_NV);
  sblExec();

  sblUnInit();

  asm("LJMP 0x2000\n");
}