Skip to content

Commit 0a86378

Browse files
ChuckMesden
authored andcommitted
Additional cleanup on lcd-serial
Remove the ISR function and remains of the hack in lcd-spi.c and convert console.c to use the LOC3 system reset code rather than the hack which only works on the F4 as it turns out.
1 parent 5379525 commit 0a86378

File tree

2 files changed

+3
-45
lines changed

2 files changed

+3
-45
lines changed

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,9 @@ void usart1_isr(void) {
6868
#ifdef RESET_ON_CTRLC
6969
/* Check for "reset" */
7070
if (recv_buf[recv_ndx_nxt] == '\003') {
71-
/* reset the system
72-
* volatile definition of return address on the stack
73-
* to insure it gets stored, changed to point to
74-
* the trampoline function (do_the_nasty) which is
75-
* required because we need to return of an interrupt
76-
* to get the internal value of the LR register reset
77-
* and put the processor back into "Thread" mode from
78-
* "Handler" mode.
79-
*
80-
* See the PM0214 Programming Manual for Cortex M,
81-
* pg 42, to see the format of the Cortex M4 stack after
82-
* an interrupt or exception has occurred.
83-
*/
84-
volatile uint32_t *ret = (&reg) + 7;
85-
86-
*ret = (uint32_t) &reset_handler;
87-
return;
71+
/* reset the system */
72+
scb_reset_system();
73+
return; /* not reached */
8874
}
8975
#endif
9076
/* Check for "overrun" */

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,6 @@
3535
static int print_decimal(int v);
3636
static int print_hex(int v);
3737

38-
/*
39-
* This is an ungainly workaround (aka hack) basically I want to know
40-
* when the SPI port is 'done' sending all of the bits out, and it is
41-
* done when it has clocked enough bits that it would have received a
42-
* byte. Since we're using the SPI port in write_only mode I am not
43-
* collecting the "received" bytes into a buffer, but one could of
44-
* course. I keep track of how many bytes should have been returned
45-
* by decrementing the 'rx_pend' volatile. When it reaches 0 we know
46-
* we are done.
47-
*/
48-
49-
volatile int rx_pend;
50-
volatile uint16_t spi_rx_buf;
51-
52-
/*
53-
* This is the ISR we use. Note that the name is based on the name
54-
* in the irq.json file of libopencm3 plus the "_isr" extension.
55-
*/
56-
void
57-
spi5_isr(void) {
58-
spi_rx_buf = SPI_DR(SPI5);
59-
--rx_pend;
60-
}
61-
6238
/* Simple double buffering, one frame is displayed, the
6339
* other being built.
6440
*/
@@ -343,10 +319,6 @@ lcd_spi_init(void) {
343319
cur_frame = (uint16_t *)(SDRAM_BASE_ADDRESS);
344320
display_frame = cur_frame + (LCD_WIDTH * LCD_HEIGHT);
345321

346-
rx_pend = 0;
347-
/* Implement state management hack */
348-
// nvic_enable_irq(NVIC_SPI5_IRQ);
349-
350322
rcc_periph_clock_enable(RCC_SPI5);
351323
spi_init_master(LCD_SPI, SPI_CR1_BAUDRATE_FPCLK_DIV_4,
352324
SPI_CR1_CPOL_CLK_TO_0_WHEN_IDLE,

0 commit comments

Comments
 (0)