mirror of
https://github.com/libretro/Mu.git
synced 2026-09-23 07:05:37 +00:00
Clean ups prepare for ADS7846 read test
This commit is contained in:
@@ -189,3 +189,39 @@ var tstat1GetSemaphoreLockOrder(){
|
||||
|
||||
return makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
}
|
||||
|
||||
var ads7846Read(){
|
||||
static Boolean firstRun = true;
|
||||
uint16_t testWriteValue = 0xF0F1;
|
||||
uint32_t y = 0;
|
||||
|
||||
if(firstRun){
|
||||
firstRun = false;
|
||||
debugSafeScreenClear(C_WHITE);
|
||||
}
|
||||
|
||||
StrPrintF(sharedDataBuffer, "TSTAT1:0x%02X", readArbitraryMemory16(HW_REG_ADDR(TSTAT1)));
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
writeArbitraryMemory16(HW_REG_ADDR(TSTAT1), testWriteValue);
|
||||
StrPrintF(sharedDataBuffer, "Write TSTAT1:0x%02X", testWriteValue);
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "New TSTAT1:0x%02X", readArbitraryMemory16(HW_REG_ADDR(TSTAT1)));
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
writeArbitraryMemory16(HW_REG_ADDR(TSTAT1), 0xFFFF);
|
||||
StrPrintF(sharedDataBuffer, "Clear Semaphore");
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
StrPrintF(sharedDataBuffer, "New TSTAT1:0x%02X", readArbitraryMemory16(HW_REG_ADDR(TSTAT1)));
|
||||
UG_PutString(0, y, sharedDataBuffer);
|
||||
y += FONT_HEIGHT + 1;
|
||||
|
||||
if(getButtonPressed(buttonBack)){
|
||||
firstRun = true;
|
||||
exitSubprogram();
|
||||
}
|
||||
|
||||
return makeVar(LENGTH_0, TYPE_NULL, 0);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,6 @@ var testButtonInput();
|
||||
var listDataRegisters();
|
||||
var interrogateSpi2();
|
||||
var tstat1GetSemaphoreLockOrder();
|
||||
var ads7846Read();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,44 @@ Err makeFile(uint8_t* data, uint32_t size, char* fileName){
|
||||
return error;
|
||||
}
|
||||
|
||||
uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bit){
|
||||
uint16_t spi2Control = readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0xE230;
|
||||
uint8_t config = 0x80;
|
||||
uint16_t value;
|
||||
|
||||
if(mode8bit)
|
||||
config |= 0x08;
|
||||
|
||||
if(referenceMode)
|
||||
config |= 0x04;
|
||||
|
||||
config |= channel << 4 & 0x70;
|
||||
|
||||
/*wait until SPI2 is free*/
|
||||
while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100);
|
||||
|
||||
/*set data to send*/
|
||||
writeArbitraryMemory16(HW_REG_ADDR(SPIDATA2), config << 8);
|
||||
|
||||
/*enable SPI 2 if disabled*/
|
||||
if(!(spi2Control & 0x0200))
|
||||
writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0200);
|
||||
|
||||
/*send data*/
|
||||
writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | 0x0007);
|
||||
while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100);
|
||||
|
||||
/*receive data, mode = 1(8 bits) or mode = 0(12 bits)*/
|
||||
writeArbitraryMemory16(HW_REG_ADDR(SPICONT2), spi2Control | (mode8bit ? 0x0007 : 0x000B));
|
||||
while(readArbitraryMemory16(HW_REG_ADDR(SPICONT2)) & 0x0100);
|
||||
|
||||
value = readArbitraryMemory16(HW_REG_ADDR(SPIDATA2));
|
||||
|
||||
/*may need to alter value some*/
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
var hexRamBrowser(){
|
||||
static Boolean firstRun = true;
|
||||
static uint32_t nibble;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "testSuite.h"
|
||||
|
||||
Err makeFile(uint8_t* data, uint32_t size, char* fileName);
|
||||
uint16_t ads7846GetValue(uint8_t channel, Boolean referenceMode, Boolean mode8bit);
|
||||
var hexRamBrowser();
|
||||
var getTrapAddress();
|
||||
var manualLssa();
|
||||
|
||||
@@ -294,6 +294,10 @@ void resetFunctionViewer(){
|
||||
StrNCopy(hwTests[totalHwTests].name, "TSTAT1 Semaphore Info", TEST_NAME_LENGTH);
|
||||
hwTests[totalHwTests].testFunction = tstat1GetSemaphoreLockOrder;
|
||||
totalHwTests++;
|
||||
|
||||
StrNCopy(hwTests[totalHwTests].name, "ADS7846 Read", TEST_NAME_LENGTH);
|
||||
hwTests[totalHwTests].testFunction = ads7846Read;
|
||||
totalHwTests++;
|
||||
}
|
||||
|
||||
StrNCopy(hwTests[totalHwTests].name, "Button Test", TEST_NAME_LENGTH);
|
||||
|
||||
@@ -42,14 +42,16 @@ void ads7846SendBit(bool bit){
|
||||
|
||||
case 0x10:
|
||||
//touchscreen y
|
||||
value = palmInput.touchscreenY;
|
||||
if(palmInput.touchscreenTouched)
|
||||
value = palmInput.touchscreenY;
|
||||
else
|
||||
value = 0;
|
||||
rangeMax = 160;
|
||||
break;
|
||||
|
||||
case 0x20:
|
||||
//battery
|
||||
//value = palmMisc.batteryLevel;
|
||||
value = 100;
|
||||
value = palmMisc.batteryLevel;
|
||||
rangeMax = 100;
|
||||
break;
|
||||
|
||||
@@ -62,7 +64,10 @@ void ads7846SendBit(bool bit){
|
||||
|
||||
case 0x50:
|
||||
//touchscreen x
|
||||
value = palmInput.touchscreenX;
|
||||
if(palmInput.touchscreenTouched)
|
||||
value = palmInput.touchscreenX;
|
||||
else
|
||||
value = 0;
|
||||
rangeMax = 160;
|
||||
break;
|
||||
|
||||
|
||||
@@ -301,7 +301,7 @@ void emulatorReset(){
|
||||
m68k_pulse_reset();
|
||||
}
|
||||
|
||||
void emulatorSetRtc(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds){
|
||||
void emulatorSetRtc(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t seconds){
|
||||
setRtc(days, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ extern void (*emulatorSetSdCardChunk)(uint64_t sessionId, uint64_t chunkId, buff
|
||||
uint32_t emulatorInit(buffer_t palmRomDump, buffer_t palmBootDump, uint32_t specialFeatures);//calling any emulator functions before emulatorInit results in undefined behavior
|
||||
void emulatorExit();
|
||||
void emulatorReset();
|
||||
void emulatorSetRtc(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
|
||||
void emulatorSetRtc(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t seconds);
|
||||
uint32_t emulatorSetNewSdCard(uint64_t size, uint8_t type);
|
||||
buffer_t emulatorGetSdCardImage();//doing anything with the emulator will alter this, do not free it, it is a direct pointer to the sdcard data
|
||||
uint32_t emulatorSetSdCardFromImage(buffer_t image, uint8_t type);
|
||||
|
||||
@@ -1070,11 +1070,11 @@ void resetHwRegisters(){
|
||||
recalculateCpuSpeed();
|
||||
}
|
||||
|
||||
void setRtc(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds){
|
||||
void setRtc(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t seconds){
|
||||
uint32_t rtcTime;
|
||||
rtcTime = seconds & 0x0000003F;
|
||||
rtcTime |= (minutes << 16) & 0x003F0000;
|
||||
rtcTime |= (hours << 24) & 0x1F000000;
|
||||
rtcTime |= minutes << 16 & 0x003F0000;
|
||||
rtcTime |= hours << 24 & 0x1F000000;
|
||||
registerArrayWrite32(RTCTIME, rtcTime);
|
||||
registerArrayWrite16(DAYR, days & 0x01FF);
|
||||
}
|
||||
|
||||
@@ -91,4 +91,4 @@ void setWriteProtectViolation();
|
||||
|
||||
//config
|
||||
void resetHwRegisters();
|
||||
void setRtc(uint32_t days, uint32_t hours, uint32_t minutes, uint32_t seconds);
|
||||
void setRtc(uint16_t days, uint8_t hours, uint8_t minutes, uint8_t seconds);
|
||||
|
||||
@@ -29,7 +29,7 @@ static inline int64_t sMax(int64_t x, int64_t y){
|
||||
|
||||
static inline uint64_t getUint64FromDouble(double data){
|
||||
//32.32 fixed point
|
||||
uint64_t fixedPointDouble = ((uint64_t)data) << 32;
|
||||
uint64_t fixedPointDouble = (uint64_t)data << 32;
|
||||
data -= (uint64_t)data;
|
||||
data *= 100000000.0;
|
||||
fixedPointDouble |= (uint64_t)data;
|
||||
|
||||
Reference in New Issue
Block a user