summaryrefslogtreecommitdiff
path: root/protocol
diff options
context:
space:
mode:
Diffstat (limited to 'protocol')
-rw-r--r--protocol/adb.c6
-rw-r--r--protocol/adb.h5
-rw-r--r--protocol/ps2.c15
3 files changed, 19 insertions, 7 deletions
diff --git a/protocol/adb.c b/protocol/adb.c
index d60b8608b1..d7105b3a9a 100644
--- a/protocol/adb.c
+++ b/protocol/adb.c
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <util/delay.h>
#include <avr/io.h>
+#include <avr/interrupt.h>
#include "adb.h"
@@ -85,8 +86,13 @@ uint16_t adb_host_kbd_recv(void)
return 0; // No data to send
if (!read_bit()) // Startbit(1)
return -2;
+
+ // ad hoc fix: without block inerrupt read wrong bit occasionally and get keys stuck
+ cli();
data = read_byte();
data = (data<<8) | read_byte();
+ sei();
+
if (read_bit()) // Stopbit(0)
return -3;
return data;
diff --git a/protocol/adb.h b/protocol/adb.h
index 177f413944..1e4ca40132 100644
--- a/protocol/adb.h
+++ b/protocol/adb.h
@@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef ADB_H
#define ADB_H
+#include <stdint.h>
#include <stdbool.h>
#if !(defined(ADB_PORT) && \
@@ -47,6 +48,10 @@ POSSIBILITY OF SUCH DAMAGE.
# error "ADB port setting is required in config.h"
#endif
+#define ADB_POWER 0x7F
+#define ADB_CAPS 0x39
+
+
// ADB host
void adb_host_init(void);
bool adb_host_psw(void);
diff --git a/protocol/ps2.c b/protocol/ps2.c
index 8a05916210..cf7b1f43ce 100644
--- a/protocol/ps2.c
+++ b/protocol/ps2.c
@@ -89,8 +89,9 @@ uint8_t ps2_error = PS2_ERR_NONE;
void ps2_host_init(void)
{
-#ifdef PS2_INT_ENABLE
- PS2_INT_ENABLE();
+#ifdef PS2_USE_INT
+ PS2_INT_INIT();
+ PS2_INT_ON();
idle();
#else
inhibit();
@@ -103,8 +104,8 @@ uint8_t ps2_host_send(uint8_t data)
uint8_t res = 0;
bool parity = true;
ps2_error = PS2_ERR_NONE;
-#ifdef PS2_INT_DISABLE
- PS2_INT_DISABLE();
+#ifdef PS2_USE_INT
+ PS2_INT_OFF();
#endif
/* terminate a transmission if we have */
inhibit();
@@ -144,8 +145,8 @@ uint8_t ps2_host_send(uint8_t data)
res = ps2_host_recv_response();
ERROR:
-#ifdef PS2_INT_ENABLE
- PS2_INT_ENABLE();
+#ifdef PS2_USE_INT
+ PS2_INT_ON();
idle();
#else
inhibit();
@@ -173,7 +174,7 @@ uint8_t ps2_host_recv_response(void)
return data;
}
-#ifndef PS2_INT_VECT
+#ifndef PS2_USE_INT
uint8_t ps2_host_recv(void)
{
return ps2_host_recv_response();