apply oldPRCR to board_init()

This commit is contained in:
hathach
2024-04-09 17:05:25 +07:00
parent bd67fdf011
commit 2828a56a4f
3 changed files with 17 additions and 15 deletions

View File

@@ -249,9 +249,10 @@ void board_init(void)
EN(SCI5, TEI5) = 1;
/* Enable USB0 */
unsigned short oldPRCR = SYSTEM.PRCR.WORD;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | SYSTEM_PRCR_PRC1;
MSTP(USB0) = 0;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY;
SYSTEM.PRCR.WORD = SYSTEM_PRCR_PRKEY | oldPRCR;
/* setup USBI0 interrupt. */
IR(USB0, USBI0) = 0;
@@ -277,6 +278,7 @@ int board_uart_read(uint8_t* buf, int len)
sci_buf[1].buf = buf;
sci_buf[1].cnt = len;
SCI5.SCR.BYTE |= SCI_SCR_RE | SCI_SCR_RIE;
// TODO change to non blocking, return -1 immediately if no data
while (SCI5.SCR.BIT.RE) ;
return len - sci_buf[1].cnt;
}