Skip to content

Commit

Permalink
msp430 makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
olikraus committed Jan 24, 2015
1 parent e30c5d0 commit 6d90d3f
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 4 deletions.
40 changes: 36 additions & 4 deletions prj/bdf/bdf2bin.c
Expand Up @@ -93,7 +93,7 @@ ISO-8859-1 was incorporated as the first 256 code points of ISO/IEC 10646 and Un
#define BDF2U8G_COMPACT_OUTPUT
#define BDF2U8G_VERSION "1.02"

//#define VERBOSE
#define VERBOSE


/*=== forward declaration ===*/
Expand Down Expand Up @@ -625,7 +625,14 @@ void fd_decode(fd_t *fd)
}
}


/*
Desc:
Output a field to the bitstream. The field size in bits is given by "cnt" and
the value of the field is "val".
Args:
cnt: Fieldsize in bits
val: The value (content) of the field. Sidecondition: val < (1<<cnt) && val >= 0
*/
void bd_out_bits(int cnt, int val)
{
int i;
Expand Down Expand Up @@ -669,6 +676,23 @@ void bd_out_bits(int cnt, int val)
}
}

/*
Desc:
Output a and b to the stream.
a and b must fit to the target size in bits.
Additionally a repeat code r (one bit) is generated:
It may look like this:
r = 0: 0aaaabb
or
r = 1: 1
If r is 0, then the number of zeros (a) and ones (b) will follow and both
values must be stored as in the decoder.
If r os 1, then the number of zeros and ones is repeated once
Args:
a: number of 0 bits, log2(a) must be smaller or equal to the fieldsize
b: number of 1 bits, log2(b) must be smaller or equal to the fieldsize
is_expand: obsolete?
*/

void bd_rle(int a, int b, int is_expand)
{
Expand Down Expand Up @@ -704,6 +728,15 @@ void bd_rle(int a, int b, int is_expand)
}
}

/*
Desc:
Write the number of zeros and ones to the bit stream.
There is no restriction on the size of a and b.
Args:
a: number of 0 bits
b: number of 1 bits
*/
void bd_expand(int a, int b)
{
while( a >= (1<<bd_bits_per_0) -1 )
Expand Down Expand Up @@ -768,8 +801,7 @@ int bd_compress(void)
{
byte = x >> 3;
bit = 7-(x & 7);



if ( (bdf_bitmap_line[y][byte] & (1<<bit)) == 0 )
{
if ( (delta_pos & 1 ) != 0 )
Expand Down
1 change: 1 addition & 0 deletions prj/bdf/do.sh
Expand Up @@ -2,3 +2,4 @@ gcc -g bdf2bin.c -o bdf2bin
./bdf2bin -b 32 -e 90 -0 4 -1 3 -w 5 -h 4 -x 3 -y 4 -d 5 helvR14small.bdf helvR14small helvR14small.c
./bdf2bin -b 48 -e 58 -0 5 -1 5 -w 5 -h 6 -x 5 -y 4 -d 5 logisoso46.bdf logisoso46 logisoso46.c
./bdf2bin -b 32 -e 90 -0 4 -1 2 -w 4 -h 4 -x 3 -y 4 -d 4 helvR12small.bdf helvR12small helvR12small.c
./bdf2bin -b 32 -e 127 -0 4 -1 2 -w 4 -h 5 -x 3 -y 4 -d 4 helvR12small.bdf helvR12small helvR12small.c
136 changes: 136 additions & 0 deletions sys/msp430/hello_world/Makefile.msp430gnu
@@ -0,0 +1,136 @@
#
# Generic and Simple Atmel AVR GNU Makefile
#
# Desinged for the gnu-avr tool chain
#
# Universal 8bit Graphics Library
#
# Copyright (c) 2012, olikraus@gmail.com
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this list
# of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Features
# - upload
# - create exe from library
# - create assembler listing (.dis)
#
# Limitations
# - only C-files supported
# - no automatic dependency checking (call 'make clean' if any .h files are changed)
#
# Targets:
# make
# create hex file, no upload
# make upload
# create and upload hex file
# make clean
# delete all generated files
#
# Note:
# Display list make database: make -p -f/dev/null | less

#================================================
# Project Information
TARGETNAME = u8g_hello_world
MCU:=msp430f5529
DMCU:=__MSP430F5529__
F_CPU:=1000000
MSRC = hello_world.c
U8GDIR = ../../../csrc/
FONTDIR = ../../../sfntsrc/


#================================================
# System/Environment Information
#TIPATH:=/usr/local/ti/ccsv6
TIPATH:=/home/kraus/prg/ti/gcc/
#MSP430GCC:=gcc_msp430_4.9.14r1_10
#TOOLSPATH:=$(TIPATH)/tools/compiler/$(MSP430GCC)/bin/
TOOLSPATH:=/home/kraus/prg/ti/gcc/bin/
# Add proper arguments for tiflahser
MSP430HEX:=


#================================================
# Main part of the Makefile starts here. Usually no changes are needed.

# Append U(G Library
SRC = system_pre_init.c
SRC += $(shell ls $(U8GDIR)*.c)
SRC += $(shell ls $(FONTDIR)*.c)

# Internal Variable Names
LIBNAME:=$(TARGETNAME).a
ELFNAME:=$(TARGETNAME).elf
HEXNAME:=$(TARGETNAME).hex
DISNAME:=$(TARGETNAME).dis
OBJ := $(SRC:.c=.o)
MOBJ := $(MSRC:.c=.o)
# GNU compiler
CC = $(TOOLSPATH)msp430-elf-gcc
CXX = $(TOOLSPATH)msp430-elf-g++
AR = $(TOOLSPATH)msp430-elf-ar
# GNU Tools
OBJCOPY:=$(TOOLSPATH)msp430-elf-objcopy
OBJDUMP:=$(TOOLSPATH)msp430-elf-objdump
SIZE:=$(TOOLSPATH)msp430-elf-size
# C flags
COMMON_FLAGS = -DF_CPU=$(F_CPU) -D$(DMCU) -mmcu=$(MCU)
COMMON_FLAGS += -g -Os -Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
COMMON_FLAGS += -I. -I$(U8GDIR) -I$(TIPATH)/include
COMMON_FLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
COMMON_FLAGS += -Wl,--relax
COMMON_FLAGS +=
CFLAGS = $(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes
# Linker script
LDLIBS = -T $(TIPATH)/include/$(MCU).ld

# Additional Suffixes
.SUFFIXES: .elf .hex .dis

# Targets
.PHONY: all
all: $(DISNAME) $(HEXNAME)
$(SIZE) $(ELFNAME)

.PHONY: upload
upload: $(DISNAME) $(HEXNAME)
$(SIZE) $(ELFNAME)

.PHONY: clean
clean:
$(RM) $(HEXNAME) $(ELFNAME) $(LIBNAME) $(DISNAME) $(OBJ) $(MOBJ)

# implicit rules
.elf.hex:
$(OBJCOPY) -O ihex -R .eeprom $< $@

# explicit rules
$(ELFNAME): $(LIBNAME)($(OBJ)) $(MOBJ)
$(LINK.o) $(COMMON_FLAGS) $(MOBJ) $(LIBNAME) $(LOADLIBES) $(LDLIBS) -o $@

$(DISNAME): $(ELFNAME)
$(OBJDUMP) -S $< > $@

0 comments on commit 6d90d3f

Please sign in to comment.