Commit Graph

336 Commits (e15f35fd9b9746c4f001710b53c073cd2672008e)

Author SHA1 Message Date
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
tmk 108b0ce8d9 usb_usb: Clean print for debug 2019-09-18 15:29:38 +09:00
tmk 13e115b352 core: Add NO_PRINT and NO_DEBUG build option
Lines below in Makefile disable print and debug functions respectively.
    NO_PRINT = yes
    NO_DEBUG = yes
2019-09-18 15:09:02 +09:00
tmk bc821b79d0 core: Remove unneeded code in bootloader_jump 2019-09-18 14:14:25 +09:00
tmk 83b90f4b6f core: Add AC_BTLD to actionmap and unimap
Now that it can jump to bootloader with AC_BTLD
2019-09-17 20:55:35 +09:00
tmk c09600b56b core: Read bootloader size from AVR fuse bits
This makes defining BOOTLOADER_SIZE macro optional.
2019-09-17 16:19:52 +09:00
tmk b3980122bb core: Fix comment and remove unused code 2019-09-16 18:43:38 +09:00
tmk 19350e3ee5 core: Add bootkey of Caterina bootloader
The bootkey set in bootloader_jump() works with Pro Micro and Leonardo.
This fix doesn't seem to prevent other bootloaders, however, it can be
disabled by defining NO_BOOTLOADER_CATERINA_BOOTKEY.
2019-09-16 17:49:38 +09:00
tmk f4fd22aaa0 core: Fix ibm4704_send() wait for clock to start 2019-07-12 16:08:05 +09:00
tmk 66e97371ba adb_usb: Fix mouse_init 2019-06-23 15:04:35 +09:00
tmk 814eaa2dff core:adb_usb: Add Extended Mouse Protocol support #274
Also add Kensington Turbo Mouse 5 specific initialization
2019-06-23 15:04:35 +09:00
tmk 2b83b9a8f9 core: Add hook_process_action() 2019-05-29 23:57:51 +09:00
tmk 8449ad385b lufa: Print TMK version to console 2019-05-29 23:42:56 +09:00
tmk 7412953fee usb_usb: Handle Rollover error
How keyobards report Rollover error:
Cherry: 0101010101010101 https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223
Apple:  0000010101010101 https://geekhack.org/index.php?topic=69169.msg2760969#msg2760969
2019-05-29 15:22:23 +09:00
tmk f3e498590c core: Add hook_usb_startup_wait_loop 2019-05-29 14:50:56 +09:00
tmk d8e304e141 lufa: Startup and suspend loop can be disabled
Startup wait loop is originally intended to start keyboard task loop and
after console output endpoint becomes available. But now that console
output is buffered when it is not available and you don't have to wait
for it to be ready. You can disable the startup wait loop by defining
NO_WAIT_FOR_USB_CONFIGURED in config.h

Suspend loop is used for power saving by making tasks stop while
USB bus is under suspend status. But this may cause problem on some
devices like converter that must keep doing its task to retain
communication with keyboard. The suspend loop can block its task for
around 15-17ms. You can disable the suspend loop  by defining
NO_USB_SUSPEND_LOOP in config.h.
2019-05-10 09:44:59 +09:00
tmk dd7b75040a lufa:usb_usb: matrix_scan() is no longer needed
This is due to SOF timing fix of USB_Host_Shield_2.0.
The matrix_scan() was needed for usb_usb converter to recognize FC660C at startup.
2019-05-10 09:44:59 +09:00
tmk 4e83400fc6 usb_hid: Change to USB_Host_Shield_2.0 of tmk repo
- Fix SOF/Keep Alive start timing
- Disable bus detection during settling after attach
- Remove keyboard LED blinking at configuring
2019-05-10 09:44:59 +09:00
tmk 993a9b02f7 lufa: Fix for freeze at re/boot time problem
Calling led_set() in ISR can cause the problem. With converter
especially, led_set() can take long time and USB can be stuck in the end.
USB-USB converter freezes occasionally when computer power up or reboot.
https://geekhack.org/index.php?topic=69169.msg2740179#msg2740179
This is also related to suspend/wakeup issue #386.
2019-05-10 09:43:44 +09:00
tmk 1e0af6809d lufa: Fix Change debug print message 2019-05-07 00:07:19 +09:00
tmk 55443fabb7 core: Avoid deadlock when uart.c is used in ISR 2019-05-07 00:07:19 +09:00
tmk 292cc939ec lufa: Fix for UART debug print 2019-05-07 00:07:19 +09:00
tmk 88ce6ff9bf lufa: This prevents resume when debug 2019-05-07 00:07:06 +09:00
tmk e23520662d lufa: Add debug print support with UART 2019-05-07 00:06:54 +09:00
tmk c41e48a0ab core: Fix uart.c for ATmega32U4 2019-04-21 11:55:47 +09:00
You Xiaojie / 尤晓杰 bf030f5420 Correct typo for linux "showkey" command (#603) 2019-03-18 07:55:40 +09:00
You Xiaojie / 尤晓杰 53f7770217 Correct two errors of keycode.txt (#594) 2019-03-13 08:37:46 +09:00
tmk feebc23563 core: System control key descriptor fix #435
https://github.com/qmk/qmk_firmware/pull/963
2019-01-26 08:42:20 +09:00
rxy0424 8345571e1d make some change to complie stm32_f103_onekey with new version of Chibios (#583) 2018-11-07 08:08:08 +09:00
tmk a0b5bf4b67 usb_usb: usb_hid: Change for USB_Host_Shield_2.0 2018-10-31 09:35:30 +09:00
tmk 23037e108f usb_hid: Add USB_Host_Shield_2.0 submodule 2018-10-31 09:35:30 +09:00
tmk 2005c88842 usb_hid: Remove USB_Host_Shield_2.0 2018-10-31 09:35:30 +09:00
tmk aa5dd8fccf lufa: usb-usb: Use LUFA startup instead of cusotom
- Change keyboard_init() timing and matrix_scan() is called in USB
  startup wait loop for FC660C
- FC660C startup seems to be faster and it doesn't work without this fix
  when plugin the keyboard and converter at same time
2018-10-31 09:35:30 +09:00
Konstantin Đorđević a159172951 Fix header guard in tmk_core/common/command.h (#581) 2018-10-31 09:34:01 +09:00
tmk 00f5ed3210 core: Update console startup for hid_listen 2018-10-16 00:40:14 +09:00
tmk b6cc5394b8 xt_usb: Change ring buffer and control Data line 2018-09-23 12:36:18 +09:00
tmk b7d80d8b0e core: lufa: Fix wait for console startup 2018-09-23 12:36:18 +09:00
tmk 5b9da20efa core: lufa: Fix timeout of send_keyboard
Change 128*40us(5.12ms) to 128*80us(10.24ms) for 6KRO
2018-09-23 12:36:18 +09:00
tmk ffb52ab0c9 core: lufa: Fix console output and init sequence
console_putc:
Linux:      works very well in general
Windows:    also works very well and connection seems to be faster than Linux
Mac:        to be: confirmed

NOTE:       long session of matrix_print still blocks keyboard_task in main loop
            and prevents it from sending keyboard report.
            XT protocol buffer overflow occurs when slamng on keys

TODO:       check when print functions are called in ISR
2018-09-23 12:36:18 +09:00
tmk 6632802c79 core: Add ring buffer file 2018-09-23 12:36:18 +09:00
tmk c0c67e2022 usb_usb: Add Cheery 0101010101010101 bug fix
https://geekhack.org/index.php?topic=69169.msg2638223#msg2638223
2018-08-01 22:34:22 +09:00
tmk dd543150b4 rule.mk: Add dfu-programmer version check again
- ubuntu 18.04 still uses old 0.6.1
2018-07-05 23:43:12 +09:00
tmk c72981f1e7 tmk_core: Now expects dfu-programmer 0.7 or later 2018-05-18 08:34:39 +09:00
tmk e11343480a xt_usb: Replace function with macro 2018-03-14 21:32:22 +09:00
tmk 136d55a249 xt_usb: Remove xt_io.h 2018-03-14 21:32:22 +09:00
tmk 1fc989947a xt_usb: Fix warning on switch-case 2018-03-14 21:32:22 +09:00
tmk acbea7fb15 xt_usb: Replace functions with macros 2018-03-14 21:32:22 +09:00
tmk 42199c90f8 xt_usb: Comment out clock check for PCINT 2018-03-14 21:32:22 +09:00
tmk ea004061a5 xt_usb: Read data earlier as possible in ISR 2018-03-14 21:32:22 +09:00
tmk 8a92f254e1 xt_usb: read data on falling edge soft/hard reset
See https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol
- read data on falling edge of clock
- add soft reset and hard reset
2018-03-14 21:32:22 +09:00
tmk c8d6796358 core: lufa: Add delay for console startup 2018-03-01 12:37:50 +09:00
Øystein Bech Gadmar 9a9b8edfa9 core: Add utility macros in action_macro.h (#532) 2018-01-29 08:10:35 +09:00
tmk d415e99f0c core: Add utility type_code() in aciton.h #528 2018-01-28 16:17:20 +09:00
alex-ong f9e3bf7f38 core: Typo (mantrix -> matrix) 2018-01-26 16:53:27 +09:00
Alex Ong ad6059adc7 core: Saved 60~ bytes (and possible performance) by storing col_mask when iterating through columns (#522) 2018-01-24 12:15:56 +09:00
Alex Ong 7d056762d0 Typos (#524)
* GH60: Found a typo

* Typo: Another typo

* Typo: More typos
2018-01-23 17:43:45 +09:00
alex-ong 8770269e1e core: Fix for un-defined function when compiling without MOUSEKEY_ENABLE 2018-01-22 14:50:38 +11:00
alex-ong 8c91a997b3 core: Fix for unused function when compiling without MOUSEKEY_ENABLE 2018-01-22 13:55:11 +11:00
tmk 01b881e87e core: Fix for warning of unused function standby() 2018-01-14 08:14:16 +09:00
tmk 8fd2cef441 core: Fix for warning of unused label. #515 2018-01-14 07:54:31 +09:00
tmk 910c204a59 core: lufa: Fix checking num of endpoints for 32u2(again) 2018-01-04 16:49:24 +09:00
tmk c80e92db43 Revert "core: LUFA: Fix checking num of endpoints for 32u2"
This reverts commit a567fec91c.
2018-01-04 16:39:44 +09:00
tmk a567fec91c core: LUFA: Fix checking num of endpoints for 32u2 2018-01-04 13:12:14 +09:00
yangdigi 78f4f666c6 fix not correctly showing 32u2 warning message when Endpints are more than 4. 2018-01-03 11:06:08 +08:00
tmk 41905715c2 core: Fix doc/keymap.md for bitwise operation 2017-10-26 14:37:52 +09:00
tmk df7ce59d1c core: Fix out-of-bounds access by TICK event #487
The error is caused in layer_swtich_get_action() and fails to access layer_pressed[][]
2017-10-22 03:43:04 +09:00
Mark Furland e54d798637 Move all ChibiOS install documentation to once place
Moved to tmk_core/protocol/chibios/README.md
2017-10-15 13:21:18 -04:00
tmk 1c2f2b6730 core: Remove unused file in vusb 2017-09-14 22:35:41 +09:00
tmk 45f6e5cb97 core: Fix for build option NO_ACTION_LAYER 2017-09-14 12:58:06 +09:00
tmk 956f806644 core: Fix for ATtiny85 2017-09-14 12:56:35 +09:00
tmk 9d66875636 core: Fix dfu-programmer version check 2017-09-07 09:00:57 +09:00
X64051 9cee272396 remove unused functions 2017-06-24 20:54:46 +02:00