2828#include "nrfx_power.h"
2929#include "tick.h"
3030#include "usb.h"
31-
32- #include "lib/mp-readline/readline.h"
3331#include "lib/utils/interrupt_char.h"
3432
3533#ifdef NRF52840_XXAA
3634
35+ //--------------------------------------------------------------------+
36+ // STRING DESCRIPTORS
37+ //--------------------------------------------------------------------+
38+
39+ // array of pointer to string descriptors
40+ uint16_t const * const string_desc_arr [] =
41+ {
42+ // 0 index is supported language = English
43+ TUD_DESC_STRCONV (0x0409 ),
44+
45+ // Manufacturer
46+ TUD_DESC_STRCONV ('A' ,'d' ,'a' ,'f' ,'r' ,'u' ,'i' ,'t' ,' ' ,'I' ,'n' ,'d' ,'u' ,'s' ,'t' ,'r' ,'i' ,'e' ,'s' ),
47+
48+ // Product
49+ TUD_DESC_STRCONV ('C' ,'i' ,'r' ,'c' ,'u' ,'i' ,'t' ,'P' ,'Y' ,' ' ,'n' ,'R' ,'F' ,'5' ,'2' ),
50+
51+ // Serials TODO use chip ID
52+ TUD_DESC_STRCONV ('1' , '2' , '3' , '4' , '5' ),
53+
54+ // CDC Interface
55+ TUD_DESC_STRCONV ('B' ,'l' ,'u' ,'e' ,'f' ,'r' ,'u' ,'i' ,'t' ,' ' ,'S' ,'e' ,'r' ,'i' ,'a' ,'l' ),
56+
57+ // MSC Interface
58+ TUD_DESC_STRCONV ('B' ,'l' ,'u' ,'e' ,'f' ,'r' ,'u' ,'i' ,'t' ,' ' ,'S' ,'t' ,'o' ,'r' ,'a' ,'g' ,'e' ),
59+
60+ // Custom Interface
61+ TUD_DESC_STRCONV ('B' ,'l' ,'u' ,'e' ,'f' ,'r' ,'u' ,'i' ,'t' ,' ' ,'C' ,'u' ,'s' ,'t' ,'o' ,'m' )
62+ };
63+
64+ // tud_desc_set is required by tinyusb stack
65+ // since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
66+ tud_desc_set_t tud_desc_set =
67+ {
68+ .device = NULL ,
69+ .config = NULL ,
70+ .string_arr = (uint8_t const * * ) string_desc_arr ,
71+ .hid_report = NULL
72+ };
73+
3774void usb_init (void ) {
3875
3976#ifdef SOFTDEVICE_PRESENT
@@ -55,12 +92,6 @@ void usb_init(void) {
5592#endif
5693
5794 tusb_init ();
58-
59- #if MICROPY_KBD_EXCEPTION
60- // set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() fired when Ctrl+C is received
61- // TODO should be called in mp_hal_set_interrupt_char()
62- tud_cdc_set_wanted_char (CHAR_CTRL_C );
63- #endif
6495}
6596
6697//--------------------------------------------------------------------+
@@ -91,12 +122,12 @@ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char)
91122 (void ) itf ; // not used
92123
93124 if (mp_interrupt_char == wanted_char ) {
94- tud_cdc_read_flush (); // flush read fifo
125+ tud_cdc_read_flush (); // flush read fifo
95126 mp_keyboard_interrupt ();
96127 }
97128}
98129
99130#endif
100131
101- #endif
132+ #endif // NRF52840_XXAA
102133
0 commit comments