Skip to content

Commit eb9b6fd

Browse files
d-katoadbridge
authored andcommitted
Moved transmission completion wait to hal_deepsleep
1 parent b5ccf51 commit eb9b6fd

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

targets/TARGET_RENESAS/TARGET_RZ_A1XX/serial_api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ void serial_putc(serial_t *obj, int c) {
592592
while (!serial_writable(obj));
593593
obj->serial.uart->SCFTDR = c;
594594
serial_put_done(obj);
595-
while ((obj->serial.uart->SCFSR & 0x40) == 0); // Wait TEND = 1
596595
}
597596

598597
static void serial_put_done(serial_t *obj)

targets/TARGET_RENESAS/TARGET_RZ_A1XX/sleep.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ void hal_deepsleep(void) {
128128
wk_CPGSTBCR13 = CPGSTBCR13;
129129
#endif
130130

131+
/* Waits for the serial transmission to complete */
132+
const struct st_scif *SCIF[SCIF_COUNT] = SCIF_ADDRESS_LIST;
133+
134+
for (int uart = 0; uart < SCIF_COUNT; uart++) {
135+
if ((wk_CPGSTBCR4 & (1 << (7 - uart))) == 0) { // Is the power turned on?
136+
if ((SCIF[uart]->SCSCR & 0x00A0) == 0x00A0) { // Is transmission enabled? (TE = 1, TIE = 1)
137+
while ((SCIF[uart]->SCFSR & 0x0040) == 0); // Waits for the transmission to complete (TEND = 1)
138+
}
139+
}
140+
}
141+
131142
/* MTU2 (for low power ticker) */
132143
CPGSTBCR3 |= ~(CPG_STBCR3_BIT_MSTP33);
133144
dummy_8 = CPGSTBCR3;

0 commit comments

Comments
 (0)