Add TSC2101 protocol handler

This commit is contained in:
meepingsnesroms
2019-08-13 17:39:57 -07:00
parent 8de283a87d
commit d4b9997d43
7 changed files with 163 additions and 70 deletions

View File

@@ -7,6 +7,7 @@
#include <QDir>
#include <stdint.h>
#include <stdio.h>
#include "mainwindow.h"
#include "emuwrapper.h"
@@ -108,7 +109,7 @@ void DebugViewer::on_debug32Bit_clicked(){
debugRadioButtonHandler();
}
void DebugViewer::on_debugDump_clicked(){
void DebugViewer::on_debugDumpToFile_clicked(){
QString fileBuffer;
QFile fileOut(((MainWindow*)parentWidget())->settings->value("resourceDirectory", "").toString() + "/debugDumps/" + ui->debugFilePath->text());
@@ -124,6 +125,12 @@ void DebugViewer::on_debugDump_clicked(){
}
}
void DebugViewer::on_debugDumpToTerminal_clicked(){
for(int index = 0; index < ui->debugValueList->count(); index++)
printf("%s\n", ui->debugValueList->item(index)->text().toStdString().c_str());
fflush(stdout);
}
void DebugViewer::on_debugShowRegisters_clicked(){
EmuWrapper& emu = ((MainWindow*)parentWidget())->emu;

View File

@@ -28,7 +28,8 @@ private slots:
void on_debug16Bit_clicked();
void on_debug32Bit_clicked();
void on_debugDump_clicked();
void on_debugDumpToFile_clicked();
void on_debugDumpToTerminal_clicked();
void on_debugShowRegisters_clicked();
void on_debugShowDebugLogs_clicked();
void on_debugEraseDebugLogs_clicked();

View File

@@ -45,6 +45,16 @@
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1">
<widget class="QRadioButton" name="debug8Bit">
<property name="text">
<string>8bit</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="11">
<widget class="QListWidget" name="debugValueList"/>
</item>
<item row="2" column="2">
<widget class="QRadioButton" name="debug16Bit">
<property name="text">
@@ -52,6 +62,34 @@
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLineEdit" name="debugFilePath">
<property name="placeholderText">
<string>File Path</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="debugAddress">
<property name="placeholderText">
<string>Address</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLineEdit" name="debugLength">
<property name="placeholderText">
<string>Length</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QRadioButton" name="debug32Bit">
<property name="text">
<string>32bit</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3">
<widget class="QPushButton" name="debugGetHexValues">
<property name="text">
@@ -62,26 +100,6 @@
</property>
</widget>
</item>
<item row="0" column="0" rowspan="10">
<widget class="QListWidget" name="debugValueList"/>
</item>
<item row="2" column="3">
<widget class="QRadioButton" name="debug32Bit">
<property name="text">
<string>32bit</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="3">
<widget class="QPushButton" name="debugDump">
<property name="text">
<string>Dump To File</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="6" column="1" colspan="3">
<widget class="QPushButton" name="debugShowRegisters">
<property name="text">
@@ -89,37 +107,6 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QLineEdit" name="debugLength">
<property name="placeholderText">
<string>Length</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="debug8Bit">
<property name="text">
<string>8bit</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="3">
<widget class="QPushButton" name="debugEraseDebugLogs">
<property name="text">
<string>Erase Debug Logs</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="1" colspan="3">
<widget class="QLineEdit" name="debugFilePath">
<property name="placeholderText">
<string>File Path</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QPushButton" name="debugShowDebugLogs">
<property name="text">
@@ -130,10 +117,33 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QLineEdit" name="debugAddress">
<property name="placeholderText">
<string>Address</string>
<item row="9" column="1" colspan="3">
<widget class="QPushButton" name="debugDumpToFile">
<property name="text">
<string>Dump To File</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="8" column="1" colspan="3">
<widget class="QPushButton" name="debugEraseDebugLogs">
<property name="text">
<string>Erase Debug Logs</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="10" column="1" colspan="3">
<widget class="QPushButton" name="debugDumpToTerminal">
<property name="text">
<string>Dump To Terminal</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>

View File

@@ -140,8 +140,6 @@ uint32_t pxa260SspReadWord(uint32_t address){
uint8_t tfl = pxa260SspTxFifoEntrys();
uint16_t value = 0x0000;
debugLog("Unimplimented PXA260 SSP SSSR read\n");
if(rfl == 0)
rfl = 0xF;
else

View File

@@ -90,15 +90,13 @@ uint8_t tps65010I2cExchange(uint8_t i2cBus){
}
tps65010CurrentI2cByte |= (i2cBus == I2C_1);
if(tps65010CurrentI2cByteBitsRemaining > 0){
if(tps65010State == I2C_SENDING){
if(tps65010SelectedRegister < 0x11)
newI2cBus = (tps65010Registers[tps65010SelectedRegister] && 1 << (tps65010CurrentI2cByteBitsRemaining - 1)) ? I2C_1 : I2C_0;
else
newI2cBus = 0x00;
}
tps65010CurrentI2cByteBitsRemaining--;
if(tps65010State == I2C_SENDING){
if(tps65010SelectedRegister < 0x11)
newI2cBus = (tps65010Registers[tps65010SelectedRegister] && 1 << (tps65010CurrentI2cByteBitsRemaining - 1)) ? I2C_1 : I2C_0;
else
newI2cBus = I2C_0;
}
tps65010CurrentI2cByteBitsRemaining--;
if(tps65010CurrentI2cByteBitsRemaining == 0){
//process data from byte

View File

@@ -4,8 +4,29 @@
#include "emulator.h"
void tsc2101Reset(void){
uint16_t tsc2101CurrentWord;
uint8_t tsc2101CurrentWordBitsRemaining;
uint8_t tsc2101CurrentPage;
uint8_t tsc2101CurrentRegister;
bool tsc2101CommandFinished;
bool tsc2101Read;
static uint16_t tsc2101RegisterRead(uint8_t page, uint8_t address){
debugLog("Unimplemented TSC2101 register read, page:0x%01X, address:0x%02X\n", page, address);
}
static void tsc2101RegisterWrite(uint8_t page, uint8_t address, uint16_t value){
debugLog("Unimplemented TSC2101 register write, page:0x%01X, address:0x%02X, value:0x%04X\n", page, address, value);
}
void tsc2101Reset(void){
tsc2101CurrentWord = 0x0000;
tsc2101CurrentWordBitsRemaining = 16;
tsc2101CurrentPage = 0;
tsc2101CurrentRegister = 0;
tsc2101CommandFinished = false;
tsc2101Read = false;
}
uint32_t tsc2101StateSize(void){
@@ -20,6 +41,56 @@ void tsc2101LoadState(uint8_t* data){
}
bool tsc2101ExchangeBit(bool bit){
debugLog("Unimplemented TSC2101 transfer:%d\n", bit);
void tsc2101SetChipSelect(bool value){
tsc2101CurrentWordBitsRemaining = 16;
tsc2101Read = false;
}
bool tsc2101ExchangeBit(bool bit){
bool output = true;//TODO: SPI return value is usualy true but this is unverified
if(!tsc2101Read){
tsc2101CurrentWord <<= 1;
tsc2101CurrentWord |= bit;
}
else{
output = !!(tsc2101CurrentWord & 0x8000);
tsc2101CurrentWord <<= 1;
}
tsc2101CurrentWordBitsRemaining--;
if(tsc2101CurrentWordBitsRemaining == 0){
if(!tsc2101CommandFinished){
//write command word
tsc2101CurrentPage = tsc2101CurrentWord >> 11 & 0x000F;
tsc2101CurrentRegister = tsc2101CurrentWord >> 5 & 0x003F;
tsc2101Read = !!(tsc2101CurrentWord & 0x8000);
if(tsc2101Read){
//add first data word
tsc2101CurrentWord = tsc2101RegisterRead(tsc2101CurrentPage, tsc2101CurrentRegister);
tsc2101CurrentRegister++;
}
}
else if(!tsc2101Read){
//write data word
if(tsc2101CurrentRegister < 0x40){
tsc2101RegisterWrite(tsc2101CurrentPage, tsc2101CurrentRegister, tsc2101CurrentWord);
tsc2101CurrentRegister++;
}
}
else{
//read data word
if(tsc2101CurrentRegister < 0x40){
tsc2101CurrentWord = tsc2101RegisterRead(tsc2101CurrentPage, tsc2101CurrentRegister);
tsc2101CurrentRegister++;
}
else{
tsc2101CurrentWord = 0xFFFF;
}
}
tsc2101CurrentWordBitsRemaining = 16;
}
return output;
}

View File

@@ -4,11 +4,19 @@
#include <stdint.h>
#include <stdbool.h>
extern uint16_t tsc2101CurrentWord;
extern uint8_t tsc2101CurrentWordBitsRemaining;
extern uint8_t tsc2101CurrentPage;
extern uint8_t tsc2101CurrentRegister;
extern bool tsc2101CommandFinished;
extern bool tsc2101Read;
void tsc2101Reset(void);
uint32_t tsc2101StateSize(void);
void tsc2101SaveState(uint8_t* data);
void tsc2101LoadState(uint8_t* data);
void tsc2101SetChipSelect(bool value);
bool tsc2101ExchangeBit(bool bit);
#endif