]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Fix print and timer
authortmk <nobody@nowhere>
Mon, 16 Jun 2014 06:38:39 +0000 (15:38 +0900)
committertmk <nobody@nowhere>
Wed, 30 Jul 2014 05:07:43 +0000 (14:07 +0900)
common/avr/timer_avr.h [new file with mode: 0644]
common/avr/xprintf.S [moved from common/xprintf.S with 100% similarity]
common/avr/xprintf.h [moved from common/xprintf.h with 100% similarity]
common/debug.h
common/debug_config.h
common/mbed/timer.c
common/nodebug.h
common/print.h
keyboard/mbed_onekey/common.mk

diff --git a/common/avr/timer_avr.h b/common/avr/timer_avr.h
new file mode 100644 (file)
index 0000000..0e85eb1
--- /dev/null
@@ -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
similarity index 100%
rename from common/xprintf.S
rename to common/avr/xprintf.S
similarity index 100%
rename from common/xprintf.h
rename to common/avr/xprintf.h
index 399b2d0a7c5f211feb5cb02ac366828bbb1ec47b..8ca2569a49653d7e088ec647b6974172a503bc54 100644 (file)
@@ -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 { \
index e00fd10336768d2e8a0d289c6fe9aedcfdd7d8d4..0e67ee49f46274bb7043217b7058b64c5c5fd346 100644 (file)
@@ -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
index a64a77239cd8073065bd904f1328706c91732bd1..c357ceb7863c92c07fd94f86da54c7642e8d2e2f 100644 (file)
@@ -11,6 +11,7 @@ void SysTick_Handler(void)  {
 
 void timer_init(void)
 {
+    timer_count = 0;
     SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
 }
 
index aec790bbc15c5f4f5f3cdff3c8ddcc17e88fc787..8ef123f9fdff464fd749b67e5e0442309c6b94dc 100644 (file)
@@ -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, ...)
index 6a6771f7100acebe523bd9aeaeea2d977bc50255..4001bcf1b5de6d5005cdc1adc5581b271202d6e2 100644 (file)
@@ -35,7 +35,7 @@
 #ifndef NO_PRINT
 
 
-#ifdef __AVR__
+#if defined(__AVR__)
 
 #include "xprintf.h"
 
 #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)
 
index 975ae9d0dae2c8bcc2e73b3b9e54608791b9c126..101a82205296889f089bb8bac936e06bc9dea386 100644 (file)
@@ -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 \