Skip to content

Commit 65b6b79

Browse files
committed
clean up and comment out tud_sof_isr_set
1 parent 5cd67ba commit 65b6b79

File tree

4 files changed

+30
-37
lines changed

4 files changed

+30
-37
lines changed

src/device/usbd.c

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static usbd_class_driver_t const _usbd_driver[] =
9898
.open = cdcd_open,
9999
.control_xfer_cb = cdcd_control_xfer_cb,
100100
.xfer_cb = cdcd_xfer_cb,
101-
.sof = NULL
101+
.sof_isr = NULL
102102
},
103103
#endif
104104

@@ -110,7 +110,7 @@ static usbd_class_driver_t const _usbd_driver[] =
110110
.open = mscd_open,
111111
.control_xfer_cb = mscd_control_xfer_cb,
112112
.xfer_cb = mscd_xfer_cb,
113-
.sof = NULL
113+
.sof_isr = NULL
114114
},
115115
#endif
116116

@@ -122,7 +122,7 @@ static usbd_class_driver_t const _usbd_driver[] =
122122
.open = hidd_open,
123123
.control_xfer_cb = hidd_control_xfer_cb,
124124
.xfer_cb = hidd_xfer_cb,
125-
.sof = NULL
125+
.sof_isr = NULL
126126
},
127127
#endif
128128

@@ -134,7 +134,7 @@ static usbd_class_driver_t const _usbd_driver[] =
134134
.open = audiod_open,
135135
.control_xfer_cb = audiod_control_xfer_cb,
136136
.xfer_cb = audiod_xfer_cb,
137-
.sof = audiod_sof
137+
.sof_isr = audiod_sof
138138
},
139139
#endif
140140

@@ -146,7 +146,7 @@ static usbd_class_driver_t const _usbd_driver[] =
146146
.open = videod_open,
147147
.control_xfer_cb = videod_control_xfer_cb,
148148
.xfer_cb = videod_xfer_cb,
149-
.sof = NULL
149+
.sof_isr = NULL
150150
},
151151
#endif
152152

@@ -158,7 +158,7 @@ static usbd_class_driver_t const _usbd_driver[] =
158158
.reset = midid_reset,
159159
.control_xfer_cb = midid_control_xfer_cb,
160160
.xfer_cb = midid_xfer_cb,
161-
.sof = NULL
161+
.sof_isr = NULL
162162
},
163163
#endif
164164

@@ -170,7 +170,7 @@ static usbd_class_driver_t const _usbd_driver[] =
170170
.open = vendord_open,
171171
.control_xfer_cb = tud_vendor_control_xfer_cb,
172172
.xfer_cb = vendord_xfer_cb,
173-
.sof = NULL
173+
.sof_isr = NULL
174174
},
175175
#endif
176176

@@ -182,7 +182,7 @@ static usbd_class_driver_t const _usbd_driver[] =
182182
.open = usbtmcd_open_cb,
183183
.control_xfer_cb = usbtmcd_control_xfer_cb,
184184
.xfer_cb = usbtmcd_xfer_cb,
185-
.sof = NULL
185+
.sof_isr = NULL
186186
},
187187
#endif
188188

@@ -194,7 +194,7 @@ static usbd_class_driver_t const _usbd_driver[] =
194194
.open = dfu_rtd_open,
195195
.control_xfer_cb = dfu_rtd_control_xfer_cb,
196196
.xfer_cb = NULL,
197-
.sof = NULL
197+
.sof_isr = NULL
198198
},
199199
#endif
200200

@@ -206,7 +206,7 @@ static usbd_class_driver_t const _usbd_driver[] =
206206
.open = dfu_moded_open,
207207
.control_xfer_cb = dfu_moded_control_xfer_cb,
208208
.xfer_cb = NULL,
209-
.sof = NULL
209+
.sof_isr = NULL
210210
},
211211
#endif
212212

@@ -218,7 +218,7 @@ static usbd_class_driver_t const _usbd_driver[] =
218218
.open = netd_open,
219219
.control_xfer_cb = netd_control_xfer_cb,
220220
.xfer_cb = netd_xfer_cb,
221-
.sof = NULL,
221+
.sof_isr = NULL,
222222
},
223223
#endif
224224

@@ -230,7 +230,7 @@ static usbd_class_driver_t const _usbd_driver[] =
230230
.open = btd_open,
231231
.control_xfer_cb = btd_control_xfer_cb,
232232
.xfer_cb = btd_xfer_cb,
233-
.sof = NULL
233+
.sof_isr = NULL
234234
},
235235
#endif
236236
};
@@ -264,7 +264,7 @@ static inline usbd_class_driver_t const * get_driver(uint8_t drvid)
264264
// DCD Event
265265
//--------------------------------------------------------------------+
266266

267-
static tud_sof_isr_t _sof_isr = NULL;
267+
//static tud_sof_isr_t _sof_isr = NULL;
268268

269269
enum { RHPORT_INVALID = 0xFFu };
270270
static uint8_t _usbd_rhport = RHPORT_INVALID;
@@ -373,11 +373,11 @@ bool tud_connect(void)
373373
return true;
374374
}
375375

376-
void tud_sof_isr_set(tud_sof_isr_t sof_isr)
377-
{
378-
_sof_isr = sof_isr;
379-
dcd_sof_enable(_usbd_rhport, _sof_isr != NULL);
380-
}
376+
//void tud_sof_isr_set(tud_sof_isr_t sof_isr)
377+
//{
378+
// _sof_isr = sof_isr;
379+
// dcd_sof_enable(_usbd_rhport, _sof_isr != NULL);
380+
//}
381381

382382
//--------------------------------------------------------------------+
383383
// USBD Task
@@ -422,7 +422,7 @@ bool tud_init (uint8_t rhport)
422422
}
423423

424424
_usbd_rhport = rhport;
425-
_sof_isr = NULL;
425+
//_sof_isr = NULL;
426426

427427
// Init device controller driver
428428
dcd_init(rhport);
@@ -585,21 +585,12 @@ void tud_task (void)
585585
}
586586
break;
587587

588-
case DCD_EVENT_SOF:
589-
TU_LOG2("\r\n");
590-
// TODO: Should this really be done here in the queue? How to distinguish the calls here from those SOF events which should be handled directly in the ISR routine? If we do it like this, the SOF routines get called two time right now, once in the ISR context and once again here
591-
// for ( uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++ )
592-
// {
593-
// usbd_class_driver_t const * driver = get_driver(i);
594-
// if ( driver->sof ) driver->sof(event.rhport, event.sof.frame_count);
595-
// }
596-
break;
597-
598588
case USBD_EVENT_FUNC_CALL:
599589
TU_LOG2("\r\n");
600590
if ( event.func_call.func ) event.func_call.func(event.func_call.param);
601591
break;
602592

593+
case DCD_EVENT_SOF:
603594
default:
604595
TU_BREAKPOINT();
605596
break;
@@ -1114,15 +1105,14 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
11141105
for (uint8_t i = 0; i < TOTAL_DRIVER_COUNT; i++)
11151106
{
11161107
usbd_class_driver_t const * driver = get_driver(i);
1117-
if (driver->sof)
1108+
if (driver->sof_isr)
11181109
{
1119-
driver->sof(event->rhport, event->sof.frame_count);
1120-
// TU_LOG2("%s sof\r\n", driver->name); // too demanding
1110+
driver->sof_isr(event->rhport, event->sof.frame_count);
11211111
}
11221112
}
11231113

11241114
// SOF user handler in ISR context
1125-
if (_sof_isr) _sof_isr(event->sof.frame_count);
1115+
// if (_sof_isr) _sof_isr(event->sof.frame_count);
11261116

11271117
// Some MCUs after running dcd_remote_wakeup() does not have way to detect the end of remote wakeup
11281118
// which last 1-15 ms. DCD can use SOF as a clear indicator that bus is back to operational
@@ -1133,6 +1123,8 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
11331123
dcd_event_t const event_resume = { .rhport = event->rhport, .event_id = DCD_EVENT_RESUME };
11341124
osal_queue_send(_usbd_q, &event_resume, in_isr);
11351125
}
1126+
1127+
// skip osal queue for SOF in usbd task
11361128
break;
11371129

11381130
default:
@@ -1411,7 +1403,8 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr)
14111403

14121404
void usbd_sof_enable(uint8_t rhport, bool en)
14131405
{
1414-
// TODO: Check needed if all drivers including the user sof_cb does not need an active SOF ISR any more. Only if all drivers switched off SOF calls the SOF interrupt may be disabled
1406+
// TODO: Check needed if all drivers including the user sof_cb does not need an active SOF ISR any more.
1407+
// Only if all drivers switched off SOF calls the SOF interrupt may be disabled
14151408
dcd_sof_enable(rhport, en);
14161409
}
14171410

src/device/usbd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool tud_connect(void);
8888

8989
// Set Start-of-frame (1ms interval) IRQ handler
9090
// NULL means disabled, frame_count may not be supported on mcus
91-
void tud_sof_isr_set(tud_sof_isr_t sof_isr);
91+
// void tud_sof_isr_set(tud_sof_isr_t sof_isr);
9292

9393
// Carry out Data and Status stage of control transfer
9494
// - If len = 0, it is equivalent to sending status only

src/device/usbd_pvt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef struct
4848
uint16_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t max_len);
4949
bool (* control_xfer_cb ) (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
5050
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes);
51-
void (* sof ) (uint8_t rhport, uint32_t frame_count); /* optional */
51+
void (* sof_isr ) (uint8_t rhport, uint32_t frame_count); // optional
5252
} usbd_class_driver_t;
5353

5454
// Invoked when initializing device stack to get additional class drivers.

src/tusb_option.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@
297297
#endif
298298

299299
#ifndef CFG_TUD_INTERFACE_MAX
300-
#define CFG_TUD_INTERFACE_MAX 8
300+
#define CFG_TUD_INTERFACE_MAX 16
301301
#endif
302302

303303
#ifndef CFG_TUD_CDC

0 commit comments

Comments
 (0)