8000 add usb_desc, disable tinyusb stack CFG_TUD_DESC_AUTO · sparkfun/circuitpython@27b2a9f · GitHub
[go: up one dir, main page]

Skip to content

Commit 27b2a9f

Browse files
committed
add usb_desc, disable tinyusb stack CFG_TUD_DESC_AUTO
1 parent d15caf0 commit 27b2a9f

File tree

7 files changed

+476
-69
lines changed

7 files changed

+476
-69
lines changed

ports/nrf/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,11 @@ ifeq ($(MCU_SUB_VARIANT),nrf52840)
210210
SRC_C += \
211211
usb/usb.c \
212212
usb/usb_msc_flash.c \
213+
usb/usb_desc.c \
213214
lib/tinyusb/src/portable/nordic/nrf5x/dcd_nrf5x.c \
214215
lib/tinyusb/src/portable/nordic/nrf5x/hal_nrf5x.c \
215216
lib/tinyusb/src/common/tusb_fifo.c \
216217
lib/tinyusb/src/device/usbd.c \
217-
lib/tinyusb/src/device/usbd_auto_desc.c \
218218
lib/tinyusb/src/class/msc/msc_device.c \
219219
lib/tinyusb/src/class/cdc/cdc_device.c \
220220
lib/tinyusb/src/class/hid/hid_device.c \

ports/nrf/common-hal/usb_hid/Device.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838

3939
#define USB_HID_NUM_DEVICES 2
4040

41+
#define USB_HID_REPORT_ID_KEYBOARD 1
42+
#define USB_HID_REPORT_ID_MOUSE 2
43+
//#define USB_HID_REPORT_ID_CONSUMER 3
44+
4145
typedef struct {
4246
mp_obj_base_t base;
4347
uint8_t* report_buffer;

ports/nrf/common-hal/usb_hid/__init__.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,11 @@
3131
#include "common-hal/usb_hid/Device.h"
3232
#include "shared-bindings/usb_hid/Device.h"
3333

34-
#define USB_HID_REPORT_ID_KEYBOARD 1
3534
#define USB_HID_REPORT_LENGTH_KEYBOARD 8
36-
37-
#define USB_HID_REPORT_ID_MOUSE 2
3835
#define USB_HID_REPORT_LENGTH_MOUSE 4
3936

4037
// Buffers are report size + 1 to include the Report ID prefix byte if needed.
41-
#ifdef USB_HID_REPORT_LENGTH_KEYBOARD
38+
#ifdef USB_HID_REPORT_ID_KEYBOARD
4239
static uint8_t keyboard_report_buffer[USB_HID_REPORT_LENGTH_KEYBOARD + 1];
4340
#endif
4441
#ifdef USB_HID_REPORT_ID_MOUSE

ports/nrf/usb/tusb_config.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,26 @@
6060
// DEVICE CONFIGURATION
6161
//--------------------------------------------------------------------+
6262

63-
#define CFG_TUD_ENDOINT0_SIZE 64
63+
#define CFG_TUD_ENDOINT0_SIZE 64
6464

6565
/*------------- Descriptors -------------*/
6666
/* Enable auto generated descriptor, tinyusb will try its best to create
6767
* descriptor ( device, configuration, hid ) that matches enabled CFG_* in this file
6868
*
6969
* Note: All CFG_TUD_DESC_* are relevant only if CFG_TUD_DESC_AUTO is enabled
7070
*/
71-
#define CFG_TUD_DESC_AUTO 1
72-
73-
/* Note: different class combination e.g CDC and (CDC + MSC) should have different
74-
* PID since Host OS will "remembered" device driver after the first plug */
75-
#define CFG_TUD_DESC_VID 0x239A
76-
#define CFG_TUD_DESC_PID 0x802A
77-
71+
#define CFG_TUD_DESC_AUTO 0
7872

7973
//------------- CLASS -------------//
8074
#define CFG_TUD_CDC 1
8175
#define CFG_TUD_MSC 1
8276
#define CFG_TUD_HID 1
8377

84-
#define CFG_TUD_HID_KEYB 8000 OARD 1
85-
#define CFG_TUD_HID_MOUSE 1
86-
87-
/* Use Boot Protocol for Keyboard, Mouse. Enable this will create separated HID interface
88-
* require more IN endpoints. If disabled, they they are all packed into a single
89-
* multiple report interface called "Generic". */
90-
#define CFG_TUD_HID_KEYBOARD_BOOT 0
91-
#define CFG_TUD_HID_MOUSE_BOOT 0
92-
9378
/*------------------------------------------------------------------*/
9479
/* CLASS DRIVER
9580
*------------------------------------------------------------------*/
9681

82+
/*------------- CDC -------------*/
9783
// FIFO size of CDC TX and RX
9884
#define CFG_TUD_CDC_RX_BUFSIZE 1024
9985
#define CFG_TUD_CDC_TX_BUFSIZE 1024
@@ -105,6 +91,8 @@
10591
*/
10692
#define CFG_TUD_CDC_FLUSH_ON_SOF 0
10793

94+
95+
/*------------- MSC -------------*/
10896
// Number of supported Logical Unit Number (At least 1)
10997
#define CFG_TUD_MSC_MAXLUN 1
11098

ports/nrf/usb/usb.c

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -36,53 +36,6 @@
3636
#include "nrf_soc.h"
3737
#endif
3838

39-
//--------------------------------------------------------------------+
40-
// STRING DESCRIPTORS
41-
//--------------------------------------------------------------------+
42-
43-
// array of pointer to string descriptors
44-
uint16_t const * const string_desc_arr [] =
45-
{
46-
// 0 index is supported language = English
47-
TUD_DESC_STRCONV(0x0409),
48-
49-
// Manufacturer
50-
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'),
51-
52-
// Product
53-
TUD_DESC_STRCONV('C','i','r','c','u','i','t','P','Y',' ','n','R','F','5','2'),
54-
55-
// Serials TODO use chip ID
56-
TUD_DESC_STRCONV('1', '2', '3', '4', '5'),
57-
58-
// CDC Interface
59-
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'),
60-
61-
// MSC Interface
62-
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','t','o','r','a','g','e'),
63-
64-
// Custom Interface
65-
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','C','u','s','t','o','m')
66-
};
67-
68-
// tud_desc_set is required by tinyusb stack
69-
// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
70-
tud_desc_set_t tud_desc_set =
71-
{
72-
.device = NULL,
73-
.config = NULL,
74-
.string_arr = (uint8_t const **) string_desc_arr,
75-
.string_count = sizeof(string_desc_arr)/sizeof(string_desc_arr[0]),
76-
77-
.hid_report =
78-
{
79-
.generic = NULL,
80-
.boot_keyboard = NULL,
81-
.boot_mouse = NULL
82-
}
83-
};
84-
85-
8639
/* tinyusb function that handles power event (detected, ready, removed)
8740
* We must call it within SD's SOC event handler, or set it as power event handler if SD is not enabled.
8841
*/

0 commit comments

Comments
 (0)
0