More UART stuff

This commit is contained in:
meepingsnesroms
2019-06-20 20:44:50 -07:00
parent d67b44130a
commit e70d84fac4
2 changed files with 35 additions and 11 deletions

View File

@@ -42,6 +42,15 @@ static uint8_t uart1RxWritePosition;
static bool uart1RxOverflowed;//this var may not be needed
static uint8_t uart1TxReadPosition;
static uint8_t uart1TxWritePosition;
/*
static uint16_t uart2RxFifo[65];
static uint16_t uart2TxFifo[65];
static uint8_t uart2RxReadPosition;
static uint8_t uart2RxWritePosition;
static bool uart2RxOverflowed;//this var may not be needed
static uint8_t uart2TxReadPosition;
static uint8_t uart2TxWritePosition;
*/
static int32_t pwm1ClocksToNextSample;
static uint8_t pwm1Fifo[6];
static uint8_t pwm1ReadPosition;
@@ -444,6 +453,16 @@ uint16_t dbvzGetRegister16(uint32_t address){
return fifoVal;
}
case UTX1:{
uint16_t uart1TxStatus = registerArrayRead16(UTX1);
uart1TxStatus |= (uart1TxFifoEntrys() == 0) << 15;
uart1TxStatus |= (uart1TxFifoEntrys() < 4) << 14;
uart1TxStatus |= (uart1TxFifoEntrys() < 8) << 13;
return uart1TxStatus;
}
case PLLFSR:
return registerArrayRead16(PLLFSR);
@@ -546,6 +565,15 @@ void dbvzSetRegister8(uint32_t address, uint8_t value){
setScr(value);
return;
case UTX1 + 1:
//this is a 16 bit register but Palm OS writes to the 8 bit FIFO section alone
//send byte and update interrupts if enabled
if((registerArrayRead16(USTCNT1) & 0xA000) == 0xA000){
uart1RxFifoWrite(value);
updateUart1Interrupt();
}
return;
case PWMS1 + 1:
//write only if PWM1 enabled
if(registerArrayRead16(PWMC1) & 0x0010)
@@ -957,7 +985,13 @@ void dbvzSetRegister16(uint32_t address, uint16_t value){
return;
case UTX1:
setUtx1(value);
registerArrayWrite16(UTX1, value & 0x1F00);
//send byte and update interrupts if enabled
if((registerArrayRead16(USTCNT1) & 0xA000) == 0xA000){
uart1RxFifoWrite(value & 0x1000 ? value & 0xFF : EMU_SERIAL_BREAK);
updateUart1Interrupt();
}
return;
case PWMC1:

View File

@@ -593,16 +593,6 @@ static void setUstcnt1(uint16_t value){
updateUart1Interrupt();
}
static void setUtx1(uint16_t value){
registerArrayWrite16(UTX1, value & 0x1F00);
//send byte and update interrupts if enabled
if((value & 0xA000) == 0xA000){
updateUart1Interrupt();
uart1RxFifoWrite(value & 0x1000 ? value & 0xFF : EMU_SERIAL_BREAK);
}
}
static void setTstat1(uint16_t value){
uint16_t oldTstat1 = registerArrayRead16(TSTAT1);
uint16_t newTstat1 = (value & timerStatusReadAcknowledge[0]) | (oldTstat1 & ~timerStatusReadAcknowledge[0]);