next: Fix NeXT keyboard signal timing #704
NeXT keyboard uses 52.75us per pulse. https://github.com/tmk/tmk_keyboard/issues/704 https://github.com/tmk/tmk_keyboard/wiki/NeXT
This commit is contained in:
parent
12cd162015
commit
dcebfb4fc4
2 changed files with 10 additions and 34 deletions
|
|
@ -59,16 +59,10 @@ static inline void query(void);
|
||||||
static inline void reset(void);
|
static inline void reset(void);
|
||||||
static inline uint32_t response(void);
|
static inline uint32_t response(void);
|
||||||
|
|
||||||
/* The keyboard sends signal with 50us pulse width on OUT line
|
#define out_hi_delay(intervals) do { out_hi(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||||
* while it seems to miss the 50us pulse on In line.
|
#define out_lo_delay(intervals) do { out_lo(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||||
* next_kbd_set_leds() often fails to sync LED status with 50us
|
#define query_delay(intervals) do { query(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||||
* but it works well with 51us(+1us) on TMK converter(ATMeaga32u2) at least.
|
#define reset_delay(intervals) do { reset(); _delay_us((NEXT_KBD_TIMING) * intervals); } while (0);
|
||||||
* TODO: test on Teensy and Pro Micro configuration
|
|
||||||
*/
|
|
||||||
#define out_hi_delay(intervals) do { out_hi(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
|
||||||
#define out_lo_delay(intervals) do { out_lo(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
|
||||||
#define query_delay(intervals) do { query(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
|
||||||
#define reset_delay(intervals) do { reset(); _delay_us((NEXT_KBD_TIMING+1) * intervals); } while (0);
|
|
||||||
|
|
||||||
void next_kbd_init(void)
|
void next_kbd_init(void)
|
||||||
{
|
{
|
||||||
|
|
@ -144,34 +138,14 @@ static inline uint32_t response(void)
|
||||||
sei();
|
sei();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
_delay_us(NEXT_KBD_TIMING / 2);
|
_delay_us(NEXT_KBD_TIMING / 2 - 1);
|
||||||
for (; i < 22; i++)
|
for (; i < 22; i++)
|
||||||
{
|
{
|
||||||
if (NEXT_KBD_READ)
|
if (NEXT_KBD_READ)
|
||||||
{
|
{
|
||||||
data |= ((uint32_t) 1 << i);
|
data |= (uint32_t)1 << 22;
|
||||||
/* Note:
|
|
||||||
* My testing with the ATmega32u4 showed that there might
|
|
||||||
* something wrong with the timing here; by the end of the
|
|
||||||
* second data byte some of the modifiers can get bumped out
|
|
||||||
* to the next bit over if we just cycle through the data
|
|
||||||
* based on the expected interval. There is a bit (i = 10)
|
|
||||||
* in the middle of the data that is always on followed by
|
|
||||||
* one that is always off - so we'll use that to reset our
|
|
||||||
* timing in case we've gotten ahead of the keyboard;
|
|
||||||
*/
|
|
||||||
if (i == 10)
|
|
||||||
{
|
|
||||||
i++;
|
|
||||||
while (NEXT_KBD_READ) ;
|
|
||||||
_delay_us(NEXT_KBD_TIMING / 2);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* redundant - but I don't want to remove if it might screw
|
|
||||||
* up the timing
|
|
||||||
*/
|
|
||||||
data |= ((uint32_t) 0 << i);
|
|
||||||
}
|
}
|
||||||
|
data >>= 1;
|
||||||
_delay_us(NEXT_KBD_TIMING);
|
_delay_us(NEXT_KBD_TIMING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define NEXT_KBD_H
|
#define NEXT_KBD_H
|
||||||
|
|
||||||
#define NEXT_KBD_KMBUS_IDLE 0x300600
|
#define NEXT_KBD_KMBUS_IDLE 0x300600
|
||||||
#define NEXT_KBD_TIMING 50
|
|
||||||
|
// https://github.com/tmk/tmk_keyboard/issues/704
|
||||||
|
#define NEXT_KBD_TIMING 52
|
||||||
|
|
||||||
extern uint8_t next_kbd_error;
|
extern uint8_t next_kbd_error;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue