Skip to content

Commit

Permalink
Moved common (shared between firmware & software) definitions to defs…
Browse files Browse the repository at this point in the history
….h, symlinked
  • Loading branch information
N-Storm committed Apr 30, 2024
1 parent 7bb6d88 commit cbbfccb
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 31 deletions.
18 changes: 12 additions & 6 deletions software/src/digilivolo.h → common/defs.h
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -18,10 +18,8 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/

#ifndef __digilivolo_h__
#define __digilivolo_h__

#include <wchar.h>
#ifndef __defs_h__
#define __defs_h__

#define DIGILIVOLO_VID 0x16c0
#define DIGILIVOLO_PID 0x05df
Expand All @@ -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__
14 changes: 1 addition & 13 deletions firmware/lib/DLUSB/DLUSB.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,14 @@
#include <string.h>
#include <stdint.h>
#include "usbdrv.h"
#include "defs.h"

#include <util/delay.h> /* for _delay_ms() */

/* Buffer size for USB TX & RX buffers. This is not the bytes, it's a count of dlusb_packet_t
* 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;
Expand Down
42 changes: 42 additions & 0 deletions firmware/lib/DLUSB/defs.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
* 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__
2 changes: 1 addition & 1 deletion software/src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <stdbool.h>
#include <stdint.h>

#include "digilivolo.h"
#include "defs.h"

#include <hidapi.h>
#include "usb_func.h"
Expand Down
6 changes: 0 additions & 6 deletions software/src/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@
#ifndef __args_h__
#define __args_h__

#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>

#include "digilivolo.h"

#include "git_version.h"
#include <argp.h>

Expand Down
42 changes: 42 additions & 0 deletions software/src/defs.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
* 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__
2 changes: 1 addition & 1 deletion software/src/digilivolo.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdbool.h>
#include <stdint.h>

#include "digilivolo.h"
#include "defs.h"
#include "args.h"

#include <hidapi.h>
Expand Down
2 changes: 1 addition & 1 deletion software/src/usb_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <stdbool.h>
#include <stdint.h>

#include "digilivolo.h"
#include "defs.h"

#include <hidapi.h>

Expand Down
3 changes: 0 additions & 3 deletions software/src/usb_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#ifndef __usb_func_h__
#define __usb_func_h__

#include <wchar.h>
#include <hidapi.h>

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);
Expand Down

0 comments on commit cbbfccb

Please sign in to comment.