diff options
| author | tmk <nobody@nowhere> | 2014-06-16 15:38:39 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2014-07-30 14:07:43 +0900 |
| commit | 04fe78ee0a7fe9baed39f021799a3dbb24ebeb36 (patch) | |
| tree | 047ab27ca15eedfcc5523ac0daf243611501ef5e /common | |
| parent | 867f115bee190515aa195dc3e58f1c381ea9695b (diff) | |
| download | qmk_firmware-04fe78ee0a7fe9baed39f021799a3dbb24ebeb36.tar.gz qmk_firmware-04fe78ee0a7fe9baed39f021799a3dbb24ebeb36.zip | |
Fix print and timer
Diffstat (limited to 'common')
| -rw-r--r-- | common/avr/timer_avr.h | 42 | ||||
| -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.h | 4 | ||||
| -rw-r--r-- | common/debug_config.h | 9 | ||||
| -rw-r--r-- | common/mbed/timer.c | 1 | ||||
| -rw-r--r-- | common/nodebug.h | 2 | ||||
| -rw-r--r-- | common/print.h | 16 |
8 files changed, 58 insertions, 16 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 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef TIMER_AVR_H | ||
| 19 | #define TIMER_AVR_H 1 | ||
| 20 | |||
| 21 | #include <stdint.h> | ||
| 22 | |||
| 23 | #ifndef TIMER_PRESCALER | ||
| 24 | # if F_CPU > 16000000 | ||
| 25 | # define TIMER_PRESCALER 256 | ||
| 26 | # elif F_CPU > 2000000 | ||
| 27 | # define TIMER_PRESCALER 64 | ||
| 28 | # elif F_CPU > 250000 | ||
| 29 | # define TIMER_PRESCALER 8 | ||
| 30 | # else | ||
| 31 | # define TIMER_PRESCALER 1 | ||
| 32 | # endif | ||
| 33 | #endif | ||
| 34 | #define TIMER_RAW_FREQ (F_CPU/TIMER_PRESCALER) | ||
| 35 | #define TIMER_RAW TCNT0 | ||
| 36 | #define TIMER_RAW_TOP (TIMER_RAW_FREQ/1000) | ||
| 37 | |||
| 38 | #if (TIMER_RAW_TOP > 255) | ||
| 39 | # error "Timer0 can't count 1ms at this clock freq. Use larger prescaler." | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #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/>. | |||
| 25 | #ifndef NO_DEBUG | 25 | #ifndef NO_DEBUG |
| 26 | 26 | ||
| 27 | #define dprint(s) do { if (debug_enable) print(s); } while (0) | 27 | #define dprint(s) do { if (debug_enable) print(s); } while (0) |
| 28 | #define dprintln() do { if (debug_enable) print_crlf(); } while (0) | 28 | #define dprintln(s) do { if (debug_enable) println(s); } while (0) |
| 29 | #define dprintf(fmt, ...) do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0) | 29 | #define dprintf(fmt, ...) do { if (debug_enable) xprintf(fmt, ##__VA_ARGS__); } while (0) |
| 30 | #define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s)) | 30 | #define dmsg(s) dprintf("%s at %s: %S\n", __FILE__, __LINE__, PSTR(s)) |
| 31 | 31 | ||
| 32 | /* DO NOT USE these anymore */ | 32 | /* DO NOT USE these anymore */ |
| 33 | #define debug(s) do { if (debug_enable) print(s); } while (0) | 33 | #define debug(s) do { if (debug_enable) print(s); } while (0) |
| 34 | #define debugln(s) do { if (debug_enable) print_crlf(); } while (0) | 34 | #define debugln(s) do { if (debug_enable) println(s); } while (0) |
| 35 | #define debug_S(s) do { if (debug_enable) print_S(s); } while (0) | 35 | #define debug_S(s) do { if (debug_enable) print_S(s); } while (0) |
| 36 | #define debug_P(s) do { if (debug_enable) print_P(s); } while (0) | 36 | #define debug_P(s) do { if (debug_enable) print_P(s); } while (0) |
| 37 | #define debug_msg(s) do { \ | 37 | #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 { | |||
| 38 | } debug_config_t; | 38 | } debug_config_t; |
| 39 | debug_config_t debug_config; | 39 | debug_config_t debug_config; |
| 40 | 40 | ||
| 41 | #ifdef __cplusplus | ||
| 42 | } | ||
| 43 | #endif | ||
| 44 | |||
| 45 | |||
| 41 | /* for backward compatibility */ | 46 | /* for backward compatibility */ |
| 42 | #define debug_enable (debug_config.enable) | 47 | #define debug_enable (debug_config.enable) |
| 43 | #define debug_matrix (debug_config.matrix) | 48 | #define debug_matrix (debug_config.matrix) |
| 44 | #define debug_keyboard (debug_config.keyboard) | 49 | #define debug_keyboard (debug_config.keyboard) |
| 45 | #define debug_mouse (debug_config.mouse) | 50 | #define debug_mouse (debug_config.mouse) |
| 46 | 51 | ||
| 47 | #ifdef __cplusplus | ||
| 48 | } | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #endif | 52 | #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) { | |||
| 11 | 11 | ||
| 12 | void timer_init(void) | 12 | void timer_init(void) |
| 13 | { | 13 | { |
| 14 | timer_count = 0; | ||
| 14 | SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */ | 15 | SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */ |
| 15 | } | 16 | } |
| 16 | 17 | ||
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/>. | |||
| 18 | #ifndef NODEBUG_H | 18 | #ifndef NODEBUG_H |
| 19 | #define NODEBUG_H 1 | 19 | #define NODEBUG_H 1 |
| 20 | 20 | ||
| 21 | #include "debug_config.h" | ||
| 22 | |||
| 23 | #define dprint(s) | 21 | #define dprint(s) |
| 24 | #define dprintln(s) | 22 | #define dprintln(s) |
| 25 | #define dprintf(fmt, ...) | 23 | #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 @@ | |||
| 35 | #ifndef NO_PRINT | 35 | #ifndef NO_PRINT |
| 36 | 36 | ||
| 37 | 37 | ||
| 38 | #ifdef __AVR__ | 38 | #if defined(__AVR__) |
| 39 | 39 | ||
| 40 | #include "xprintf.h" | 40 | #include "xprintf.h" |
| 41 | 41 | ||
| @@ -44,21 +44,21 @@ | |||
| 44 | #ifndef __cplusplus | 44 | #ifndef __cplusplus |
| 45 | #define print(s) xputs(PSTR(s)) | 45 | #define print(s) xputs(PSTR(s)) |
| 46 | #endif | 46 | #endif |
| 47 | #define println(s) xputs(PSTR(s "\n")) | 47 | #define println(s) xputs(PSTR(s "\r\n")) |
| 48 | 48 | ||
| 49 | #ifdef __cplusplus | 49 | #ifdef __cplusplus |
| 50 | extern "C" { | 50 | extern "C" |
| 51 | #endif | 51 | #endif |
| 52 | /* function pointer of sendchar to be used by print utility */ | 52 | /* function pointer of sendchar to be used by print utility */ |
| 53 | void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t)); | 53 | void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t)); |
| 54 | 54 | ||
| 55 | #elif __arm__ | 55 | #elif defined(__arm__) |
| 56 | |||
| 57 | #include "mbed/xprintf.h" | ||
| 56 | 58 | ||
| 57 | #include "mbed.h" | ||
| 58 | Serial ser(UART_TX, UART_RX); | ||
| 59 | #define xprintf ser.printf | ||
| 60 | #define print(s) xprintf(s) | 59 | #define print(s) xprintf(s) |
| 61 | #define println(s) xprintf(s "\n") | 60 | #define println(s) xprintf(s "\r\n") |
| 61 | |||
| 62 | /* TODO: to select output destinations: UART/USBSerial */ | 62 | /* TODO: to select output destinations: UART/USBSerial */ |
| 63 | #define print_set_sendchar(func) | 63 | #define print_set_sendchar(func) |
| 64 | 64 | ||
