private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { if (mwa.Size == MemorySize.Byte) { return; } switch (mwa.Address) { case 0x01d30000: { //WTCON _wtcon = (mwa.Value & 0x0000ffff); _prescaler = (_wtcon & 0x0000f000) >> 8; _wdgEnable = Utils.bitsSet(_wtcon, 0x00000020); _intEnable = Utils.bitsSet(_wtcon, 0x00000004); _rstEnable = Utils.bitsSet(_wtcon, 0x00000001); uint code = ((_wtcon & 0x18) >> 3) & 0x03; _divisor = (uint)Math.Pow(2.0, (code + 4)); this.ResetCurrentCycles(); } break; case 0x01d30004: { //WTDAT _wtdat = mwa.Value; this.ResetCurrentCycles(); } break; case 0x01d30008: { //WTCNT _wtcnt = mwa.Value; this.ResetCurrentCycles(); } break; } //switch } //onMemoryAccessWrite
private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { if (mwa.Size != MemorySize.Word) { return; } return; }
}//onMemoryAccessRead /// <summary> /// This function is called when a memory write has occurred on the button id register. /// </summary> /// <param name="sender"></param> /// <param name="mwa"></param> private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { //we only allow word access if (mwa.Size == MemorySize.Word) { //clear bits where a '1' is written mBlackButtonID &= (uint)(~mwa.Value); } }//onMemoryAccessWrite
}//onExecuteSWI /// <summary> /// This function is called whenever a write access is performed on a reserved block /// Input: /// mwa:properties of the write opertaion /// </summary> /// <param name="mwa"></param> public void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { //ignore any non-word writes if (mwa.Size != MemorySize.Word) { return; } //set the bottom eight bits as the display byte for our control mEightSegmentDisplayControl.Code = (byte)mwa.Value; }//onMemoryAccessWrite
}//onMemoryAccessRead private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { if (mwa.Size == MemorySize.Word && Utils.isValidAddress(mwa.Address, MemorySize.Word)) { uint index = (mwa.Address - mLowerAddress) >> 2; if (index < mPortDefinitions.Length) { mPortDefinitions[index].Write(mwa.Value); } } }//onMemoryAccessWrite
private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { switch (mwa.Address) { case 0x01d50000: { //TCFG0 if (mwa.Size != MemorySize.Word) { break; } _timerBlocks[0].PreScaler = (byte)(mwa.Value & 0xff); _timerBlocks[1].PreScaler = (byte)(mwa.Value >> 8 & 0xff); _timerBlocks[2].PreScaler = (byte)(mwa.Value >> 16 & 0xff); } break; case 0x01d50004: { //TCFG1 if (mwa.Size != MemorySize.Word) { break; } _timerBlocks[0].MUX = (byte)(mwa.Value & 0xff); _timerBlocks[1].MUX = (byte)(mwa.Value >> 8 & 0xff); _timerBlocks[2].MUX = (byte)(mwa.Value >> 16 & 0xff); } break; case 0x01d50008: { //TCON if (mwa.Size != MemorySize.Word) { break; } _timerBlocks[0].SetFlags((mwa.Value & 0x1f), (mwa.Value >> 8 & 0x0f)); _timerBlocks[1].SetFlags((mwa.Value >> 12 & 0x0f), (mwa.Value >> 16 & 0x0f)); _timerBlocks[2].SetFlags((mwa.Value >> 20 & 0x0f), (mwa.Value >> 24 & 0x07)); } break; default: { //TCNTBx,TCMPBx,TCNTOx if (mwa.Size == MemorySize.Byte) { break; } uint baseAddress = (mwa.Address - 0x01d5000c); int timer = (int)((baseAddress / 12) % 2); int timerBlock = timer >> 1; if (timerBlock >= _timerBlocks.Length) { return; } _timerBlocks[timerBlock].SetTimerCounts(timer, (baseAddress % 12), (mwa.Value & 0x0000ffff)); } break; //default }//switch }//onMemoryAccessWrite
}//onMemoryAccessRead /// <summary> /// This function is called when a memory write has occurred on either the Command or Data register. /// </summary> /// <param name="sender"></param> /// <param name="mwa"></param> private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { //we only allow word access if (mwa.Size == MemorySize.Word) { //determine which register was accessed and handle it if (mwa.Address == mBaseAddress) { CommandRegisterWrite(mwa.Value); } else { //The Data register. Write character to the current cursor location mTwoLineLCDDisplay.PutChar((int)(mwa.Value & 0x7f)); } } mTwoLineLCDDisplay.Invalidate(); }//onMemoryAccessWrite
}//onMemoryAccessRead /// <summary> /// This function is called when the memory locations declared by the LEDs have been written. /// </summary> /// <param name="sender"></param> /// <param name="mwa"></param> private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { // only word access allowed if (mwa.Size == MemorySize.Word) { //obtain the bottom 2 bits of the value written uint newValue = (uint)(mwa.Value & 0x03); //Note:this test is to avoid excessive updating of the leds. If the state of the //LEDs does not change, dont update UI //if the value has changed, notify UI to update itself. if (mLedsState != newValue) { //save new value mLedsState = newValue; UpdateUserInterface(); } } //if } //onMemoryAccessWrite
} //onMemoryAccessRead /// <summary> /// This function is called when the memory locations declared by the timers has been written. /// </summary> /// <param name="sender"></param> /// <param name="mwa"></param> private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { // only word access allowed if (mwa.Size != MemorySize.Word) { return; } //determine the timer block number from bit 4 int block = ((int)mwa.Address >> 4) & 0x01; //grab the value being written, only bottom 16 bits ushort value = (ushort)(mwa.Value & 0x0000ffff); //and access the timer based on the address (bits 0-3) switch (mwa.Address & 0x0f) { case 0x00: //WTCON mTimerBlocks[block].ControlRegister = value; break; case 0x04: //WTDAT mTimerBlocks[block].DataRegister = value; break; case 0x08: //WTCNT mTimerBlocks[block].CountRegister = value; break; case 0x0c: //intID mInterruptID &= (uint)(~value); break; default: break; }//switch //user interface needs updating this.UpdateUserInterface(false); }//onMemoryAccessWrite
private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { if (mwa.Size != MemorySize.Word) { return; } uint memOffset = (mwa.Address - LCD_ACTIVBUFFER) / 4; if (memOffset >= mLcdBuffer.Length) { return; } int ypos = (int)(memOffset / (PIXELS_WIDTH / PIXELS_PER_WORD)); int xpos = (int)((memOffset % (PIXELS_WIDTH / PIXELS_PER_WORD)) * 8); int pixels = (int)mwa.Value; mLcdBuffer[memOffset] = pixels; //mLcd.DrawPixel8(xpos, ypos, (uint)pixels); }
private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { }
}//onMemoryAccessRead private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { if (mwa.Size != MemorySize.Word || Utils.isValidAddress(mwa.Address, MemorySize.Word)) { return; } Uart uart = ((mwa.Address & 0x01d04000) == 0) ? mUart0 : mUart1; switch (mwa.Address & 0x01d00000) { //ULCON:Uart Line Control Register case 0x01d00000: uart.ULCON = mwa.Value; break; //UCON:Uart Control Register case 0x01d00004: uart.UCON = mwa.Value; break; //UFCON:Uart FIFO Control Register case 0x01d00008: uart.UFCON = mwa.Value; break; //UMCON:Uart Modem Control Register case 0x01d0000c: uart.UMCON = mwa.Value; break; //UTRSTAT:Uart Tx/Rx Status Register (read-only) case 0x01d00010: break; //UERSTAT:Uart Error Status Register case 0x01d00014: uart.UERSTAT = mwa.Value; break; //UFSTAT:Uart FIFO Status Register (read-only) case 0x01d00018: //uart.UFSTAT = mwa.Value; break; //UMSTAT:Uart Modem Status Register case 0x01d0001c: //uart.UMSTAT = mwa.Value; break; //UTXH:Uart Transmit Holding(Buffer) Register case 0x01d00020: uart.UTXH = mwa.Value; break; //URXH:Uart Receive Holding(Buffer) Register case 0x01d00024: //uart.URXH = mwa.Value; break; //UBRDIV:Uart Baud Rate Division Register case 0x01d00028: uart.UBRDIV = mwa.Value; break; } } //onMemoryAccessWrite
} //SetMasterPriorities private void onMemoryAccessWrite(object sender, MemoryAccessWriteEventArgs mwa) { switch (mwa.Address) { case 0x01e00000: { //INTCON uint value = (mwa.Value & 0x07); _vectorMode = ((value & 0x04) == 0); _IRQEnable = ((value & 0x02) == 0); _FIQEnable = ((value & 0x01) == 0); } break; case 0x01e00008: { //INTMOD if (mwa.Size != MemorySize.Word) { break; } _interuptMode = mwa.Value; } break; case 0x01e0000c: { //INTMSK if (mwa.Size != MemorySize.Word) { break; } _interuptMask = mwa.Value; } break; case 0x01e00010: { //I_PSLV if (mwa.Size != MemorySize.Word) { break; } SetSlavePriorities(mwa.Value); } break; case 0x01e00014: { //I_PMST if (mwa.Size == MemorySize.Byte) { break; //cannot write a byte here } SetMasterPriorities(mwa.Value); } break; case 0x01e00024: case 0x01e0003c: { //I_ISPC,F_ISPC //todo - implement if (mwa.Size != MemorySize.Word) { break; //must be a full word } uint mask = mwa.Value; _interuptPending &= ~mask; _currentInteruptService = 0; } break; }//switch ProcessInterupts(); mInterruptControllerDisplay.UpdateInterruptControllerDisplay(); } //onMemoryAccessWrite