summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/avr/timer_avr.h42
-rw-r--r--common/avr/xprintf.S (renamed from common/xprintf.S)0
-rw-r--r--common/avr/xprintf.h (renamed from common/xprintf.h)0
-rw-r--r--common/debug.h4
-rw-r--r--common/debug_config.h9
-rw-r--r--common/mbed/timer.c1
-rw-r--r--common/nodebug.h2
-rw-r--r--common/print.h16
-rw-r--r--keyboard/mbed_onekey/common.mk3
9 files changed, 60 insertions, 17 deletions
diff --git a/common/avr/timer_avr.h b/common/avr/timer_avr.h
new file mode 100644
index 000000000..0e85eb101
--- /dev/null
+++ b/common/avr/timer_avr.h
@@ -0,0 +1,42 @@
+/*
+Copyright 2011 Jun Wako <wakojun@gmail.com>
+
+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 2 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 TIMER_AVR_H
+#define TIMER_AVR_H 1
+
+#include <stdint.h>
+
+#ifndef TIMER_PRESCALER
+# if F_CPU > 16000000
+# define TIMER_PRESCALER 256
+# elif F_CPU > 2000000
+# define TIMER_PRESCALER 64
+# elif F_CPU > 250000
+# define TIMER_PRESCALER 8
+# else
+# define TIMER_PRESCALER 1
+# endif
+#endif
+#define TIMER_RAW_FREQ (F_CPU/TIMER_PRESCALER)
+#define TIMER_RAW TCNT0
+#define TIMER_RAW_TOP (TIMER_RAW_FREQ/1000)
+
+#if (TIMER_RAW_TOP > 255)
+# error "Timer0 can't count 1ms at this clock freq. Use larger prescaler."
+#endif
+
+#endif
diff --git a/common/xprintf.S b/common/avr/xprintf.S
index 0cec70ce2..0cec70ce2 100644
--- a/common/xprintf.S
+++ b/common/avr/xprintf.S
diff --git a/common/xprintf.h b/common/avr/xprintf.h
index f58bca817..f58bca817 100644
--- a/common/xprintf.h
+++ b/common/avr/xprintf.h
diff --git a/common/debug.h b/common/debug.h
index 399b2d0a7..8ca2569a4 100644
--- a/common/debug.h
+++ b/common/debug.h
@@ -25,13 +25,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NO_DEBUG
#define dprint(s) do { if (debug_enable) print(s); } while (0)
-#define dprintln() do { if (debug_enable) print_crlf(); } while (0)
+#define dprintln(s) do { if (debug_enable) println(s); } while (0)
#define dprintf(fmt, ...) do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0)
#define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s))
/* DO NOT USE these anymore */
#define debug(s) do { if (debug_enable) print(s); } while (0)
-#define debugln(s) do { if (debug_enable) print_crlf(); } while (0)
+#define debugln(s) do { if (debug_enable) println(s); } while (0)
#define debug_S(s) do { if (debug_enable) print_S(s); } while (0)
#define debug_P(s) do { if (debug_enable) print_P(s); } while (0)
#define debug_msg(s) do { \
diff --git a/common/debug_config.h b/common/debug_config.h
index e00fd1033..0e67ee49f 100644
--- a/common/debug_config.h
+++ b/common/debug_config.h
@@ -38,14 +38,15 @@ typedef union {
} debug_config_t;
debug_config_t debug_config;
+#ifdef __cplusplus
+}
+#endif
+
+
/* for backward compatibility */
#define debug_enable (debug_config.enable)
#define debug_matrix (debug_config.matrix)
#define debug_keyboard (debug_config.keyboard)
#define debug_mouse (debug_config.mouse)
-#ifdef __cplusplus
-}
-#endif
-
#endif
diff --git a/common/mbed/timer.c b/common/mbed/timer.c
index a64a77239..c357ceb78 100644
--- a/common/mbed/timer.c
+++ b/common/mbed/timer.c
@@ -11,6 +11,7 @@ void SysTick_Handler(void) {
void timer_init(void)
{
+ timer_count = 0;
SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
}
diff --git a/common/nodebug.h b/common/nodebug.h
index aec790bbc..8ef123f9f 100644
--- a/common/nodebug.h
+++ b/common/nodebug.h
@@ -18,8 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NODEBUG_H
#define NODEBUG_H 1
-#include "debug_config.h"
-
#define dprint(s)
#define dprintln(s)
#define dprintf(fmt, ...)
diff --git a/common/print.h b/common/print.h
index 6a6771f71..4001bcf1b 100644
--- a/common/print.h
+++ b/common/print.h
@@ -35,7 +35,7 @@
#ifndef NO_PRINT
-#ifdef __AVR__
+#if defined(__AVR__)
#include "xprintf.h"
@@ -44,21 +44,21 @@
#ifndef __cplusplus
#define print(s) xputs(PSTR(s))
#endif
-#define println(s) xputs(PSTR(s "\n"))
+#define println(s) xputs(PSTR(s "\r\n"))
#ifdef __cplusplus
-extern "C" {
+extern "C"
#endif
/* function pointer of sendchar to be used by print utility */
void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
-#elif __arm__
+#elif defined(__arm__)
+
+#include "mbed/xprintf.h"
-#include "mbed.h"
-Serial ser(UART_TX, UART_RX);
-#define xprintf ser.printf
#define print(s) xprintf(s)
-#define println(s) xprintf(s "\n")
+#define println(s) xprintf(s "\r\n")
+
/* TODO: to select output destinations: UART/USBSerial */
#define print_set_sendchar(func)
diff --git a/keyboard/mbed_onekey/common.mk b/keyboard/mbed_onekey/common.mk
index 975ae9d0d..101a82205 100644
--- a/keyboard/mbed_onekey/common.mk
+++ b/keyboard/mbed_onekey/common.mk
@@ -1,16 +1,17 @@
COMMON_DIR = common
OBJECTS += \
$(OBJDIR)/$(COMMON_DIR)/mbed/timer.o \
+ $(OBJDIR)/$(COMMON_DIR)/mbed/xprintf.o \
INCLUDE_PATHS += \
-I$(TMK_DIR)/$(COMMON_DIR)
+# $(OBJDIR)/$(COMMON_DIR)/action.o \
# $(OBJDIR)/$(COMMON_DIR)/host.o \
# $(OBJDIR)/$(COMMON_DIR)/keyboard.o \
-# $(OBJDIR)/$(COMMON_DIR)/action.o \
# $(OBJDIR)/$(COMMON_DIR)/action_tapping.o \
# $(OBJDIR)/$(COMMON_DIR)/action_macro.o \
# $(OBJDIR)/$(COMMON_DIR)/action_layer.o \