Skip to content

Commit f81ad86

Browse files
committed
remove tinyusb task to __empty() so that freerots can overwrite yield()
1 parent 93c34f3 commit f81ad86

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

cores/arduino/hooks.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
1818

19+
#include <stdint.h>
1920
/**
2021
* Empty yield() hook.
2122
*
@@ -25,23 +26,30 @@
2526
* Its defined as a weak symbol and it can be redefined to implement a
2627
* real cooperative scheduler.
2728
*/
28-
static void __empty() {
29-
// Empty
29+
extern void tud_task(void);
30+
extern uint32_t tud_cdc_n_write_flush (uint8_t itf);
31+
static void __empty()
32+
{
33+
// Empty
34+
#if defined(USE_TINYUSB)
35+
tud_task();
36+
tud_cdc_n_write_flush(0);
37+
#endif
3038
}
31-
32-
void yield(void) __attribute__ ((weak, alias("__empty")));
39+
void yield(void) __attribute__((weak, alias("__empty")));
3340

3441
/**
3542
* SysTick hook
3643
*
3744
* This function is called from SysTick handler, before the default
3845
* handler provided by Arduino.
3946
*/
40-
static int __false() {
41-
// Return false
42-
return 0;
47+
static int __false()
48+
{
49+
// Return false
50+
return 0;
4351
}
44-
int sysTickHook(void) __attribute__ ((weak, alias("__false")));
52+
int sysTickHook(void) __attribute__((weak, alias("__false")));
4553

4654
/**
4755
* SVC hook
@@ -50,10 +58,11 @@ int sysTickHook(void) __attribute__ ((weak, alias("__false")));
5058
* These functions are called from SVC handler, and PensSV handler.
5159
* Default action is halting.
5260
*/
53-
static void __halt() {
54-
// Halts
55-
while (1)
56-
;
61+
static void __halt()
62+
{
63+
// Halts
64+
while (1)
65+
;
5766
}
58-
void svcHook(void) __attribute__ ((weak, alias("__halt")));
59-
void pendSVHook(void) __attribute__ ((weak, alias("__halt")));
67+
void svcHook(void) __attribute__((weak, alias("__halt")));
68+
void pendSVHook(void) __attribute__((weak, alias("__halt")));

0 commit comments

Comments
 (0)