mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
fixed pinout, refactoring
This commit is contained in:
parent
42475809fc
commit
5bcf2df687
@ -9,6 +9,7 @@ framework = arduino
|
||||
lib_deps =
|
||||
HID-Project@2.6.1
|
||||
git+https://github.com/Harvie/ps2dev#v0.0.3
|
||||
digitalWriteFast@1.0.0
|
||||
extra_scripts =
|
||||
pre:avrdude.py
|
||||
post:patch.py
|
||||
@ -17,8 +18,6 @@ platform_packages =
|
||||
|
||||
[_common]
|
||||
build_flags =
|
||||
-DHID_PS2_KBD_CLOCK_PIN=7
|
||||
-DHID_PS2_KBD_DATA_PIN=5
|
||||
-DHID_USB_CHECK_ENDPOINT
|
||||
# ----- The default config with dynamic switching -----
|
||||
-DHID_DYNAMIC
|
||||
@ -39,13 +38,20 @@ build_flags =
|
||||
# -DHID_SET_PS2_KBD
|
||||
# -DHID_SET_USB_MOUSE_REL
|
||||
|
||||
[_non_aum_pinout] =
|
||||
build_flags =
|
||||
-DHID_PS2_KBD_CLOCK_PIN=7
|
||||
-DHID_PS2_KBD_DATA_PIN=5
|
||||
|
||||
|
||||
# ===== Serial =====
|
||||
[env:serial]
|
||||
extends =
|
||||
_common
|
||||
_non_aum_pinout
|
||||
build_flags =
|
||||
${_common.build_flags}
|
||||
${_non_aum_pinout.build_flags}
|
||||
-DCMD_SERIAL=Serial1
|
||||
-DCMD_SERIAL_SPEED=115200
|
||||
-DCMD_SERIAL_TIMEOUT=100000
|
||||
@ -63,7 +69,7 @@ upload_flags =
|
||||
extra_scripts =
|
||||
pre:avrdude.py
|
||||
|
||||
[env:spi]
|
||||
[_common_spi]
|
||||
extends =
|
||||
_common
|
||||
build_flags =
|
||||
@ -84,12 +90,26 @@ upload_flags =
|
||||
$BOARD_MCU
|
||||
upload_command = avrdude $UPLOAD_FLAGS -U flash:w:$SOURCE:i
|
||||
|
||||
[env:spi]
|
||||
extends =
|
||||
_common_spi
|
||||
_non_aum_pinout
|
||||
build_flags =
|
||||
${_common_spi.build_flags}
|
||||
${_non_aum_pinout.build_flags}
|
||||
|
||||
[env:aum]
|
||||
extends =
|
||||
env:spi
|
||||
lib_deps =
|
||||
${env:spi.lib_deps}
|
||||
digitalWriteFast@1.0.0
|
||||
_common_spi
|
||||
build_flags =
|
||||
${env:spi.build_flags}
|
||||
${_common_spi.build_flags}
|
||||
-DAUM
|
||||
-DAUM_IS_USB_POWERED_PIN=A4
|
||||
-DAUM_SET_USB_VBUS_PIN=11
|
||||
-DAUM_SET_USB_CONNECTED_PIN=A5
|
||||
-DHID_PS2_KBD_VBUS_PIN=8
|
||||
-DHID_PS2_KBD_CLOCK_PIN=10
|
||||
-DHID_PS2_KBD_DATA_PIN=5
|
||||
-DHID_PS2_MOUSE_VBUS_PIN=6
|
||||
-DHID_PS2_MOUSE_CLOCK_PIN=9
|
||||
-DHID_PS2_MOUSE_DATA_PIN=13
|
||||
|
||||
@ -38,9 +38,7 @@
|
||||
|
||||
#if defined(AUM) && defined(HID_WITH_USB)
|
||||
# include <digitalWriteFast.h>
|
||||
# define AUM_IS_USB_POWERED_PIN A4
|
||||
# define AUM_SET_USB_VBUS_PIN 11
|
||||
# define AUM_SET_USB_PLUGGED_PIN A5
|
||||
// #define bla-bla-bla AUM_* pins
|
||||
#endif
|
||||
|
||||
#include "proto.h"
|
||||
@ -165,9 +163,9 @@ static void _cmdSetMouse(const uint8_t *data) { // 1 bytes
|
||||
# endif
|
||||
}
|
||||
|
||||
static void _cmdSetUsbPlugged(const uint8_t *data) { // 1 byte
|
||||
static void _cmdSetUsbConnected(const uint8_t *data) { // 1 byte
|
||||
# if defined(AUM) && defined(HID_WITH_USB)
|
||||
digitalWriteFast(AUM_SET_USB_PLUGGED_PIN, (bool)data[0]);
|
||||
digitalWriteFast(AUM_SET_USB_CONNECTED_PIN, (bool)data[0]);
|
||||
# endif
|
||||
}
|
||||
|
||||
@ -243,7 +241,7 @@ static uint8_t _handleRequest(const uint8_t *data) { // 8 bytes
|
||||
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_USB_PLUGGED: HANDLE(_cmdSetUsbPlugged);
|
||||
case PROTO::CMD::SET_USB_CONNECTED: HANDLE(_cmdSetUsbConnected);
|
||||
case PROTO::CMD::CLEAR_HID: HANDLE(_cmdClearHid);
|
||||
case PROTO::CMD::KEYBOARD::KEY: HANDLE(_cmdKeyEvent);
|
||||
case PROTO::CMD::MOUSE::BUTTON: HANDLE(_cmdMouseButtonEvent);
|
||||
@ -295,9 +293,9 @@ static void _sendResponse(uint8_t code) {
|
||||
response[2] |= PROTO::OUTPUTS::MOUSE::USB_REL;
|
||||
} // TODO: ps2
|
||||
# if defined(AUM) && defined(HID_WITH_USB)
|
||||
response[3] |= PROTO::PARAMS::USB_PLUGGABLE;
|
||||
if (digitalReadFast(AUM_SET_USB_PLUGGED_PIN)) {
|
||||
response[3] |= PROTO::PARAMS::USB_PLUGGED;
|
||||
response[3] |= PROTO::PARAMS::USB_CONNECTABLE;
|
||||
if (digitalReadFast(AUM_SET_USB_CONNECTED_PIN)) {
|
||||
response[3] |= PROTO::PARAMS::USB_CONNECTED;
|
||||
}
|
||||
# endif
|
||||
# ifdef HID_WITH_USB
|
||||
@ -326,8 +324,8 @@ int main() {
|
||||
# if defined(AUM) && defined(HID_WITH_USB)
|
||||
pinModeFast(AUM_IS_USB_POWERED_PIN, INPUT);
|
||||
pinModeFast(AUM_SET_USB_VBUS_PIN, OUTPUT);
|
||||
pinModeFast(AUM_SET_USB_PLUGGED_PIN, OUTPUT);
|
||||
digitalWriteFast(AUM_SET_USB_PLUGGED_PIN, HIGH);
|
||||
pinModeFast(AUM_SET_USB_CONNECTED_PIN, OUTPUT);
|
||||
digitalWriteFast(AUM_SET_USB_CONNECTED_PIN, HIGH);
|
||||
# endif
|
||||
|
||||
# ifdef CMD_SERIAL
|
||||
|
||||
@ -63,17 +63,17 @@ namespace PROTO {
|
||||
namespace PARAMS {
|
||||
const uint8_t HAS_USB = 0b00000001;
|
||||
const uint8_t HAS_PS2 = 0b00000010;
|
||||
const uint8_t USB_PLUGGABLE = 0b10000000;
|
||||
const uint8_t USB_PLUGGED = 0b01000000;
|
||||
const uint8_t USB_CONNECTABLE = 0b10000000;
|
||||
const uint8_t USB_CONNECTED = 0b01000000;
|
||||
}
|
||||
|
||||
namespace CMD {
|
||||
const uint8_t PING = 0x01;
|
||||
const uint8_t REPEAT = 0x02;
|
||||
const uint8_t SET_KEYBOARD = 0x03;
|
||||
const uint8_t SET_MOUSE = 0x04;
|
||||
const uint8_t SET_USB_PLUGGED = 0x05;
|
||||
const uint8_t CLEAR_HID = 0x10;
|
||||
const uint8_t PING = 0x01;
|
||||
const uint8_t REPEAT = 0x02;
|
||||
const uint8_t SET_KEYBOARD = 0x03;
|
||||
const uint8_t SET_MOUSE = 0x04;
|
||||
const uint8_t SET_USB_CONNECTED = 0x05;
|
||||
const uint8_t CLEAR_HID = 0x10;
|
||||
|
||||
namespace KEYBOARD {
|
||||
const uint8_t KEY = 0x11;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user