Skip to content

Commit 22f59c4

Browse files
ChuckMesden
authored andcommitted
LCD version of the Mandelbrot example
This version is the ASCII one but uses the LCD display that is attached to the board for a more colorful result. This example also zooms into a more "interesting" place in the set so the display stays interesting during the full 100 generations.
1 parent 4de8d15 commit 22f59c4

File tree

9 files changed

+946
-0
lines changed

9 files changed

+946
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
##
2+
## This file is part of the libopencm3 project.
3+
##
4+
## Copyright (C) 2009 Uwe Hermann <[email protected]>
5+
##
6+
## This library is free software: you can redistribute it and/or modify
7+
## it under the terms of the GNU Lesser General Public License as published by
8+
## the Free Software Foundation, either version 3 of the License, or
9+
## (at your option) any later version.
10+
##
11+
## This library is distributed in the hope that it will be useful,
12+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
## GNU Lesser General Public License for more details.
15+
##
16+
## You should have received a copy of the GNU Lesser General Public License
17+
## along with this library. If not, see <http://www.gnu.org/licenses/>.
18+
##
19+
20+
OBJS = sdram.o lcd.o clock.o
21+
22+
BINARY = mandel
23+
24+
LDSCRIPT = ../stm32f429i-discovery.ld
25+
26+
include ../../Makefile.include
27+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# README
2+
3+
This example program demonstrates the floating point coprocessor usage on
4+
the ST STM32F429IDISCOVERY eval board.
5+
6+
The mandlebrot is calculated and displayed on the attached LCD
7+
8+
## Board connections
9+
10+
| Port | Function | Description |
11+
| ----- | ------------- | --------------------------------- |
12+
| `PA9` | `(USART1_TX)` | TTL serial output `(115200,8,N,1)` |
13+
14+
Data can be sent to the serial port for debugging.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
* This file is part of the libopencm3 project.
3+
*
4+
* Copyright (C) 2009 Uwe Hermann <[email protected]>
5+
* Copyright (C) 2011 Stephen Caudle <[email protected]>
6+
* Copyright (C) 2012 Daniel Serpell <[email protected]>
7+
* Copyright (C) 2015 Piotr Esden-Tempski <[email protected]>
8+
* Copyright (C) 2015 Chuck McManis <[email protected]>
9+
*
10+
* This library is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Lesser General Public License as published by
12+
* the Free Software Foundation, either version 3 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* This library is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with this library. If not, see <http://www.gnu.org/licenses/>.
22+
*/
23+
24+
#include <stdio.h>
25+
#include <ctype.h>
26+
#include <libopencm3/stm32/rcc.h>
27+
#include <libopencm3/stm32/gpio.h>
28+
#include <libopencm3/stm32/usart.h>
29+
#include <libopencm3/cm3/systick.h>
30+
#include <libopencm3/cm3/nvic.h>
31+
#include "clock.h"
32+
33+
void clock_setup(void)
34+
{
35+
rcc_clock_setup_hse_3v3(&hse_8mhz_3v3[CLOCK_3V3_168MHZ]);
36+
37+
/* set up the SysTick function (1mS interrupts) */
38+
systick_set_clocksource(STK_CSR_CLKSOURCE_AHB);
39+
STK_CVR = 0;
40+
systick_set_reload(rcc_ahb_frequency / 1000);
41+
systick_counter_enable();
42+
systick_interrupt_enable();
43+
}
44+
45+
/* simple millisecond counter */
46+
static volatile uint32_t system_millis;
47+
static volatile uint32_t delay_timer;
48+
49+
/*
50+
* Simple systick handler
51+
*
52+
* Increments a 32 bit value once per millesecond
53+
* which rolls over every 49 days.
54+
*/
55+
void sys_tick_handler(void)
56+
{
57+
system_millis++;
58+
if (delay_timer > 0) {
59+
delay_timer--;
60+
}
61+
}
62+
63+
/*
64+
* Simple spin loop waiting for time to pass
65+
*
66+
* A couple of things to note:
67+
* First, you can't just compare to
68+
* system_millis because doing so will mean
69+
* you delay forever if you happen to hit a
70+
* time where it is rolling over.
71+
* Second, accuracy is "at best" 1mS as you
72+
* may call this "just before" the systick hits
73+
* with a value of '1' and it would return
74+
* nearly immediately. So if you need really
75+
* precise delays, use one of the timers.
76+
*/
77+
void
78+
msleep(uint32_t delay)
79+
{
80+
delay_timer = delay;
81+
while (delay_timer);
82+
}
83+
84+
uint32_t
85+
mtime(void)
86+
{
87+
return system_millis;
88+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* This file is part of the libopencm3 project.
3+
*
4+
* Copyright (C) 2014-2015 Chuck McManis <[email protected]>
5+
*
6+
* This library is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU Lesser General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This library is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
/*
21+
* clock functions
22+
*/
23+
24+
extern void clock_setup(void);
25+
extern void msleep(uint32_t);
26+
extern uint32_t mtime(void);
27+

0 commit comments

Comments
 (0)