mirror of https://github.com/wwarthen/RomWBW.git
30 changed files with 1033 additions and 174 deletions
@ -0,0 +1,254 @@ |
|||||
|
; |
||||
|
; Generated from source-doc/base-drv/./class_hid.c.asm -- not to be modify directly |
||||
|
; |
||||
|
; |
||||
|
;-------------------------------------------------------- |
||||
|
; File Created by SDCC : free open source ISO C Compiler |
||||
|
; Version 4.4.0 #14648 (Linux) |
||||
|
;-------------------------------------------------------- |
||||
|
; Processed by Z88DK |
||||
|
;-------------------------------------------------------- |
||||
|
|
||||
|
|
||||
|
;-------------------------------------------------------- |
||||
|
; Public variables in this module |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; Externals used |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; special function registers |
||||
|
;-------------------------------------------------------- |
||||
|
_CH376_DATA_PORT .EQU 0xff88 |
||||
|
_CH376_COMMAND_PORT .EQU 0xff89 |
||||
|
_USB_MODULE_LEDS .EQU 0xff8a |
||||
|
;-------------------------------------------------------- |
||||
|
; ram data |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; ram data |
||||
|
;-------------------------------------------------------- |
||||
|
|
||||
|
#IF 0 |
||||
|
|
||||
|
; .area _INITIALIZED removed by z88dk |
||||
|
|
||||
|
|
||||
|
#ENDIF |
||||
|
|
||||
|
;-------------------------------------------------------- |
||||
|
; absolute external ram data |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; global & static initialisations |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; Home |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; code |
||||
|
;-------------------------------------------------------- |
||||
|
;source-doc/base-drv/./class_hid.c:6: usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1) { |
||||
|
; --------------------------------- |
||||
|
; Function hid_set_protocol |
||||
|
; --------------------------------- |
||||
|
_hid_set_protocol: |
||||
|
push ix |
||||
|
ld ix,0 |
||||
|
add ix,sp |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
ex de, hl |
||||
|
;source-doc/base-drv/./class_hid.c:9: cmd = cmd_hid_set; |
||||
|
push de |
||||
|
ex de, hl |
||||
|
ld hl,2 |
||||
|
add hl, sp |
||||
|
ex de, hl |
||||
|
ld hl,_cmd_hid_set |
||||
|
ld bc,0x0008 |
||||
|
ldir |
||||
|
pop de |
||||
|
;source-doc/base-drv/./class_hid.c:11: cmd.bRequest = HID_SET_PROTOCOL; |
||||
|
ld (ix-7),0x0b |
||||
|
;source-doc/base-drv/./class_hid.c:12: cmd.bValue[0] = protocol; |
||||
|
ld a,(ix+4) |
||||
|
ld (ix-6),a |
||||
|
;source-doc/base-drv/./class_hid.c:14: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); |
||||
|
ld l, e |
||||
|
ld h, d |
||||
|
inc hl |
||||
|
ld c, (hl) |
||||
|
ex de, hl |
||||
|
ld a, (hl) |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
and 0x0f |
||||
|
ld h, c |
||||
|
push hl |
||||
|
inc sp |
||||
|
push af |
||||
|
inc sp |
||||
|
ld hl,0x0000 |
||||
|
push hl |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
push hl |
||||
|
call _usb_control_transfer |
||||
|
pop af |
||||
|
pop af |
||||
|
pop af |
||||
|
ld a, l |
||||
|
;source-doc/base-drv/./class_hid.c:16: RETURN_CHECK(result); |
||||
|
;source-doc/base-drv/./class_hid.c:17: } |
||||
|
ld sp, ix |
||||
|
pop ix |
||||
|
pop hl |
||||
|
inc sp |
||||
|
jp (hl) |
||||
|
_cmd_hid_set: |
||||
|
DEFB +0x21 |
||||
|
DEFB +0x0b |
||||
|
DEFB +0x00 |
||||
|
DEFB +0x00 |
||||
|
DEFB +0x00 |
||||
|
DEFB +0x00 |
||||
|
DEFW +0x0000 |
||||
|
;source-doc/base-drv/./class_hid.c:19: usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1) { |
||||
|
; --------------------------------- |
||||
|
; Function hid_set_idle |
||||
|
; --------------------------------- |
||||
|
_hid_set_idle: |
||||
|
push ix |
||||
|
ld ix,0 |
||||
|
add ix,sp |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
ex de, hl |
||||
|
;source-doc/base-drv/./class_hid.c:22: cmd = cmd_hid_set; |
||||
|
push de |
||||
|
ex de, hl |
||||
|
ld hl,2 |
||||
|
add hl, sp |
||||
|
ex de, hl |
||||
|
ld hl,_cmd_hid_set |
||||
|
ld bc,0x0008 |
||||
|
ldir |
||||
|
pop de |
||||
|
;source-doc/base-drv/./class_hid.c:24: cmd.bRequest = HID_SET_IDLE; |
||||
|
ld (ix-7),0x0a |
||||
|
;source-doc/base-drv/./class_hid.c:25: cmd.bValue[0] = duration; |
||||
|
ld a,(ix+4) |
||||
|
ld (ix-6),a |
||||
|
;source-doc/base-drv/./class_hid.c:27: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); |
||||
|
ld l, e |
||||
|
ld h, d |
||||
|
inc hl |
||||
|
ld c, (hl) |
||||
|
ex de, hl |
||||
|
ld a, (hl) |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
and 0x0f |
||||
|
ld h, c |
||||
|
push hl |
||||
|
inc sp |
||||
|
push af |
||||
|
inc sp |
||||
|
ld hl,0x0000 |
||||
|
push hl |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
push hl |
||||
|
call _usb_control_transfer |
||||
|
pop af |
||||
|
pop af |
||||
|
pop af |
||||
|
ld a, l |
||||
|
;source-doc/base-drv/./class_hid.c:29: RETURN_CHECK(result); |
||||
|
;source-doc/base-drv/./class_hid.c:30: } |
||||
|
ld sp, ix |
||||
|
pop ix |
||||
|
pop hl |
||||
|
inc sp |
||||
|
jp (hl) |
||||
|
;source-doc/base-drv/./class_hid.c:32: usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { |
||||
|
; --------------------------------- |
||||
|
; Function hid_get_input_report |
||||
|
; --------------------------------- |
||||
|
_hid_get_input_report: |
||||
|
push ix |
||||
|
ld ix,0 |
||||
|
add ix,sp |
||||
|
ld c, l |
||||
|
ld b, h |
||||
|
ld hl, -9 |
||||
|
add hl, sp |
||||
|
ld sp, hl |
||||
|
ld l, c |
||||
|
ld h, b |
||||
|
;source-doc/base-drv/./class_hid.c:35: cmd = cmd_hid_set; |
||||
|
push de |
||||
|
push hl |
||||
|
ex de, hl |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
ex de, hl |
||||
|
ld hl,_cmd_hid_set |
||||
|
ld bc,0x0008 |
||||
|
ldir |
||||
|
pop bc |
||||
|
pop de |
||||
|
;source-doc/base-drv/./class_hid.c:37: cmd.bmRequestType = 0xA1; |
||||
|
ld (ix-9),0xa1 |
||||
|
;source-doc/base-drv/./class_hid.c:38: cmd.bValue[0] = 1; |
||||
|
ld (ix-7),0x01 |
||||
|
;source-doc/base-drv/./class_hid.c:39: cmd.bValue[1] = 1; |
||||
|
ld (ix-6),0x01 |
||||
|
;source-doc/base-drv/./class_hid.c:40: cmd.bRequest = HID_GET_REPORT; |
||||
|
ld (ix-8),0x01 |
||||
|
;source-doc/base-drv/./class_hid.c:41: cmd.wLength = 8; |
||||
|
ld (ix-3),0x08 |
||||
|
xor a |
||||
|
ld (ix-2),a |
||||
|
;source-doc/base-drv/./class_hid.c:43: result = usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); |
||||
|
ld l, c |
||||
|
ld h, b |
||||
|
inc hl |
||||
|
ld a, (hl) |
||||
|
ld (ix-1),a |
||||
|
ld l, c |
||||
|
ld h, b |
||||
|
ld a, (hl) |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
and 0x0f |
||||
|
ld h,(ix-1) |
||||
|
push hl |
||||
|
inc sp |
||||
|
push af |
||||
|
inc sp |
||||
|
push de |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
push hl |
||||
|
call _usb_control_transfer |
||||
|
pop af |
||||
|
pop af |
||||
|
pop af |
||||
|
ld a, l |
||||
|
;source-doc/base-drv/./class_hid.c:45: RETURN_CHECK(result); |
||||
|
;source-doc/base-drv/./class_hid.c:46: } |
||||
|
ld sp, ix |
||||
|
pop ix |
||||
|
ret |
||||
@ -0,0 +1,3 @@ |
|||||
|
; Generated File -- not to be modify directly |
||||
|
#include "ch376-native/keyboard/kyb-init.c.s" |
||||
|
#include "ch376-native/keyboard/class_hid.c.s" |
||||
@ -0,0 +1,254 @@ |
|||||
|
; |
||||
|
; Generated from source-doc/keyboard/./class_hid.c.asm -- not to be modify directly |
||||
|
; |
||||
|
; |
||||
|
;-------------------------------------------------------- |
||||
|
; File Created by SDCC : free open source ISO C Compiler |
||||
|
; Version 4.4.0 #14648 (Linux) |
||||
|
;-------------------------------------------------------- |
||||
|
; Processed by Z88DK |
||||
|
;-------------------------------------------------------- |
||||
|
|
||||
|
|
||||
|
;-------------------------------------------------------- |
||||
|
; Public variables in this module |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; Externals used |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; special function registers |
||||
|
;-------------------------------------------------------- |
||||
|
_CH376_DATA_PORT .EQU 0xff88 |
||||
|
_CH376_COMMAND_PORT .EQU 0xff89 |
||||
|
_USB_MODULE_LEDS .EQU 0xff8a |
||||
|
;-------------------------------------------------------- |
||||
|
; ram data |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; ram data |
||||
|
;-------------------------------------------------------- |
||||
|
|
||||
|
#IF 0 |
||||
|
|
||||
|
; .area _INITIALIZED removed by z88dk |
||||
|
|
||||
|
|
||||
|
#ENDIF |
||||
|
|
||||
|
;-------------------------------------------------------- |
||||
|
; absolute external ram data |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; global & static initialisations |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; Home |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; code |
||||
|
;-------------------------------------------------------- |
||||
|
;source-doc/keyboard/./class_hid.c:6: usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1) { |
||||
|
; --------------------------------- |
||||
|
; Function hid_set_protocol |
||||
|
; --------------------------------- |
||||
|
_hid_set_protocol: |
||||
|
push ix |
||||
|
ld ix,0 |
||||
|
add ix,sp |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
ex de, hl |
||||
|
;source-doc/keyboard/./class_hid.c:9: cmd = cmd_hid_set; |
||||
|
push de |
||||
|
ex de, hl |
||||
|
ld hl,2 |
||||
|
add hl, sp |
||||
|
ex de, hl |
||||
|
ld hl,_cmd_hid_set |
||||
|
ld bc,0x0008 |
||||
|
ldir |
||||
|
pop de |
||||
|
;source-doc/keyboard/./class_hid.c:11: cmd.bRequest = HID_SET_PROTOCOL; |
||||
|
ld (ix-7),0x0b |
||||
|
;source-doc/keyboard/./class_hid.c:12: cmd.bValue[0] = protocol; |
||||
|
ld a,(ix+4) |
||||
|
ld (ix-6),a |
||||
|
;source-doc/keyboard/./class_hid.c:14: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); |
||||
|
ld l, e |
||||
|
ld h, d |
||||
|
inc hl |
||||
|
ld c, (hl) |
||||
|
ex de, hl |
||||
|
ld a, (hl) |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
and 0x0f |
||||
|
ld h, c |
||||
|
push hl |
||||
|
inc sp |
||||
|
push af |
||||
|
inc sp |
||||
|
ld hl,0x0000 |
||||
|
push hl |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
push hl |
||||
|
call _usb_control_transfer |
||||
|
pop af |
||||
|
pop af |
||||
|
pop af |
||||
|
ld a, l |
||||
|
;source-doc/keyboard/./class_hid.c:16: RETURN_CHECK(result); |
||||
|
;source-doc/keyboard/./class_hid.c:17: } |
||||
|
ld sp, ix |
||||
|
pop ix |
||||
|
pop hl |
||||
|
inc sp |
||||
|
jp (hl) |
||||
|
_cmd_hid_set: |
||||
|
DEFB +0x21 |
||||
|
DEFB +0x0b |
||||
|
DEFB +0x00 |
||||
|
DEFB +0x00 |
||||
|
DEFB +0x00 |
||||
|
DEFB +0x00 |
||||
|
DEFW +0x0000 |
||||
|
;source-doc/keyboard/./class_hid.c:19: usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1) { |
||||
|
; --------------------------------- |
||||
|
; Function hid_set_idle |
||||
|
; --------------------------------- |
||||
|
_hid_set_idle: |
||||
|
push ix |
||||
|
ld ix,0 |
||||
|
add ix,sp |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
push af |
||||
|
ex de, hl |
||||
|
;source-doc/keyboard/./class_hid.c:22: cmd = cmd_hid_set; |
||||
|
push de |
||||
|
ex de, hl |
||||
|
ld hl,2 |
||||
|
add hl, sp |
||||
|
ex de, hl |
||||
|
ld hl,_cmd_hid_set |
||||
|
ld bc,0x0008 |
||||
|
ldir |
||||
|
pop de |
||||
|
;source-doc/keyboard/./class_hid.c:24: cmd.bRequest = HID_SET_IDLE; |
||||
|
ld (ix-7),0x0a |
||||
|
;source-doc/keyboard/./class_hid.c:25: cmd.bValue[0] = duration; |
||||
|
ld a,(ix+4) |
||||
|
ld (ix-6),a |
||||
|
;source-doc/keyboard/./class_hid.c:27: result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); |
||||
|
ld l, e |
||||
|
ld h, d |
||||
|
inc hl |
||||
|
ld c, (hl) |
||||
|
ex de, hl |
||||
|
ld a, (hl) |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
and 0x0f |
||||
|
ld h, c |
||||
|
push hl |
||||
|
inc sp |
||||
|
push af |
||||
|
inc sp |
||||
|
ld hl,0x0000 |
||||
|
push hl |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
push hl |
||||
|
call _usb_control_transfer |
||||
|
pop af |
||||
|
pop af |
||||
|
pop af |
||||
|
ld a, l |
||||
|
;source-doc/keyboard/./class_hid.c:29: RETURN_CHECK(result); |
||||
|
;source-doc/keyboard/./class_hid.c:30: } |
||||
|
ld sp, ix |
||||
|
pop ix |
||||
|
pop hl |
||||
|
inc sp |
||||
|
jp (hl) |
||||
|
;source-doc/keyboard/./class_hid.c:32: usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { |
||||
|
; --------------------------------- |
||||
|
; Function hid_get_input_report |
||||
|
; --------------------------------- |
||||
|
_hid_get_input_report: |
||||
|
push ix |
||||
|
ld ix,0 |
||||
|
add ix,sp |
||||
|
ld c, l |
||||
|
ld b, h |
||||
|
ld hl, -9 |
||||
|
add hl, sp |
||||
|
ld sp, hl |
||||
|
ld l, c |
||||
|
ld h, b |
||||
|
;source-doc/keyboard/./class_hid.c:35: cmd = cmd_hid_set; |
||||
|
push de |
||||
|
push hl |
||||
|
ex de, hl |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
ex de, hl |
||||
|
ld hl,_cmd_hid_set |
||||
|
ld bc,0x0008 |
||||
|
ldir |
||||
|
pop bc |
||||
|
pop de |
||||
|
;source-doc/keyboard/./class_hid.c:37: cmd.bmRequestType = 0xA1; |
||||
|
ld (ix-9),0xa1 |
||||
|
;source-doc/keyboard/./class_hid.c:38: cmd.bValue[0] = 1; |
||||
|
ld (ix-7),0x01 |
||||
|
;source-doc/keyboard/./class_hid.c:39: cmd.bValue[1] = 1; |
||||
|
ld (ix-6),0x01 |
||||
|
;source-doc/keyboard/./class_hid.c:40: cmd.bRequest = HID_GET_REPORT; |
||||
|
ld (ix-8),0x01 |
||||
|
;source-doc/keyboard/./class_hid.c:41: cmd.wLength = 8; |
||||
|
ld (ix-3),0x08 |
||||
|
xor a |
||||
|
ld (ix-2),a |
||||
|
;source-doc/keyboard/./class_hid.c:43: result = usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); |
||||
|
ld l, c |
||||
|
ld h, b |
||||
|
inc hl |
||||
|
ld a, (hl) |
||||
|
ld (ix-1),a |
||||
|
ld l, c |
||||
|
ld h, b |
||||
|
ld a, (hl) |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
rlca |
||||
|
and 0x0f |
||||
|
ld h,(ix-1) |
||||
|
push hl |
||||
|
inc sp |
||||
|
push af |
||||
|
inc sp |
||||
|
push de |
||||
|
ld hl,4 |
||||
|
add hl, sp |
||||
|
push hl |
||||
|
call _usb_control_transfer |
||||
|
pop af |
||||
|
pop af |
||||
|
pop af |
||||
|
ld a, l |
||||
|
;source-doc/keyboard/./class_hid.c:45: RETURN_CHECK(result); |
||||
|
;source-doc/keyboard/./class_hid.c:46: } |
||||
|
ld sp, ix |
||||
|
pop ix |
||||
|
ret |
||||
@ -0,0 +1,134 @@ |
|||||
|
; |
||||
|
; Generated from source-doc/keyboard/./kyb-init.c.asm -- not to be modify directly |
||||
|
; |
||||
|
; |
||||
|
;-------------------------------------------------------- |
||||
|
; File Created by SDCC : free open source ISO C Compiler |
||||
|
; Version 4.4.0 #14648 (Linux) |
||||
|
;-------------------------------------------------------- |
||||
|
; Processed by Z88DK |
||||
|
;-------------------------------------------------------- |
||||
|
|
||||
|
|
||||
|
;-------------------------------------------------------- |
||||
|
; Public variables in this module |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; Externals used |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; special function registers |
||||
|
;-------------------------------------------------------- |
||||
|
_CH376_DATA_PORT .EQU 0xff88 |
||||
|
_CH376_COMMAND_PORT .EQU 0xff89 |
||||
|
_USB_MODULE_LEDS .EQU 0xff8a |
||||
|
;-------------------------------------------------------- |
||||
|
; ram data |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; ram data |
||||
|
;-------------------------------------------------------- |
||||
|
|
||||
|
#IF 0 |
||||
|
|
||||
|
; .area _INITIALIZED removed by z88dk |
||||
|
|
||||
|
|
||||
|
#ENDIF |
||||
|
|
||||
|
;-------------------------------------------------------- |
||||
|
; absolute external ram data |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; global & static initialisations |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; Home |
||||
|
;-------------------------------------------------------- |
||||
|
;-------------------------------------------------------- |
||||
|
; code |
||||
|
;-------------------------------------------------------- |
||||
|
;source-doc/keyboard/./kyb-init.c:8: void keyboard_init(void) { |
||||
|
; --------------------------------- |
||||
|
; Function keyboard_init |
||||
|
; --------------------------------- |
||||
|
_keyboard_init: |
||||
|
;source-doc/keyboard/./kyb-init.c:10: uint8_t index = 1; |
||||
|
;source-doc/keyboard/./kyb-init.c:11: do { |
||||
|
ld bc,0x0101 |
||||
|
l_keyboard_init_00105: |
||||
|
;source-doc/keyboard/./kyb-init.c:12: device_config_keyboard *const keyboard_config = (device_config_keyboard *)get_usb_device_config(index); |
||||
|
push bc |
||||
|
ld a, b |
||||
|
call _get_usb_device_config |
||||
|
pop bc |
||||
|
;source-doc/keyboard/./kyb-init.c:14: if (keyboard_config == NULL) |
||||
|
ld a, d |
||||
|
or e |
||||
|
jr Z,l_keyboard_init_00107 |
||||
|
;source-doc/keyboard/./kyb-init.c:17: const usb_device_type t = keyboard_config->type; |
||||
|
ld l, e |
||||
|
ld h, d |
||||
|
ld a, (hl) |
||||
|
and 0x0f |
||||
|
;source-doc/keyboard/./kyb-init.c:19: if (t == USB_IS_KEYBOARD) { |
||||
|
sub 0x04 |
||||
|
jr NZ,l_keyboard_init_00106 |
||||
|
;source-doc/keyboard/./kyb-init.c:20: print_string("\r\nUSB: KEYBOARD @ $"); |
||||
|
push bc |
||||
|
push de |
||||
|
ld hl,kyb_init_str_0 |
||||
|
call _print_string |
||||
|
pop de |
||||
|
pop bc |
||||
|
;source-doc/keyboard/./kyb-init.c:21: print_uint16(index); |
||||
|
ld h,0x00 |
||||
|
push de |
||||
|
ld l, c |
||||
|
call _print_uint16 |
||||
|
ld hl,kyb_init_str_1 |
||||
|
call _print_string |
||||
|
pop de |
||||
|
;source-doc/keyboard/./kyb-init.c:25: hid_set_protocol(keyboard_config, 1); |
||||
|
push de |
||||
|
ld a,0x01 |
||||
|
push af |
||||
|
inc sp |
||||
|
ex de,hl |
||||
|
call _hid_set_protocol |
||||
|
pop de |
||||
|
;source-doc/keyboard/./kyb-init.c:26: hid_set_idle(keyboard_config, 0x80); |
||||
|
ld a,0x80 |
||||
|
push af |
||||
|
inc sp |
||||
|
ex de, hl |
||||
|
call _hid_set_idle |
||||
|
;source-doc/keyboard/./kyb-init.c:27: return; |
||||
|
jr l_keyboard_init_00108 |
||||
|
l_keyboard_init_00106: |
||||
|
;source-doc/keyboard/./kyb-init.c:29: } while (++index != MAX_NUMBER_OF_DEVICES + 1); |
||||
|
inc b |
||||
|
ld a,b |
||||
|
ld c,a |
||||
|
sub 0x07 |
||||
|
jr NZ,l_keyboard_init_00105 |
||||
|
l_keyboard_init_00107: |
||||
|
;source-doc/keyboard/./kyb-init.c:31: print_string("\r\nUSB: KEYBOARD: NOT FOUND$"); |
||||
|
ld hl,kyb_init_str_2 |
||||
|
jp _print_string |
||||
|
l_keyboard_init_00108: |
||||
|
;source-doc/keyboard/./kyb-init.c:32: } |
||||
|
ret |
||||
|
kyb_init_str_0: |
||||
|
DEFB 0x0d |
||||
|
DEFB 0x0a |
||||
|
DEFM "USB: KEYBOARD @ $" |
||||
|
DEFB 0x00 |
||||
|
kyb_init_str_1: |
||||
|
DEFM " $" |
||||
|
DEFB 0x00 |
||||
|
kyb_init_str_2: |
||||
|
DEFB 0x0d |
||||
|
DEFB 0x0a |
||||
|
DEFM "USB: KEYBOARD: NOT FOUND$" |
||||
|
DEFB 0x00 |
||||
@ -0,0 +1,46 @@ |
|||||
|
#include "class_hid.h" |
||||
|
#include <stdint.h> |
||||
|
|
||||
|
const setup_packet cmd_hid_set = {0x21, HID_SET_PROTOCOL, {0, 0}, {0, 0}, 0}; |
||||
|
|
||||
|
usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1) { |
||||
|
usb_error result; |
||||
|
setup_packet cmd; |
||||
|
cmd = cmd_hid_set; |
||||
|
|
||||
|
cmd.bRequest = HID_SET_PROTOCOL; |
||||
|
cmd.bValue[0] = protocol; |
||||
|
|
||||
|
result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); |
||||
|
|
||||
|
RETURN_CHECK(result); |
||||
|
} |
||||
|
|
||||
|
usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1) { |
||||
|
usb_error result; |
||||
|
setup_packet cmd; |
||||
|
cmd = cmd_hid_set; |
||||
|
|
||||
|
cmd.bRequest = HID_SET_IDLE; |
||||
|
cmd.bValue[0] = duration; |
||||
|
|
||||
|
result = usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); |
||||
|
|
||||
|
RETURN_CHECK(result); |
||||
|
} |
||||
|
|
||||
|
usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { |
||||
|
usb_error result; |
||||
|
setup_packet cmd; |
||||
|
cmd = cmd_hid_set; |
||||
|
|
||||
|
cmd.bmRequestType = 0xA1; |
||||
|
cmd.bValue[0] = 1; |
||||
|
cmd.bValue[1] = 1; |
||||
|
cmd.bRequest = HID_GET_REPORT; |
||||
|
cmd.wLength = 8; |
||||
|
|
||||
|
result = usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); |
||||
|
|
||||
|
RETURN_CHECK(result); |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
#ifndef __CLASS_HID_H__ |
||||
|
#define __CLASS_HID_H__ |
||||
|
|
||||
|
#include "ch376.h" |
||||
|
#include "protocol.h" |
||||
|
|
||||
|
#define HID_GET_REPORT 0x01 |
||||
|
#define HID_GET_IDLE 0x02 |
||||
|
#define HID_GET_PROTOCOL 0x03 |
||||
|
#define HID_SET_REPORT 0x09 |
||||
|
#define HID_SET_IDLE 0x0A |
||||
|
#define HID_SET_PROTOCOL 0x0B |
||||
|
|
||||
|
#define HID_BOOT_PROTOCOL 0x00 |
||||
|
#define HID_REPORT_PROTOCOL 0x01 |
||||
|
|
||||
|
extern usb_error hid_set_protocol(const device_config_keyboard *const dev, const uint8_t protocol) __sdcccall(1); |
||||
|
extern usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t duration) __sdcccall(1); |
||||
|
extern usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1); |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,24 @@ |
|||||
|
#ifndef __CLASS_HID_KEYBOARD_H__ |
||||
|
#define __CLASS_HID_KEYBOARD_H__ |
||||
|
|
||||
|
#include <stdint.h> |
||||
|
|
||||
|
typedef struct { |
||||
|
uint8_t bModifierKeys; |
||||
|
uint8_t bReserved; |
||||
|
uint8_t keyCode[6]; |
||||
|
} keyboard_report; |
||||
|
|
||||
|
#define KEY_MOD_LCTRL 0x01 |
||||
|
#define KEY_MOD_LSHIFT 0x02 |
||||
|
#define KEY_MOD_LALT 0x04 |
||||
|
#define KEY_MOD_LMETA 0x08 |
||||
|
#define KEY_MOD_RCTRL 0x10 |
||||
|
#define KEY_MOD_RSHIFT 0x20 |
||||
|
#define KEY_MOD_RALT 0x40 |
||||
|
#define KEY_MOD_RMETA 0x80 |
||||
|
|
||||
|
extern char scancodes_table[128]; |
||||
|
extern char scancode_to_char(const uint8_t modifier_keys, const uint8_t code) __sdcccall(1); |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,54 @@ |
|||||
|
#include "class_hid.h" |
||||
|
#include "class_hid_keyboard.h" |
||||
|
#include <dev_transfers.h> |
||||
|
#include <print.h> |
||||
|
#include <stdint.h> |
||||
|
#include <usb_state.h> |
||||
|
|
||||
|
void keyboard_init(void) { |
||||
|
|
||||
|
uint8_t index = 1; |
||||
|
do { |
||||
|
device_config_keyboard *const keyboard_config = (device_config_keyboard *)get_usb_device_config(index); |
||||
|
|
||||
|
if (keyboard_config == NULL) |
||||
|
break; |
||||
|
|
||||
|
const usb_device_type t = keyboard_config->type; |
||||
|
|
||||
|
if (t == USB_IS_KEYBOARD) { |
||||
|
print_string("\r\nUSB: KEYBOARD @ $"); |
||||
|
print_uint16(index); |
||||
|
print_string(" $"); |
||||
|
|
||||
|
// keyboard_config->drive_index = usb_device_count++;
|
||||
|
hid_set_protocol(keyboard_config, 1); |
||||
|
hid_set_idle(keyboard_config, 0x80); |
||||
|
return; |
||||
|
} |
||||
|
} while (++index != MAX_NUMBER_OF_DEVICES + 1); |
||||
|
|
||||
|
print_string("\r\nUSB: KEYBOARD: NOT FOUND$"); |
||||
|
} |
||||
|
|
||||
|
// void drv_timi_keyboard(void) {
|
||||
|
// _usb_state *const p = get_usb_work_area();
|
||||
|
// if (p->active)
|
||||
|
// return;
|
||||
|
|
||||
|
// p->active = true;
|
||||
|
|
||||
|
// device_config_keyboard *const keyboard_config = (device_config_keyboard *)find_device_config(USB_IS_KEYBOARD);
|
||||
|
|
||||
|
// keyboard_report report;
|
||||
|
|
||||
|
// ch_configure_nak_retry_disable();
|
||||
|
// const usb_error result = usbdev_data_in_transfer_ep0((device_config *)keyboard_config, (uint8_t *)report, 8);
|
||||
|
// ch_configure_nak_retry_3s();
|
||||
|
// if (result == 0) {
|
||||
|
// const char c = scancode_to_char(report.bModifierKeys, report.keyCode[0]);
|
||||
|
// key_put_into_buf(c);
|
||||
|
// }
|
||||
|
|
||||
|
// p->active = false;
|
||||
|
// }
|
||||
@ -0,0 +1,90 @@ |
|||||
|
; |
||||
|
;================================================================================================== |
||||
|
; CH376 NATIVE USB KEYBOARD DRIVER |
||||
|
;================================================================================================== |
||||
|
; |
||||
|
|
||||
|
#DEFINE DEFM .DB |
||||
|
#DEFINE DEFB .DB |
||||
|
#DEFINE DEFW .DW |
||||
|
|
||||
|
#IF (SYSTIM == TM_NONE) |
||||
|
.ECHO "*** ERROR: MKY REQUIRES SYSTEM TIMER -- NONE CONFIGURED!!!\n" |
||||
|
!!! ; FORCE AN ASSEMBLY ERROR |
||||
|
#ENDIF |
||||
|
|
||||
|
#include "./ch376-native/keyboard.s" |
||||
|
|
||||
|
|
||||
|
CHUKB_INIT .EQU _keyboard_init |
||||
|
|
||||
|
; ### Function 0x4C -- Keyboard Status (VDAKST) |
||||
|
; |
||||
|
; Inputs: |
||||
|
; None |
||||
|
; |
||||
|
; Outputs: |
||||
|
; A: Status / Codes Pending |
||||
|
; |
||||
|
; Return a count of the number of key Codes Pending (A) in the keyboard buffer. |
||||
|
; If it is not possible to determine the actual number in the buffer, it is |
||||
|
; acceptable to return 1 to indicate there are key codes available to read and |
||||
|
; 0 if there are none available. |
||||
|
; The value returned in register A is used as both a Status (A) code and the |
||||
|
; return value. Negative values (bit 7 set) indicate a standard HBIOS result |
||||
|
; (error) code. Otherwise, the return value represents the number of key codes |
||||
|
; pending. |
||||
|
; |
||||
|
UKY_STAT: |
||||
|
XOR A |
||||
|
RET |
||||
|
|
||||
|
; ### Function 0x4D -- Video Keyboard Flush (VDAKFL) |
||||
|
; |
||||
|
; Inputs: |
||||
|
; C: Video Unit |
||||
|
; |
||||
|
; Outputs: |
||||
|
; A: standard HBIOS result code |
||||
|
; |
||||
|
; Purged and all contents discarded. The Status (A) is a standard HBIOS result code. |
||||
|
; |
||||
|
UKY_FLUSH: |
||||
|
RET |
||||
|
; |
||||
|
; ### Function 0x4E -- Video Keyboard Read (VDAKRD) |
||||
|
; |
||||
|
; Inputs: |
||||
|
; None |
||||
|
; |
||||
|
; Outputs: |
||||
|
; A: Status |
||||
|
; C: Scancode |
||||
|
; D: Keystate |
||||
|
; E: Keycode |
||||
|
; |
||||
|
; Read the next key data from the keyboard. If a buffer is used, return the next key code in the buffer. |
||||
|
; If no key data is available, this function will wait indefinitely for a keypress. The Status (A) is a |
||||
|
; standard HBIOS result code. |
||||
|
; |
||||
|
; The Scancode (C) value is the raw scancode from the keyboard for the keypress. Scancodes are from |
||||
|
; the PS/2 scancode set 2 standard. |
||||
|
; |
||||
|
; The Keystate (D) is a bitmap representing the value of all modifier keys and shift states as they |
||||
|
; existed at the time of the keystroke. The bitmap is defined as: |
||||
|
; |
||||
|
; Bit Keystate Indication |
||||
|
; 7 Key pressed was from the num pad |
||||
|
; 6 Caps Lock was active |
||||
|
; 5 Num Lock was active |
||||
|
; 4 Scroll Lock was active |
||||
|
; 3 Windows key was held down |
||||
|
; 2 Alt key was held down |
||||
|
; 1 Control key was held down |
||||
|
; 0 Shift key was held down |
||||
|
; |
||||
|
; The Keycode (E) is generally returned as appropriate ASCII values, if possible. Special keys, like |
||||
|
; function keys and arrows, are returned as reserved codes as described at the start of this section. |
||||
|
; |
||||
|
UKY_READ: |
||||
|
RET |
||||
Loading…
Reference in new issue