aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/libboard
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-07 14:56:43 +0200
committerKévin Redon <kredon@sysmocom.de>2018-07-07 14:56:50 +0200
commitd24e9bde26230f5364fbea8fc8a5052a693b7790 (patch)
treeec5795d01b727d029ea1f687da9726593a287c69 /firmware/libboard
parent2bdaa73aff9f42b2c62e743c207af61e55d6bd4b (diff)
DFU: re-enable UART after testing forced bootloader
The qmod does not have a separate force button as simtrace has. Instead it check is TX and RX of UART are shorted using PIO. If the pins are not set back to the UART peripheral, the TRACE/debug console output will not work anymore. Change-Id: Id434b49909d6395a2f93a00f39d2d770a5725466
Diffstat (limited to 'firmware/libboard')
-rw-r--r--firmware/libboard/qmod/source/board_qmod.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/firmware/libboard/qmod/source/board_qmod.c b/firmware/libboard/qmod/source/board_qmod.c
index dd6e616..0eda1ef 100644
--- a/firmware/libboard/qmod/source/board_qmod.c
+++ b/firmware/libboard/qmod/source/board_qmod.c
@@ -261,20 +261,32 @@ static int uart_has_loopback_jumper(void)
/* Configure UART pins as I/O */
PIO_Configure(uart_loopback_pins, PIO_LISTSIZE(uart_loopback_pins));
+ /* Send pattern over UART TX and check if it is received on RX
+ * If the loop doesn't get interrupted, RxD always follows TxD and thus a
+ * loopback jumper has been placed on RxD/TxD, and we will boot
+ * into DFU unconditionally
+ */
+ int has_loopback_jumper = 1;
for (i = 0; i < 10; i++) {
/* Set TxD high; abort if RxD doesn't go high either */
PIO_Set(&uart_loopback_pins[1]);
- if (!PIO_Get(&uart_loopback_pins[0]))
- return 0;
+ if (!PIO_Get(&uart_loopback_pins[0])) {
+ has_loopback_jumper = 0;
+ break;
+ }
/* Set TxD low, abort if RxD doesn't go low either */
PIO_Clear(&uart_loopback_pins[1]);
- if (PIO_Get(&uart_loopback_pins[0]))
- return 0;
+ if (PIO_Get(&uart_loopback_pins[0])) {
+ has_loopback_jumper = 0;
+ break;
+ }
}
- /* if we reached here, RxD always follows TxD and thus a
- * loopback jumper has been placed on RxD/TxD, and we will boot
- * into DFU unconditionally */
- return 1;
+
+ /* Put pins back to UART mode */
+ const Pin uart_pins[] = {PINS_UART};
+ PIO_Configure(uart_pins, PIO_LISTSIZE(uart_pins));
+
+ return has_loopback_jumper;
}
int board_override_enter_dfu(void)