Exemple #1
0
/**************************************************************************************************
 * @fn          sblExec
 *
 * @brief       Infinite SBL execute loop that jumps upon receiving a code enable.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
static void sblExec(void)
{
  uint32 dlyCnt = 0;

  while (1)
  {
    HalUARTPollUSB();

    if (sbExec() && sbImgValid())
    {
      SB_TURN_ON_LED1();
      SB_TURN_ON_LED2();
      // Delay to allow the SB_ENABLE_CMD response to be flushed.
      for (dlyCnt = 0; dlyCnt < 0x40000; dlyCnt++)
      {
        HalUARTPollUSB();
      }

      sblJump();
    }
    else if (dlyCnt++ & 0x4000)
    {
      SB_TOGGLE_LED1();
    }
  }
}
Exemple #2
0
/**************************************************************************************************
 * @fn          sblExec
 *
 * @brief       Infinite SBL execute loop that returns upon receiving a code enable.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
static void sblExec(void)
{
  uint32 dlyCnt = 0;
  vddWait(VDD_MIN_NV);
  HAL_ENABLE_INTERRUPTS();

  while (1)
  {
    if (dlyCnt++ & 0x4000)
    {
      SB_TOGGLE_LED1();
    }

    HalUARTPollUSB();
    if (sbExec())
    {
      break;
    }
  }

  SB_TURN_ON_LED1();
  SB_TURN_ON_LED2();
  // Delay to allow the SB_ENABLE_CMD response to be flushed.
  for (dlyCnt = 0; dlyCnt < 0x40000; dlyCnt++)
  {
    HalUARTPollUSB();
  }
}
Exemple #3
0
/**************************************************************************************************
 * @fn          sblJump
 *
 * @brief       Execute a simple long jump from non-banked SBL code to non-banked RC code space.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 */
static void sblJump(void)
{
  SB_TURN_ON_LED1();
  SB_TURN_ON_LED2();
  while (SB1_PRESS || SB2_PRESS);
  SB_TURN_OFF_LED1();
  SB_TURN_OFF_LED2();
  asm("LJMP 0x2000\n");  // Immediate jump to run-code.
  HAL_SYSTEM_RESET();
}
Exemple #4
0
/**************************************************************************************************
 * @fn          sblWait
 *
 * @brief       A timed-out wait loop that exits early upon receiving a force code/sbl byte.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      TRUE to run the code image, FALSE to run the SBL.
 **************************************************************************************************
 */
static uint8 sblWait(void)
{
  uint32 dlyCnt = 0x260000;
  uint8 rtrn = FALSE;
  HAL_ENABLE_INTERRUPTS();

  while (1)
  {
    uint8 ch;

    HalUARTPollUSB();
    if (HalUARTRx(&ch, 1))
    {
      if (ch == SB_FORCE_BOOT)
      {
        break;
      }
      else if (ch == SB_FORCE_RUN)
      {
        dlyCnt = 0;
      }
    }

    if (SB1_PRESS)
    {
      break;
    }

    if (SB2_PRESS || (dlyCnt-- == 0))
    {
      rtrn = TRUE;
      break;
    }

    // RR-xing LED display while waiting.
    if (dlyCnt & 0x2000)
    {
      SB_TURN_OFF_LED2();
      SB_TURN_ON_LED1();
    }
    else
    {
      SB_TURN_OFF_LED1();
      SB_TURN_ON_LED2();
    }
  }

  HAL_DISABLE_INTERRUPTS();
  SB_TURN_OFF_LED1();
  SB_TURN_OFF_LED2();

  return rtrn;
}
Exemple #5
0
/**************************************************************************************************
 * @fn          sblWait
 *
 * @brief       A timed-out wait loop that exits early upon receiving a force code/sbl byte.
 *
 * input parameters
 *
 * None.
 *
 * output parameters
 *
 * None.
 *
 * @return      None.
 **************************************************************************************************
 */
static void sblWait(void)
{
  uint32 dlyCnt = SB_UART_DELAY;

  while (1)
  {
    uint8 ch;

    HalUARTPollUSB();
    if (HalUARTRx(&ch, 1))
    {
      if (ch == SB_FORCE_BOOT)
      {
        break;
      }
      else if (ch == SB_FORCE_RUN)
      {
        dlyCnt = 0;
      }
    }

    if (SB1_PRESS)
    {
      break;
    }

    if (SB2_PRESS || (dlyCnt-- == 0))
    {
      sblJump();
    }

    // RR-xing LED display while waiting.
    if (dlyCnt & 0x2000)
    {
      SB_TURN_OFF_LED2();
      SB_TURN_ON_LED1();
    }
    else
    {
      SB_TURN_OFF_LED1();
      SB_TURN_ON_LED2();
    }
  }

  SB_TURN_OFF_LED1();
  SB_TURN_OFF_LED2();
}