diff --git a/converter/archimedes_usb/Makefile b/converter/archimedes_usb/Makefile new file mode 100644 index 00000000..7cd9ce92 --- /dev/null +++ b/converter/archimedes_usb/Makefile @@ -0,0 +1,89 @@ +# Target file name (without extension). +TARGET ?= archimedes_usb + +# Directory common source filess exist +TMK_DIR ?= ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR ?= . + +# project specific files +SRC ?= $(TARGET).c \ + protocol/serial_soft.c + +CONFIG_H ?= config.h + + +# MCU name +MCU ?= atmega32u2 + + +# Processor frequency. +# Normally the first thing your program should do is set the clock prescaler, +# so your program will run at the correct speed. You should also set this +# variable to same clock speed. The _delay_ms() macro uses this, and many +# examples use this variable to calculate timings. Do not add a "UL" here. +F_CPU ?= 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH ?= AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB ?= $(F_CPU) + + +# Build Options +# *Comment out* to disable the options. +# +#MOUSEKEY_ENABLE ?= yes # Mouse keys +#EXTRAKEY_ENABLE ?= yes # Audio control and System control +CONSOLE_ENABLE ?= yes # Console for debug +COMMAND_ENABLE ?= yes # Commands for debug and configuration +#NKRO_ENABLE ?= yes # USB Nkey Rollover +UNIMAP_ENABLE = yes +KEYMAP_SECTION_ENABLE = yes + +#NO_KEYBOARD = yes + + +# +# Keymap file +# +ifeq (yes,$(strip $(UNIMAP_ENABLE))) + KEYMAP_FILE = unimap +else + ifeq (yes,$(strip $(ACTIONMAP_ENABLE))) + KEYMAP_FILE = actionmap + else + KEYMAP_FILE = keymap + endif +endif +ifdef KEYMAP + SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC) +else + SRC := $(KEYMAP_FILE)_plain.c $(SRC) +endif + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/archimedes_usb/archimedes_usb.c b/converter/archimedes_usb/archimedes_usb.c new file mode 100644 index 00000000..3bb607d4 --- /dev/null +++ b/converter/archimedes_usb/archimedes_usb.c @@ -0,0 +1,88 @@ +/* +Copyright 2023 Jun Wako + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include +#include +#include "protocol/serial.h" +#include "debug.h" +#include "print.h" + +// Archimedes commands +#define HRST 0xFF +#define RAK1 0xFE +#define RAK2 0xFD +#define RQMP 0x22 +#define PRST 0x21 +#define RQID 0x20 +#define LEDS(stat) (0x00 | (stat & 0x7)) +#define RQPD(data) (0x40 | (data & 0xF)) + +// Archimedes Replies +#define BACK 0x3F +#define NACK 0x30 +#define SACK 0x31 +#define MACK 0x32 +#define SMAK 0x33 + + +void matrix_init(void) +{ + //debug_enable = true; + + serial_init(); + + // wait for keyboard coming up + // otherwise LED status update fails + print("Archimedes starts.\n"); + print("Sending HRST(0xFF): "); + + return; +} + +uint8_t matrix_scan(void) +{ + //while (1) { + print("."); + serial_send(0xFF); + _delay_ms(10); + serial_send(RAK1); + _delay_ms(10); + serial_send(RAK2); + _delay_ms(10); + serial_send(SACK); + + _delay_ms(10); + //serial_send(LEDS(0x5)); // ScrollLock and CapsLock + //serial_send(LEDS(0x3)); // NumLock and CapsLock + serial_send(LEDS(0x6)); // NumLock and CapsLock + + //serial_send(RQID); + + _delay_ms(500); + //} +} + +uint8_t matrix_get_row(uint8_t row) +{ + // TODO + return 0; +} diff --git a/converter/archimedes_usb/config.h b/converter/archimedes_usb/config.h new file mode 100644 index 00000000..693409ca --- /dev/null +++ b/converter/archimedes_usb/config.h @@ -0,0 +1,99 @@ +/* +Copyright 2023 Jun Wako + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xACAC +#define DEVICE_VER 0x0100 +#define MANUFACTURER TMK +#define PRODUCT Archimedes keyboard converter +#define DESCRIPTION converts Archimedes keyboard into USB + +/* matrix size */ +#define MATRIX_ROWS 16 +#define MATRIX_COLS 8 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ + keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* Software Serial configuration + * RX: PD1, TX: PD3 + * asynchronous, negative logic, 31250 baud + * start bit(0), 8-bit data(LSB first), 9th bit(1), stop bit(1) + */ +#define SERIAL_SOFT_BAUD 31250 +// TODO: 9th bit is optional? +//#define SERIAL_SOFT_9TH_BIT +#define SERIAL_SOFT_PARITY_NONE +#define SERIAL_SOFT_BIT_ORDER_LSB +#define SERIAL_SOFT_LOGIC_NEGATIVE +/* RXD Port */ +#define SERIAL_SOFT_RXD_ENABLE +#define SERIAL_SOFT_RXD_DDR DDRD +#define SERIAL_SOFT_RXD_PORT PORTD +#define SERIAL_SOFT_RXD_PIN PIND +#define SERIAL_SOFT_RXD_BIT 1 +#define SERIAL_SOFT_RXD_VECT INT1_vect +/* RXD Interupt */ +#ifdef SERIAL_SOFT_LOGIC_NEGATIVE +/* enable interrupt: INT1(rising edge) */ +#define INTR_TRIG_EDGE ((1< + +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 . +*/ +#include "unimap_trans.h" + + +#ifdef KEYMAP_SECTION_ENABLE +const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = { +#endif +}; diff --git a/converter/archimedes_usb/unimap_trans.h b/converter/archimedes_usb/unimap_trans.h new file mode 100644 index 00000000..bf8469be --- /dev/null +++ b/converter/archimedes_usb/unimap_trans.h @@ -0,0 +1,67 @@ +/* +Copyright 2019 Jun Wako + +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 . +*/ +#ifndef UNIMAP_TRANS_H +#define UNIMAP_TRANS_H + +#include +#include "unimap.h" + + +/* + * Scan Code Set 2: + * ,-----------------------------------------------. + * |F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24| + * ,---. |-----------------------------------------------| ,-----------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut| + * `---' `-----------------------------------------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsL | A| S| D| F| G| H| J| K| L| ;| '| ^a|Entr| | 4| 5| 6|KP,| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shft| <| Z| X| C| V| B| N| M| ,| .| /| RO|Shift | |Up | | 1| 2| 3|Ent| + * |-----------------------------------------------------------| ,-----------. |---------------| + * |Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | #| 0| .|KP=| + * `-----------------------------------------------------------' `-----------' `---------------' + * + * ,-----------------------------------------------. + * | 08| 10| 18| 20| 28| 30| 38| 40| 48| 50| 57| 5F| + * ,---. |-----------------------------------------------| ,-----------. ,-----------. + * | 76| | 05| 06| 04| 0C| 03| 0B| 83| 0A| 01| 09| 78| 07| |+7C| 7E|+77| |*21|*32|*23| + * `---' `-----------------------------------------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 6A| 66| |*70|*6C|*7D| | 77|*4A| 7C| 7B| + * |-----------------------------------------------------------| |-----------| |---------------| + * | 0D | 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B| 5D | |*71|*69|*7A| | 6C| 75| 7D| 79| + * |-----------------------------------------------------------| `-----------' |---------------| + * | 58 | 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| ^a| 5A | | 6B| 73| 74| 6D| + * |-----------------------------------------------------------| ,---. |---------------| + * | 12 | 61| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 51| 59 | |*75| | 69| 72| 7A|*5A| + * |-----------------------------------------------------------| ,-----------. |---------------| + * | 14|*1F| 11| 67 | 29 | 64 | 13 |*11|*27|*2F|*14| |*6B|*72|*74| | 68| 70| 71| 63| + * `-----------------------------------------------------------' `-----------' `---------------' + * *: E0-prefixed codes. See cs2_e0code() for remapping to unimap array. + * +: Special codes sequence + * ^a: ISO hash key and US backslash use identical code 5D. + * 51, 63, 68, 6A, 6D: Hidden keys in IBM model M [6] + */ +const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = { +}; + +#endif