diff --git a/tmk_core/protocol/adb.c b/tmk_core/protocol/adb.c index e774680d..0b66da7b 100644 --- a/tmk_core/protocol/adb.c +++ b/tmk_core/protocol/adb.c @@ -104,6 +104,12 @@ void adb_mouse_task(void) { } #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. 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 // 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 + if (!data_in()) { adb_srq = true; } else { adb_srq = false; } if (!wait_data_hi(500)) { // Service Request(310us Adjustable Keyboard): just ignored xprintf("R"); sei(); @@ -227,7 +234,8 @@ void adb_host_listen_buf(uint8_t addr, uint8_t reg, uint8_t *buf, uint8_t len) attention(); send_byte((addr<<4) | ADB_CMD_LISTEN | reg); 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 place_bit1(); // Startbit(1) for (int8_t i = 0; i < len; i++) { diff --git a/tmk_core/protocol/adb.h b/tmk_core/protocol/adb.h index 1c1ace5d..914f1085 100644 --- a/tmk_core/protocol/adb.h +++ b/tmk_core/protocol/adb.h @@ -121,6 +121,7 @@ void adb_host_kbd_led(uint8_t addr, uint8_t led); void adb_mouse_task(void); void adb_mouse_init(void); uint8_t adb_mouse_buttons(void); +bool adb_service_request(void); #endif