summaryrefslogtreecommitdiffstats
path: root/converter
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-06-19 09:13:35 +0200
committertmk <nobody@nowhere>2014-07-30 07:07:43 +0200
commit4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856 (patch)
tree2141d2e168ad043ea18bcb3aee3f3a03dd2a2f1b /converter
parent80c3ff5fa03429f1e4ea15032f665ceb88c9b8c3 (diff)
downloadqmk_firmware-4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856.tar.gz
qmk_firmware-4c8e0fd0bd1712421f957ec5e0ca16fc6bbb3856.tar.xz
Port ps2_usb to mbed
Diffstat (limited to 'converter')
-rw-r--r--converter/ps2_usb/Makefile.mbed44
-rw-r--r--converter/ps2_usb/config_mbed.h60
-rw-r--r--converter/ps2_usb/keymap_common.c3
-rw-r--r--converter/ps2_usb/keymap_common.h1
-rw-r--r--converter/ps2_usb/main.cpp46
-rw-r--r--converter/ps2_usb/matrix.c3
6 files changed, 153 insertions, 4 deletions
diff --git a/converter/ps2_usb/Makefile.mbed b/converter/ps2_usb/Makefile.mbed
new file mode 100644
index 000000000..631f270f7
--- /dev/null
+++ b/converter/ps2_usb/Makefile.mbed
@@ -0,0 +1,44 @@
+PROJECT = ps2_usb
+
+TMK_DIR = ../..
+MBED_DIR = $(TMK_DIR)/mbed-sdk
+
+#VPATH += $(MBED_DIR):$(TMK_DIR)
+vpath %.s .:$(MBED_DIR):$(TMK_DIR)
+vpath %.c .:$(MBED_DIR):$(TMK_DIR)
+vpath %.cpp .:$(MBED_DIR):$(TMK_DIR)
+
+OBJDIR = ./build
+
+OBJECTS = \
+ $(OBJDIR)/protocol/ps2_busywait.o \
+ $(OBJDIR)/protocol/ps2_io_mbed.o \
+ $(OBJDIR)/./keymap_common.o \
+ $(OBJDIR)/./matrix.o \
+ $(OBJDIR)/./led.o \
+ $(OBJDIR)/./main.o
+
+ifdef KEYMAP
+ OBJECTS := $(OBJDIR)/keymap_$(KEYMAP).o $(OBJECTS)
+else
+ OBJECTS := $(OBJDIR)/keymap_plain.o $(OBJECTS)
+endif
+
+CONFIG_H = config_mbed.h
+
+SYS_OBJECTS =
+
+INCLUDE_PATHS = -I.
+
+LIBRARY_PATHS =
+LIBRARIES =
+
+# Build Options
+# Comment out to disable
+#BOOTMAGIC_ENABLE = yes
+MOUSEKEY_ENABLE = yes
+
+
+include $(TMK_DIR)/tool/mbed/mbed.mk
+include $(TMK_DIR)/tool/mbed/common.mk
+include $(TMK_DIR)/tool/mbed/gcc.mk
diff --git a/converter/ps2_usb/config_mbed.h b/converter/ps2_usb/config_mbed.h
new file mode 100644
index 000000000..5819763e6
--- /dev/null
+++ b/converter/ps2_usb/config_mbed.h
@@ -0,0 +1,60 @@
+/*
+Copyright 2012 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 CONFIG_MBED_H
+#define CONFIG_MBED_H
+
+
+#if 0
+// duplicated name against mbed USBDeivce
+#define VENDOR_ID 0xFEED
+#define PRODUCT_ID 0x6512
+#endif
+#define DEVICE_VER 0x0001
+#define MANUFACTURER t.m.k.
+#define PRODUCT PS/2 keyboard converter
+#define DESCRIPTION convert PS/2 keyboard to USB
+
+
+/* matrix size */
+#define MATRIX_ROWS 32 // keycode bit: 3-0
+#define MATRIX_COLS 8 // keycode bit: 6-4
+
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \
+ keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \
+)
+
+
+/*
+ * PS/2 Busywait
+ */
+#ifdef PS2_USE_BUSYWAIT
+# define PS2_CLOCK_PORT PORTD
+# define PS2_CLOCK_PIN PIND
+# define PS2_CLOCK_DDR DDRD
+# define PS2_CLOCK_BIT 5
+# define PS2_DATA_PORT PORTD
+# define PS2_DATA_PIN PIND
+# define PS2_DATA_DDR DDRD
+# define PS2_DATA_BIT 2
+#endif
+
+
+#endif
diff --git a/converter/ps2_usb/keymap_common.c b/converter/ps2_usb/keymap_common.c
index 241d2e33b..e344fb416 100644
--- a/converter/ps2_usb/keymap_common.c
+++ b/converter/ps2_usb/keymap_common.c
@@ -15,10 +15,11 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "keymap_common.h"
+#include "progmem.h"
/* translates key to keycode */
-uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
}
diff --git a/converter/ps2_usb/keymap_common.h b/converter/ps2_usb/keymap_common.h
index 216a8dc02..d783e01de 100644
--- a/converter/ps2_usb/keymap_common.h
+++ b/converter/ps2_usb/keymap_common.h
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include <stdbool.h>
-#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
diff --git a/converter/ps2_usb/main.cpp b/converter/ps2_usb/main.cpp
new file mode 100644
index 000000000..860af149a
--- /dev/null
+++ b/converter/ps2_usb/main.cpp
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "debug.h"
+#include "timer.h"
+#include "action.h"
+#include "keycode.h"
+#include "host.h"
+#include "host_driver.h"
+#include "mbed_driver.h"
+
+
+// Button and LEDs of LPC11U35 board
+DigitalIn isp(P0_1); // ISP button
+DigitalOut led_red(P0_20);
+DigitalOut led_green(P0_21);
+
+
+int main(void) {
+ isp.mode(PullUp);
+ led_red = 1;
+ led_green = 0;
+
+ timer_init();
+ host_set_driver(&mbed_driver);
+ keyboard_init();
+
+ //debug_enable = true;
+ xprintf("mbed_onekey ver.eee:\r\n");
+
+
+ bool last_isp = isp;
+ while (1) {
+ keyboard_task();
+
+ //led_green = !led_green;
+ if (last_isp == isp) continue;
+ last_isp = isp;
+ if (last_isp == 0) {
+ led_red = 0; // on
+ dprintf("timer: %i\r\n", timer_read());
+ //register_code(KC_A);
+ } else {
+ led_red = 1; // off
+ //unregister_code(KC_A);
+ }
+ }
+}
diff --git a/converter/ps2_usb/matrix.c b/converter/ps2_usb/matrix.c
index 45344c0f7..45cf2a4a9 100644
--- a/converter/ps2_usb/matrix.c
+++ b/converter/ps2_usb/matrix.c
@@ -17,8 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include <stdbool.h>
-#include <avr/io.h>
-#include <util/delay.h>
#include "action.h"
#include "print.h"
#include "util.h"
@@ -189,6 +187,7 @@ uint8_t matrix_scan(void)
}
uint8_t code = ps2_host_recv();
+ if (code) xprintf("%i\r\n", code);
if (!ps2_error) {
switch (state) {
case INIT: