Commit graph

307 commits

Author SHA1 Message Date
tmk
12eaedf9cf ibmpc: Change timeout period: 1.0ms to 2.0ms
Timeout error *could*(not always) detects when signal sequence takes beyond 1.0ms.
Now this gives 2.0ms window at least to read signal sequence.
2020-07-05 12:46:47 +09:00
tmk
5c45beb89e core: Fix matrix_print() 2020-06-02 00:57:37 +09:00
tmk
3208b7e447 core: Add default impl for led_set() 2020-05-30 15:20:05 +09:00
tmk
0ab0ebf8cb core: Make TIMER0 ISR noblock
The TIMER0 ISR takes 1.5us and can affect IBMPC protocol ISR.
Add ISR_NOBLOCK to allow interrupt during TIMER0 ISR.
2020-05-22 11:52:44 +09:00
tmk
f80601db96 ibmpc: Add Z-150 AT protocol recognition
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#zenith-z-150-beige
2020-05-15 14:32:14 +09:00
tmk
343c32afc6 ibmpc: Fix 'Ack' check of sending data 2020-05-13 23:12:50 +09:00
tmk
54e3c239fc ibmpc: Fix AT 'request to send' signaling
Without this fix Realforce 101 PS/2 fails to receive 'set indicator'
command sometimes when pressing Caps Lock and some keys simultaneously.

before fix:
      ____     ______
clock     \___/
      ________
data          \_______
          | 100|

after fix:
      ____          __
clock     \________/
      ________
data          \_______
          | 100| 100|
2020-05-13 22:32:14 +09:00
tmk
c6a6049bc8 ibmpc_usb: Add 'protocol change detection'
for better keybaord hotswap support
2020-05-13 14:47:18 +09:00
tmk
346169c5ed ibmpc: Fix ibmpc_host_isr_clear() 2020-05-12 18:51:39 +09:00
tmk
3e801a63e4 ibmpc: Add debug code for isr_state 2020-05-12 18:50:21 +09:00
tmk
77c5017cb2 ibmpc: Fix buffer full check
recv_data should appear to as 'sstt' when it is full with two data.
Both upper and lower byte should be checked.
2020-05-12 18:28:07 +09:00
tmk
4028b200be ibmpc: Fix Timeout error
Timeout error may be recoverable but may not in some situations.
For safety it is handled as a real error to start keyboard
recognition again.
2020-05-12 18:21:40 +09:00
tmk
dd316b990f core: Add HID usage for Display Brightness Control 2020-05-11 21:58:50 +09:00
tmk
53d10fe247 ibmpc: Update ERR_FF, ERR_FULL handling 2020-05-11 16:13:47 +09:00
tmk
0cf9dfc888 ibmpc: Add ibmpc_isr_debug to see isr_state 2020-05-11 16:12:36 +09:00
tmk
7c3b669e6f ibmpc: Add handling for erroneous start bit XT(IBM)
This is **not perferred** if it is evitable.
It allows to read start(0) as 1 wrongly at cost of 100us wait.
2020-05-11 16:11:39 +09:00
tmk
9f04146031 lufa: Fix comment on INTERRUPT_CONTROL_ENDPOINT 2020-05-08 22:39:55 +09:00
tmk
820d96bdab core: ibmpc: Check response of set indicator command 2020-05-08 21:48:59 +09:00
tmk
27812520eb core: ibmpc: Add comments on stop bit of Z-150 AT 2020-05-08 21:46:33 +09:00
tmk
46bd3670cf core: Add 'dude' makefile target for avrdude
Run like `make dude DEV=/dev/ttyACM0` to program
Arduino such as Pro Micro and Leonardo
2020-05-06 09:36:28 +09:00
Purdea Andrei
061e662345 tmk_core/common/timer.h: Improve code generation for TIMER_DIFF* macros
Because of integer promotion the compiler is having a hard time generating
efficient code to calculate TIMER_DIFF* macros in some situations.
In the below example, the return value is "int", and this is causing the
trouble.

Example C code:

int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}

BEFORE: (with -Os)

00004c40 <test>:
    4c40:       28 2f           mov     r18, r24
    4c42:       30 e0           ldi     r19, 0x00       ; 0
    4c44:       46 2f           mov     r20, r22
    4c46:       50 e0           ldi     r21, 0x00       ; 0
    4c48:       86 17           cp      r24, r22
    4c4a:       20 f0           brcs    .+8             ; 0x4c54 <test+0x14>
    4c4c:       c9 01           movw    r24, r18
    4c4e:       84 1b           sub     r24, r20
    4c50:       95 0b           sbc     r25, r21
    4c52:       08 95           ret
    4c54:       c9 01           movw    r24, r18
    4c56:       84 1b           sub     r24, r20
    4c58:       95 0b           sbc     r25, r21
    4c5a:       93 95           inc     r25
    4c5c:       08 95           ret

AFTER: (with -Os)

00004c40 <test>:
    4c40:       86 1b           sub     r24, r22
    4c42:       90 e0           ldi     r25, 0x00       ; 0
    4c44:       08 95           ret

Note: the example is showing -Os but improvements can be seen at all optimization levels,
including -O0. We never use -O0, but I tested it to make sure that no extra code is
generated in that case.
2020-04-01 07:46:18 +03:00
Purdea Andrei
338a1506dc tmk_core/common/timer.h: Fixing TIMER_DIFF macro to calculate difference correctly after the timer wraps.
Let's go through an example, using the following macro:

If the first timer read is 0xe4 and the second one is 0x32, the timer wrapped.
If the timer would have had more bits, it's new value would have been 0x132,
and the correct difference in time is 0x132 - 0xe4 = 0x4e

old code TIMER_DIFF_8(0x32, 0xe4) = 0xff - 0xe4 + 0x32 = 0x4d, which is wrong.
new code TIMER_DIFF_8(0x32, 0xe4) = 0xff + 1 - 0xe4 + 0x32 = 0x4e, which is correct.

This also gives a chance for a smart compiler to optimize the code using normal
integer overflow.

For example on AVR, the following C code:
uint8_t __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}
With the original code, it gets translated to the following list of instructions:
00004c6e <test>:
    4c6e:       98 2f           mov     r25, r24
    4c70:       86 1b           sub     r24, r22
    4c72:       96 17           cp      r25, r22
    4c74:       08 f4           brcc    .+2             ; 0x4c78 <test+0xa>
    4c76:       81 50           subi    r24, 0x01       ; 1
    4c78:       08 95           ret
But with this commit, it gets translated to a single instruction:
00004c40 <test>:
    4c40:       86 1b           sub     r24, r22
    4c42:       08 95           ret

This unfortunately doesn't always work so nicely, for example the following C code:
int __attribute__ ((noinline)) test(uint8_t current_timer, uint8_t start_timer)
{
    return TIMER_DIFF_8(current_timer, start_timer);
}
(Note: return type changed to int)
With the original code it gets translated to:
00004c6e <test>:
    4c6e:       28 2f           mov     r18, r24
    4c70:       30 e0           ldi     r19, 0x00       ; 0
    4c72:       46 2f           mov     r20, r22
    4c74:       50 e0           ldi     r21, 0x00       ; 0
    4c76:       86 17           cp      r24, r22
    4c78:       20 f0           brcs    .+8             ; 0x4c82 <test+0x14>
    4c7a:       c9 01           movw    r24, r18
    4c7c:       84 1b           sub     r24, r20
    4c7e:       95 0b           sbc     r25, r21
    4c80:       08 95           ret
    4c82:       c9 01           movw    r24, r18
    4c84:       84 1b           sub     r24, r20
    4c86:       95 0b           sbc     r25, r21
    4c88:       81 50           subi    r24, 0x01       ; 1
    4c8a:       9f 4f           sbci    r25, 0xFF       ; 255
    4c8c:       08 95           ret
Wth this commit it gets translated to:
00004c40 <test>:
    4c40:       28 2f           mov     r18, r24
    4c42:       30 e0           ldi     r19, 0x00       ; 0
    4c44:       46 2f           mov     r20, r22
    4c46:       50 e0           ldi     r21, 0x00       ; 0
    4c48:       86 17           cp      r24, r22
    4c4a:       20 f0           brcs    .+8             ; 0x4c54 <test+0x14>
    4c4c:       c9 01           movw    r24, r18
    4c4e:       84 1b           sub     r24, r20
    4c50:       95 0b           sbc     r25, r21
    4c52:       08 95           ret
    4c54:       c9 01           movw    r24, r18
    4c56:       84 1b           sub     r24, r20
    4c58:       95 0b           sbc     r25, r21
    4c5a:       93 95           inc     r25
    4c5c:       08 95           ret
There is not much performance improvement in this case, however at least with this
commit it functions correctly.

Note: The following commit will improve compiler output for the latter example.
2020-04-01 07:45:05 +03:00
tmk
a7ccdc25b1 lufa: Add comment on INTERRUPT_CONTROL_ENDPOINT
This feature can block other executions and prevents converter
from handling signal.
2020-03-20 14:34:44 +09:00
tmk
ab16474335 lufa: Disable SOF interrupt
The interrupt takes 3us every 1ms and can prevent
signal handling of ibmpc converter.
2020-03-20 12:46:48 +09:00
tmk
f8685ce694 ibmpc: Fix debug print 2020-03-02 14:11:16 +09:00
tmk
2c9ae5ac95 ibmpc: Protocol detection between AT and XT 2020-03-02 11:04:30 +09:00
tmk
0481aa08e5 ibmpc: Check buffer full and error code FF 2020-03-02 01:48:11 +09:00
tmk
0b1fbeb135 ibmpc: Fix comments 2020-03-02 01:21:04 +09:00
tmk
b7412f6228 ibmpc: Add timeout check 2020-03-02 00:14:09 +09:00
tmk
2f640de68d ibmpc: Refactor code 2020-02-29 17:29:55 +09:00
tmk
4588ae8dac ibmpc: Fix debug print and wait time 2020-02-29 17:29:55 +09:00
tmk
9acc900ffb ibmpc: Add two-byte buffer for data received 2020-02-29 17:29:55 +09:00
tmk
e89ade52e1 ibmpc: Fix stop bit check code in ISR
removing function call makes prologue/epilogue shorter
2020-02-29 17:29:55 +09:00
tmk
a42cc4bddb ibmpc_usb: Fix hard reset code 2020-02-29 17:29:55 +09:00
tmk
c2e8c0d43e ibmpc: Change ISR code
It reads data line within 3us
2020-02-29 17:29:54 +09:00
tmk
15ab461f44 ibmpc: Add ibmpc_host_clear_isr 2020-02-29 17:29:54 +09:00
tmk
b2fb5b715c ibmpc: Add intruppt disable and enable function 2020-02-29 17:29:54 +09:00
tmk
f7b74361a0 ibmpc: Fix START case in ISR 2020-02-29 17:29:54 +09:00
tmk
3e2900dcc8 ibmpc: Read data line earlier in ISR as possible 2020-02-29 17:29:54 +09:00
tmk
6209ceebfb lufa: Rename LUFA_DEBUG to TMK_LUFA_DEBUG 2020-02-09 21:17:52 +09:00
tmk
ea1d7ff240 lufa: Update makefile for new LUFA 2020-02-09 21:04:43 +09:00
tmk
28662f2978 lufa: Use the latest LUFA library on github 2020-02-09 21:03:49 +09:00
tmk
4726938779 lufa: Remove old LUFA directory 2020-02-09 21:03:04 +09:00
tmk
91a125baeb lufa: Fix console_putc
buffering before host and hid_listen become ready
2020-02-09 20:53:45 +09:00
tmk
01477b7ef2 core: Fix unimap translation range 2020-02-03 12:47:01 +09:00
tmk
37a452f7c9 core: Fix bootloader for 128KB flash
Got warning on bootloader address calculation when MCU has 128KB flash
2019-12-04 15:09:36 +09:00
tmk
ee4686eafc core: Fix ldscript for AT90USB to support unimap 2019-12-04 15:09:36 +09:00
tmk
909277107f core: Add ldscript for AT90USB to support unimap 2019-12-04 15:09:25 +09:00
tmk
c4b8b36950 core: Add IBM PC Keyboard protocol support 2019-12-04 11:34:05 +09:00
tmk
698c957cad core: Add short name for keycode KP_00 and KP_000 2019-11-12 15:38:31 +09:00