diff options
Diffstat (limited to 'converter/sun_usb')
| -rw-r--r-- | converter/sun_usb/Makefile | 1 | ||||
| -rw-r--r-- | converter/sun_usb/command_extra.c | 43 | ||||
| -rw-r--r-- | converter/sun_usb/config.h | 17 | ||||
| -rw-r--r-- | converter/sun_usb/led.c | 10 |
4 files changed, 69 insertions, 2 deletions
diff --git a/converter/sun_usb/Makefile b/converter/sun_usb/Makefile index 4c79a8d27..c6e8390cc 100644 --- a/converter/sun_usb/Makefile +++ b/converter/sun_usb/Makefile | |||
| @@ -11,6 +11,7 @@ TARGET_DIR = . | |||
| 11 | SRC = keymap.c \ | 11 | SRC = keymap.c \ |
| 12 | matrix.c \ | 12 | matrix.c \ |
| 13 | led.c \ | 13 | led.c \ |
| 14 | command_extra.c \ | ||
| 14 | protocol/serial_soft.c | 15 | protocol/serial_soft.c |
| 15 | 16 | ||
| 16 | CONFIG_H = config.h | 17 | CONFIG_H = config.h |
diff --git a/converter/sun_usb/command_extra.c b/converter/sun_usb/command_extra.c new file mode 100644 index 000000000..50389467e --- /dev/null +++ b/converter/sun_usb/command_extra.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #include "stdbool.h" | ||
| 2 | #include "stdint.h" | ||
| 3 | #include "keycode.h" | ||
| 4 | #include "serial.h" | ||
| 5 | #include "print.h" | ||
| 6 | #include "command.h" | ||
| 7 | |||
| 8 | bool command_extra(uint8_t code) | ||
| 9 | { | ||
| 10 | switch (code) { | ||
| 11 | case KC_H: | ||
| 12 | case KC_SLASH: /* ? */ | ||
| 13 | print("\n\n----- Sun converter Help -----\n"); | ||
| 14 | print("UP: Bell On\n"); | ||
| 15 | print("DOWN: Bell Off\n"); | ||
| 16 | print("LEFT: Click On\n"); | ||
| 17 | print("RIGHT: Click Off\n"); | ||
| 18 | return false; | ||
| 19 | case KC_UP: | ||
| 20 | print("Bell On\n"); | ||
| 21 | serial_send(0x02); | ||
| 22 | break; | ||
| 23 | case KC_DOWN: | ||
| 24 | print("Bell Off\n"); | ||
| 25 | serial_send(0x03); | ||
| 26 | break; | ||
| 27 | case KC_LEFT: | ||
| 28 | print("Click On\n"); | ||
| 29 | serial_send(0x0A); | ||
| 30 | break; | ||
| 31 | case KC_RIGHT: | ||
| 32 | print("Click Off\n"); | ||
| 33 | serial_send(0x0B); | ||
| 34 | break; | ||
| 35 | case KC_NUMLOCK: | ||
| 36 | print("layout\n"); | ||
| 37 | serial_send(0x0F); | ||
| 38 | break; | ||
| 39 | default: | ||
| 40 | return false; | ||
| 41 | } | ||
| 42 | return true; | ||
| 43 | } | ||
diff --git a/converter/sun_usb/config.h b/converter/sun_usb/config.h index 66961d933..b4f0ff977 100644 --- a/converter/sun_usb/config.h +++ b/converter/sun_usb/config.h | |||
| @@ -43,8 +43,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 43 | * asynchronous, negative logic, 1200baud, no flow control | 43 | * asynchronous, negative logic, 1200baud, no flow control |
| 44 | * 1-start bit, 8-data bit, non parity, 1-stop bit | 44 | * 1-start bit, 8-data bit, non parity, 1-stop bit |
| 45 | */ | 45 | */ |
| 46 | #define SERIAL_NEGATIVE_LOGIC | ||
| 47 | #define SERIAL_BAUD 1200 | 46 | #define SERIAL_BAUD 1200 |
| 47 | |||
| 48 | #define SERIAL_RXD_DDR DDRD | 48 | #define SERIAL_RXD_DDR DDRD |
| 49 | #define SERIAL_RXD_PORT PORTD | 49 | #define SERIAL_RXD_PORT PORTD |
| 50 | #define SERIAL_RXD_PIN PIND | 50 | #define SERIAL_RXD_PIN PIND |
| @@ -63,5 +63,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 63 | /* clear interrupt flag */ \ | 63 | /* clear interrupt flag */ \ |
| 64 | EIFR = (1<<INTF2); \ | 64 | EIFR = (1<<INTF2); \ |
| 65 | } while (0) | 65 | } while (0) |
| 66 | #define SERIAL_RXD_READ() (~SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT)) | ||
| 67 | |||
| 68 | #define SERIAL_TXD_DDR DDRD | ||
| 69 | #define SERIAL_TXD_PORT PORTD | ||
| 70 | #define SERIAL_TXD_PIN PIND | ||
| 71 | #define SERIAL_TXD_BIT 3 | ||
| 72 | /* negative logic */ | ||
| 73 | #define SERIAL_TXD_ON() do { SERIAL_TXD_PORT &= ~(1<<SERIAL_TXD_BIT); } while (0) | ||
| 74 | #define SERIAL_TXD_OFF() do { SERIAL_TXD_PORT |= (1<<SERIAL_TXD_BIT); } while (0) | ||
| 75 | #define SERIAL_TXD_INIT() do { \ | ||
| 76 | /* pin configuration: output */ \ | ||
| 77 | SERIAL_TXD_DDR |= (1<<SERIAL_TXD_BIT); \ | ||
| 78 | /* idle */ \ | ||
| 79 | SERIAL_TXD_ON(); \ | ||
| 80 | } while (0) | ||
| 66 | 81 | ||
| 67 | #endif | 82 | #endif |
diff --git a/converter/sun_usb/led.c b/converter/sun_usb/led.c index 5490ec0c6..48c3f1c2b 100644 --- a/converter/sun_usb/led.c +++ b/converter/sun_usb/led.c | |||
| @@ -16,10 +16,18 @@ 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 "serial.h" | ||
| 19 | #include "led.h" | 20 | #include "led.h" |
| 20 | 21 | ||
| 21 | 22 | ||
| 22 | void led_set(uint8_t usb_led) | 23 | void led_set(uint8_t usb_led) |
| 23 | { | 24 | { |
| 24 | // not supported now | 25 | uint8_t sun_led = 0; |
| 26 | if (usb_led & (1<<USB_LED_NUM_LOCK)) sun_led |= (1<<0); | ||
| 27 | if (usb_led & (1<<USB_LED_COMPOSE)) sun_led |= (1<<1); | ||
| 28 | if (usb_led & (1<<USB_LED_SCROLL_LOCK)) sun_led |= (1<<2); | ||
| 29 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) sun_led |= (1<<3); | ||
| 30 | |||
| 31 | serial_send(0x0E); | ||
| 32 | serial_send(sun_led); | ||
| 25 | } | 33 | } |
