aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-06-21 16:34:39 +0900
committertmk <nobody@nowhere>2013-06-22 02:32:45 +0900
commit42c962412b92a0ab4bd26c95f25867c645064bd6 (patch)
tree936222d372c4b36bc2fcae87bc9c7df0b08d41c6
parent1f7461578dd489898389b7e9c488f7df9ac75399 (diff)
downloadqmk_firmware-42c962412b92a0ab4bd26c95f25867c645064bd6.tar.gz
qmk_firmware-42c962412b92a0ab4bd26c95f25867c645064bd6.zip
Add LED support to x68k
-rw-r--r--converter/x68k_usb/Makefile20
-rw-r--r--converter/x68k_usb/config_pjrc.h23
-rw-r--r--converter/x68k_usb/led.c24
-rw-r--r--protocol/x68k.c6
-rw-r--r--protocol/x68k.h1
5 files changed, 62 insertions, 12 deletions
diff --git a/converter/x68k_usb/Makefile b/converter/x68k_usb/Makefile
index 62b976c56..fd66ed563 100644
--- a/converter/x68k_usb/Makefile
+++ b/converter/x68k_usb/Makefile
@@ -16,7 +16,8 @@ TARGET_DIR = .
16SRC = keymap.c \ 16SRC = keymap.c \
17 matrix.c \ 17 matrix.c \
18 led.c \ 18 led.c \
19 x68k.c 19 protocol/x68k.c
20# protocol/serial_uart.c
20 21
21CONFIG_H = config_pjrc.h 22CONFIG_H = config_pjrc.h
22 23
@@ -37,12 +38,23 @@ MCU = atmega32u4 # Teensy 2.0
37F_CPU = 16000000 38F_CPU = 16000000
38 39
39 40
41# Boot Section Size in bytes
42# Teensy halfKay 512
43# Atmel DFU loader 4096
44# LUFA bootloader 4096
45OPT_DEFS += -DBOOTLOADER_SIZE=4096
46
47
40# Build Options 48# Build Options
41# *Comment out* to disable the options. 49# *Comment out* to disable the options.
42# 50#
43MOUSEKEY_ENABLE = yes # Mouse keys 51BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
44EXTRAKEY_ENABLE = yes # Audio control and System control 52MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
45NKRO_ENABLE = yes # USB Nkey Rollover 53EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
54CONSOLE_ENABLE = yes # Console for debug(+400)
55COMMAND_ENABLE = yes # Commands for debug and configuration
56#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
57#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
46 58
47 59
48 60
diff --git a/converter/x68k_usb/config_pjrc.h b/converter/x68k_usb/config_pjrc.h
index 2df83a2cb..dd277cff1 100644
--- a/converter/x68k_usb/config_pjrc.h
+++ b/converter/x68k_usb/config_pjrc.h
@@ -40,11 +40,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
40/* legacy keymap support */ 40/* legacy keymap support */
41#define USE_LEGACY_KEYMAP 41#define USE_LEGACY_KEYMAP
42 42
43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
48 43
49/* USART configuration 44/* USART configuration
50 * asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control 45 * asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control
@@ -57,7 +52,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
57# define KBD_RX_INIT() do { \ 52# define KBD_RX_INIT() do { \
58 UBRR1L = (uint8_t) KBD_RX_UBBR; \ 53 UBRR1L = (uint8_t) KBD_RX_UBBR; \
59 UBRR1H = (uint8_t) (KBD_RX_UBBR>>8); \ 54 UBRR1H = (uint8_t) (KBD_RX_UBBR>>8); \
60 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1); \ 55 UCSR1B |= (1<<RXCIE1) | (1<<RXEN1) | (1<<TXEN1); \
56 } while(0)
57
58
59 #define SERIAL_UART_BAUD 2400
60 #define SERIAL_UART_DATA UDR1
61 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1)
62 #define SERIAL_UART_RXD_VECT USART1_RX_vect
63 #define SERIAL_UART_TXD_READY (UCSR1A&(1<<UDRE1))
64 #define SERIAL_UART_INIT() do { \
65 UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
66 UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
67 UCSR1B = (1<<RXCIE1) | (1<<RXEN1) | /* RX: interrupt, RX: enable */ \
68 (1<<TXEN1); /* TX: enable */ \
69 UCSR1C = (1<<UPM11) | (1<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
70 (0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* 8bit-data(011) */ \
71 sei(); \
61 } while(0) 72 } while(0)
62#else 73#else
63# error "USART configuration is needed." 74# error "USART configuration is needed."
diff --git a/converter/x68k_usb/led.c b/converter/x68k_usb/led.c
index 40156cf4a..a1c1d546e 100644
--- a/converter/x68k_usb/led.c
+++ b/converter/x68k_usb/led.c
@@ -16,11 +16,31 @@ 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 "x68k.h" 19#include "serial.h"
20#include "led.h" 20#include "led.h"
21#include "debug.h"
22#include "x68k.h"
21 23
22 24
23void led_set(uint8_t usb_led) 25void led_set(uint8_t usb_led)
24{ 26{
25 // not supported now 27 /* X68000 LED bits 0: on, 1: off
28 * bit 7 1(fixed)
29 * bit 6 全角
30 * bit 5 ひらがな
31 * bit 4 INS
32 * bit 3 CAPS
33 * bit 2 コード入力
34 * bit 1 ローマ字
35 * bit 0 かな
36 */
37 uint8_t led = 0xFF;
38 xprintf("usb_led: %02X\n", usb_led);
39 if (usb_led&(1<<USB_LED_NUM_LOCK)) led &= ~(1<<2);
40 if (usb_led&(1<<USB_LED_CAPS_LOCK)) led &= ~(1<<3);
41 if (usb_led&(1<<USB_LED_SCROLL_LOCK)) led &= ~(1<<1);
42 if (usb_led&(1<<USB_LED_COMPOSE)) led &= ~(1<<4);
43 if (usb_led&(1<<USB_LED_KANA)) led &= ~(1<<0);
44 xprintf("led: %02X\n", led);
45 x68k_send(led);
26} 46}
diff --git a/protocol/x68k.c b/protocol/x68k.c
index d17af51cc..b54e3d9a8 100644
--- a/protocol/x68k.c
+++ b/protocol/x68k.c
@@ -64,6 +64,12 @@ uint8_t x68k_recv(void)
64 return data; 64 return data;
65} 65}
66 66
67void x68k_send(uint8_t d)
68{
69 while (!(UCSR1A&(1<<UDRE1)));
70 UDR1 = d;
71}
72
67// USART RX complete interrupt 73// USART RX complete interrupt
68ISR(KBD_RX_VECT) 74ISR(KBD_RX_VECT)
69{ 75{
diff --git a/protocol/x68k.h b/protocol/x68k.h
index 2cfda63a7..0d9c7de80 100644
--- a/protocol/x68k.h
+++ b/protocol/x68k.h
@@ -41,6 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
41/* host role */ 41/* host role */
42void x68k_init(void); 42void x68k_init(void);
43uint8_t x68k_recv(void); 43uint8_t x68k_recv(void);
44void x68k_send(uint8_t d);
44 45
45/* device role */ 46/* device role */
46 47