summaryrefslogtreecommitdiff
path: root/tmk_core/protocol
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-03-18 00:48:52 +0000
committerQMK Bot <hello@qmk.fm>2021-03-18 00:48:52 +0000
commit4aa57e9e46b8d0ed1814131bf2944b2b45ee077c (patch)
tree1ad17b424b4771a5de4678a0b0fbb162e19e66b5 /tmk_core/protocol
parentd0c2f3c403f184d318c61b55b2ad049880a8d15c (diff)
parent9331c22620fb9a4012a370d717e6362a5ab84ec4 (diff)
downloadqmk_firmware-4aa57e9e46b8d0ed1814131bf2944b2b45ee077c.tar.gz
qmk_firmware-4aa57e9e46b8d0ed1814131bf2944b2b45ee077c.zip
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'tmk_core/protocol')
-rw-r--r--tmk_core/protocol/xt.h39
-rw-r--r--tmk_core/protocol/xt_interrupt.c7
2 files changed, 26 insertions, 20 deletions
diff --git a/tmk_core/protocol/xt.h b/tmk_core/protocol/xt.h
index 6dc5f19d00..cc55b7dbca 100644
--- a/tmk_core/protocol/xt.h
+++ b/tmk_core/protocol/xt.h
@@ -38,33 +38,36 @@ POSSIBILITY OF SUCH DAMAGE.
#pragma once
-#define XT_DATA_IN() \
- do { \
- XT_DATA_DDR &= ~(1 << XT_DATA_BIT); \
- XT_DATA_PORT |= (1 << XT_DATA_BIT); \
+#include "quantum.h"
+
+#define XT_DATA_IN() \
+ do { \
+ setPinInput(XT_DATA_PIN); \
+ writePinHigh(XT_DATA_PIN); \
} while (0)
-#define XT_DATA_READ() (XT_DATA_PIN & (1 << XT_DATA_BIT))
+#define XT_DATA_READ() readPin(XT_DATA_PIN)
-#define XT_DATA_LO() \
- do { \
- XT_DATA_PORT &= ~(1 << XT_DATA_BIT); \
- XT_DATA_DDR |= (1 << XT_DATA_BIT); \
+#define XT_DATA_LO() \
+ do { \
+ writePinLow(XT_DATA_PIN); \
+ setPinOutput(XT_DATA_PIN); \
} while (0)
-#define XT_CLOCK_IN() \
- do { \
- XT_CLOCK_DDR &= ~(1 << XT_CLOCK_BIT); \
- XT_CLOCK_PORT |= (1 << XT_CLOCK_BIT); \
+#define XT_CLOCK_IN() \
+ do { \
+ setPinInput(XT_CLOCK_PIN); \
+ writePinHigh(XT_CLOCK_PIN); \
} while (0)
-#define XT_CLOCK_READ() (XT_CLOCK_PIN & (1 << XT_CLOCK_BIT))
+#define XT_CLOCK_READ() readPin(XT_CLOCK_PIN)
-#define XT_CLOCK_LO() \
- do { \
- XT_CLOCK_PORT &= ~(1 << XT_CLOCK_BIT); \
- XT_CLOCK_DDR |= (1 << XT_CLOCK_BIT); \
+#define XT_CLOCK_LO() \
+ do { \
+ writePinLow(XT_CLOCK_PIN); \
+ setPinOutput(XT_CLOCK_PIN); \
} while (0)
void xt_host_init(void);
+
uint8_t xt_host_recv(void);
diff --git a/tmk_core/protocol/xt_interrupt.c b/tmk_core/protocol/xt_interrupt.c
index 51e52243fd..3dd7e6177b 100644
--- a/tmk_core/protocol/xt_interrupt.c
+++ b/tmk_core/protocol/xt_interrupt.c
@@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <avr/interrupt.h>
-#include <util/delay.h>
#include "xt.h"
#include "wait.h"
#include "debug.h"
@@ -60,7 +59,7 @@ void xt_host_init(void) {
/* soft reset: pull clock line down for 20ms */
XT_DATA_LO();
XT_CLOCK_LO();
- _delay_ms(20);
+ wait_ms(20);
/* input mode with pullup */
XT_CLOCK_IN();
@@ -123,6 +122,7 @@ ISR(XT_INT_VECT) {
static uint8_t pbuf[PBUF_SIZE];
static uint8_t pbuf_head = 0;
static uint8_t pbuf_tail = 0;
+
static inline void pbuf_enqueue(uint8_t data) {
uint8_t sreg = SREG;
cli();
@@ -135,6 +135,7 @@ static inline void pbuf_enqueue(uint8_t data) {
}
SREG = sreg;
}
+
static inline uint8_t pbuf_dequeue(void) {
uint8_t val = 0;
@@ -148,6 +149,7 @@ static inline uint8_t pbuf_dequeue(void) {
return val;
}
+
static inline bool pbuf_has_data(void) {
uint8_t sreg = SREG;
cli();
@@ -155,6 +157,7 @@ static inline bool pbuf_has_data(void) {
SREG = sreg;
return has_data;
}
+
static inline void pbuf_clear(void) {
uint8_t sreg = SREG;
cli();