Merge branch 'adb_keypad_fix'

This commit is contained in:
tmk 2022-04-24 19:06:37 +09:00
commit 1d3e9a2e59
3 changed files with 12 additions and 1 deletions

View file

@ -392,6 +392,7 @@ void adb_mouse_task(void)
} }
len = adb_host_talk_buf(ADB_ADDR_MOUSE_POLL, ADB_REG_0, buf, sizeof(buf)); len = adb_host_talk_buf(ADB_ADDR_MOUSE_POLL, ADB_REG_0, buf, sizeof(buf));
if (!len && adb_service_request()) len = adb_host_talk_buf(ADB_ADDR_MOUSE, ADB_REG_0, buf, sizeof(buf));
// If nothing received reset mouse acceleration, and quit. // If nothing received reset mouse acceleration, and quit.
if (len < 2) { if (len < 2) {
@ -616,6 +617,7 @@ uint8_t matrix_scan(void)
tick_ms = timer_read(); tick_ms = timer_read();
codes = adb_host_kbd_recv(ADB_ADDR_KBD_POLL); codes = adb_host_kbd_recv(ADB_ADDR_KBD_POLL);
if (!codes && adb_service_request()) codes = adb_host_kbd_recv(ADB_ADDR_KEYBOARD);
if (codes) xprintf("%04X ", codes); if (codes) xprintf("%04X ", codes);
// Adjustable keybaord media keys // Adjustable keybaord media keys

View file

@ -104,6 +104,12 @@ void adb_mouse_task(void) {
} }
#endif #endif
static bool adb_srq = false;
bool adb_service_request(void)
{
return adb_srq;
}
// This sends Talk command to read data from register and returns length of the data. // This sends Talk command to read data from register and returns length of the data.
uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len)
{ {
@ -157,6 +163,7 @@ uint8_t adb_host_talk_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len)
// portion of the stop bit of any command or data transaction. The device must lengthen // portion of the stop bit of any command or data transaction. The device must lengthen
// the stop by a minimum of 140 J.lS beyond its normal duration, as shown in Figure 8-15." // the stop by a minimum of 140 J.lS beyond its normal duration, as shown in Figure 8-15."
// http://ww1.microchip.com/downloads/en/AppNotes/00591b.pdf // http://ww1.microchip.com/downloads/en/AppNotes/00591b.pdf
if (!data_in()) { adb_srq = true; } else { adb_srq = false; }
if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored
xprintf("R"); xprintf("R");
sei(); sei();
@ -227,7 +234,8 @@ void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len)
attention(); attention();
send_byte((addr<<4) | ADB_CMD_LISTEN | reg); send_byte((addr<<4) | ADB_CMD_LISTEN | reg);
place_bit0(); // Stopbit(0) place_bit0(); // Stopbit(0)
// TODO: Service Request if (!data_in()) { adb_srq = true; } else { adb_srq = false; }
wait_data_hi(500); // Service Request
_delay_us(200); // Tlt/Stop to Start _delay_us(200); // Tlt/Stop to Start
place_bit1(); // Startbit(1) place_bit1(); // Startbit(1)
for (int8_t i = 0; i < len; i++) { for (int8_t i = 0; i < len; i++) {

View file

@ -121,6 +121,7 @@ void adb_host_kbd_led(uint8_t addr, uint8_t led);
void adb_mouse_task(void); void adb_mouse_task(void);
void adb_mouse_init(void); void adb_mouse_init(void);
uint8_t adb_mouse_buttons(void); uint8_t adb_mouse_buttons(void);
bool adb_service_request(void);
#endif #endif