[stm32f429i-discovery] Replaced the ctrl-c handler in console for a shorter version.

Thanks to ChuckM for that.
This commit is contained in:
Piotr Esden-Tempski
2015-02-05 16:30:59 -08:00
parent 8c6eb9ca57
commit 51dda90570
3 changed files with 17 additions and 31 deletions

View File

@@ -67,11 +67,13 @@ void usart1_isr(void)
if (reg & USART_SR_RXNE) { if (reg & USART_SR_RXNE) {
recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART); recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART);
#ifdef RESET_ON_CTRLC #ifdef RESET_ON_CTRLC
/* Check for "reset" */ /*
* This bit of code will jump to the ResetHandler if you
* hit ^C
*/
if (recv_buf[recv_ndx_nxt] == '\003') { if (recv_buf[recv_ndx_nxt] == '\003') {
/* reset the system */
scb_reset_system(); scb_reset_system();
return; /* not reached */ return; /* never actually reached */
} }
#endif #endif
/* Check for "overrun" */ /* Check for "overrun" */

View File

@@ -79,16 +79,13 @@ void usart1_isr(void)
if (reg & USART_SR_RXNE) { if (reg & USART_SR_RXNE) {
recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART); recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART);
#ifdef RESET_ON_CTRLC #ifdef RESET_ON_CTRLC
/* Check for "reset" */ /*
* This bit of code will jump to the ResetHandler if you
* hit ^C
*/
if (recv_buf[recv_ndx_nxt] == '\003') { if (recv_buf[recv_ndx_nxt] == '\003') {
/* reset the system */ scb_reset_system();
/* Return address on stack */ return; /* never actually reached */
volatile uint32_t *ret = (&reg) + 7;
/* force system reset */
*ret = (uint32_t) &reset_handler;
/* go to new address */
return;
} }
#endif #endif
/* Check for "overrun" */ /* Check for "overrun" */

View File

@@ -67,26 +67,13 @@ void usart1_isr(void)
if (reg & USART_SR_RXNE) { if (reg & USART_SR_RXNE) {
recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART); recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART);
#ifdef RESET_ON_CTRLC #ifdef RESET_ON_CTRLC
/* Check for "reset" */ /*
* This bit of code will jump to the ResetHandler if you
* hit ^C
*/
if (recv_buf[recv_ndx_nxt] == '\003') { if (recv_buf[recv_ndx_nxt] == '\003') {
/* reset the system volatile definition of scb_reset_system();
* return address on the stack to insure it return; /* never actually reached */
* gets stored, changed to point to the
* trampoline function (do_the_nasty) which is
* required because we need to return of an
* interrupt to get the internal value of the
* LR register reset and put the processor back
* into "Thread" mode from "Handler" mode.
*
* See the PM0214 Programming Manual for Cortex
* M, pg 42, to see the format of the Cortex M4
* stack after an interrupt or exception has
* occurred.
*/
volatile uint32_t *ret = (&reg) + 7;
*ret = (uint32_t) &reset_handler;
return;
} }
#endif #endif
/* Check for "overrun" */ /* Check for "overrun" */