From cbbfccb1e048d37328b8e5cbf64b733068bbebc8 Mon Sep 17 00:00:00 2001 From: N-Storm Date: Tue, 30 Apr 2024 10:42:58 +0300 Subject: [PATCH] Moved common (shared between firmware & software) definitions to defs.h, symlinked --- software/src/digilivolo.h => common/defs.h | 18 ++++++---- firmware/lib/DLUSB/DLUSB.h | 14 +------- firmware/lib/DLUSB/defs.h | 42 ++++++++++++++++++++++ software/src/args.c | 2 +- software/src/args.h | 6 ---- software/src/defs.h | 42 ++++++++++++++++++++++ software/src/digilivolo.c | 2 +- software/src/usb_func.c | 2 +- software/src/usb_func.h | 3 -- 9 files changed, 100 insertions(+), 31 deletions(-) rename software/src/digilivolo.h => common/defs.h (80%) create mode 100644 firmware/lib/DLUSB/defs.h create mode 100644 software/src/defs.h diff --git a/software/src/digilivolo.h b/common/defs.h similarity index 80% rename from software/src/digilivolo.h rename to common/defs.h index cd6d1d4..cedead9 100644 --- a/software/src/digilivolo.h +++ b/common/defs.h @@ -1,4 +1,4 @@ -/* Part of the DigiLivolo control software. +/* Part of the DigiLivolo project. * https://github.com/N-Storm/DigiLivolo/ * Copyright (c) 2024 GitHub user N-Storm. * @@ -18,10 +18,8 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ -#ifndef __digilivolo_h__ -#define __digilivolo_h__ - -#include +#ifndef __defs_h__ +#define __defs_h__ #define DIGILIVOLO_VID 0x16c0 #define DIGILIVOLO_PID 0x05df @@ -32,5 +30,13 @@ #define CMD_SWITCH 0x01 // IN,OUT send Livolo keycode command or send ACK to the host #define CMD_RDY 0x10 // OUT, device ready command +#define CMD_FAIL_BIT (uint8_t)(1 << 7) // Not used + +typedef struct dlusb_packet { + uint8_t report_id; + uint8_t cmd_id; + uint16_t remote_id; + uint8_t btn_id; +} dlusb_packet_t; -#endif // __digilivolo_h__ +#endif // __defs_h__ diff --git a/firmware/lib/DLUSB/DLUSB.h b/firmware/lib/DLUSB/DLUSB.h index b3de31a..e2cdaff 100644 --- a/firmware/lib/DLUSB/DLUSB.h +++ b/firmware/lib/DLUSB/DLUSB.h @@ -18,6 +18,7 @@ #include #include #include "usbdrv.h" +#include "defs.h" #include /* for _delay_ms() */ @@ -25,19 +26,6 @@ * structures it holds. I.e. how many packets it can store before processing. */ #define RING_BUFFER_SIZE 16 -#define REPORT_ID 0x4c - -#define CMD_SWITCH 0x01 // IN,OUT send Livolo keycode command or send ACK to the host -#define CMD_RDY 0x10 // OUT, device ready command -#define CMD_FAIL_BIT (uint8_t)(1 << 7) // Not used - -typedef struct dlusb_packet { - uint8_t report_id; - uint8_t cmd_id; - uint16_t remote_id; - uint8_t btn_id; -} dlusb_packet_t; - struct ring_buffer { dlusb_packet_t buffer[RING_BUFFER_SIZE]; int head; diff --git a/firmware/lib/DLUSB/defs.h b/firmware/lib/DLUSB/defs.h new file mode 100644 index 0000000..cedead9 --- /dev/null +++ b/firmware/lib/DLUSB/defs.h @@ -0,0 +1,42 @@ +/* Part of the DigiLivolo project. + * https://github.com/N-Storm/DigiLivolo/ + * Copyright (c) 2024 GitHub user N-Storm. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#ifndef __defs_h__ +#define __defs_h__ + +#define DIGILIVOLO_VID 0x16c0 +#define DIGILIVOLO_PID 0x05df +#define DIGILIVOLO_MANUFACTURER_STRING L"digilivolo@yandex.com" +#define DIGILIVOLO_PRODUCT_STRING L"DigiLivolo" + +#define REPORT_ID 0x4c + +#define CMD_SWITCH 0x01 // IN,OUT send Livolo keycode command or send ACK to the host +#define CMD_RDY 0x10 // OUT, device ready command +#define CMD_FAIL_BIT (uint8_t)(1 << 7) // Not used + +typedef struct dlusb_packet { + uint8_t report_id; + uint8_t cmd_id; + uint16_t remote_id; + uint8_t btn_id; +} dlusb_packet_t; + +#endif // __defs_h__ diff --git a/software/src/args.c b/software/src/args.c index 533970b..8ec4fe2 100644 --- a/software/src/args.c +++ b/software/src/args.c @@ -24,7 +24,7 @@ #include #include -#include "digilivolo.h" +#include "defs.h" #include #include "usb_func.h" diff --git a/software/src/args.h b/software/src/args.h index 1c5e171..aad9994 100644 --- a/software/src/args.h +++ b/software/src/args.h @@ -21,12 +21,6 @@ #ifndef __args_h__ #define __args_h__ -#include -#include -#include - -#include "digilivolo.h" - #include "git_version.h" #include diff --git a/software/src/defs.h b/software/src/defs.h new file mode 100644 index 0000000..cedead9 --- /dev/null +++ b/software/src/defs.h @@ -0,0 +1,42 @@ +/* Part of the DigiLivolo project. + * https://github.com/N-Storm/DigiLivolo/ + * Copyright (c) 2024 GitHub user N-Storm. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#ifndef __defs_h__ +#define __defs_h__ + +#define DIGILIVOLO_VID 0x16c0 +#define DIGILIVOLO_PID 0x05df +#define DIGILIVOLO_MANUFACTURER_STRING L"digilivolo@yandex.com" +#define DIGILIVOLO_PRODUCT_STRING L"DigiLivolo" + +#define REPORT_ID 0x4c + +#define CMD_SWITCH 0x01 // IN,OUT send Livolo keycode command or send ACK to the host +#define CMD_RDY 0x10 // OUT, device ready command +#define CMD_FAIL_BIT (uint8_t)(1 << 7) // Not used + +typedef struct dlusb_packet { + uint8_t report_id; + uint8_t cmd_id; + uint16_t remote_id; + uint8_t btn_id; +} dlusb_packet_t; + +#endif // __defs_h__ diff --git a/software/src/digilivolo.c b/software/src/digilivolo.c index e8be8ca..d8a8405 100644 --- a/software/src/digilivolo.c +++ b/software/src/digilivolo.c @@ -25,7 +25,7 @@ #include #include -#include "digilivolo.h" +#include "defs.h" #include "args.h" #include diff --git a/software/src/usb_func.c b/software/src/usb_func.c index 075f9dd..b473450 100644 --- a/software/src/usb_func.c +++ b/software/src/usb_func.c @@ -25,7 +25,7 @@ #include #include -#include "digilivolo.h" +#include "defs.h" #include diff --git a/software/src/usb_func.h b/software/src/usb_func.h index ebdc826..cd817cc 100644 --- a/software/src/usb_func.h +++ b/software/src/usb_func.h @@ -21,9 +21,6 @@ #ifndef __usb_func_h__ #define __usb_func_h__ -#include -#include - extern const char* hid_bus_name(hid_bus_type bus_type); extern void print_device_details(struct hid_device_info* cur_dev); extern void print_device(struct hid_device_info* cur_dev);