From: tmk Date: Mon, 24 Nov 2014 04:50:33 +0000 (+0900) Subject: Merge branch 'rn42' into merge_rn42 X-Git-Url: https://git.donarmstrong.com/?p=tmk_firmware.git;a=commitdiff_plain;h=363950982a291c3bfa03ac6362061b1d37dc06b0 Merge branch 'rn42' into merge_rn42 Conflicts: .gitignore common.mk common/debug_config.h common/print.h --- 363950982a291c3bfa03ac6362061b1d37dc06b0 diff --cc .gitignore index 0fd85b5,b79d72b..f3f4687 --- a/.gitignore +++ b/.gitignore @@@ -8,4 -8,5 +8,6 @@@ *.map *.sym tags +*~ + build/ + *.bak diff --cc common.mk index 1cffc3c,04f0364..b854f09 --- a/common.mk +++ b/common.mk @@@ -7,13 -7,12 +7,13 @@@ SRC += $(COMMON_DIR)/host.c $(COMMON_DIR)/action_layer.c \ $(COMMON_DIR)/action_util.c \ $(COMMON_DIR)/keymap.c \ - $(COMMON_DIR)/timer.c \ $(COMMON_DIR)/print.c \ + $(COMMON_DIR)/debug.c \ - $(COMMON_DIR)/bootloader.c \ - $(COMMON_DIR)/suspend.c \ - $(COMMON_DIR)/xprintf.S \ - $(COMMON_DIR)/util.c + $(COMMON_DIR)/util.c \ + $(COMMON_DIR)/avr/suspend.c \ + $(COMMON_DIR)/avr/xprintf.S \ + $(COMMON_DIR)/avr/timer.c \ + $(COMMON_DIR)/avr/bootloader.c # Option modules diff --cc common/avr/xprintf.h index 0000000,f58bca8..59c6f253 mode 000000,100644..100644 --- a/common/avr/xprintf.h +++ b/common/avr/xprintf.h @@@ -1,0 -1,103 +1,111 @@@ + /*--------------------------------------------------------------------------- + Extended itoa, puts and printf (C)ChaN, 2011 + -----------------------------------------------------------------------------*/ + + #ifndef XPRINTF_H + #define XPRINTF_H + + #include + #include + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ + extern void (*xfunc_out)(uint8_t); + #define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func) + + /* This is a pointer to user defined output function. It must be initialized + before using this modle. + */ + + void xputc(char chr); + + /* This is a stub function to forward outputs to user defined output function. + All outputs from this module are output via this function. + */ + + + /*-----------------------------------------------------------------------------*/ + void xputs(const char *string_p); + + /* The string placed in the ROM is forwarded to xputc() directly. + */ + + + /*-----------------------------------------------------------------------------*/ + void xitoa(long value, char radix, char width); + + /* Extended itoa(). + + value radix width output + 100 10 6 " 100" + 100 10 -6 "000100" + 100 10 0 "100" + 4294967295 10 0 "4294967295" + 4294967295 -10 0 "-1" + 655360 16 -8 "000A0000" + 1024 16 0 "400" + 0x55 2 -8 "01010101" + */ + + + /*-----------------------------------------------------------------------------*/ + #define xprintf(format, ...) __xprintf(PSTR(format), ##__VA_ARGS__) + #define xsprintf(str, format, ...) __xsprintf(str, PSTR(format), ##__VA_ARGS__) + #define xfprintf(func, format, ...) __xfprintf(func, PSTR(format), ##__VA_ARGS__) + + void __xprintf(const char *format_p, ...); /* Send formatted string to the registered device */ + void __xsprintf(char*, const char *format_p, ...); /* Put formatted string to the memory */ + void __xfprintf(void(*func)(uint8_t), const char *format_p, ...); /* Send formatted string to the specified device */ + + /* Format string is placed in the ROM. The format flags is similar to printf(). + + %[flag][width][size]type + + flag + A '0' means filled with '0' when output is shorter than width. + ' ' is used in default. This is effective only numeral type. + width + Minimum width in decimal number. This is effective only numeral type. + Default width is zero. + size + A 'l' means the argument is long(32bit). Default is short(16bit). + This is effective only numeral type. + type + 'c' : Character, argument is the value + 's' : String placed on the RAM, argument is the pointer + 'S' : String placed on the ROM, argument is the pointer + 'd' : Signed decimal, argument is the value + 'u' : Unsigned decimal, argument is the value + 'X' : Hexdecimal, argument is the value + 'b' : Binary, argument is the value + '%' : '%' + + */ + + + /*-----------------------------------------------------------------------------*/ + char xatoi(char **str, long *ret); + + /* Get value of the numeral string. + + str + Pointer to pointer to source string + + "0b11001010" binary + "0377" octal + "0xff800" hexdecimal + "1250000" decimal + "-25000" decimal + + ret + Pointer to return value + */ + ++#ifdef __cplusplus ++} ++#endif ++ + #endif + diff --cc common/debug.h index 8aaa5ed,26472c8..472dd47 --- a/common/debug.h +++ b/common/debug.h @@@ -19,22 -19,54 +19,54 @@@ along with this program. If not, see < #define DEBUG_H 1 #include "print.h" - #include "debug_config.h" + /* + * Debug output control + */ + #ifdef __cplusplus + extern "C" { + #endif + + typedef union { - uint8_t raw; + struct { + bool enable:1; + bool matrix:1; + bool keyboard:1; + bool mouse:1; + uint8_t reserved:4; + }; ++ uint8_t raw; + } debug_config_t; + + extern debug_config_t debug_config; + debug_config_t debug_config __attribute__ ((weak)) = {}; + + #ifdef __cplusplus + } + #endif + + #define debug_enable (debug_config.enable) + #define debug_matrix (debug_config.matrix) + #define debug_keyboard (debug_config.keyboard) + #define debug_mouse (debug_config.mouse) + + + + /* + * Debug print utils + */ #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 dprintf(fmt, ...) do { if (debug_enable) __xprintf(PSTR(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 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 { \ + #define dprint(s) do { if (debug_enable) print(s); } 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)) + + /* Deprecated. DO NOT USE these anymore, use dprintf instead. */ + #define debug(s) do { if (debug_enable) print(s); } while (0) + #define debugln(s) do { if (debug_enable) println(s); } while (0) + #define debug_msg(s) do { \ if (debug_enable) { \ print(__FILE__); print(" at "); print_dec(__LINE__); print(" in "); print(": "); print(s); \ } \