示例#1
0
auto R65816::op_sta_idp_b() {
  dp = readPC();
  idle2();
  aa.l = readDP(dp + 0);
  aa.h = readDP(dp + 1);
L writeDB(aa.w, r.a.l);
}
示例#2
0
auto R65816::op_sta_idpy_w() {
  dp = readPC();
  idle2();
  aa.l = readDP(dp + 0);
  aa.h = readDP(dp + 1);
  idle();
  writeDB(aa.w + r.y.w + 0, r.a.l);
L writeDB(aa.w + r.y.w + 1, r.a.h);
}
示例#3
0
/**********************************************************
 * Reads one word from internal memory
 * 
 * @param addr 
 *    The address to read from
 * 
 * @returns 
 *    The value at @param addr
 **********************************************************/
uint32_t readMem(uint32_t addr)
{
  uint32_t ret;
  writeAP(AP_TAR, addr);
  readAP(AP_DRW, &ret);
  readDP(DP_RDBUFF, &ret);
  return ret;
}
示例#4
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);
  }
}
示例#5
0
/**********************************************************
 * Halts the target CPU
 **********************************************************/
void haltTarget(void)
{
  int timeout = DEBUG_EVENT_TIMEOUT;
  writeAP(AP_TAR, (uint32_t)&(CoreDebug->DHCSR));
  writeAP(AP_DRW, STOP_CMD);
  
  uint32_t dhcrState;
  do {
    writeAP(AP_TAR, (uint32_t)&(CoreDebug->DHCSR));
    readAP(AP_DRW, &dhcrState);
    readDP(DP_RDBUFF, &dhcrState);
    timeout--;
  } while ( !(dhcrState & CoreDebug_DHCSR_S_HALT_Msk) && timeout > 0 ); 
  
  if ( !(dhcrState & CoreDebug_DHCSR_S_HALT_Msk) ) {
    RAISE(SWD_ERROR_TIMEOUT_HALT);
  }
}