Skip to content

Commit 14432a7

Browse files
committed
Add support for SH1106 OLED display driver
+ associated example/demo code
1 parent 15d1083 commit 14432a7

File tree

7 files changed

+1566
-0
lines changed

7 files changed

+1566
-0
lines changed

examples/board_sh1106/Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright 2008-2011 Michel Pollet <buserror@gmail.com>
3+
#
4+
# This file is part of simavr.
5+
#
6+
# simavr is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU 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+
# simavr 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 General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with simavr. If not, see <http://www.gnu.org/licenses/>.
18+
19+
target= sh1106demo
20+
simavr = ../../
21+
22+
IPATH = .
23+
IPATH += ../parts
24+
IPATH += ${simavr}/include
25+
IPATH += ${simavr}/simavr/sim
26+
27+
VPATH = .
28+
VPATH += ../parts
29+
30+
LDFLAGS += -lpthread
31+
32+
include ../Makefile.opengl
33+
34+
all: obj ${target}
35+
36+
include ${simavr}/Makefile.common
37+
38+
board = ${OBJ}/${target}.elf
39+
40+
${board} : ${OBJ}/sh1106_virt.o
41+
${board} : ${OBJ}/sh1106_glut.o
42+
${board} : ${OBJ}/button.o
43+
${board} : ${OBJ}/${target}.o
44+
45+
${target}: ${board}
46+
@echo $@ done
47+
48+
clean: clean-${OBJ}
49+
rm -rf *.hex *.a *.axf ${target} *.vcd .*.swo .*.swp .*.swm .*.swn

examples/board_sh1106/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# SH1106 OLED demo (navigation menu for a motor controller)
2+
3+
See detailed description of the emulated system here https://github.com/jpcornil-git/Cone2Hank
4+
5+
- Use arrows to navigate menu
6+
- \<enter\> to select
7+
- \<space\> to start,pause or stop (long press) motor
8+
- 'v' to start/stop VCD traces
9+
- 'q' or ESC to quit
10+
11+
**NOTE**: Emulation may be slightly slower than realtime and a keypress has to be long enough to cope with that.
12+
13+
## Usage
14+
Command line options:
15+
```
16+
$ sh1106demo.elf --help
17+
Usage: sh1106demo.elf [...] <firmware>
18+
[--help|-h|-?] Display this usage message and exit
19+
[--list-cores] List all supported AVR cores and exit
20+
[-v] Raise verbosity level
21+
(can be passed more than once)
22+
[--freq|-f <freq>] Sets the frequency for an .hex firmware
23+
[--mcu|-m <device>] Sets the MCU type for an .hex firmware
24+
[--gdb|-g [<port>]] Listen for gdb connection on <port> (default 1234)
25+
[--output|-o <file>] VCD file to save signal traces (default gtkwave_trace.vcd)
26+
[--start-vcd|-s Start VCD output from reset
27+
[--pc-trace|-p Add PC to VCD traces
28+
[--add-trace|-at <name=[portpin|irq|trace]@addr/mask or [sram8|sram16]@addr>]
29+
Add signal to be included in VCD output
30+
<firmware> An ELF file (can include debugging syms)
31+
```
32+
## Examples
33+
### Execute firmware.elf (with no .mmcu section -> -m and -f required) on system
34+
```
35+
$ sh1106demo.elf -m atmega32u4 -f 16000000 firmware_no_mmcu.elf
36+
```
37+
38+
### Start system and wait for gdb to connect, load firmware, ...
39+
```
40+
$ sh1106demo.elf -m atmega32u4 -f 16000000 -g
41+
```
42+
43+
### Execute firmware.elf on system and trace signals in a VCD file
44+
- .mmcu section of the firmware includes something like:
45+
```
46+
#include "avr_mcu_section.h"
47+
48+
extern void *__brkval;
49+
50+
AVR_MCU (F_CPU, "atmega32u4" );
51+
AVR_MCU_VOLTAGES(3300, 3300, 3300);
52+
AVR_MCU_VCD_FILE("simavr.vcd", 10000000);
53+
54+
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
55+
{ AVR_MCU_VCD_SYMBOL("Encoder"), .what = (void*) &PIND, .mask=(1<<PIND2), },
56+
{ AVR_MCU_VCD_SRAM_16("Heap"), .what = (void*)(&__brkval), },
57+
};
58+
```
59+
- Options from the command line:
60+
- Add a 16 bits trace for Stack Pointer (SPL/SPH) (could also be in the section above)
61+
- Add a (16 bits) trace for Program Counter (PC)
62+
- Start VCD dump (set to "simavr.vcd" in the .mmcu section) from reset
63+
```
64+
$ sh1106demo.elf --add-trace Stack=sram16@0x5d -p -s firmware_mmcu.elf
65+
```
66+
GTKWave ouput
67+
68+
![PS_SP-Heap_3x](https://github.com/jpcornil-git/simavr/assets/40644331/b4cefeb2-e33f-4c21-afa6-2b15b92eed37)

0 commit comments

Comments
 (0)