refactor constants

This commit is contained in:
Peli de Halleux 2019-10-13 09:32:43 -07:00
parent ccf6164d87
commit 20be398c2c

View File

@ -540,8 +540,6 @@ void cUiUpdatePower(void)
function uartClearChange(port: number) { function uartClearChange(port: number) {
control.dmesg(`UART clear change`); control.dmesg(`UART clear change`);
const UART_DATA_READY = 8
const UART_PORT_CHANGED = 1
while (true) { while (true) {
let status = getUartStatus(port) let status = getUartStatus(port)
if (port < 0) break if (port < 0) break
@ -575,6 +573,8 @@ void cUiUpdatePower(void)
const port = ports.pop(); const port = ports.pop();
const status = waitNonZeroUartStatus(port) const status = waitNonZeroUartStatus(port)
control.dmesg(`UART status ${status} at ${port}`); control.dmesg(`UART status ${status} at ${port}`);
if (!(status & UART_DATA_READY))
setUartMode(port, devcon[DevConOff.Mode + port]);
} }
} }
@ -585,8 +585,9 @@ void cUiUpdatePower(void)
devcon.setNumber(NumberFormat.Int8LE, DevConOff.Mode + port, mode) devcon.setNumber(NumberFormat.Int8LE, DevConOff.Mode + port, mode)
} }
const UART_PORT_CHANGED = 1
const UART_DATA_READY = 8
function setUartMode(port: number, mode: number) { function setUartMode(port: number, mode: number) {
const UART_PORT_CHANGED = 1
while (true) { while (true) {
if (port < 0) return if (port < 0) return
updateUartMode(port, mode); updateUartMode(port, mode);
@ -598,7 +599,8 @@ void cUiUpdatePower(void)
uartClearChange(port) uartClearChange(port)
} else { } else {
control.dmesg(`UART status ${status}`); control.dmesg(`UART status ${status}`);
break; if (status & UART_DATA_READY)
break;
} }
pause(10) pause(10)
} }