Skip to content

Commit 596d9c0

Browse files
authored
Merge pull request #92 from adafruit/update-fix-warings
Update tinyusb to latest and fix warings
2 parents e02de0e + 31c3fea commit 596d9c0

File tree

17 files changed

+247
-151
lines changed

17 files changed

+247
-151
lines changed

src/arduino/hid/Adafruit_USBD_HID.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static Adafruit_USBD_HID *_hid_dev = NULL;
3838
//------------- IMPLEMENTATION -------------//
3939
Adafruit_USBD_HID::Adafruit_USBD_HID(void) {
4040
_interval_ms = 10;
41-
_protocol = HID_PROTOCOL_NONE;
41+
_protocol = HID_ITF_PROTOCOL_NONE;
4242

4343
_out_endpoint = false;
4444
_mouse_button = 0;

src/arduino/ports/Adafruit_TinyUSB_nrf.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838

3939
#define USBD_STACK_SZ (200)
4040

41-
// tinyusb function that handles power event (detected, ready, removed)
42-
// We must call it within SD's SOC event handler, or set it as power event
43-
// handler if SD is not enabled.
44-
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
45-
4641
//--------------------------------------------------------------------+
4742
// Forward USB interrupt events to TinyUSB IRQ Handler
4843
//--------------------------------------------------------------------+
@@ -105,6 +100,15 @@ uint8_t TinyUSB_Port_GetSerialNumber(uint8_t serial_id[16]) {
105100
// Helper
106101
//--------------------------------------------------------------------+
107102

103+
// tinyusb function that handles power event (detected, ready, removed)
104+
// We must call it within SD's SOC event handler, or set it as power event
105+
// handler if SD is not enabled.
106+
extern "C" void tusb_hal_nrf_power_event(uint32_t event);
107+
108+
static void power_event_handler(nrfx_power_usb_evt_t event) {
109+
tusb_hal_nrf_power_event((uint32_t)event);
110+
}
111+
108112
// Init usb hardware when starting up. Softdevice is not enabled yet
109113
static void usb_hardware_init(void) {
110114
// Priorities 0, 1, 4 (nRF52) are reserved for SoftDevice
@@ -120,10 +124,9 @@ static void usb_hardware_init(void) {
120124
nrfx_power_init(&pwr_cfg);
121125

122126
// Register tusb function as USB power handler
123-
const nrfx_power_usbevt_config_t config = {
124-
.handler = (nrfx_power_usb_event_handler_t)tusb_hal_nrf_power_event};
125-
nrfx_power_usbevt_init(&config);
127+
const nrfx_power_usbevt_config_t config = {.handler = power_event_handler};
126128

129+
nrfx_power_usbevt_init(&config);
127130
nrfx_power_usbevt_enable();
128131

129132
if (usb_reg & POWER_USBREGSTATUS_VBUSDETECT_Msk) {

src/class/audio/audio_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ static bool audiod_rx_done_cb(uint8_t rhport, audiod_function_t* audio, uint16_t
496496
if (tud_audio_rx_done_pre_read_cb || tud_audio_rx_done_post_read_cb)
497497
{
498498
idx_audio_fct = audiod_get_audio_fct_idx(audio);
499-
TU_VERIFY(audiod_get_AS_interface_index(audio->ep_in_as_intf_num, audio, &idxItf, &dummy2));
499+
TU_VERIFY(audiod_get_AS_interface_index(audio->ep_out_as_intf_num, audio, &idxItf, &dummy2));
500500
}
501501

502502
// Call a weak callback here - a possibility for user to get informed an audio packet was received and data gets now loaded into EP FIFO (or decoded into support RX software FIFO)

src/class/hid/hid.h

Lines changed: 103 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,23 @@ typedef enum
6262
{
6363
HID_SUBCLASS_NONE = 0, ///< No Subclass
6464
HID_SUBCLASS_BOOT = 1 ///< Boot Interface Subclass
65-
}hid_subclass_type_t;
65+
}hid_subclass_enum_t;
6666

67-
/// HID Protocol
67+
/// HID Interface Protocol
6868
typedef enum
6969
{
70-
HID_PROTOCOL_NONE = 0, ///< None
71-
HID_PROTOCOL_KEYBOARD = 1, ///< Keyboard
72-
HID_PROTOCOL_MOUSE = 2 ///< Mouse
73-
}hid_protocol_type_t;
70+
HID_ITF_PROTOCOL_NONE = 0, ///< None
71+
HID_ITF_PROTOCOL_KEYBOARD = 1, ///< Keyboard
72+
HID_ITF_PROTOCOL_MOUSE = 2 ///< Mouse
73+
}hid_interface_protocol_enum_t;
7474

7575
/// HID Descriptor Type
7676
typedef enum
7777
{
7878
HID_DESC_TYPE_HID = 0x21, ///< HID Descriptor
7979
HID_DESC_TYPE_REPORT = 0x22, ///< Report Descriptor
8080
HID_DESC_TYPE_PHYSICAL = 0x23 ///< Physical Descriptor
81-
}hid_descriptor_type_t;
81+
}hid_descriptor_enum_t;
8282

8383
/// HID Request Report Type
8484
typedef enum
@@ -98,9 +98,9 @@ typedef enum
9898
HID_REQ_CONTROL_SET_REPORT = 0x09, ///< Set Report
9999
HID_REQ_CONTROL_SET_IDLE = 0x0a, ///< Set Idle
100100
HID_REQ_CONTROL_SET_PROTOCOL = 0x0b ///< Set Protocol
101-
}hid_request_type_t;
101+
}hid_request_enum_t;
102102

103-
/// HID Country Code
103+
/// HID Local Code
104104
typedef enum
105105
{
106106
HID_LOCAL_NotSupported = 0 , ///< NotSupported
@@ -139,7 +139,14 @@ typedef enum
139139
HID_LOCAL_US , ///< US
140140
HID_LOCAL_Yugoslavia , ///< Yugoslavia
141141
HID_LOCAL_Turkish_F ///< Turkish-F
142-
} hid_country_code_t;
142+
} hid_local_enum_t;
143+
144+
// HID protocol value used by GetProtocol / SetProtocol
145+
typedef enum
146+
{
147+
HID_PROTOCOL_BOOT = 0,
148+
HID_PROTOCOL_REPORT = 1
149+
} hid_protocol_mode_enum_t;
143150

144151
/** @} */
145152

@@ -479,6 +486,7 @@ typedef enum
479486
//--------------------------------------------------------------------+
480487
// REPORT DESCRIPTOR
481488
//--------------------------------------------------------------------+
489+
482490
//------------- ITEM & TAG -------------//
483491
#define HID_REPORT_DATA_0(data)
484492
#define HID_REPORT_DATA_1(data) , data
@@ -488,18 +496,31 @@ typedef enum
488496
#define HID_REPORT_ITEM(data, tag, type, size) \
489497
(((tag) << 4) | ((type) << 2) | (size)) HID_REPORT_DATA_##size(data)
490498

491-
#define RI_TYPE_MAIN 0
492-
#define RI_TYPE_GLOBAL 1
493-
#define RI_TYPE_LOCAL 2
499+
// Report Item Types
500+
enum {
501+
RI_TYPE_MAIN = 0,
502+
RI_TYPE_GLOBAL = 1,
503+
RI_TYPE_LOCAL = 2
504+
};
505+
506+
//------------- Main Items - HID 1.11 section 6.2.2.4 -------------//
507+
508+
// Report Item Main group
509+
enum {
510+
RI_MAIN_INPUT = 8,
511+
RI_MAIN_OUTPUT = 9,
512+
RI_MAIN_COLLECTION = 10,
513+
RI_MAIN_FEATURE = 11,
514+
RI_MAIN_COLLECTION_END = 12
515+
};
494516

495-
//------------- MAIN ITEMS 6.2.2.4 -------------//
496-
#define HID_INPUT(x) HID_REPORT_ITEM(x, 8, RI_TYPE_MAIN, 1)
497-
#define HID_OUTPUT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_MAIN, 1)
498-
#define HID_COLLECTION(x) HID_REPORT_ITEM(x, 10, RI_TYPE_MAIN, 1)
499-
#define HID_FEATURE(x) HID_REPORT_ITEM(x, 11, RI_TYPE_MAIN, 1)
500-
#define HID_COLLECTION_END HID_REPORT_ITEM(x, 12, RI_TYPE_MAIN, 0)
517+
#define HID_INPUT(x) HID_REPORT_ITEM(x, RI_MAIN_INPUT , RI_TYPE_MAIN, 1)
518+
#define HID_OUTPUT(x) HID_REPORT_ITEM(x, RI_MAIN_OUTPUT , RI_TYPE_MAIN, 1)
519+
#define HID_COLLECTION(x) HID_REPORT_ITEM(x, RI_MAIN_COLLECTION , RI_TYPE_MAIN, 1)
520+
#define HID_FEATURE(x) HID_REPORT_ITEM(x, RI_MAIN_FEATURE , RI_TYPE_MAIN, 1)
521+
#define HID_COLLECTION_END HID_REPORT_ITEM(x, RI_MAIN_COLLECTION_END, RI_TYPE_MAIN, 0)
501522

502-
//------------- INPUT, OUTPUT, FEATURE 6.2.2.5 -------------//
523+
//------------- Input, Output, Feature - HID 1.11 section 6.2.2.5 -------------//
503524
#define HID_DATA (0<<0)
504525
#define HID_CONSTANT (1<<0)
505526

@@ -527,7 +548,7 @@ typedef enum
527548
#define HID_BITFIELD (0<<8)
528549
#define HID_BUFFERED_BYTES (1<<8)
529550

530-
//------------- COLLECTION ITEM 6.2.2.6 -------------//
551+
//------------- Collection Item - HID 1.11 section 6.2.2.6 -------------//
531552
enum {
532553
HID_COLLECTION_PHYSICAL = 0,
533554
HID_COLLECTION_APPLICATION,
@@ -538,49 +559,81 @@ enum {
538559
HID_COLLECTION_USAGE_MODIFIER
539560
};
540561

541-
//------------- GLOBAL ITEMS 6.2.2.7 -------------//
542-
#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, 1)
543-
#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_GLOBAL, n)
562+
//------------- Global Items - HID 1.11 section 6.2.2.7 -------------//
563+
564+
// Report Item Global group
565+
enum {
566+
RI_GLOBAL_USAGE_PAGE = 0,
567+
RI_GLOBAL_LOGICAL_MIN = 1,
568+
RI_GLOBAL_LOGICAL_MAX = 2,
569+
RI_GLOBAL_PHYSICAL_MIN = 3,
570+
RI_GLOBAL_PHYSICAL_MAX = 4,
571+
RI_GLOBAL_UNIT_EXPONENT = 5,
572+
RI_GLOBAL_UNIT = 6,
573+
RI_GLOBAL_REPORT_SIZE = 7,
574+
RI_GLOBAL_REPORT_ID = 8,
575+
RI_GLOBAL_REPORT_COUNT = 9,
576+
RI_GLOBAL_PUSH = 10,
577+
RI_GLOBAL_POP = 11
578+
};
579+
580+
#define HID_USAGE_PAGE(x) HID_REPORT_ITEM(x, RI_GLOBAL_USAGE_PAGE, RI_TYPE_GLOBAL, 1)
581+
#define HID_USAGE_PAGE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_USAGE_PAGE, RI_TYPE_GLOBAL, n)
544582

545-
#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, 1)
546-
#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_GLOBAL, n)
583+
#define HID_LOGICAL_MIN(x) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MIN, RI_TYPE_GLOBAL, 1)
584+
#define HID_LOGICAL_MIN_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MIN, RI_TYPE_GLOBAL, n)
547585

548-
#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, 1)
549-
#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_GLOBAL, n)
586+
#define HID_LOGICAL_MAX(x) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MAX, RI_TYPE_GLOBAL, 1)
587+
#define HID_LOGICAL_MAX_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_LOGICAL_MAX, RI_TYPE_GLOBAL, n)
550588

551-
#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, 1)
552-
#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, 3, RI_TYPE_GLOBAL, n)
589+
#define HID_PHYSICAL_MIN(x) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MIN, RI_TYPE_GLOBAL, 1)
590+
#define HID_PHYSICAL_MIN_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MIN, RI_TYPE_GLOBAL, n)
553591

554-
#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, 1)
555-
#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, 4, RI_TYPE_GLOBAL, n)
592+
#define HID_PHYSICAL_MAX(x) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MAX, RI_TYPE_GLOBAL, 1)
593+
#define HID_PHYSICAL_MAX_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_PHYSICAL_MAX, RI_TYPE_GLOBAL, n)
556594

557-
#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, 1)
558-
#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, 5, RI_TYPE_GLOBAL, n)
595+
#define HID_UNIT_EXPONENT(x) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT_EXPONENT, RI_TYPE_GLOBAL, 1)
596+
#define HID_UNIT_EXPONENT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT_EXPONENT, RI_TYPE_GLOBAL, n)
559597

560-
#define HID_UNIT(x) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, 1)
561-
#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, 6, RI_TYPE_GLOBAL, n)
598+
#define HID_UNIT(x) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT, RI_TYPE_GLOBAL, 1)
599+
#define HID_UNIT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_UNIT, RI_TYPE_GLOBAL, n)
562600

563-
#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, 1)
564-
#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, 7, RI_TYPE_GLOBAL, n)
601+
#define HID_REPORT_SIZE(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, 1)
602+
#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, n)
565603

566-
#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, 1),
567-
#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, 8, RI_TYPE_GLOBAL, n),
604+
#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, 1),
605+
#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, n),
568606

569-
#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, 1)
570-
#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, 9, RI_TYPE_GLOBAL, n)
607+
#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, 1)
608+
#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, n)
571609

572-
#define HID_PUSH HID_REPORT_ITEM(x, 10, RI_TYPE_GLOBAL, 0)
573-
#define HID_POP HID_REPORT_ITEM(x, 11, RI_TYPE_GLOBAL, 0)
610+
#define HID_PUSH HID_REPORT_ITEM(x, RI_GLOBAL_PUSH, RI_TYPE_GLOBAL, 0)
611+
#define HID_POP HID_REPORT_ITEM(x, RI_GLOBAL_POP, RI_TYPE_GLOBAL, 0)
574612

575613
//------------- LOCAL ITEMS 6.2.2.8 -------------//
576-
#define HID_USAGE(x) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, 1)
577-
#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, 0, RI_TYPE_LOCAL, n)
578614

579-
#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, 1)
580-
#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, 1, RI_TYPE_LOCAL, n)
615+
enum {
616+
RI_LOCAL_USAGE = 0,
617+
RI_LOCAL_USAGE_MIN = 1,
618+
RI_LOCAL_USAGE_MAX = 2,
619+
RI_LOCAL_DESIGNATOR_INDEX = 3,
620+
RI_LOCAL_DESIGNATOR_MIN = 4,
621+
RI_LOCAL_DESIGNATOR_MAX = 5,
622+
// 6 is reserved
623+
RI_LOCAL_STRING_INDEX = 7,
624+
RI_LOCAL_STRING_MIN = 8,
625+
RI_LOCAL_STRING_MAX = 9,
626+
RI_LOCAL_DELIMITER = 10,
627+
};
628+
629+
#define HID_USAGE(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE, RI_TYPE_LOCAL, 1)
630+
#define HID_USAGE_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE, RI_TYPE_LOCAL, n)
631+
632+
#define HID_USAGE_MIN(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MIN, RI_TYPE_LOCAL, 1)
633+
#define HID_USAGE_MIN_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MIN, RI_TYPE_LOCAL, n)
581634

582-
#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, 1)
583-
#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, 2, RI_TYPE_LOCAL, n)
635+
#define HID_USAGE_MAX(x) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MAX, RI_TYPE_LOCAL, 1)
636+
#define HID_USAGE_MAX_N(x, n) HID_REPORT_ITEM(x, RI_LOCAL_USAGE_MAX, RI_TYPE_LOCAL, n)
584637

585638
//--------------------------------------------------------------------+
586639
// Usage Table

0 commit comments

Comments
 (0)