mirror of
https://github.com/firewalkwithm3/qmk_firmware.git
synced 2024-11-22 19:40:29 +08:00
Fix print and timer
This commit is contained in:
parent
867f115bee
commit
04fe78ee0a
42
common/avr/timer_avr.h
Normal file
42
common/avr/timer_avr.h
Normal file
|
@ -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
|
|
@ -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 { \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,6 +11,7 @@ void SysTick_Handler(void) {
|
|||
|
||||
void timer_init(void)
|
||||
{
|
||||
timer_count = 0;
|
||||
SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
|
||||
}
|
||||
|
||||
|
|
|
@ -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, ...)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue