aboutsummaryrefslogtreecommitdiff
path: root/libpsn00b/psxsio
diff options
context:
space:
mode:
Diffstat (limited to 'libpsn00b/psxsio')
-rw-r--r--libpsn00b/psxsio/sio.c40
-rw-r--r--libpsn00b/psxsio/tty.c4
2 files changed, 22 insertions, 22 deletions
diff --git a/libpsn00b/psxsio/sio.c b/libpsn00b/psxsio/sio.c
index cdcef0e..919f0cb 100644
--- a/libpsn00b/psxsio/sio.c
+++ b/libpsn00b/psxsio/sio.c
@@ -36,8 +36,8 @@ static volatile RingBuffer _tx_buffer, _rx_buffer;
static void _sio_handler(void) {
// Handle any incoming bytes.
- while (SIO_STAT & SR_RXRDY) {
- uint8_t value = SIO_TXRX;
+ while (SIO_STAT(1) & SR_RXRDY) {
+ uint8_t value = SIO_DATA(1);
// Skip storing this byte into the RX buffer if the callback returns a
// non-zero value.
@@ -63,7 +63,7 @@ static void _sio_handler(void) {
// Send the next byte in the buffer if the TX unit is ready. Note that
// checking for CTS is unnecessary as the serial port is already hardwired
// to do so.
- if (SIO_STAT & (SR_TXRDY | SR_TXU)) {
+ if (SIO_STAT(1) & (SR_TXRDY | SR_TXU)) {
int length = _tx_buffer.length;
if (length) {
@@ -71,18 +71,18 @@ static void _sio_handler(void) {
_tx_buffer.head = (head + 1) % BUFFER_LENGTH;
_tx_buffer.length = length - 1;
- SIO_CTRL |= CR_TXIEN;
- SIO_TXRX = _tx_buffer.data[head];
+ SIO_CTRL(1) |= CR_TXIEN;
+ SIO_DATA(1) = _tx_buffer.data[head];
} else {
- SIO_CTRL &= CR_TXIEN ^ 0xffff;
+ SIO_CTRL(1) &= CR_TXIEN ^ 0xffff;
}
}
// Acknowledge the IRQ and update flow control signals.
if (_rx_buffer.length < BUFFER_LENGTH)
- SIO_CTRL = CR_INTRST | (SIO_CTRL | _ctrl_reg_flag);
+ SIO_CTRL(1) = CR_INTRST | (SIO_CTRL(1) | _ctrl_reg_flag);
else
- SIO_CTRL = CR_INTRST | (SIO_CTRL & (_ctrl_reg_flag ^ 0xffff));
+ SIO_CTRL(1) = CR_INTRST | (SIO_CTRL(1) & (_ctrl_reg_flag ^ 0xffff));
}
/* Serial port initialization API */
@@ -91,10 +91,10 @@ void SIO_Init(int baud, uint16_t mode) {
EnterCriticalSection();
_old_sio_handler = InterruptCallback(IRQ_SIO1, &_sio_handler);
- SIO_CTRL = CR_ERRRST;
- SIO_MODE = (mode & 0xfffc) | MR_BR_16;
- SIO_BAUD = (uint16_t) ((int) 0x1fa400 / baud);
- SIO_CTRL = CR_TXEN | CR_RXEN | CR_RXIEN;
+ SIO_CTRL(1) = CR_ERRRST;
+ SIO_MODE(1) = (mode & 0xfffc) | MR_BR_16;
+ SIO_BAUD(1) = (uint16_t) ((int) 0x1fa400 / baud);
+ SIO_CTRL(1) = CR_TXEN | CR_RXEN | CR_RXIEN;
_tx_buffer.head = 0;
_tx_buffer.tail = 0;
@@ -113,7 +113,7 @@ void SIO_Quit(void) {
EnterCriticalSection();
InterruptCallback(IRQ_SIO1, _old_sio_handler);
- SIO_CTRL = CR_ERRRST;
+ SIO_CTRL(1) = CR_ERRRST;
ExitCriticalSection();
}
@@ -126,21 +126,21 @@ void SIO_SetFlowControl(SIO_FlowControl mode) {
_flow_control = SIO_FC_NONE;
_ctrl_reg_flag = 0;
- SIO_CTRL &= 0xffff ^ CR_DSRIEN;
+ SIO_CTRL(1) &= 0xffff ^ CR_DSRIEN;
break;
case SIO_FC_RTS_CTS:
_flow_control = SIO_FC_RTS_CTS;
_ctrl_reg_flag = CR_RTS;
- SIO_CTRL &= 0xffff ^ CR_DSRIEN;
+ SIO_CTRL(1) &= 0xffff ^ CR_DSRIEN;
break;
/*case SIO_FC_DTR_DSR:
_flow_control = SIO_FC_DTR_DSR;
_ctrl_reg_flag = CR_DTR;
- SIO_CTRL |= CR_DSRIEN;
+ SIO_CTRL(1) |= CR_DSRIEN;
break;*/
}
@@ -218,8 +218,8 @@ int SIO_WriteByte2(uint8_t value) {
// than via syscalls for performance reasons.
FastEnterCriticalSection();
- if (SIO_STAT & (SR_TXRDY | SR_TXU)) {
- SIO_TXRX = value;
+ if (SIO_STAT(1) & (SR_TXRDY | SR_TXU)) {
+ SIO_DATA(1) = value;
FastExitCriticalSection();
return 0;
}
@@ -238,7 +238,7 @@ int SIO_WriteByte2(uint8_t value) {
_tx_buffer.length = length + 1;
_tx_buffer.data[tail] = value;
- SIO_CTRL |= CR_TXIEN;
+ SIO_CTRL(1) |= CR_TXIEN;
FastExitCriticalSection();
return length;
@@ -256,7 +256,7 @@ int SIO_WriteSync(int mode) {
if (!_tx_buffer.length) {
// Wait for the TX unit to finish sending the last byte.
- while (!(SIO_STAT & (SR_TXRDY | SR_TXU)))
+ while (!(SIO_STAT(1) & (SR_TXRDY | SR_TXU)))
__asm__ volatile("");
} else {
//_sdk_log("SIO_WriteSync() timeout\n");
diff --git a/libpsn00b/psxsio/tty.c b/libpsn00b/psxsio/tty.c
index 4dc9fd1..a1b33c8 100644
--- a/libpsn00b/psxsio/tty.c
+++ b/libpsn00b/psxsio/tty.c
@@ -32,10 +32,10 @@ static int _sio_inout(FCB *fcb, int cmd) {
case 2: // write
for (int i = 0; i < fcb->trns_len; i++) {
- while (!(SIO_STAT & (SR_TXRDY | SR_TXU)))
+ while (!(SIO_STAT(1) & (SR_TXRDY | SR_TXU)))
__asm__ volatile("");
- SIO_TXRX = *(ptr++);
+ SIO_DATA(1) = *(ptr++);
}
return fcb->trns_len;