mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
refactoring
This commit is contained in:
parent
52ac8d93a1
commit
79e1b457b7
@ -21,8 +21,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
|
|
||||||
#ifdef CMD_SPI
|
#ifdef CMD_SPI
|
||||||
#include <SPI.h>
|
|
||||||
|
|
||||||
static volatile uint8_t _spi_in[8] = {0};
|
static volatile uint8_t _spi_in[8] = {0};
|
||||||
static volatile uint8_t _spi_in_index = 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[8] = {0};
|
||||||
static volatile uint8_t _spi_out_index = 0;
|
static volatile uint8_t _spi_out_index = 0;
|
||||||
|
|
||||||
|
|
||||||
namespace DRIVERS {
|
namespace DRIVERS {
|
||||||
void Spi::begin() {
|
void Spi::begin() {
|
||||||
pinMode(MISO, OUTPUT);
|
pinMode(MISO, OUTPUT);
|
||||||
@ -77,4 +79,5 @@ ISR(SPI_STC_vect) {
|
|||||||
SPDR = 0;
|
SPDR = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -23,8 +23,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
|
||||||
|
|
||||||
namespace DRIVERS {
|
namespace DRIVERS {
|
||||||
struct Spi : public Connection {
|
struct Spi : public Connection {
|
||||||
Spi() : Connection(CONNECTION) {}
|
Spi() : Connection(CONNECTION) {}
|
||||||
|
|||||||
@ -25,8 +25,9 @@
|
|||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
|
|
||||||
namespace DRIVERS {
|
namespace DRIVERS {
|
||||||
typedef void(*DataHandler)(const uint8_t * data, size_t len);
|
typedef void (*DataHandler)(const uint8_t *data, size_t size);
|
||||||
typedef void (*TimeoutHandler)();
|
typedef void (*TimeoutHandler)();
|
||||||
|
|
||||||
struct Connection : public Driver {
|
struct Connection : public Driver {
|
||||||
|
|||||||
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef CMD_SERIAL
|
#ifdef CMD_SERIAL
|
||||||
#include "connection.h"
|
#include "connection.h"
|
||||||
|
|
||||||
|
|
||||||
namespace DRIVERS {
|
namespace DRIVERS {
|
||||||
#ifdef Serial
|
#ifdef Serial
|
||||||
# undef Serial
|
# undef Serial
|
||||||
|
|||||||
@ -11,7 +11,6 @@ lib_deps =
|
|||||||
git+https://github.com/Harvie/ps2dev#v0.0.3
|
git+https://github.com/Harvie/ps2dev#v0.0.3
|
||||||
digitalWriteFast@1.0.0
|
digitalWriteFast@1.0.0
|
||||||
HID@1.0
|
HID@1.0
|
||||||
SPI
|
|
||||||
drivers-avr
|
drivers-avr
|
||||||
extra_scripts =
|
extra_scripts =
|
||||||
pre:avrdude.py
|
pre:avrdude.py
|
||||||
|
|||||||
@ -220,7 +220,7 @@ static void _onTimeout() {
|
|||||||
_sendResponse(PROTO::RESP::TIMEOUT_ERROR);
|
_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));
|
_sendResponse(_handleRequest(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user