Exemplo n.º 1
0
/**********************************************************
 * This function will check if a Zero Gecko device is
 * locked. The method is different from other MCUs,
 * we have to read the AAP registers from the internal
 * memory space.
 * 
 * This process can fail (we receive a FAULT response) on 
 * other devices so wee need to check for failure on the AP 
 * transaction and clear the STICKYERR flag in CTRL/STAT 
 * before continuing. 
 **********************************************************/
void checkIfZeroGeckoIsLocked(void)
{
  int readError = SWD_ERROR_OK;
  uint32_t readVal;
  uint32_t apId;
  
  /* Try reading the AAP_IDR register on Zero. 
   * Do in a separate TRY/CATCH block in case to allow
   * failure in this transaction.
   */
  TRY 
    apId = readMem(AAP_IDR_ZERO);
  CATCH
    /* If transaction failed. Store error code */
    readError = errorCode;
  ENDTRY
  
  /* If the transaction was OK we check if we got
   * access to the AAP registers. If we do, the device
   * is locked. 
   */
  if ( readError == SWD_ERROR_OK )
  {
    if ( apId == EFM32_AAP_ID ) 
    {
      RAISE(SWD_ERROR_MCU_LOCKED);
    }
  } 
  /* We received a FAULT or WAIT error. This is normal on non-ZG devices. 
   * If this happens we have to clear the STICKYERR flag before continuing. 
   * If we do not do this all subsequent AP transactions will fail. 
   */
  else if ( readError == SWD_ERROR_FAULT || readError == SWD_ERROR_WAIT )
  {
    /* Read CTRL/STAT register */
    readDP(DP_CTRL, &readVal);
    
    /* See if STICKYERR is set */
    if ( readVal & (1 << 5) )
    {
      /* Clear sticky error */
      writeDP(DP_ABORT, (1 << 2));
    } 
  } 
  /* We received another error, e.g. protocol error. 
   * Report the error back to the calling function */
  else  
  {
    RAISE(readError);
  }
}
Exemplo n.º 2
0
auto R65816::op_write_dpr_b(Reg16& reg, Reg16& idx) {
  dp = readPC();
  idle2();
  idle();
L writeDP(dp + idx, reg);
}
Exemplo n.º 3
0
auto R65816::op_write_dp_b(Reg16& reg) {
  dp = readPC();
  idle2();
L writeDP(dp, reg);
}