]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Merge branch 'rn42' into merge_rn42
authortmk <nobody@nowhere>
Mon, 24 Nov 2014 04:50:33 +0000 (13:50 +0900)
committertmk <nobody@nowhere>
Mon, 24 Nov 2014 04:50:33 +0000 (13:50 +0900)
Conflicts:
.gitignore
common.mk
common/debug_config.h
common/print.h

1  2 
.gitignore
common.mk
common/action.c
common/avr/xprintf.h
common/debug.h
common/keyboard.c
protocol.mk

diff --combined .gitignore
index 0fd85b53143e75f8b4c4ebdee59d1d30520b2644,b79d72b7c7ae72142099d4e3b9efa6d3e54d7f99..f3f46872a07e990dcf0f8dca6c8de554d0fdce66
@@@ -8,4 -8,5 +8,6 @@@
  *.map
  *.sym
  tags
 +*~
+ build/
+ *.bak
diff --combined common.mk
index 1cffc3cc22c5d7b46adf24267a50c2d612f3b115,04f036477115de2a1410d5e7fb517ec3f2d2ed2c..b854f09cdbf98a0dd2d872d084140911e20c293e
+++ b/common.mk
@@@ -7,19 -7,18 +7,19 @@@ 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)/bootloader.c \
-       $(COMMON_DIR)/suspend.c \
-       $(COMMON_DIR)/xprintf.S \
-       $(COMMON_DIR)/util.c
 +      $(COMMON_DIR)/debug.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
  ifdef BOOTMAGIC_ENABLE
      SRC += $(COMMON_DIR)/bootmagic.c
-     SRC += $(COMMON_DIR)/eeconfig.c
+     SRC += $(COMMON_DIR)/avr/eeconfig.c
      OPT_DEFS += -DBOOTMAGIC_ENABLE
  endif
  
diff --combined common/action.c
index 83bc8a6187990b9dc16ce2d9259d43af307acfa5,94498fe6cb33e456069537ab9feffc721016e52c..ec8eeae7bc8b7bfb6f8e372ce9acc097b4351948
@@@ -237,16 -237,6 +237,16 @@@ void process_action(keyrecord_t *record
          case ACT_LAYER_TAP:
          case ACT_LAYER_TAP_EXT:
              switch (action.layer_tap.code) {
 +                case 0xe0 ... 0xef:
 +                    /* layer On/Off with modifiers(left only) */
 +                    if (event.pressed) {
 +                        layer_on(action.layer_tap.val);
 +                        register_mods(action.layer_tap.code & 0x0f);
 +                    } else {
 +                        layer_off(action.layer_tap.val);
 +                        unregister_mods(action.layer_tap.code & 0x0f);
 +                    }
 +                    break;
                  case OP_TAP_TOGGLE:
                      /* tap toggle */
                      if (event.pressed) {
@@@ -509,7 -499,7 +509,7 @@@ void clear_keyboard_but_mods(void
  #endif
  }
  
- bool is_tap_key(key_t key)
+ bool is_tap_key(keypos_t key)
  {
      action_t action = layer_switch_get_action(key);
  
diff --combined common/avr/xprintf.h
index 0000000000000000000000000000000000000000,f58bca817be791356cc11b2aed9a16841e03618d..59c6f253123957e4aa7527c0bdc5b47d392563ef
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,103 +1,111 @@@
+ /*---------------------------------------------------------------------------\r
+    Extended itoa, puts and printf                    (C)ChaN, 2011\r
+ -----------------------------------------------------------------------------*/\r
\r
+ #ifndef XPRINTF_H\r
+ #define XPRINTF_H\r
\r
+ #include <inttypes.h>\r
+ #include <avr/pgmspace.h>\r
\r
++#ifdef __cplusplus\r
++extern "C" {\r
++#endif\r
++\r
+ extern void (*xfunc_out)(uint8_t);\r
+ #define xdev_out(func) xfunc_out = (void(*)(uint8_t))(func)\r
\r
+ /* This is a pointer to user defined output function. It must be initialized\r
+    before using this modle.\r
+ */\r
\r
+ void xputc(char chr);\r
\r
+ /* This is a stub function to forward outputs to user defined output function.\r
+    All outputs from this module are output via this function.\r
+ */\r
\r
\r
+ /*-----------------------------------------------------------------------------*/\r
+ void xputs(const char *string_p);\r
\r
+ /*  The string placed in the ROM is forwarded to xputc() directly.\r
+ */\r
\r
\r
+ /*-----------------------------------------------------------------------------*/\r
+ void xitoa(long value, char radix, char width);\r
\r
+ /* Extended itoa().\r
\r
+       value  radix  width   output\r
+         100     10      6   "   100"\r
+         100     10     -6   "000100"\r
+         100     10      0   "100"\r
+  4294967295     10      0   "4294967295"\r
+  4294967295    -10      0   "-1"\r
+      655360     16     -8   "000A0000"\r
+        1024     16      0   "400"\r
+        0x55      2     -8   "01010101"\r
+ */\r
\r
\r
+ /*-----------------------------------------------------------------------------*/\r
+ #define xprintf(format, ...)            __xprintf(PSTR(format), ##__VA_ARGS__)\r
+ #define xsprintf(str, format, ...)      __xsprintf(str, PSTR(format), ##__VA_ARGS__)\r
+ #define xfprintf(func, format, ...)     __xfprintf(func, PSTR(format), ##__VA_ARGS__)\r
\r
+ void __xprintf(const char *format_p, ...);    /* Send formatted string to the registered device */\r
+ void __xsprintf(char*, const char *format_p, ...);    /* Put formatted string to the memory */\r
+ void __xfprintf(void(*func)(uint8_t), const char *format_p, ...); /* Send formatted string to the specified device */\r
\r
+ /* Format string is placed in the ROM. The format flags is similar to printf().\r
\r
+    %[flag][width][size]type\r
\r
+    flag\r
+      A '0' means filled with '0' when output is shorter than width.\r
+      ' ' is used in default. This is effective only numeral type.\r
+    width\r
+      Minimum width in decimal number. This is effective only numeral type.\r
+      Default width is zero.\r
+    size\r
+      A 'l' means the argument is long(32bit). Default is short(16bit).\r
+      This is effective only numeral type.\r
+    type\r
+      'c' : Character, argument is the value\r
+      's' : String placed on the RAM, argument is the pointer\r
+      'S' : String placed on the ROM, argument is the pointer\r
+      'd' : Signed decimal, argument is the value\r
+      'u' : Unsigned decimal, argument is the value\r
+      'X' : Hexdecimal, argument is the value\r
+      'b' : Binary, argument is the value\r
+      '%' : '%'\r
\r
+ */\r
\r
\r
+ /*-----------------------------------------------------------------------------*/\r
+ char xatoi(char **str, long *ret);\r
\r
+ /* Get value of the numeral string. \r
\r
+   str\r
+     Pointer to pointer to source string\r
\r
+     "0b11001010" binary\r
+     "0377" octal\r
+     "0xff800" hexdecimal\r
+     "1250000" decimal\r
+     "-25000" decimal\r
\r
+   ret\r
+     Pointer to return value\r
+ */\r
\r
++#ifdef __cplusplus\r
++}\r
++#endif\r
++\r
+ #endif\r
\r
diff --combined common/debug.h
index 8aaa5ed915e2b62a9ada6ff3b9e6b628cc21122c,26472c8fa3980725f8eea07e9568b3ee7eb749da..472dd478c407c4390600fc30dd89a2c747cb878c
@@@ -19,44 -19,100 +19,100 @@@ along with this program.  If not, see <
  #define DEBUG_H 1
  
  #include "print.h"
- #include "debug_config.h"
  
  
 -    uint8_t raw;
+ /* 
+  * Debug output control
+  */
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ typedef union {
+     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); \
      } \
  } while (0)
- #define debug_dec(data)           do { if (debug_enable) print_dec(data); } while (0)
- #define debug_decs(data)          do { if (debug_enable) print_decs(data); } while (0)
- #define debug_hex4(data)          do { if (debug_enable) print_hex4(data); } while (0)
- #define debug_hex8(data)          do { if (debug_enable) print_hex8(data); } while (0)
- #define debug_hex16(data)         do { if (debug_enable) print_hex16(data); } while (0)
- #define debug_hex32(data)         do { if (debug_enable) print_hex32(data); } while (0)
- #define debug_bin8(data)          do { if (debug_enable) print_bin8(data); } while (0)
- #define debug_bin16(data)         do { if (debug_enable) print_bin16(data); } while (0)
- #define debug_bin32(data)         do { if (debug_enable) print_bin32(data); } while (0)
- #define debug_bin_reverse8(data)  do { if (debug_enable) print_bin_reverse8(data); } while (0)
- #define debug_bin_reverse16(data) do { if (debug_enable) print_bin_reverse16(data); } while (0)
- #define debug_bin_reverse32(data) do { if (debug_enable) print_bin_reverse32(data); } while (0)
- #define debug_hex(data)           debug_hex8(data)
- #define debug_bin(data)           debug_bin8(data)
- #define debug_bin_reverse(data)   debug_bin8(data)
+ #define debug_dec(data)             do { if (debug_enable) print_dec(data); } while (0)
+ #define debug_decs(data)            do { if (debug_enable) print_decs(data); } while (0)
+ #define debug_hex4(data)            do { if (debug_enable) print_hex4(data); } while (0)
+ #define debug_hex8(data)            do { if (debug_enable) print_hex8(data); } while (0)
+ #define debug_hex16(data)           do { if (debug_enable) print_hex16(data); } while (0)
+ #define debug_hex32(data)           do { if (debug_enable) print_hex32(data); } while (0)
+ #define debug_bin8(data)            do { if (debug_enable) print_bin8(data); } while (0)
+ #define debug_bin16(data)           do { if (debug_enable) print_bin16(data); } while (0)
+ #define debug_bin32(data)           do { if (debug_enable) print_bin32(data); } while (0)
+ #define debug_bin_reverse8(data)    do { if (debug_enable) print_bin_reverse8(data); } while (0)
+ #define debug_bin_reverse16(data)   do { if (debug_enable) print_bin_reverse16(data); } while (0)
+ #define debug_bin_reverse32(data)   do { if (debug_enable) print_bin_reverse32(data); } while (0)
+ #define debug_hex(data)             debug_hex8(data)
+ #define debug_bin(data)             debug_bin8(data)
+ #define debug_bin_reverse(data)     debug_bin8(data)
  
  #else
- #include "nodebug.h"
+ /* NO_DEBUG */
+ #define dprint(s)
+ #define dprintln(s)
+ #define dprintf(fmt, ...)
+ #define dmsg(s)
+ #define debug(s)
+ #define debugln(s)
+ #define debug_msg(s)
+ #define debug_dec(data)
+ #define debug_decs(data)
+ #define debug_hex4(data)
+ #define debug_hex8(data)
+ #define debug_hex16(data)
+ #define debug_hex32(data)
+ #define debug_bin8(data)
+ #define debug_bin16(data)
+ #define debug_bin32(data)
+ #define debug_bin_reverse8(data)
+ #define debug_bin_reverse16(data)
+ #define debug_bin_reverse32(data)
+ #define debug_hex(data)
+ #define debug_bin(data)
+ #define debug_bin_reverse(data)
  #endif
  
  #endif
diff --combined common/keyboard.c
index 020be8eadf2f09ad9bc1e94a32e7e83c5730c09d,9a809ff4a153dbfca52f1a248cb9e001e26cfd06..1e3fb510a44d254d01a3b290ac6042764e785552
@@@ -15,7 -15,6 +15,6 @@@ You should have received a copy of the 
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
  #include <stdint.h>
- #include <util/delay.h>
  #include "keyboard.h"
  #include "matrix.h"
  #include "keymap.h"
@@@ -37,9 -36,6 +36,9 @@@
  #ifdef PS2_MOUSE_ENABLE
  #   include "ps2_mouse.h"
  #endif
 +#ifdef SERIAL_MOUSE_ENABLE
 +#include "serial_mouse.h"
 +#endif
  
  
  #ifdef MATRIX_HAS_GHOST
@@@ -67,10 -63,6 +66,10 @@@ void keyboard_init(void
  #ifdef PS2_MOUSE_ENABLE
      ps2_mouse_init();
  #endif
 +#ifdef SERIAL_MOUSE_ENABLE
 +    serial_mouse_init();
 +#endif
 +
  
  #ifdef BOOTMAGIC_ENABLE
      bootmagic();
@@@ -107,7 -99,7 +106,7 @@@ void keyboard_task(void
              for (uint8_t c = 0; c < MATRIX_COLS; c++) {
                  if (matrix_change & ((matrix_row_t)1<<c)) {
                      action_exec((keyevent_t){
-                         .key = (key_t){ .row = r, .col = c },
+                         .key = (keypos_t){ .row = r, .col = c },
                          .pressed = (matrix_row & ((matrix_row_t)1<<c)),
                          .time = (timer_read() | 1) /* time should not be 0 */
                      });
@@@ -133,10 -125,6 +132,10 @@@ MATRIX_LOOP_END
      ps2_mouse_task();
  #endif
  
 +#ifdef SERIAL_MOUSE_ENABLE
 +        serial_mouse_task();
 +#endif
 +
      // update LED
      if (led_status != host_keyboard_leds()) {
          led_status = host_keyboard_leds();
diff --combined protocol.mk
index de7014e866386c281774cc59e55a2442ecffd7c7,ca435ba43ca1acc2b7c3bb67705ea9eaccd851e0..e057d1d601e0f3d6af0fb5020491ca97686a3b39
@@@ -9,6 -9,7 +9,7 @@@ endi
  
  ifdef PS2_USE_BUSYWAIT
      SRC += protocol/ps2_busywait.c
+     SRC += protocol/ps2_io_avr.c
      OPT_DEFS += -DPS2_USE_BUSYWAIT
  endif
  
@@@ -23,25 -24,5 +24,25 @@@ ifdef PS2_USE_USAR
  endif
  
  
 +ifdef SERIAL_MOUSE_MICROSOFT_ENABLE
 +    SRC += $(PROTOCOL_DIR)/serial_mouse_microsoft.c
 +    OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MICROSOFT \
 +                -DMOUSE_ENABLE
 +endif
 +
 +ifdef SERIAL_MOUSE_MOUSESYSTEMS_ENABLE
 +    SRC += $(PROTOCOL_DIR)/serial_mouse_mousesystems.c
 +    OPT_DEFS += -DSERIAL_MOUSE_ENABLE -DSERIAL_MOUSE_MOUSESYSTEMS \
 +                -DMOUSE_ENABLE
 +endif
 +
 +ifdef SERIAL_MOUSE_USE_SOFT
 +    SRC += $(PROTOCOL_DIR)/serial_soft.c
 +endif
 +
 +ifdef SERIAL_MOUSE_USE_UART
 +    SRC += $(PROTOCOL_DIR)/serial_uart.c
 +endif
 +
  # Search Path
  VPATH += $(TOP_DIR)/protocol