Moved transmission completion wait to hal_deepsleep

pull/11816/head
d-kato 2019-11-07 12:19:10 +09:00
parent 86f648d0b7
commit 4fbb87d2bb
2 changed files with 11 additions and 1 deletions

View File

@ -592,7 +592,6 @@ void serial_putc(serial_t *obj, int c) {
while (!serial_writable(obj));
obj->serial.uart->SCFTDR = c;
serial_put_done(obj);
while ((obj->serial.uart->SCFSR & 0x40) == 0); // Wait TEND = 1
}
static void serial_put_done(serial_t *obj)

View File

@ -128,6 +128,17 @@ void hal_deepsleep(void) {
wk_CPGSTBCR13 = CPGSTBCR13;
#endif
/* Waits for the serial transmission to complete */
const struct st_scif *SCIF[SCIF_COUNT] = SCIF_ADDRESS_LIST;
for (int uart = 0; uart < SCIF_COUNT; uart++) {
if ((wk_CPGSTBCR4 & (1 << (7 - uart))) == 0) { // Is the power turned on?
if ((SCIF[uart]->SCSCR & 0x00A0) == 0x00A0) { // Is transmission enabled? (TE = 1, TIE = 1)
while ((SCIF[uart]->SCFSR & 0x0040) == 0); // Waits for the transmission to complete (TEND = 1)
}
}
}
/* MTU2 (for low power ticker) */
CPGSTBCR3 |= ~(CPG_STBCR3_BIT_MSTP33);
dummy_8 = CPGSTBCR3;