From c12d824fc2f17a58d9dc09c2d6315f986f67ec89 Mon Sep 17 00:00:00 2001 From: meepingsnesroms Date: Tue, 26 Jun 2018 11:50:55 -0700 Subject: [PATCH] New test, minor cleanups and bugfixes --- disassemblyNotes.txt | 5 ++ hwTestSuite/tests.c | 30 +++++++++++ hwTestSuite/tests.h | 1 + hwTestSuite/tools.c | 83 ++++-------------------------- hwTestSuite/viewer.c | 12 +++-- qtBuildSystem/Mu/Mu.pro.user | 2 +- src/hardwareRegistersAccessors.c.h | 3 ++ unimplementedHardware.txt | 9 ++-- 8 files changed, 60 insertions(+), 85 deletions(-) diff --git a/disassemblyNotes.txt b/disassemblyNotes.txt index 02906e8..cb3ff61 100644 --- a/disassemblyNotes.txt +++ b/disassemblyNotes.txt @@ -1,3 +1,8 @@ +HwrIRQ4Handler Interrupt Level 4 Priority(top of the list is checked first): +UART 1 and 2(they have the same priority) +RTC +All Buttons + IVR = 0x18 interrupt vector start = 0x60 diff --git a/hwTestSuite/tests.c b/hwTestSuite/tests.c index 06fa3f6..23119cb 100644 --- a/hwTestSuite/tests.c +++ b/hwTestSuite/tests.c @@ -537,6 +537,36 @@ var getCpuInfo(){ return makeVar(LENGTH_0, TYPE_NULL, 0); } +var getInterruptInfo(){ + static Boolean firstRun = true; + uint16_t y = 0; + + if(firstRun){ + debugSafeScreenClear(C_WHITE); + firstRun = false; + } + + if(getButtonPressed(buttonBack)){ + firstRun = true; + exitSubprogram(); + } + + StrPrintF(sharedDataBuffer, "IMR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(IMR))); + UG_PutString(0, y, sharedDataBuffer); + y += FONT_HEIGHT + 1; + StrPrintF(sharedDataBuffer, "IPR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(IPR))); + UG_PutString(0, y, sharedDataBuffer); + y += FONT_HEIGHT + 1; + StrPrintF(sharedDataBuffer, "ISR:0x%08lX", readArbitraryMemory32(HW_REG_ADDR(ISR))); + UG_PutString(0, y, sharedDataBuffer); + y += FONT_HEIGHT + 1; + StrPrintF(sharedDataBuffer, "ILCR:0x%04X", readArbitraryMemory16(HW_REG_ADDR(ILCR))); + UG_PutString(0, y, sharedDataBuffer); + y += FONT_HEIGHT + 1; + + return makeVar(LENGTH_0, TYPE_NULL, 0); +} + var toggleBacklight(){ static Boolean firstRun = true; uint16_t y = 0; diff --git a/hwTestSuite/tests.h b/hwTestSuite/tests.h index b219ff0..3b4741d 100644 --- a/hwTestSuite/tests.h +++ b/hwTestSuite/tests.h @@ -15,6 +15,7 @@ var selfProbeSpi2(); var getClk32Frequency(); var getDeviceId(); var getCpuInfo(); +var getInterruptInfo(); var toggleBacklight(); var toggleMotor(); var toggleAlarmLed(); diff --git a/hwTestSuite/tools.c b/hwTestSuite/tools.c index 1f1cdd2..bc56758 100644 --- a/hwTestSuite/tools.c +++ b/hwTestSuite/tools.c @@ -9,38 +9,6 @@ #include "debug.h" #include "ugui.h" -#if 0 -Err makeFile(uint8_t* data, uint32_t size, char* fileName){ - FileHand file; - Err error; - uint32_t count; - - file = FileOpen(0 /*cardNo*/, fileName, (uint32_t)'DATA', (uint32_t)'GuiC', fileModeReadWrite, &error); - if(file == fileNullHandle || error != errNone) - return error; - - /*the copy is used to anonymize the data source*/ - count = size; - while(count != 0){ - uint32_t chunkSize = min(count, SHARED_DATA_BUFFER_SIZE); - int32_t bytesWritten; - uint32_t i; - for(i = 0; i < chunkSize; i++){ - sharedDataBuffer[i] = data[i + size - count]; - } - bytesWritten = FileWrite(file, sharedDataBuffer, 1, chunkSize, &error); - if(bytesWritten != chunkSize || error != errNone){ - FileClose(file); - return error; - } - - count -= chunkSize; - } - - error = FileClose(file); - return error; -} -#endif Err makeFile(uint8_t* data, uint32_t size, char* fileName){ uint16_t volRef = 0; @@ -84,9 +52,6 @@ Err makeFile(uint8_t* data, uint32_t size, char* fileName){ } uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bit){ - uint8_t osPgdata = readArbitraryMemory8(HW_REG_ADDR(PGDATA)); - uint16_t osSpi2Control = readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0xE230;/*use data rate, phase and polarity from OS, also check if SPI2 is enabled*/ - uint16_t spi2Control = osSpi2Control; uint8_t config = 0x80; uint16_t value; @@ -98,55 +63,25 @@ uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bi config |= channel << 4 & 0x70; - /*the chip select line seems to be here, pull it low*/ - //writeArbitraryMemory8(HW_REG_ADDR(PGDATA), osPgdata & 0xFB); - writeArbitraryMemory8(HW_REG_ADDR(PGDATA), osPgdata | 0x08); - - /*wait until SPI2 is free*/ - while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); - /*enable SPI 2 if disabled*/ - if(!(spi2Control & 0x0200)){ - spi2Control |= 0x0200; - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control); - } - - /*flush the register*/ - writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), 0x0000); - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0100/*exchange*/ | 0x0015); - while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4207); /*set data to send*/ writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config << 8); -#if 1 /*send data*/ - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0100/*exchange*/ | 0x0007); + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4307); + while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); + + /*receive data*/ + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0x4300 | (mode8bit ? 0x0008 : 0x000C)); while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); - /*clear any data received in SPIDATA2 during the previous send*/ - writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), 0x0000); - /*trigger a busy event*//*there is a 1 bit delay after the config byte before data is sent*/ - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0100/*exchange*/); - - /*receive data, mode = 1(8 bits) or mode = 0(12 bits), 1 bit is a busy event*/ - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0100/*exchange*/ | (mode8bit ? 0x0007 : 0x000B)); - while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); -#endif -#if 0 - /*send and receive at the same time, should be 7 bits in SPIDATA2*/ - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0100/*exchange*/ | 0x000F); - while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100); -#endif - - /*get value returned, should have*/ + /*get value returned*/ value = readArbitraryMemory16(HW_REG_ADDR(SPIDATA2)); - /*return to OS state*/ - writeArbitraryMemory8(HW_REG_ADDR(PGDATA), osPgdata); - writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), osSpi2Control); - - /*may need to convert returned value some*/ + /*disable SPI2*/ + writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), 0xE000); return value; } diff --git a/hwTestSuite/viewer.c b/hwTestSuite/viewer.c index b4eb40e..16d4ea6 100644 --- a/hwTestSuite/viewer.c +++ b/hwTestSuite/viewer.c @@ -323,10 +323,18 @@ void resetFunctionViewer(){ hwTests[totalHwTests].testFunction = getCpuInfo; totalHwTests++; + StrNCopy(hwTests[totalHwTests].name, "Get Interrupt Info", TEST_NAME_LENGTH); + hwTests[totalHwTests].testFunction = getInterruptInfo; + totalHwTests++; + StrNCopy(hwTests[totalHwTests].name, "Watch ICR", TEST_NAME_LENGTH); hwTests[totalHwTests].testFunction = watchIcr; totalHwTests++; + StrNCopy(hwTests[totalHwTests].name, "ADS7846 Read", TEST_NAME_LENGTH); + hwTests[totalHwTests].testFunction = ads7846Read; + totalHwTests++; + if(isM515){ StrNCopy(hwTests[totalHwTests].name, "Toggle Backlight", TEST_NAME_LENGTH); hwTests[totalHwTests].testFunction = toggleBacklight; @@ -354,10 +362,6 @@ void resetFunctionViewer(){ hwTests[totalHwTests].testFunction = tstat1GetSemaphoreLockOrder; totalHwTests++; - StrNCopy(hwTests[totalHwTests].name, "ADS7846 Read", TEST_NAME_LENGTH); - hwTests[totalHwTests].testFunction = ads7846Read; - totalHwTests++; - StrNCopy(hwTests[totalHwTests].name, "Get SPI2 ENABLE Delay", TEST_NAME_LENGTH); hwTests[totalHwTests].testFunction = checkSpi2EnableBitDelay; totalHwTests++; diff --git a/qtBuildSystem/Mu/Mu.pro.user b/qtBuildSystem/Mu/Mu.pro.user index 8ab1f6d..8f83adc 100644 --- a/qtBuildSystem/Mu/Mu.pro.user +++ b/qtBuildSystem/Mu/Mu.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/src/hardwareRegistersAccessors.c.h b/src/hardwareRegistersAccessors.c.h index 6bc2bc9..cccbae8 100644 --- a/src/hardwareRegistersAccessors.c.h +++ b/src/hardwareRegistersAccessors.c.h @@ -273,6 +273,9 @@ static inline void setSpiCont2(uint16_t value){ setIprIsrBit(INT_SPI2); } + //check for any interrupts from the transfer + checkInterrupts(); + registerArrayWrite16(SPICONT2, value & 0xE3FF); } diff --git a/unimplementedHardware.txt b/unimplementedHardware.txt index a7100be..0f618ff 100644 --- a/unimplementedHardware.txt +++ b/unimplementedHardware.txt @@ -32,7 +32,6 @@ port d IRQ* bits edge triggered interrupt mode is not emulated edgeTriggeredInterruptLastValue may need to be locked when PLL is off port d data register seems to have its data bits cleared when an edge triggered interrupt is cleared(according to MC68VZ328UM.pdf Page 10-15) Dont know if it possible to have the backlight on and the display off at the same time(theres no reason for it but it may be possible) -CSD and CSC chaining(the Palm m515 does this to create its 16mb RAM address space, verified with hardware test) Debug tools: missing icons @@ -43,15 +42,13 @@ Sdcard can't be inserted or removed Sdcard has no error handling in save/load state USB chip address range USB chip may be swapped in to address space with a GPIO and reconfiguring CSC chip select +EMUCS memory range is unemulated +CSD and CSC chaining to create a 16mb address space from 4x4mb chunks(the Palm m515 does this to create its 16mb RAM address space, verified with hardware test) +the second line on all the chip selects is not properly emulated, CS(ABCD)1 is missing, this halves the size of the ranges, if the ROM only uses one chip per chip select this will go unnoticed SED1376: swivelview register - -Safe Bugs: -the second line on all the chip selects is not properly emulated, CS(ABCD)1 is missing, this halves the size of the ranges, if the ROM only uses one chip per chip select this will go unnoticed(only supporting 1x16mb) -CSD and CSC may be chained to create a 16mb address space from 4x4mb chunks(only supporting 1x16mb) - Fixed: storage RAM protect(already done from fixing chip select bits, ROP bit set in CSD, verified with hardware test) interrupt control register(ICR) POL5