aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-17 22:41:14 +0900
committertmk <nobody@nowhere>2014-07-30 14:07:43 +0900
commite81c70149ecf73256f8bb7d77cefc07f2b91d2be (patch)
treed918595b92aa099537640cd02285f914b343bd67 /common
parentee70fe59ee8ebc6dcbf55171b1a2dd72e1744ae6 (diff)
downloadqmk_firmware-e81c70149ecf73256f8bb7d77cefc07f2b91d2be.tar.gz
qmk_firmware-e81c70149ecf73256f8bb7d77cefc07f2b91d2be.zip
Fix common files for mbed
Diffstat (limited to 'common')
-rw-r--r--common/avr/bootloader.c (renamed from common/bootloader.c)0
-rw-r--r--common/avr/eeconfig.c (renamed from common/eeconfig.c)0
-rw-r--r--common/avr/suspend.c (renamed from common/suspend.c)24
-rw-r--r--common/avr/suspend_avr.h27
-rw-r--r--common/host.h4
-rw-r--r--common/keyboard.c1
-rw-r--r--common/keymap.c1
-rw-r--r--common/mbed/bootloader.c4
-rw-r--r--common/mbed/suspend.c6
-rw-r--r--common/mbed/xprintf.cpp46
-rw-r--r--common/mbed/xprintf.h17
-rw-r--r--common/mousekey.c1
-rw-r--r--common/mousekey.h20
-rw-r--r--common/progmem.h11
-rw-r--r--common/suspend.h20
15 files changed, 150 insertions, 32 deletions
diff --git a/common/bootloader.c b/common/avr/bootloader.c
index cda295b18..cda295b18 100644
--- a/common/bootloader.c
+++ b/common/avr/bootloader.c
diff --git a/common/eeconfig.c b/common/avr/eeconfig.c
index 5bd47dc6a..5bd47dc6a 100644
--- a/common/eeconfig.c
+++ b/common/avr/eeconfig.c
diff --git a/common/suspend.c b/common/avr/suspend.c
index 5b378892f..f44a036be 100644
--- a/common/suspend.c
+++ b/common/avr/suspend.c
@@ -1,7 +1,29 @@
1#include "suspend.h" 1#include <stdbool.h>
2#include <avr/sleep.h>
3#include <avr/wdt.h>
4#include <avr/interrupt.h>
2#include "matrix.h" 5#include "matrix.h"
3#include "action.h" 6#include "action.h"
4#include "backlight.h" 7#include "backlight.h"
8#include "suspend_avr.h"
9#include "suspend.h"
10
11
12#define wdt_intr_enable(value) \
13__asm__ __volatile__ ( \
14 "in __tmp_reg__,__SREG__" "\n\t" \
15 "cli" "\n\t" \
16 "wdr" "\n\t" \
17 "sts %0,%1" "\n\t" \
18 "out __SREG__,__tmp_reg__" "\n\t" \
19 "sts %0,%2" "\n\t" \
20 : /* no outputs */ \
21 : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
22 "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
23 "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \
24 _BV(WDIE) | (value & 0x07)) ) \
25 : "r0" \
26)
5 27
6 28
7void suspend_power_down(void) 29void suspend_power_down(void)
diff --git a/common/avr/suspend_avr.h b/common/avr/suspend_avr.h
new file mode 100644
index 000000000..357102da4
--- /dev/null
+++ b/common/avr/suspend_avr.h
@@ -0,0 +1,27 @@
1#ifndef SUSPEND_AVR_H
2#define SUSPEND_AVR_H
3
4#include <stdint.h>
5#include <stdbool.h>
6#include <avr/sleep.h>
7#include <avr/wdt.h>
8#include <avr/interrupt.h>
9
10
11#define wdt_intr_enable(value) \
12__asm__ __volatile__ ( \
13 "in __tmp_reg__,__SREG__" "\n\t" \
14 "cli" "\n\t" \
15 "wdr" "\n\t" \
16 "sts %0,%1" "\n\t" \
17 "out __SREG__,__tmp_reg__" "\n\t" \
18 "sts %0,%2" "\n\t" \
19 : /* no outputs */ \
20 : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
21 "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
22 "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \
23 _BV(WDIE) | (value & 0x07)) ) \
24 : "r0" \
25)
26
27#endif
diff --git a/common/host.h b/common/host.h
index a56e6c3b0..918af69e8 100644
--- a/common/host.h
+++ b/common/host.h
@@ -32,8 +32,8 @@ extern "C" {
32extern bool keyboard_nkro; 32extern bool keyboard_nkro;
33#endif 33#endif
34 34
35uint8_t keyboard_idle; 35extern uint8_t keyboard_idle;
36uint8_t keyboard_protocol; 36extern uint8_t keyboard_protocol;
37 37
38 38
39/* host driver */ 39/* host driver */
diff --git a/common/keyboard.c b/common/keyboard.c
index b71d5bf13..9a809ff4a 100644
--- a/common/keyboard.c
+++ b/common/keyboard.c
@@ -15,7 +15,6 @@ You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include <stdint.h> 17#include <stdint.h>
18#include <util/delay.h>
19#include "keyboard.h" 18#include "keyboard.h"
20#include "matrix.h" 19#include "matrix.h"
21#include "keymap.h" 20#include "keymap.h"
diff --git a/common/keymap.c b/common/keymap.c
index 0df2e2edf..4c0b61b8c 100644
--- a/common/keymap.c
+++ b/common/keymap.c
@@ -14,7 +14,6 @@ GNU General Public License for more details.
14You should have received a copy of the GNU General Public License 14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>. 15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17#include <avr/pgmspace.h>
18#include "keymap.h" 17#include "keymap.h"
19#include "report.h" 18#include "report.h"
20#include "keycode.h" 19#include "keycode.h"
diff --git a/common/mbed/bootloader.c b/common/mbed/bootloader.c
new file mode 100644
index 000000000..b51e83943
--- /dev/null
+++ b/common/mbed/bootloader.c
@@ -0,0 +1,4 @@
1#include "bootloader.h"
2
3
4void bootloader_jump(void) {}
diff --git a/common/mbed/suspend.c b/common/mbed/suspend.c
new file mode 100644
index 000000000..32651574f
--- /dev/null
+++ b/common/mbed/suspend.c
@@ -0,0 +1,6 @@
1#include <stdbool.h>
2
3
4void suspend_power_down(void) {}
5bool suspend_wakeup_condition(void) { return true; }
6void suspend_wakeup_init(void) {}
diff --git a/common/mbed/xprintf.cpp b/common/mbed/xprintf.cpp
new file mode 100644
index 000000000..4342b79f8
--- /dev/null
+++ b/common/mbed/xprintf.cpp
@@ -0,0 +1,46 @@
1#include <cstdarg>
2//#include <stdarg.h>
3#include "mbed.h"
4#include "mbed/xprintf.h"
5
6
7#define STRING_STACK_LIMIT 120
8
9/* mbed Serial */
10Serial ser(UART_TX, UART_RX);
11
12/* TODO: Need small implementation for embedded */
13int xprintf(const char* format, ...)
14{
15 /* copy from mbed/common/RawSerial.cpp */
16 std::va_list arg;
17 va_start(arg, format);
18 int len = vsnprintf(NULL, 0, format, arg);
19 if (len < STRING_STACK_LIMIT) {
20 char temp[STRING_STACK_LIMIT];
21 vsprintf(temp, format, arg);
22 ser.puts(temp);
23 } else {
24 char *temp = new char[len + 1];
25 vsprintf(temp, format, arg);
26 ser.puts(temp);
27 delete[] temp;
28 }
29 va_end(arg);
30 return len;
31
32/* Fail: __builtin_va_arg_pack?
33 * https://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Constructing-Calls.html#Constructing-Calls
34 void *arg = __builtin_apply_args();
35 void *ret = __builtin_apply((void*)(&(ser.printf)), arg, 100);
36 __builtin_return(ret)
37*/
38/* Fail: varargs can not be passed to printf
39 //int r = ser.printf("test %i\r\n", 123);
40 va_list arg;
41 va_start(arg, format);
42 int r = ser.printf(format, arg);
43 va_end(arg);
44 return r;
45*/
46}
diff --git a/common/mbed/xprintf.h b/common/mbed/xprintf.h
new file mode 100644
index 000000000..26bc529e5
--- /dev/null
+++ b/common/mbed/xprintf.h
@@ -0,0 +1,17 @@
1#ifndef XPRINTF_H
2#define XPRINTF_H
3
4//#define xprintf(format, ...) __xprintf(format, ##__VA_ARGS__)
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10int xprintf(const char *format, ...);
11
12#ifdef __cplusplus
13}
14#endif
15
16
17#endif
diff --git a/common/mousekey.c b/common/mousekey.c
index 017be9411..23469476e 100644
--- a/common/mousekey.c
+++ b/common/mousekey.c
@@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/ 16*/
17 17
18#include <stdint.h> 18#include <stdint.h>
19#include <util/delay.h>
20#include "keycode.h" 19#include "keycode.h"
21#include "host.h" 20#include "host.h"
22#include "timer.h" 21#include "timer.h"
diff --git a/common/mousekey.h b/common/mousekey.h
index d8d7beaaa..6eede06b4 100644
--- a/common/mousekey.h
+++ b/common/mousekey.h
@@ -52,12 +52,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
52#endif 52#endif
53 53
54 54
55uint8_t mk_delay; 55#ifdef __cplusplus
56uint8_t mk_interval; 56extern "C" {
57uint8_t mk_max_speed; 57#endif
58uint8_t mk_time_to_max; 58
59uint8_t mk_wheel_max_speed; 59extern uint8_t mk_delay;
60uint8_t mk_wheel_time_to_max; 60extern uint8_t mk_interval;
61extern uint8_t mk_max_speed;
62extern uint8_t mk_time_to_max;
63extern uint8_t mk_wheel_max_speed;
64extern uint8_t mk_wheel_time_to_max;
61 65
62 66
63void mousekey_task(void); 67void mousekey_task(void);
@@ -66,4 +70,8 @@ void mousekey_off(uint8_t code);
66void mousekey_clear(void); 70void mousekey_clear(void);
67void mousekey_send(void); 71void mousekey_send(void);
68 72
73#ifdef __cplusplus
74}
75#endif
76
69#endif 77#endif
diff --git a/common/progmem.h b/common/progmem.h
new file mode 100644
index 000000000..09aeb8b7c
--- /dev/null
+++ b/common/progmem.h
@@ -0,0 +1,11 @@
1#ifndef PROGMEM_H
2#define PROGMEM_H 1
3
4#if defined(__AVR__)
5# include <avr/pgmspace.h>
6#elif defined(__arm__)
7# define PROGMEM
8# define pgm_read_byte(p) *(p)
9#endif
10
11#endif
diff --git a/common/suspend.h b/common/suspend.h
index 1c1e41ac3..9b76f280d 100644
--- a/common/suspend.h
+++ b/common/suspend.h
@@ -3,26 +3,6 @@
3 3
4#include <stdint.h> 4#include <stdint.h>
5#include <stdbool.h> 5#include <stdbool.h>
6#include <avr/sleep.h>
7#include <avr/wdt.h>
8#include <avr/interrupt.h>
9
10
11#define wdt_intr_enable(value) \
12__asm__ __volatile__ ( \
13 "in __tmp_reg__,__SREG__" "\n\t" \
14 "cli" "\n\t" \
15 "wdr" "\n\t" \
16 "sts %0,%1" "\n\t" \
17 "out __SREG__,__tmp_reg__" "\n\t" \
18 "sts %0,%2" "\n\t" \
19 : /* no outputs */ \
20 : "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
21 "r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
22 "r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \
23 _BV(WDIE) | (value & 0x07)) ) \
24 : "r0" \
25)
26 6
27 7
28void suspend_power_down(void); 8void suspend_power_down(void);