Skip to content

Commit 51dda90

Browse files
committed
[stm32f429i-discovery] Replaced the ctrl-c handler in console for a shorter version.
Thanks to ChuckM for that.
1 parent 8c6eb9c commit 51dda90

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

examples/stm32/f4/stm32f429i-discovery/lcd-serial/console.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ void usart1_isr(void)
6767
if (reg & USART_SR_RXNE) {
6868
recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART);
6969
#ifdef RESET_ON_CTRLC
70-
/* Check for "reset" */
70+
/*
71+
* This bit of code will jump to the ResetHandler if you
72+
* hit ^C
73+
*/
7174
if (recv_buf[recv_ndx_nxt] == '\003') {
72-
/* reset the system */
7375
scb_reset_system();
74-
return; /* not reached */
76+
return; /* never actually reached */
7577
}
7678
#endif
7779
/* Check for "overrun" */

examples/stm32/f4/stm32f429i-discovery/sdram/console.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,13 @@ void usart1_isr(void)
7979
if (reg & USART_SR_RXNE) {
8080
recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART);
8181
#ifdef RESET_ON_CTRLC
82-
/* Check for "reset" */
82+
/*
83+
* This bit of code will jump to the ResetHandler if you
84+
* hit ^C
85+
*/
8386
if (recv_buf[recv_ndx_nxt] == '\003') {
84-
/* reset the system */
85-
/* Return address on stack */
86-
volatile uint32_t *ret = (&reg) + 7;
87-
88-
/* force system reset */
89-
*ret = (uint32_t) &reset_handler;
90-
/* go to new address */
91-
return;
87+
scb_reset_system();
88+
return; /* never actually reached */
9289
}
9390
#endif
9491
/* Check for "overrun" */

examples/stm32/f4/stm32f429i-discovery/spi/console.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,13 @@ void usart1_isr(void)
6767
if (reg & USART_SR_RXNE) {
6868
recv_buf[recv_ndx_nxt] = USART_DR(CONSOLE_UART);
6969
#ifdef RESET_ON_CTRLC
70-
/* Check for "reset" */
70+
/*
71+
* This bit of code will jump to the ResetHandler if you
72+
* hit ^C
73+
*/
7174
if (recv_buf[recv_ndx_nxt] == '\003') {
72-
/* reset the system volatile definition of
73-
* return address on the stack to insure it
74-
* gets stored, changed to point to the
75-
* trampoline function (do_the_nasty) which is
76-
* required because we need to return of an
77-
* interrupt to get the internal value of the
78-
* LR register reset and put the processor back
79-
* into "Thread" mode from "Handler" mode.
80-
*
81-
* See the PM0214 Programming Manual for Cortex
82-
* M, pg 42, to see the format of the Cortex M4
83-
* stack after an interrupt or exception has
84-
* occurred.
85-
*/
86-
volatile uint32_t *ret = (&reg) + 7;
87-
88-
*ret = (uint32_t) &reset_handler;
89-
return;
75+
scb_reset_system();
76+
return; /* never actually reached */
9077
}
9178
#endif
9279
/* Check for "overrun" */

0 commit comments

Comments
 (0)