adb: Detection of Service Request(SRQ)

This commit is contained in:
tmk 2022-04-24 18:59:37 +09:00
parent 732dfbb3ed
commit f1f32a743f
2 changed files with 10 additions and 1 deletions

View file

@ -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++) {

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_init(void);
uint8_t adb_mouse_buttons(void);
bool adb_service_request(void);
#endif