Added DOGM128 LCD display example (SPI).
This commit is contained in:
@@ -24,7 +24,7 @@ Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
endif
|
||||
|
||||
all: i2c_stts75_sensor adc_temperature_sensor dma_mem2mem timer_interrupt systick
|
||||
all: i2c_stts75_sensor adc_temperature_sensor dma_mem2mem timer_interrupt systick dogm128
|
||||
|
||||
i2c_stts75_sensor:
|
||||
@printf " BUILD examples/other/i2c_stts75_sensor\n"
|
||||
@@ -46,6 +46,10 @@ systick:
|
||||
@printf " BUILD examples/other/systick\n"
|
||||
$(Q)$(MAKE) -C systick
|
||||
|
||||
dogm128:
|
||||
@printf " BUILD examples/other/dogm128\n"
|
||||
$(Q)$(MAKE) -C dogm128
|
||||
|
||||
clean:
|
||||
@printf " CLEAN examples/other/i2c_stts75_sensor\n"
|
||||
$(Q)$(MAKE) -C i2c_stts75_sensor clean
|
||||
@@ -57,6 +61,8 @@ clean:
|
||||
$(Q)$(MAKE) -C timer_interrupt clean
|
||||
@printf " CLEAN examples/other/systick\n"
|
||||
$(Q)$(MAKE) -C systick clean
|
||||
@printf " CLEAN examples/other/dogm128\n"
|
||||
$(Q)$(MAKE) -C dogm128 clean
|
||||
|
||||
.PHONY: i2c_stts75_sensor adc_temperature_sensor dma_mem2mem timer_interrupt systick clean
|
||||
.PHONY: i2c_stts75_sensor adc_temperature_sensor dma_mem2mem timer_interrupt systick dogm128 clean
|
||||
|
||||
|
||||
95
examples/other/dogm128/Makefile
Normal file
95
examples/other/dogm128/Makefile
Normal file
@@ -0,0 +1,95 @@
|
||||
##
|
||||
## This file is part of the libopenstm32 project.
|
||||
##
|
||||
## Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
|
||||
##
|
||||
## This program 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.
|
||||
##
|
||||
## This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
##
|
||||
|
||||
BINARY = main
|
||||
|
||||
# PREFIX ?= arm-none-eabi
|
||||
PREFIX ?= arm-elf
|
||||
CC = $(PREFIX)-gcc
|
||||
LD = $(PREFIX)-ld
|
||||
OBJCOPY = $(PREFIX)-objcopy
|
||||
OBJDUMP = $(PREFIX)-objdump
|
||||
# Uncomment this line if you want to use the installed (not local) library.
|
||||
#TOOLCHAIN_DIR = `dirname \`which $(CC)\``/..
|
||||
TOOLCHAIN_DIR = ../../..
|
||||
CFLAGS = -O0 -g -Wall -Wextra -I$(TOOLCHAIN_DIR)/include -fno-common \
|
||||
-mcpu=cortex-m3 -mthumb
|
||||
LDSCRIPT = $(BINARY).ld
|
||||
LDFLAGS = -L$(TOOLCHAIN_DIR)/lib -T$(LDSCRIPT) -nostartfiles
|
||||
OBJS = $(BINARY).o dogm128.o
|
||||
|
||||
OPENOCD_BASE = /usr
|
||||
OPENOCD = $(OPENOCD_BASE)/bin/openocd
|
||||
OPENOCD_SCRIPTS = $(OPENOCD_BASE)/share/openocd/scripts
|
||||
OPENOCD_FLASHER = $(OPENOCD_SCRIPTS)/interface/jtagkey.cfg
|
||||
OPENOCD_BOARD = $(OPENOCD_SCRIPTS)/target/stm32.cfg
|
||||
|
||||
# Be silent per default, but 'make V=1' will show all compiler calls.
|
||||
ifneq ($(V),1)
|
||||
Q := @
|
||||
NULL := 2>/dev/null
|
||||
endif
|
||||
|
||||
all: images
|
||||
|
||||
images: $(BINARY)
|
||||
@printf " OBJCOPY $(BINARY).bin\n"
|
||||
$(Q)$(OBJCOPY) -Obinary $(BINARY) $(BINARY).bin
|
||||
@printf " OBJCOPY $(BINARY).hex\n"
|
||||
$(Q)$(OBJCOPY) -Oihex $(BINARY) $(BINARY).hex
|
||||
@printf " OBJCOPY $(BINARY).srec\n"
|
||||
$(Q)$(OBJCOPY) -Osrec $(BINARY) $(BINARY).srec
|
||||
@printf " OBJDUMP $(BINARY).list\n"
|
||||
$(Q)$(OBJDUMP) -S $(BINARY) > $(BINARY).list
|
||||
|
||||
$(BINARY): $(OBJS) $(LDSCRIPT)
|
||||
@printf " LD $(subst $(shell pwd)/,,$(@))\n"
|
||||
$(Q)$(LD) $(LDFLAGS) -o $(BINARY) $(OBJS) -lopenstm32
|
||||
|
||||
%.o: %.c Makefile
|
||||
@printf " CC $(subst $(shell pwd)/,,$(@))\n"
|
||||
$(Q)$(CC) $(CFLAGS) -o $@ -c $<
|
||||
|
||||
clean:
|
||||
@printf " CLEAN $(subst $(shell pwd)/,,$(OBJS))\n"
|
||||
$(Q)rm -f *.o
|
||||
@printf " CLEAN $(BINARY)\n"
|
||||
$(Q)rm -f $(BINARY)
|
||||
@printf " CLEAN $(BINARY).bin\n"
|
||||
$(Q)rm -f $(BINARY).bin
|
||||
@printf " CLEAN $(BINARY).hex\n"
|
||||
$(Q)rm -f $(BINARY).hex
|
||||
@printf " CLEAN $(BINARY).srec\n"
|
||||
$(Q)rm -f $(BINARY).srec
|
||||
@printf " CLEAN $(BINARY).list\n"
|
||||
$(Q)rm -f $(BINARY).list
|
||||
|
||||
flash: images
|
||||
@printf " FLASH $(BINARY).bin\n"
|
||||
@# IMPORTANT: Don't use "resume", only "reset" will work correctly!
|
||||
$(Q)$(OPENOCD) -s $(OPENOCD_SCRIPTS) \
|
||||
-f $(OPENOCD_FLASHER) \
|
||||
-f $(OPENOCD_BOARD) \
|
||||
-c "init" -c "reset halt" \
|
||||
-c "flash write_image erase $(BINARY).hex" \
|
||||
-c "reset" \
|
||||
-c "shutdown" $(NULL)
|
||||
|
||||
.PHONY: images clean
|
||||
|
||||
42
examples/other/dogm128/README
Normal file
42
examples/other/dogm128/README
Normal file
@@ -0,0 +1,42 @@
|
||||
------------------------------------------------------------------------------
|
||||
README
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
This example program writes some text on an DOGM128 LCD display connected to SPI2.
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
$ make
|
||||
|
||||
Running 'make' on the top-level libopenstm32 directory will automatically
|
||||
also build this example. Or you can build the library "manually" and
|
||||
then run 'make' in this directory.
|
||||
|
||||
You may want to override the toolchain (e.g., arm-elf or arm-none-eabi):
|
||||
|
||||
$ PREFIX=arm-none-eabi make
|
||||
|
||||
For a more verbose build you can use
|
||||
|
||||
$ make V=1
|
||||
|
||||
|
||||
Flashing
|
||||
--------
|
||||
|
||||
You can flash the generated code using OpenOCD:
|
||||
|
||||
$ make flash
|
||||
|
||||
Or you can do the same manually via:
|
||||
|
||||
$ openocd -f interface/jtagkey-tiny.cfg -f target/stm32.cfg
|
||||
$ telnet localhost 4444
|
||||
> reset halt
|
||||
> flash write_image erase main.hex
|
||||
> reset
|
||||
|
||||
Replace the "jtagkey-tiny.cfg" with whatever JTAG device you are using, and/or
|
||||
replace "stm.cfg" with your respective config file.
|
||||
|
||||
291
examples/other/dogm128/dogm128.c
Normal file
291
examples/other/dogm128/dogm128.c
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
* This file is part of the libopenstm32 project.
|
||||
*
|
||||
* Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "./dogm128.h"
|
||||
|
||||
u8 dogm128_ram[1024];
|
||||
u8 dogm128_cursor_x;
|
||||
u8 dogm128_cursor_y;
|
||||
|
||||
void dogm128_send_command(u8 command)
|
||||
{
|
||||
u32 counter;
|
||||
|
||||
gpio_clear(DOGM128_A0_PORT, DOGM128_A0_PIN); /* A0 low for commands */
|
||||
spi_send(DOGM128_SPI, command);
|
||||
|
||||
for (counter = 0; counter<=500; counter++) /* wait */
|
||||
{}
|
||||
}
|
||||
|
||||
void dogm128_send_data(u8 data)
|
||||
{
|
||||
u32 counter;
|
||||
|
||||
gpio_set(DOGM128_A0_PORT, DOGM128_A0_PIN); /* A0 high for data */
|
||||
spi_send(DOGM128_SPI, data);
|
||||
|
||||
for (counter = 0; counter<=500; counter++) /* wait */
|
||||
{}
|
||||
}
|
||||
|
||||
void dogm128_init()
|
||||
{
|
||||
u32 counter;
|
||||
|
||||
/* reset the display */
|
||||
gpio_clear(DOGM128_RESET_PORT, DOGM128_RESET_PIN); /* reset low for dogm128 */
|
||||
for (counter = 0; counter<=60000; counter++) /* wait */
|
||||
{}
|
||||
gpio_set(DOGM128_RESET_PORT, DOGM128_RESET_PIN); /* reset high for dogm128 */
|
||||
|
||||
for (counter = 0; counter<=60000; counter++) /* wait */
|
||||
{}
|
||||
|
||||
gpio_clear(DOGM128_A0_PORT, DOGM128_A0_PIN); /* A0 low for init */
|
||||
|
||||
/* tell the display that we want to start */
|
||||
spi_set_nss_low(DOGM128_SPI);
|
||||
|
||||
/* init sequence */
|
||||
dogm128_send_command(DOGM128_DISPLAY_START_ADDRESS_BASE + 0);
|
||||
dogm128_send_command(DOGM128_ADC_REVERSE);
|
||||
dogm128_send_command(DOGM128_COM_OUTPUT_SCAN_NORMAL);
|
||||
dogm128_send_command(DOGM128_DISPLAY_NORMAL);
|
||||
dogm128_send_command(DOGM128_BIAS_19);
|
||||
dogm128_send_command(DOGM128_POWER_CONTROL_BASE + 0x07);
|
||||
dogm128_send_command(DOGM128_BOOSTER_RATIO_SET);
|
||||
dogm128_send_command(0x00); /* Booster x4 */
|
||||
dogm128_send_command(DOGM128_V0_OUTPUT_RESISTOR_BASE + 0x07);
|
||||
dogm128_send_command(DOGM128_ELECTRONIC_VOLUME_MODE_SET);
|
||||
dogm128_send_command(0x16); /* Contrast */
|
||||
dogm128_send_command(DOGM128_STATIC_INDICATOR_OFF);
|
||||
dogm128_send_command(0x00); /* Flashing OFF */
|
||||
dogm128_send_command(DOGM128_DISPLAY_ON);
|
||||
|
||||
/* end transfer */
|
||||
spi_set_nss_high(DOGM128_SPI);
|
||||
}
|
||||
|
||||
void dogm128_print_char(u8 data)
|
||||
{
|
||||
u8 i;
|
||||
u8 page;
|
||||
u8 shift;
|
||||
u8 xcoord;
|
||||
u8 ycoord;
|
||||
|
||||
xcoord = dogm128_cursor_x;
|
||||
ycoord = dogm128_cursor_y;
|
||||
|
||||
page = (63 - ycoord) / 8; /* the display consists of 8 lines a 8 dots each. */
|
||||
shift = (7 -((63 - ycoord) % 8)); /* vertical shift */
|
||||
|
||||
/* font is 8x5 so iterate each column of the character */
|
||||
for (i = 0; i <= 5; i++) {
|
||||
/* right border reached? */
|
||||
if ((xcoord + i) > 127)
|
||||
return;
|
||||
dogm128_cursor_x++;
|
||||
|
||||
/* 0xAA = end of character - no dots in this line */
|
||||
if (dogm128_font[data - 0x20][i] == 0xAA) {
|
||||
dogm128_ram[(page * 128) + xcoord + i] &= ~(0xFF >> shift); /* clear area */
|
||||
if ((shift > 0) && (page > 0))
|
||||
dogm128_ram[((page - 1) * 128) + xcoord + i] &= ~(0xFF << (8 - shift)); /* clear area */
|
||||
return;
|
||||
}
|
||||
|
||||
/* lower part */
|
||||
dogm128_ram[(page * 128) + xcoord + i] &= ~(0xFF >> shift); /* clear area */
|
||||
dogm128_ram[(page * 128) + xcoord + i] = (dogm128_font[data - 0x20][i] >> shift);
|
||||
/* higher part if needed */
|
||||
if ((shift > 0) && (page > 0)) {
|
||||
dogm128_ram[((page - 1) * 128) + xcoord + i] &= ~(0xFF << (8 - shift)); /* clear area */
|
||||
dogm128_ram[((page - 1) * 128) + xcoord + i] = (dogm128_font[data - 0x20][i] << (8 - shift));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dogm128_set_cursor(u8 xcoord, u8 ycoord)
|
||||
{
|
||||
dogm128_cursor_x = xcoord;
|
||||
dogm128_cursor_y = ycoord;
|
||||
}
|
||||
|
||||
void dogm128_print_string(char * s)
|
||||
{
|
||||
while (*s != 0) {
|
||||
dogm128_print_char(*s);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void dogm128_set_dot(u8 xcoord, u8 ycoord)
|
||||
{
|
||||
dogm128_ram[(((63 - ycoord) / 8) * 128) + xcoord] |= (1 << ((63 - ycoord) % 8));
|
||||
}
|
||||
|
||||
void dogm128_clear_dot(u8 xcoord, u8 ycoord)
|
||||
{
|
||||
dogm128_ram[(((63 - ycoord) / 8) * 128) + xcoord] &= ~(1 << ((63 - ycoord) % 8));
|
||||
}
|
||||
|
||||
void dogm128_update_display()
|
||||
{
|
||||
u8 page;
|
||||
u8 column;
|
||||
|
||||
/* tell the display that we want to start */
|
||||
spi_set_nss_low(DOGM128_SPI);
|
||||
|
||||
for (page = 0; page <= 7; page++) {
|
||||
dogm128_send_command(0xB0 + page); /* set page */
|
||||
dogm128_send_command(0x10); /* set column upper address to 0 */
|
||||
dogm128_send_command(0x00); /* set column lower address to 0 */
|
||||
|
||||
for (column = 0; column <= 127; column++) {
|
||||
dogm128_send_data(dogm128_ram[(page * 128) + column]);
|
||||
}
|
||||
}
|
||||
|
||||
spi_set_nss_high(DOGM128_SPI);
|
||||
}
|
||||
|
||||
void dogm128_clear()
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i<=1023; i++) {
|
||||
dogm128_ram[i] = 0;
|
||||
}
|
||||
dogm128_update_display();
|
||||
}
|
||||
|
||||
/* This is a non-monospace font definition (upside down for better handling).
|
||||
* 0xAA is the end of the character so its not space efficient in your memory, but on your display.
|
||||
* We are starting with " " as the first printable character at 0x20, so we have to substract 0x20 later.
|
||||
* Its the only defined to 127/0x7F so if you have german umlauts or other special characters from above
|
||||
* you have to expand this definition a little bit. */
|
||||
|
||||
const u8 dogm128_font[96][6] = {
|
||||
|
||||
/* 20 SPACE */ {0x00, 0x00, 0x00, 0xAA, 0xAA, 0xAA},
|
||||
/* 21 ! */ {0x5E, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 22 " */ {0x66, 0x00, 0x66, 0xAA, 0xAA, 0xAA},
|
||||
/* 23 # */ {0x28, 0x7C, 0x28, 0x7C, 0x28, 0xAA},
|
||||
/* 24 $ */ {0x24, 0x2A, 0x7F, 0x2A, 0x10, 0xAA},
|
||||
/* 25 % */ {0x62, 0x18, 0x46, 0xAA, 0xAA, 0xAA},
|
||||
/* 26 & */ {0x30, 0x4C, 0x5A, 0x24, 0x50, 0xAA},
|
||||
/* 27 ' */ {0x06, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 28 ( */ {0x3E, 0x41, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 29 ) */ {0x41, 0x3E, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 2A * */ {0x28, 0x10, 0x7C, 0x10, 0x28, 0xAA},
|
||||
/* 2B + */ {0x10, 0x38, 0x10, 0xAA, 0xAA, 0xAA},
|
||||
/* 2C , */ {0xC0, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 2D - */ {0x10, 0x10, 0x10, 0xAA, 0xAA, 0xAA},
|
||||
/* 2E . */ {0x40, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 2F / */ {0x60, 0x18, 0x06, 0xAA, 0xAA, 0xAA},
|
||||
|
||||
/* 30 0 */ {0x3C, 0x42, 0x42, 0x3C, 0xAA, 0xAA},
|
||||
/* 31 1 */ {0x44, 0x7E, 0x40, 0xAA, 0xAA, 0xAA},
|
||||
/* 32 2 */ {0x44, 0x62, 0x52, 0x4C, 0xAA, 0xAA},
|
||||
/* 33 3 */ {0x4A, 0x4A, 0x34, 0xAA, 0xAA, 0xAA},
|
||||
/* 34 4 */ {0x1E, 0x10, 0x78, 0x10, 0xAA, 0xAA},
|
||||
/* 35 5 */ {0x4E, 0x4A, 0x32, 0xAA, 0xAA, 0xAA},
|
||||
/* 36 6 */ {0x3C, 0x4A, 0x4A, 0x30, 0xAA, 0xAA},
|
||||
/* 37 7 */ {0x62, 0x12, 0x0E, 0xAA, 0xAA, 0xAA},
|
||||
/* 38 8 */ {0x34, 0x4A, 0x4A, 0x34, 0xAA, 0xAA},
|
||||
/* 39 9 */ {0x0C, 0x52, 0x52, 0x3C, 0xAA, 0xAA},
|
||||
/* 3A : */ {0x28, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 3B ; */ {0xC8, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 3C < */ {0x10, 0x28, 0x44, 0xAA, 0xAA, 0xAA},
|
||||
/* 3D = */ {0x28, 0x28, 0x28, 0xAA, 0xAA, 0xAA},
|
||||
/* 3E > */ {0x44, 0x28, 0x10, 0xAA, 0xAA, 0xAA},
|
||||
/* 3F ? */ {0x02, 0x52, 0x0C, 0xAA, 0xAA, 0xAA},
|
||||
|
||||
/* 40 @ */ {0x3C, 0x42, 0x12, 0x2A, 0x3C, 0xAA},
|
||||
/* 41 A */ {0x7C, 0x12, 0x12, 0x7C, 0xAA, 0xAA},
|
||||
/* 42 B */ {0x7E, 0x4A, 0x4A, 0x34, 0xAA, 0xAA},
|
||||
/* 43 C */ {0x3C, 0x42, 0x42, 0x24, 0xAA, 0xAA},
|
||||
/* 44 D */ {0x7E, 0x42, 0x42, 0x3C, 0xAA, 0xAA},
|
||||
/* 45 E */ {0x7E, 0x4A, 0x4A, 0xAA, 0xAA, 0xAA},
|
||||
/* 46 F */ {0x7E, 0x0A, 0x0A, 0xAA, 0xAA, 0xAA},
|
||||
/* 47 G */ {0x3C, 0x42, 0x52, 0x34, 0xAA, 0xAA},
|
||||
/* 48 H */ {0x7E, 0x08, 0x08, 0x7E, 0xAA, 0xAA},
|
||||
/* 49 I */ {0x42, 0x7E, 0x42, 0xAA, 0xAA, 0xAA},
|
||||
/* 4A J */ {0x42, 0x42, 0x3E, 0xAA, 0xAA, 0xAA},
|
||||
/* 4B K */ {0x7E, 0x08, 0x14, 0x62, 0xAA, 0xAA},
|
||||
/* 4C L */ {0x7E, 0x40, 0x40, 0xAA, 0xAA, 0xAA},
|
||||
/* 4D M */ {0x7E, 0x04, 0x08, 0x04, 0x7E, 0xAA},
|
||||
/* 4E N */ {0x7E, 0x04, 0x18, 0x20, 0x7E, 0xAA},
|
||||
/* 4F O */ {0x3C, 0x42, 0x42, 0x3C, 0xAA, 0xAA},
|
||||
|
||||
/* 50 P */ {0x7E, 0x12, 0x12, 0x0C, 0xAA, 0xAA},
|
||||
/* 51 Q */ {0x3C, 0x42, 0x42, 0xBC, 0xAA, 0xAA},
|
||||
/* 52 R */ {0x7E, 0x12, 0x12, 0x6C, 0xAA, 0xAA},
|
||||
/* 53 S */ {0x44, 0x4A, 0x4A, 0x30, 0xAA, 0xAA},
|
||||
/* 54 T */ {0x02, 0x7E, 0x02, 0xAA, 0xAA, 0xAA},
|
||||
/* 55 U */ {0x3E, 0x40, 0x40, 0x3E, 0xAA, 0xAA},
|
||||
/* 56 V */ {0x06, 0x18, 0x60, 0x18, 0x06, 0xAA},
|
||||
/* 57 W */ {0x3E, 0x40, 0x3E, 0x40, 0x3E, 0xAA},
|
||||
/* 58 X */ {0x42, 0x24, 0x18, 0x24, 0x42, 0xAA},
|
||||
/* 59 Y */ {0x9E, 0xA0, 0xA0, 0x7E, 0xAA, 0xAA},
|
||||
/* 5A Z */ {0x62, 0x52, 0x4A, 0x46, 0xAA, 0xAA},
|
||||
/* 5B [ */ {0x7E, 0x42, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 5C \ */ {0x06, 0x18, 0x60, 0xAA, 0xAA, 0xAA},
|
||||
/* 5D ] */ {0x42, 0x7E, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 5E ^ */ {0x04, 0x02, 0x04, 0xAA, 0xAA, 0xAA},
|
||||
/* 5F _ */ {0x40, 0x40, 0x40, 0xAA, 0xAA, 0xAA},
|
||||
|
||||
/* 60 ` */ {0x02, 0x04, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 61 a */ {0x20, 0x54, 0x54, 0x78, 0xAA, 0xAA},
|
||||
/* 62 b */ {0x7E, 0x44, 0x44, 0x38, 0xAA, 0xAA},
|
||||
/* 63 c */ {0x38, 0x44, 0x44, 0x28, 0xAA, 0xAA},
|
||||
/* 64 d */ {0x38, 0x44, 0x44, 0x7E, 0xAA, 0xAA},
|
||||
/* 65 e */ {0x38, 0x54, 0x54, 0x58, 0xAA, 0xAA},
|
||||
/* 66 f */ {0x7C, 0x0A, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 67 g */ {0x98, 0xA4, 0xA4, 0x7C, 0xAA, 0xAA},
|
||||
/* 68 h */ {0x7E, 0x04, 0x04, 0x78, 0xAA, 0xAA},
|
||||
/* 69 i */ {0x7A, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 6A j */ {0x40, 0x3A, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 6B k */ {0x7E, 0x10, 0x28, 0x44, 0xAA, 0xAA},
|
||||
/* 6C l */ {0x7E, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 6D m */ {0x7C, 0x04, 0x78, 0x04, 0x78, 0xAA},
|
||||
/* 6E n */ {0x7C, 0x04, 0x04, 0x78, 0xAA, 0xAA},
|
||||
/* 6F o */ {0x38, 0x44, 0x44, 0x38, 0xAA, 0xAA},
|
||||
|
||||
/* 70 p */ {0xFC, 0x24, 0x24, 0x18, 0xAA, 0xAA},
|
||||
/* 71 q */ {0x18, 0x24, 0x24, 0xFC, 0xAA, 0xAA},
|
||||
/* 72 r */ {0x78, 0x04, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 73 s */ {0x48, 0x54, 0x54, 0x20, 0xAA, 0xAA},
|
||||
/* 74 t */ {0x04, 0x3E, 0x44, 0xAA, 0xAA, 0xAA},
|
||||
/* 75 u */ {0x3C, 0x40, 0x40, 0x3C, 0xAA, 0xAA},
|
||||
/* 76 v */ {0x0C, 0x30, 0x40, 0x30, 0x0C, 0xAA},
|
||||
/* 77 w */ {0x3C, 0x40, 0x3C, 0x40, 0x3C, 0xAA},
|
||||
/* 78 x */ {0x44, 0x28, 0x10, 0x28, 0x44, 0xAA},
|
||||
/* 79 y */ {0x1C, 0xA0, 0xA0, 0x7C, 0xAA, 0xAA},
|
||||
/* 7A z */ {0x64, 0x54, 0x4C, 0xAA, 0xAA, 0xAA},
|
||||
/* 7B { */ {0x08, 0x36, 0x41, 0xAA, 0xAA, 0xAA},
|
||||
/* 7C | */ {0x7E, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA},
|
||||
/* 7D } */ {0x41, 0x36, 0x08, 0xAA, 0xAA, 0xAA},
|
||||
/* 7E ~ */ {0x20, 0x10, 0x20, 0x10, 0xAA, 0xAA},
|
||||
/* 7F DEL */ {0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA}
|
||||
};
|
||||
|
||||
86
examples/other/dogm128/dogm128.h
Normal file
86
examples/other/dogm128/dogm128.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the libopenstm32 project.
|
||||
*
|
||||
* Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DOGM128_H
|
||||
#define DOGM128_H
|
||||
|
||||
#include <libopenstm32/common.h>
|
||||
#include <libopenstm32/gpio.h>
|
||||
#include <libopenstm32/spi.h>
|
||||
|
||||
/* PB10 GPIO - ~RESET
|
||||
* PB12 SPI2_NSS - ~CS1
|
||||
* PB13 SPI2_SCK - SCL
|
||||
* PB14 SPI2_MISO - A0
|
||||
* PB15 SPI2_MOSI - SI */
|
||||
|
||||
#define DOGM128_SPI SPI2
|
||||
#define DOGM128_RESET_PIN GPIO10
|
||||
#define DOGM128_RESET_PORT GPIOB
|
||||
#define DOGM128_A0_PIN GPIO14
|
||||
#define DOGM128_A0_PORT GPIOB
|
||||
|
||||
/* DOGM128 display commands */
|
||||
#define DOGM128_PAGE_BASE 0xB0
|
||||
#define DOGM128_PAGE0 0xB0
|
||||
#define DOGM128_PAGE1 0xB1
|
||||
#define DOGM128_PAGE2 0xB2
|
||||
#define DOGM128_PAGE3 0xB3
|
||||
#define DOGM128_PAGE4 0xB4
|
||||
#define DOGM128_PAGE5 0xB5
|
||||
#define DOGM128_PAGE6 0xB6
|
||||
#define DOGM128_PAGE7 0xB7
|
||||
#define DOGM128_DISPLAY_ON 0xAF
|
||||
#define DOGM128_DISPLAY_OFF 0xAE
|
||||
#define DOGM128_DISPLAY_START_ADDRESS_BASE 0x40
|
||||
#define DOGM128_ADC_NORMAL 0xA0
|
||||
#define DOGM128_ADC_REVERSE 0xA1
|
||||
#define DOGM128_DISPLAY_NORMAL 0xA6
|
||||
#define DOGM128_DISPLAY_REVERSE 0xA7
|
||||
#define DOGM128_ALL_POINTS_ON 0xA5
|
||||
#define DOGM128_ALL_POINTS_OFF 0xA4
|
||||
#define DOGM128_BIAS_19 0xA2
|
||||
#define DOGM128_BIAS_17 0xA3
|
||||
#define DOGM128_INTERNAL_RESET 0xE2
|
||||
#define DOGM128_COM_OUTPUT_SCAN_NORMAL 0xC0
|
||||
#define DOGM128_COM_OUTPUT_SCAN_REVERSE 0xC8
|
||||
#define DOGM128_POWER_CONTROL_BASE 0x28
|
||||
#define DOGM128_V0_OUTPUT_RESISTOR_BASE 0x20
|
||||
#define DOGM128_ELECTRONIC_VOLUME_MODE_SET 0x81
|
||||
#define DOGM128_STATIC_INDICATOR_OFF 0xAC
|
||||
#define DOGM128_STATIC_INDICATOR_ON 0xAD
|
||||
#define DOGM128_BOOSTER_RATIO_SET 0xF8
|
||||
|
||||
extern const u8 dogm128_font[96][6];
|
||||
extern u8 dogm128_ram[1024];
|
||||
extern u8 dogm128_cursor_x;
|
||||
extern u8 dogm128_cursor_y;
|
||||
|
||||
void dogm128_send_command(u8 command);
|
||||
void dogm128_set_cursor(u8 xcoord, u8 ycoord);
|
||||
void dogm128_print_char(u8 data);
|
||||
void dogm128_print_string(char * s);
|
||||
void dogm128_set_dot(u8 xcoord, u8 ycoord);
|
||||
void dogm128_clear_dot(u8 xcoord, u8 ycoord);
|
||||
void dogm128_send_data(u8 data);
|
||||
void dogm128_init();
|
||||
void dogm128_update_display();
|
||||
void dogm128_clear();
|
||||
|
||||
#endif
|
||||
151
examples/other/dogm128/main.c
Normal file
151
examples/other/dogm128/main.c
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* This file is part of the libopenstm32 project.
|
||||
*
|
||||
* Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <libopenstm32/rcc.h>
|
||||
#include <libopenstm32/flash.h>
|
||||
#include <libopenstm32/gpio.h>
|
||||
#include <libopenstm32/usart.h>
|
||||
#include <libopenstm32/timer.h>
|
||||
#include <libopenstm32/nvic.h>
|
||||
#include <libopenstm32/spi.h>
|
||||
#include "./dogm128.h"
|
||||
|
||||
/* Set STM32 to 72 MHz. HSE 16MHz */
|
||||
void clock_setup(void)
|
||||
{
|
||||
/* enable Internal High Speed Oscillator */
|
||||
rcc_osc_on(HSI);
|
||||
rcc_wait_for_osc_ready(HSI);
|
||||
|
||||
/* Select HSI as SYSCLK source. */
|
||||
rcc_set_sysclk_source(SW_SYSCLKSEL_HSICLK);
|
||||
|
||||
/* enable External High Speed Oscillator 16MHz */
|
||||
rcc_osc_on(HSE);
|
||||
rcc_wait_for_osc_ready(HSE);
|
||||
rcc_set_sysclk_source(SW_SYSCLKSEL_HSECLK);
|
||||
|
||||
/* set prescalers for ADC, ABP1, ABP2... make this before touching the PLL */
|
||||
rcc_set_hpre(HPRE_SYSCLK_NODIV); //prescales the AHB clock from the SYSCLK
|
||||
rcc_set_adcpre(ADCPRE_PLCK2_DIV6); //prescales the ADC from the APB2 clock; max 14MHz
|
||||
rcc_set_ppre1(PPRE1_HCLK_DIV2); //prescales the APB1 from the AHB clock; max 36MHz
|
||||
rcc_set_ppre2(PPRE2_HCLK_NODIV); //prescales the APB2 from the AHB clock; max 72MHz
|
||||
|
||||
/* sysclk should run with 72MHz -> 2 Waitstates ; choose 0WS from 0-24MHz, 1WS from 24-48MHz, 2WS from 48-72MHz */
|
||||
flash_set_ws(FLASH_LATENCY_2WS);
|
||||
|
||||
/* Set the PLL multiplication factor to 9. -> 16MHz (external) * 9 (multiplier) / 2 (PLLXTPRE_HSE_CLK_DIV2) = 72MHz */
|
||||
rcc_set_pll_multiplication_factor(PLLMUL_PLL_CLK_MUL9);
|
||||
|
||||
/* Select HSI as PLL source. */
|
||||
rcc_set_pll_source(PLLSRC_HSE_CLK);
|
||||
|
||||
/* divide external frequency by 2 before entering pll (only valid/needed for HSE) */
|
||||
rcc_set_pllxtpre(PLLXTPRE_HSE_CLK_DIV2);
|
||||
|
||||
/* Enable PLL oscillator and wait for it to stabilize. */
|
||||
rcc_osc_on(PLL);
|
||||
rcc_wait_for_osc_ready(PLL);
|
||||
|
||||
/* Select PLL as SYSCLK source. */
|
||||
rcc_set_sysclk_source(SW_SYSCLKSEL_PLLCLK);
|
||||
}
|
||||
|
||||
void gpio_setup(void)
|
||||
{
|
||||
/* Enable GPIOB clock. */
|
||||
rcc_peripheral_enable_clock(&RCC_APB2ENR, IOPBEN);
|
||||
|
||||
/* Set GPIO6/7 (in GPIO port B) to 'output push-pull' for the LEDs. */
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO6);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_2_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO7);
|
||||
|
||||
/* A0 of DOGM128 */
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO14);
|
||||
/*reset of DOGM128 */
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_PUSHPULL, GPIO10);
|
||||
|
||||
/* DOGM128/SPI2 clock and MOSI and NSS(CS1) */
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO12);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO13);
|
||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
|
||||
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO15);
|
||||
}
|
||||
|
||||
void spi_setup()
|
||||
{
|
||||
/* the DOGM128 display is connected to SPI2, so initialise it correctly */
|
||||
|
||||
rcc_peripheral_enable_clock(&RCC_APB1ENR, SPI2EN);
|
||||
|
||||
spi_set_unidirectional_mode(DOGM128_SPI); /* we want to send only */
|
||||
spi_disable_crc(DOGM128_SPI); /* no CRC for this slave */
|
||||
spi_set_dff_8bit(DOGM128_SPI); /* 8-bit dataword-length */
|
||||
spi_set_full_duplex_mode(DOGM128_SPI); /* not receive-only */
|
||||
spi_enable_software_slave_management(DOGM128_SPI); /* we want to handle the CS signal in software */
|
||||
spi_set_nss_high(DOGM128_SPI);
|
||||
spi_set_baudrate_prescaler(DOGM128_SPI, SPI_CR1_BR_FPCLK_DIV_256); /* PCLOCK/256 as clock */
|
||||
spi_set_master_mode(DOGM128_SPI); /* we want to control everything and generate the clock -> master */
|
||||
spi_set_clock_polarity_1(DOGM128_SPI); /* sck idle state high */
|
||||
spi_set_clock_phase_1(DOGM128_SPI); /* bit is taken on the second (rising edge) of sck */
|
||||
spi_enable_ss_output(DOGM128_SPI);
|
||||
spi_enable(DOGM128_SPI);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
clock_setup();
|
||||
gpio_setup();
|
||||
spi_setup();
|
||||
|
||||
gpio_clear(GPIOB, GPIO7); /* LED1 on */
|
||||
gpio_set(GPIOB, GPIO6); /* LED2 off */
|
||||
|
||||
dogm128_init();
|
||||
dogm128_clear();
|
||||
|
||||
dogm128_set_cursor(0, 56);
|
||||
dogm128_print_string("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||
dogm128_set_cursor(0, 48);
|
||||
dogm128_print_string("abcdefghijklmnopqrstuvwxyz");
|
||||
dogm128_set_cursor(0, 40);
|
||||
dogm128_print_string(" !#$%&'()*+,-./0123456789");
|
||||
dogm128_set_cursor(0, 32);
|
||||
dogm128_print_string(":;<=>?@[\\]^_`{|}~");
|
||||
|
||||
dogm128_set_dot(10, 10);
|
||||
dogm128_set_dot(20, 10);
|
||||
dogm128_set_dot(30, 10);
|
||||
dogm128_set_dot(40, 10);
|
||||
dogm128_set_dot(50, 10);
|
||||
|
||||
dogm128_update_display();
|
||||
|
||||
gpio_set(GPIOB, GPIO7); /* LED1 off */
|
||||
while(1); /* Halt. */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
31
examples/other/dogm128/main.ld
Normal file
31
examples/other/dogm128/main.ld
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of the libopenstm32 project.
|
||||
*
|
||||
* Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Linker script for an STM32F103RBT6 board (128K flash, 20K RAM). */
|
||||
|
||||
/* Define memory regions. */
|
||||
MEMORY
|
||||
{
|
||||
rom (rx) : ORIGIN = 0x08000000, LENGTH = 128K
|
||||
ram (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
|
||||
}
|
||||
|
||||
/* Include the common ld script from libopenstm32. */
|
||||
INCLUDE libopenstm32.ld
|
||||
|
||||
Reference in New Issue
Block a user