setupadvanced.mac

来自「《IAR EWARM 嵌入式系统 编程与实践》书中例程」· MAC 代码 · 共 57 行

MAC
57
字号
__var _fileHandle;
__var _interruptID;
__var _breakID;

execUserSetup() {
  __message "execUserSetup() called\n";
  // 调用模拟仿真设置
  SimulationSetup ();
}

execUserReset() {
  __message "execUserReset() called\n";
  if( _fileHandle ) {
    __resetFile( _fileHandle );
  }
}

execUserExit() {
  __message "execUserExit() called\n";
  // 调用模拟仿真关闭
  SimulationShutdown();
}

SimulationSetup() {
  // 打开文本文件InputData.txt读取ASCII码
  _fileHandle = __openFile( "$PROJ_DIR$\\InputData.txt", "r" );
  if( !_fileHandle ) {
    __message "could not open file" ;
  }
_interruptID = __orderInterrupt( "IRQ", 4000, 2000, 0, 0, 0, 100 );
  if( -1 == _interruptID ) {
    __message "ERROR: syntax error in interrupt description";
  }
  // 设置立即断点
  _breakID = __setSimBreak( "UARTRBRTHR", "R", "Access()" );
}

Access() {
  __message "Access() called\n";
  // 从文件中读取fib数列
  __var _fibValue;
  if( 0 == __readFile( _fileHandle, &_fibValue)) {
    UARTRBRTHR = _fibValue;
  }
  else {
    __message "error reading value from file";
  }
  __message "UARTRBR = 0x", _fibValue:%X,"\n";
}

SimulationShutdown() {
  __cancelInterrupt( _interruptID );
  __clearBreak( _breakID );
  __closeFile( _fileHandle );
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?