-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #541 from jpcornil-git/pr_sh1106
Add support for SH1106 OLED display
- Loading branch information
Showing
9 changed files
with
1,631 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# | ||
# Copyright 2008-2011 Michel Pollet <buserror@gmail.com> | ||
# | ||
# This file is part of simavr. | ||
# | ||
# simavr is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# simavr is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with simavr. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
target= sh1106demo | ||
simavr = ../../ | ||
|
||
IPATH = . | ||
IPATH += ../parts | ||
IPATH += ${simavr}/include | ||
IPATH += ${simavr}/simavr/sim | ||
|
||
VPATH = . | ||
VPATH += ../parts | ||
|
||
LDFLAGS += -lpthread | ||
|
||
include ../Makefile.opengl | ||
|
||
all: obj ${target} | ||
|
||
include ${simavr}/Makefile.common | ||
|
||
board = ${OBJ}/${target}.elf | ||
|
||
${board} : ${OBJ}/sh1106_virt.o | ||
${board} : ${OBJ}/sh1106_glut.o | ||
${board} : ${OBJ}/button.o | ||
${board} : ${OBJ}/${target}.o | ||
|
||
${target}: ${board} | ||
@echo $@ done | ||
|
||
clean: clean-${OBJ} | ||
rm -rf *.hex *.a *.axf ${target} *.vcd .*.swo .*.swp .*.swm .*.swn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
SH1106 OLED demo (navigation menu for a motor controller) | ||
========================================================= | ||
See detailed description of the emulated system here https://github.com/jpcornil-git/Cone2Hank | ||
|
||
- Use arrows to navigate menu | ||
- <enter> to select | ||
- <space> to start,pause or stop (long press) motor | ||
- 'v' to start/stop VCD traces | ||
- 'q' or ESC to quit | ||
|
||
NOTE: Emulation may be slightly slower than realtime and a keypress has to be long enough to cope with that. | ||
|
||
Usage | ||
===== | ||
Command line options: | ||
|
||
$ sh1106demo.elf --help | ||
Usage: sh1106demo.elf [...] <firmware> | ||
[--help|-h|-?] Display this usage message and exit | ||
[--list-cores] List all supported AVR cores and exit | ||
[-v] Raise verbosity level | ||
(can be passed more than once) | ||
[--freq|-f <freq>] Sets the frequency for an .hex firmware | ||
[--mcu|-m <device>] Sets the MCU type for an .hex firmware | ||
[--gdb|-g [<port>]] Listen for gdb connection on <port> (default 1234) | ||
[--output|-o <file>] VCD file to save signal traces (default gtkwave_trace.vcd) | ||
[--start-vcd|-s Start VCD output from reset | ||
[--pc-trace|-p Add PC to VCD traces | ||
[--add-trace|-at <name=[portpin|irq|trace]@addr/mask or [sram8|sram16]@addr>] | ||
Add signal to be included in VCD output | ||
<firmware> An ELF file (can include debugging syms) | ||
|
||
Examples | ||
======== | ||
Execute firmware.elf (with no .mmcu section -> -m and -f required) on system | ||
|
||
$ sh1106demo.elf -m atmega32u4 -f 16000000 firmware_no_mmcu.elf | ||
|
||
Start system and wait for gdb to connect, load firmware, ... | ||
|
||
$ sh1106demo.elf -m atmega32u4 -f 16000000 -g | ||
|
||
Execute firmware.elf on system and trace signals in a VCD file | ||
|
||
1. .mmcu section of the firmware includes something like: | ||
|
||
#include "avr_mcu_section.h" | ||
|
||
extern void *__brkval; | ||
|
||
AVR_MCU (F_CPU, "atmega32u4" ); | ||
AVR_MCU_VOLTAGES(3300, 3300, 3300); | ||
AVR_MCU_VCD_FILE("simavr.vcd", 10000000); | ||
|
||
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = { | ||
{ AVR_MCU_VCD_SYMBOL("Encoder"), .what = (void*) &PIND, .mask=(1<<PIND2), }, | ||
{ AVR_MCU_VCD_SRAM_16("Heap"), .what = (void*)(&__brkval), }, | ||
}; | ||
|
||
2. Options from the command line: | ||
- Add a 16 bits trace for Stack Pointer (SPL/SPH) (could also be in the section above) | ||
- Add a (16 bits) trace for Program Counter (PC) | ||
- Start VCD dump (set to "simavr.vcd" in the .mmcu section) from reset | ||
|
||
$ sh1106demo.elf --add-trace Stack=sram16@0x5d -p -s firmware_mmcu.elf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# SH1106 OLED demo (navigation menu for a motor controller) | ||
|
||
See detailed description of the emulated system here https://github.com/jpcornil-git/Cone2Hank | ||
|
||
- Use arrows to navigate menu | ||
- \<enter\> to select | ||
- \<space\> to start,pause or stop (long press) motor | ||
- 'v' to start/stop VCD traces | ||
- 'q' or ESC to quit | ||
|
||
**NOTE**: Emulation may be slightly slower than realtime and a keypress has to be long enough to cope with that. | ||
|
||
## Usage | ||
Command line options: | ||
``` | ||
$ sh1106demo.elf --help | ||
Usage: sh1106demo.elf [...] <firmware> | ||
[--help|-h|-?] Display this usage message and exit | ||
[--list-cores] List all supported AVR cores and exit | ||
[-v] Raise verbosity level | ||
(can be passed more than once) | ||
[--freq|-f <freq>] Sets the frequency for an .hex firmware | ||
[--mcu|-m <device>] Sets the MCU type for an .hex firmware | ||
[--gdb|-g [<port>]] Listen for gdb connection on <port> (default 1234) | ||
[--output|-o <file>] VCD file to save signal traces (default gtkwave_trace.vcd) | ||
[--start-vcd|-s Start VCD output from reset | ||
[--pc-trace|-p Add PC to VCD traces | ||
[--add-trace|-at <name=[portpin|irq|trace]@addr/mask or [sram8|sram16]@addr>] | ||
Add signal to be included in VCD output | ||
<firmware> An ELF file (can include debugging syms) | ||
``` | ||
## Examples | ||
### Execute firmware.elf (with no .mmcu section -> -m and -f required) on system | ||
``` | ||
$ sh1106demo.elf -m atmega32u4 -f 16000000 firmware_no_mmcu.elf | ||
``` | ||
### Start system and wait for gdb to connect, load firmware, ... | ||
``` | ||
$ sh1106demo.elf -m atmega32u4 -f 16000000 -g | ||
``` | ||
|
||
### Execute firmware.elf on system and trace signals in a VCD file | ||
- .mmcu section of the firmware includes something like: | ||
``` | ||
#include "avr_mcu_section.h" | ||
extern void *__brkval; | ||
AVR_MCU (F_CPU, "atmega32u4" ); | ||
AVR_MCU_VOLTAGES(3300, 3300, 3300); | ||
AVR_MCU_VCD_FILE("simavr.vcd", 10000000); | ||
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = { | ||
{ AVR_MCU_VCD_SYMBOL("Encoder"), .what = (void*) &PIND, .mask=(1<<PIND2), }, | ||
{ AVR_MCU_VCD_SRAM_16("Heap"), .what = (void*)(&__brkval), }, | ||
}; | ||
``` | ||
- Options from the command line: | ||
- Add a 16 bits trace for Stack Pointer (SPL/SPH) (could also be in the section above) | ||
- Add a (16 bits) trace for Program Counter (PC) | ||
- Start VCD dump (set to "simavr.vcd" in the .mmcu section) from reset | ||
``` | ||
$ sh1106demo.elf --add-trace Stack=sram16@0x5d -p -s firmware_mmcu.elf | ||
``` | ||
GTKWave ouput | ||
|
||
![PS_SP-Heap_3x](https://github.com/jpcornil-git/simavr/assets/40644331/b4cefeb2-e33f-4c21-afa6-2b15b92eed37) |
Binary file not shown.
Oops, something went wrong.