summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hid/lib/drivers-avr/spi.cpp5
-rw-r--r--hid/lib/drivers-avr/spi.h2
-rw-r--r--hid/lib/drivers/connection.h5
-rw-r--r--hid/lib/drivers/serial.h4
-rw-r--r--hid/platformio-avr.ini1
-rw-r--r--hid/src/main.cpp4
6 files changed, 14 insertions, 7 deletions
diff --git a/hid/lib/drivers-avr/spi.cpp b/hid/lib/drivers-avr/spi.cpp
index ae54f545..d01c7070 100644
--- a/hid/lib/drivers-avr/spi.cpp
+++ b/hid/lib/drivers-avr/spi.cpp
@@ -21,8 +21,9 @@
#include "spi.h"
+
#ifdef CMD_SPI
-#include <SPI.h>
+
static volatile uint8_t _spi_in[8] = {0};
static volatile uint8_t _spi_in_index = 0;
@@ -30,6 +31,7 @@ static volatile uint8_t _spi_in_index = 0;
static volatile uint8_t _spi_out[8] = {0};
static volatile uint8_t _spi_out_index = 0;
+
namespace DRIVERS {
void Spi::begin() {
pinMode(MISO, OUTPUT);
@@ -77,4 +79,5 @@ ISR(SPI_STC_vect) {
SPDR = 0;
}
}
+
#endif
diff --git a/hid/lib/drivers-avr/spi.h b/hid/lib/drivers-avr/spi.h
index 4fb43d89..aade0a26 100644
--- a/hid/lib/drivers-avr/spi.h
+++ b/hid/lib/drivers-avr/spi.h
@@ -23,8 +23,10 @@
#pragma once
#include <Arduino.h>
+
#include "connection.h"
+
namespace DRIVERS {
struct Spi : public Connection {
Spi() : Connection(CONNECTION) {}
diff --git a/hid/lib/drivers/connection.h b/hid/lib/drivers/connection.h
index 20560571..39973a5a 100644
--- a/hid/lib/drivers/connection.h
+++ b/hid/lib/drivers/connection.h
@@ -25,9 +25,10 @@
#include "driver.h"
#include "stdint.h"
+
namespace DRIVERS {
- typedef void(*DataHandler)(const uint8_t * data, size_t len);
- typedef void(*TimeoutHandler)();
+ typedef void (*DataHandler)(const uint8_t *data, size_t size);
+ typedef void (*TimeoutHandler)();
struct Connection : public Driver {
using Driver::Driver;
diff --git a/hid/lib/drivers/serial.h b/hid/lib/drivers/serial.h
index d88c8fb4..8eaadaff 100644
--- a/hid/lib/drivers/serial.h
+++ b/hid/lib/drivers/serial.h
@@ -21,12 +21,14 @@
#pragma once
+
#ifdef CMD_SERIAL
#include "connection.h"
+
namespace DRIVERS {
#ifdef Serial
-#undef Serial
+# undef Serial
#endif
struct Serial : public Connection {
Serial() : Connection(CONNECTION) {}
diff --git a/hid/platformio-avr.ini b/hid/platformio-avr.ini
index df437218..8484ef50 100644
--- a/hid/platformio-avr.ini
+++ b/hid/platformio-avr.ini
@@ -11,7 +11,6 @@ lib_deps =
git+https://github.com/Harvie/ps2dev#v0.0.3
- SPI
drivers-avr
extra_scripts =
pre:avrdude.py
diff --git a/hid/src/main.cpp b/hid/src/main.cpp
index 6692bd93..63e776f1 100644
--- a/hid/src/main.cpp
+++ b/hid/src/main.cpp
@@ -115,7 +115,7 @@ static uint8_t _handleRequest(const uint8_t *data) { // 8 bytes
if (data[0] == PROTO::MAGIC && PROTO::crc16(data, 6) == PROTO::merge8(data[6], data[7])) {
# define HANDLE(_handler) { _handler(data + 2); return PROTO::PONG::OK; }
switch (data[1]) {
- case PROTO::CMD::PING: return PROTO::PONG::OK;
+ case PROTO::CMD::PING: return PROTO::PONG::OK;
case PROTO::CMD::SET_KEYBOARD: HANDLE(_cmdSetKeyboard);
case PROTO::CMD::SET_MOUSE: HANDLE(_cmdSetMouse);
case PROTO::CMD::SET_CONNECTED: HANDLE(_cmdSetConnected);
@@ -220,7 +220,7 @@ static void _onTimeout() {
_sendResponse(PROTO::RESP::TIMEOUT_ERROR);
}
-static void _onData(const uint8_t * data, size_t len) {
+static void _onData(const uint8_t *data, size_t size) {
_sendResponse(_handleRequest(data));
}