OSDN Git Service

Added NT-Logger example project.
authorShinichiro Nakamura <shinta.main.jp@gmail.com>
Sun, 26 Aug 2012 21:21:47 +0000 (06:21 +0900)
committerShinichiro Nakamura <shinta.main.jp@gmail.com>
Sun, 26 Aug 2012 21:21:47 +0000 (06:21 +0900)
firm/bare_metal/ntlogger_example/Makefile [new file with mode: 0644]
firm/bare_metal/ntlogger_example/main.c [new file with mode: 0644]

diff --git a/firm/bare_metal/ntlogger_example/Makefile b/firm/bare_metal/ntlogger_example/Makefile
new file mode 100644 (file)
index 0000000..39de4d1
--- /dev/null
@@ -0,0 +1,230 @@
+#
+# Project name (also used for output file name)
+#
+PROJECT = bluetank
+
+#
+# Source files and search directories
+#
+CSRC   += lcd.c led.c rotenc.c
+CSRC   += mmc.c pff.c
+CSRC   += twi.c uart.c
+CSRC   += ssm2603.c at24c.c
+CSRC   += bfin_util.c uzura.c
+CSRC   += tinyrand.c
+CSRC   += ntl.c ntlser.c
+CSRC   += effect.c system.c main.c
+ASRC   +=
+VPATH   = ../common/ ../common/ntlogger
+
+#
+# Optimization level (0, 1, 2, 3, 4 or s)
+#
+OPTIMIZE = s
+
+#
+# C Standard level (c89, gnu89, c99 or gnu99)
+#
+CSTD = gnu89
+
+#
+# Processor type for CSRC/ASRC files.
+#
+CPU = bf592-any
+
+#
+# Linker script for the target MCU
+#
+LINKSCRIPT =
+
+#
+# Output file format (ihex, bin or both) and debugger type
+#
+OUTPUT  = ihex
+DEBUG   = dwarf-2
+
+#
+# Include dirs, library dirs and definitions
+#
+LIBS    =
+LIBDIRS =
+INCDIRS = ../common/ ../common/ntlogger
+DEFS    =
+ADEFS   =
+
+#
+# Warning contorls
+#
+WARNINGS = all extra
+
+#
+# Object output directory
+#
+OBJDIR = obj
+
+#
+# Programs to build porject
+#
+CC      = bfin-elf-gcc
+OBJCOPY = bfin-elf-objcopy
+OBJDUMP = bfin-elf-objdump
+SIZE    = bfin-elf-size
+NM      = bfin-elf-nm
+
+#
+# Define all object files
+#
+COBJ      = $(CSRC:.c=.o)
+AOBJ      = $(ASRC:.S=.o)
+COBJ      := $(addprefix $(OBJDIR)/,$(COBJ))
+AOBJ      := $(addprefix $(OBJDIR)/,$(AOBJ))
+PROJECT   := $(OBJDIR)/$(PROJECT)
+
+#
+# Flags for C files
+#
+CFLAGS += -std=$(CSTD)
+CFLAGS += -g$(DEBUG)
+CFLAGS += -O$(OPTIMIZE)
+CFLAGS += -fmessage-length=0
+CFLAGS += $(addprefix -W,$(WARNINGS))
+CFLAGS += $(addprefix -I,$(INCDIRS))
+CFLAGS += $(addprefix -D,$(DEFS))
+CFLAGS += -Wp,-M,-MP,-MT,$(OBJDIR)/$(*F).o,-MF,$(OBJDIR)/$(*F).d
+
+#
+# Assembler flags
+#
+ASFLAGS += $(addprefix -D,$(ADEFS)) -Wa,-g$(DEBUG)
+
+#
+# Linker flags
+#
+LDFLAGS += -Wl,-Map=$(PROJECT).map,--cref,--gc-sections
+LDFLAGS += -lc -lgcc
+LDFLAGS += $(patsubst %,-L%,$(LIBDIRS)) $(patsubst %,-l%,$(LIBS))
+#LDFLAGS += -T$(LINKSCRIPT)
+#LDFLAGS += -nostartfiles
+#LDFLAGS += -nodefaultlibs
+#LDFLAGS += -nostdlib
+#LDFLAGS += -fno-builtin
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS  = -mcpu=$(CPU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mcpu=$(CPU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+#
+# Default target.
+#
+all: version build size
+
+ifeq ($(OUTPUT),ihex)
+build: elf hex lst sym
+hex: $(PROJECT).hex
+else
+ifeq ($(OUTPUT),binary)
+build: elf bin lst sym
+bin: $(PROJECT).bin
+else
+ifeq ($(OUTPUT),both)
+build: elf hex bin lst sym
+hex: $(PROJECT).hex
+bin: $(PROJECT).bin
+else
+$(error "Invalid format: $(OUTPUT)")
+endif
+endif
+endif
+
+elf: $(PROJECT).elf
+lst: $(PROJECT).lst
+sym: $(PROJECT).sym
+
+#
+# Display compiler version information.
+#
+version :
+       @$(CC) --version
+
+#
+# Create final output file (.hex or .bin) from ELF output file.
+#
+%.hex: %.elf
+       @echo
+       $(OBJCOPY) -O ihex $< $@
+
+%.bin: %.elf
+       @echo
+       $(OBJCOPY) -O binary $< $@
+
+#
+# Create extended listing file from ELF output file.
+#
+%.lst: %.elf
+       @echo
+       $(OBJDUMP) -h -S -C $< > $@
+
+#
+# Create a symbol table from ELF output file.
+#
+%.sym: %.elf
+       @echo
+       $(NM) -n $< > $@
+
+#
+# Display size of file.
+#
+size:
+       @echo
+       $(SIZE) -A $(PROJECT).elf
+
+#
+# Link: create ELF output file from object files.
+#
+%.elf:  $(AOBJ) $(COBJ)
+       @echo
+       @echo Linking...
+       $(CC) $(ALL_CFLAGS) $(AOBJ) $(COBJ) --output $@ $(LDFLAGS)
+
+#
+# Compile: create object files from C source files.
+#
+$(COBJ) : $(OBJDIR)/%.o : %.c
+       @echo
+       @echo $< :
+       $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+#
+# Assemble: create object files from assembler source files.
+#
+$(AOBJ) : $(OBJDIR)/%.o : %.S
+       @echo
+       @echo $< :
+       $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+#
+# Target: clean project.
+#
+clean:
+       @echo
+       rm -f -r $(OBJDIR) | exit 0
+
+#
+# Load: Load ldr for Blackfin
+#
+load:
+       bfin-elf-ldr -T BF592 -c $(PROJECT).ldr $(PROJECT).elf
+       bfin-elf-ldr -l $(PROJECT).ldr /dev/ttyUSB0 -b 57600 -C
+
+#
+# Console: Console
+#
+console:
+       minicom -b 57600 -D /dev/ttyUSB0
+
+#
+# Include the dependency files.
+#
+-include $(shell mkdir $(OBJDIR) 2>/dev/null) $(wildcard $(OBJDIR)/*.d)
+
diff --git a/firm/bare_metal/ntlogger_example/main.c b/firm/bare_metal/ntlogger_example/main.c
new file mode 100644 (file)
index 0000000..9972fab
--- /dev/null
@@ -0,0 +1,96 @@
+/**
+ * @file main.c
+ * @author Copyright(C) 2012 Shinichiro Nakamura
+ * @brief BlueTank ACB-BF592 Application Sample Codes.
+ */
+
+/*
+ * ===============================================================
+ *  BlueTank
+ * ===============================================================
+ * Copyright (c) 2012 Shinichiro Nakamura
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ * ===============================================================
+ */
+
+#include <stdlib.h>
+#include "uzura.h"
+#include "effect.h"
+#include "system.h"
+#include "ntl.h"
+#include "lcd.h"
+
+typedef struct {
+    UZURA uzura;
+} work_t;
+
+static void s_effect_through(
+        UZURA *p,
+        const int32_t *src, int32_t *des, int32_t count)
+{
+    int i;
+    NTL_EVENT_START(0, 0);
+    UZURA_LEVEL_INPUT(p).left = 0;
+    UZURA_LEVEL_INPUT(p).right = 0;
+    UZURA_LEVEL_OUTPUT(p).left = 0;
+    UZURA_LEVEL_OUTPUT(p).right = 0;
+    for (i = 0; i < count; i+=2) {
+        *(des + i + 0) = *(src + i + 0);
+        *(des + i + 1) = *(src + i + 1);
+        UZURA_LEVEL_INPUT(p).left += abs(*(src + i + 0)) >> 1;
+        UZURA_LEVEL_INPUT(p).right += abs(*(src + i + 1)) >> 1;
+        UZURA_LEVEL_OUTPUT(p).left += abs(*(des + i + 0)) >> 1;
+        UZURA_LEVEL_OUTPUT(p).right += abs(*(des + i + 1)) >> 1;
+    }
+    NTL_EVENT_END(0, 0);
+}
+
+static void s_system_default(UZURA *p)
+{
+    NTL_EVENT_START(1, 0);
+    lcd_goto(0, 0);
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).left   >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).right  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).left  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).right >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).left   >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_INPUT(p).right  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).left  >> 29));
+    lcd_putc(0x08 + (UZURA_LEVEL_OUTPUT(p).right >> 29));
+    NTL_EVENT_END(1, 0);
+}
+
+int main(void)
+{
+    work_t w;
+
+    ntl_init();
+    effect_param_init();
+    uzura_init(&w.uzura, &w);
+    uzura_set_effect(&w.uzura, s_effect_through);
+    uzura_set_system(&w.uzura, s_system_default);
+    uzura_execute(&w.uzura);
+
+    return 0;
+}
+