Skip to content

Commit 46d1424

Browse files
committed
more cleanup and reorganization
1 parent 758f79b commit 46d1424

File tree

2 files changed

+24
-26
lines changed

2 files changed

+24
-26
lines changed

src/usb.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
#define USB_PID 0xbeef
1717
#endif
1818

19-
// TODO: replace usage / rename
20-
#define REPORT_TYPE_OUTPUT 2
21-
#define REPORT_TYPE_FEATURE 3
22-
23-
#define DEVICE_TYPE 0
24-
#define INTERFACE_TYPE 1
25-
#define ENDPOINT_TYPE 2
26-
2719
// EP0 States
2820
#define NEW_SETUP_PHASE 0x00
2921
#define IN0_DATA_PHASE 0x01
@@ -34,7 +26,7 @@
3426
#define OUT0_KeyMode_PHASE 0x0a
3527
#define OUT0_ISP_PHASE 0x05
3628

37-
/* interface */
29+
// interface
3830
#define interface0_PHASE 0x00
3931
#define interface1_PHASE 0x01
4032

@@ -75,13 +67,6 @@
7567
#define IEP0CNT_SET(COUNT) \
7668
do { IEP0CNT_CLR; IEP0CNT |= COUNT; } while (0)
7769

78-
enum {
79-
REPORT_ID_ACPI = 0x01,
80-
REPORT_ID_CONSUMER = 0x02,
81-
REPORT_ID_ISP = 0x05,
82-
REPORT_ID_NKRO = 0x06
83-
};
84-
8570
const uint8_t hid_report_desc_keyboard[] = {
8671
// *INDENT-OFF*
8772
HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop Controls
@@ -303,10 +288,17 @@ static usb_desc_langid_c usb_langid = {
303288
.wLANGID = { /* English (United States) */ 0x0409 },
304289
};
305290

291+
enum usb_string_index {
292+
USB_STRING_LANGUAGE_ID = 0,
293+
USB_STRING_MANUFACTURER = 1,
294+
USB_STRING_PRODUCT = 2,
295+
USB_STRING_SERIAL_NUMBER = 3,
296+
};
297+
306298
usb_ascii_string_c usb_strings[] = {
307299
[USB_STRING_MANUFACTURER - 1] = "[email protected]",
308300
[USB_STRING_PRODUCT - 1] = "SMK Keyboard",
309-
[USB_STRING_SERIAL_NUMBER - 1] = "0001" // TODO: include this
301+
[USB_STRING_SERIAL_NUMBER - 1] = "0001"
310302
};
311303

312304
usb_descriptor_set_c usb_descriptor_set = {
@@ -317,6 +309,13 @@ usb_descriptor_set_c usb_descriptor_set = {
317309
.strings = usb_strings,
318310
};
319311

312+
enum report_id {
313+
REPORT_ID_ACPI = 1,
314+
REPORT_ID_CONSUMER = 2,
315+
REPORT_ID_ISP = 5,
316+
REPORT_ID_NKRO = 6,
317+
};
318+
320319
// interrupt handlers
321320
static void usb_setup_irq();
322321
static void usb_ep0_out_irq();
@@ -370,7 +369,6 @@ volatile __bit device_remote_wakeup_f;
370369
volatile uint8_t __xdata configution_value;
371370

372371
uint8_t __xdata EP1_IDLE_TIME;
373-
uint8_t __xdata EP1_IDLE_COUNT;
374372

375373
uint8_t __xdata ep0_xfer_state;
376374

@@ -990,8 +988,8 @@ static void usb_hid_set_report_handler(__xdata struct usb_req_setup *req)
990988

991989
static void usb_hid_set_idle_handler(__xdata struct usb_req_setup *req)
992990
{
993-
// TODO: is this used?
994-
EP1_IDLE_TIME = EP1_IDLE_COUNT = req->wValue >> 8;
991+
// TODO: finish implementaiton to use the set idle time
992+
EP1_IDLE_TIME = req->wValue >> 8;
995993

996994
IEP0CNT_CLR;
997995
IN0_SET_READY;

src/usbdef.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33

44
#include <stdint.h>
55

6-
// USB string type
7-
#define USB_STRING_LANGUAGE_ID 0x00
8-
#define USB_STRING_MANUFACTURER 0x01
9-
#define USB_STRING_PRODUCT 0x02
10-
#define USB_STRING_SERIAL_NUMBER 0x03
11-
126
typedef struct {
137
uint8_t request_type;
148
uint8_t request;
@@ -316,4 +310,10 @@ struct usb_descriptor_set {
316310
typedef __code const struct usb_descriptor_set
317311
usb_descriptor_set_c;
318312

313+
enum report_type {
314+
REPORT_TYPE_INPUT = 1,
315+
REPORT_TYPE_OUTPUT = 2,
316+
REPORT_TYPE_FEATURE = 3,
317+
};
318+
319319
#endif

0 commit comments

Comments
 (0)