Add more tsc2101 stuff

This commit is contained in:
meepingsnesroms
2019-08-15 13:40:34 -07:00
parent d4b9997d43
commit 136cdca5d7
5 changed files with 74 additions and 22 deletions

View File

@@ -55,6 +55,7 @@ Other:
Qt port dosent support Windows touchscreen input
memory dumping dosent work for OS 5 yet
T3 I2C currently has no ACK bits(should work without them its just inaccurate)
remove specs folder, make the headers belong to the main file of the target chip being emulated
Fixed:
UART1 USTCNT1

View File

@@ -21,7 +21,7 @@
//The LCD power-on sequence is activated by programming the Power Save Mode Enable bit (REG[A0h] bit 0) to 0.
//The LCD power-off sequence is activated by programming the Power Save Mode Enable bit (REG[A0h] bit 0) to 1.
//TODO: remove size declarations and append file namespace to all vars and functions
#define SED1376_REG_SIZE 0xB4
#define SED1376_LUT_SIZE 0x100
#define SED1376_RAM_SIZE 0x20000//actual size is 0x14000, but that cant be masked off by address lines so size is increased to prevent buffer overflow

View File

@@ -44,18 +44,18 @@ static void tps65010WriteRegister(uint8_t address, uint8_t value){
void tps65010Reset(void){
memset(tps65010Registers, 0x00, sizeof(tps65010Registers));
tps65010CurrentI2cByte = 0x00;
tps65010CurrentI2cByteBitsRemaining = 8;
tps65010SelectedRegister = 0x00;
tps65010State = I2C_WAIT_FOR_ADDR;
tps65010SelectedRegisterAlreadySet = false;
tps65010Registers[MASK1] = 0xFF;
tps65010Registers[MASK2] = 0xFF;
tps65010Registers[CHGCONFIG] = 0x1B;
tps65010Registers[VDCDC1] = 0x72;//TODO: 0x7(2/3) need to check DEFMAIN pin
tps65010Registers[VDCDC2] = 0x68;//TODO: 0x(6/7)8 need to check DEFCORE pin
tps65010Registers[VREGS1] = 0x88;
tps65010CurrentI2cByte = 0x00;
tps65010CurrentI2cByteBitsRemaining = 8;
tps65010SelectedRegister = 0x00;
tps65010State = I2C_WAIT_FOR_ADDR;
tps65010SelectedRegisterAlreadySet = false;
}
uint32_t tps65010StateSize(void){

View File

@@ -1,32 +1,89 @@
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "emulator.h"
uint16_t tsc2101CurrentWord;
uint8_t tsc2101CurrentWordBitsRemaining;
uint8_t tsc2101CurrentPage;
uint8_t tsc2101CurrentRegister;
bool tsc2101CommandFinished;
bool tsc2101Read;
#define TSC2101_REG_LOCATION(page, address) ((page) << 6 | (address))
enum{
TOUCH_DATA_X = TSC2101_REG_LOCATION(0, 0x00),
TOUCH_DATA_Y,
TOUCH_DATA_Z1,
TOUCH_DATA_Z2,
TOUCH_DATA_RESERVED_0,
TOUCH_DATA_BAT,
TOUCH_DATA_RESERVED_1,
TOUCH_DATA_AUX1,
TOUCH_DATA_AUX2,
TOUCH_DATA_TEMP1,
TOUCH_DATA_TEMP2,
//TOUCH_DATA_RESERVED_X...
TOUCH_CONTROL_TSC_ADC = TSC2101_REG_LOCATION(1, 0x00),
TOUCH_CONTROL_STATUS,
TOUCH_CONTROL_BUFFER_MODE,
TOUCH_CONTROL_REFERENCE,
TOUCH_CONTROL_RESET_CONTROL_REGISTER,
TOUCH_CONTROL_CONFIGURATION,
TOUCH_CONTROL_TEMPERATURE_MAX,
TOUCH_CONTROL_TEMPERATURE_MIN,
TOUCH_CONTROL_AUX1_MAX,
TOUCH_CONTROL_AUX1_MIN,
TOUCH_CONTROL_AUX2_MAX,
TOUCH_CONTROL_AUX2_MIN,
TOUCH_CONTROL_MEASUREMENT_CONFIGURATION,
TOUCH_CONTROL_PROGRAMMABLE_DELAY
//TOUCH_CONTROL_RESERVED_X...
//TODO: add audio control registers
};
static uint16_t tsc2101Registers[0xFF];
static uint16_t tsc2101CurrentWord;
static uint8_t tsc2101CurrentWordBitsRemaining;
static uint8_t tsc2101CurrentPage;
static uint8_t tsc2101CurrentRegister;
static bool tsc2101CommandFinished;
static 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);
uint8_t combinedRegisterNumber = TSC2101_REG_LOCATION(page, address);
switch(combinedRegisterNumber){
case TOUCH_CONTROL_STATUS:
//simple read, no actions needed
return tsc2101Registers[combinedRegisterNumber];
default:
debugLog("Unimplemented TSC2101 register read, page:0x%01X, address:0x%02X\n", page, address);
return 0x0000;//TODO: this may need to be 0xFFFF
}
}
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);
uint8_t combinedRegisterNumber = TSC2101_REG_LOCATION(page, address);
switch(combinedRegisterNumber){
default:
debugLog("Unimplemented TSC2101 register write, page:0x%01X, address:0x%02X, value:0x%04X\n", page, address, value);
return;
}
}
void tsc2101Reset(void){
memset(tsc2101Registers, 0x00, sizeof(tsc2101Registers));
tsc2101CurrentWord = 0x0000;
tsc2101CurrentWordBitsRemaining = 16;
tsc2101CurrentPage = 0;
tsc2101CurrentRegister = 0;
tsc2101CommandFinished = false;
tsc2101Read = false;
//TODO: need to add all the registers here
tsc2101Registers[TOUCH_CONTROL_STATUS] = 0x8000;
}
uint32_t tsc2101StateSize(void){

View File

@@ -4,13 +4,6 @@
#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);
@@ -18,5 +11,6 @@ void tsc2101LoadState(uint8_t* data);
void tsc2101SetChipSelect(bool value);
bool tsc2101ExchangeBit(bool bit);
//TODO: this chip seems to do audio output, need to add a 16bit optimized transfer function
#endif