aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorKévin Redon <kredon@sysmocom.de>2018-07-07 14:41:11 +0200
committerKévin Redon <kredon@sysmocom.de>2018-07-07 14:43:50 +0200
commitd44cb80bc59681259f14d4d9c768edf40f892304 (patch)
tree709603a55547f9ad6a026c3a727b12edcae99cf3 /firmware
parent9e29a3eb37acde5ec5a63b29bdab26055a60bd80 (diff)
DFU: disable configured console UART before starting main app
The DFU uses the UART peripheral (with IRQ/ISR) for the debug output console. Before starting the main application we should make sure this configuration is reset to avoid interference (particularly the IRQ/ISR). This is not too important though since the main application reconfigures the UART for console output. Other peripheral could also be disabled (e.g. all other PIO used by DFU), but most of them also get configured by the main application. Change-Id: I8234d1b85938ad6393094c08183f613ad09ee01b
Diffstat (limited to 'firmware')
-rw-r--r--firmware/libboard/common/include/uart_console.h1
-rw-r--r--firmware/libboard/common/source/board_cstartup_gnu.c2
-rw-r--r--firmware/libboard/common/source/uart_console.c16
3 files changed, 19 insertions, 0 deletions
diff --git a/firmware/libboard/common/include/uart_console.h b/firmware/libboard/common/include/uart_console.h
index c48c2c1..0e49bfd 100644
--- a/firmware/libboard/common/include/uart_console.h
+++ b/firmware/libboard/common/include/uart_console.h
@@ -34,6 +34,7 @@
#include <stdint.h>
extern void UART_Configure( uint32_t dwBaudrate, uint32_t dwMasterClock ) ;
+extern void UART_Exit(void) ;
extern void UART_PutChar( uint8_t uc ) ;
extern uint32_t UART_GetChar( void ) ;
extern uint32_t UART_IsRxReady( void ) ;
diff --git a/firmware/libboard/common/source/board_cstartup_gnu.c b/firmware/libboard/common/source/board_cstartup_gnu.c
index 4b561ec..42231fb 100644
--- a/firmware/libboard/common/source/board_cstartup_gnu.c
+++ b/firmware/libboard/common/source/board_cstartup_gnu.c
@@ -173,6 +173,8 @@ void ResetException( void )
* the second entry in the vector table is the reset address, corresponding to the application start
*/
if (((*((uint32_t*)(IFLASH_ADDR+BOARD_DFU_BOOT_SIZE)))&0xFFFF0000)==0x20000000) {
+ UART_Exit();
+ __disable_irq();
BootIntoApp();
/* Infinite loop */
while ( 1 ) ;
diff --git a/firmware/libboard/common/source/uart_console.c b/firmware/libboard/common/source/uart_console.c
index a47ba0c..fe64922 100644
--- a/firmware/libboard/common/source/uart_console.c
+++ b/firmware/libboard/common/source/uart_console.c
@@ -103,6 +103,22 @@ extern void UART_Configure( uint32_t baudrate, uint32_t masterClock)
_ucIsConsoleInitialized=1 ;
}
+/**
+ * \brief Disables the USART peripheral and related IRQ
+ */
+void UART_Exit(void)
+{
+ if (!_ucIsConsoleInitialized) {
+ return;
+ }
+
+ Uart *pUart = CONSOLE_UART;
+ pUart->UART_IDR = UART_IDR_TXRDY;
+ pUart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX | UART_CR_RXDIS | UART_CR_TXDIS | UART_CR_RSTSTA;
+ PMC->PMC_PCDR0 = 1 << CONSOLE_ID;
+ NVIC_DisableIRQ(CONSOLE_IRQ);
+}
+
/** Interrupt Service routine to transmit queued data */
void CONSOLE_ISR(void)
{