Skip to content

Commit d77f8e0

Browse files
authored
add yield(default weak) (#70)
1 parent 5f91713 commit d77f8e0

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

cores/arduino/Arduino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343
extern void setup(void) ;
4444
extern void loop(void) ;
4545

46-
// void yield(void)
46+
void yield(void);
4747

4848
#ifdef __cplusplus
4949
} // extern "C"

cores/arduino/hooks.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
Copyright (c) 2012 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#include <stdint.h>
20+
21+
/**
22+
* Empty yield() hook.
23+
*
24+
* This function is intended to be used by library writers to build
25+
* libraries or sketches that supports cooperative threads.
26+
*
27+
* Its defined as a weak symbol and it can be redefined to implement a
28+
* real cooperative scheduler.
29+
*/
30+
static void __empty()
31+
{
32+
// Empty
33+
}
34+
void yield(void) __attribute__((weak, alias("__empty")));
35+
36+
#ifdef DTR_TOGGLING_SEQ
37+
/**
38+
* Empty dtr_toggling() hook.
39+
*
40+
* This function is intended to be used by library writers to build
41+
* libraries or sketches that require DTR toggling feature.
42+
*
43+
* Its defined as a weak symbol and it can be redefined to implement
44+
* task to achieve in this case.
45+
*/
46+
static void __empty_dtr_toggling(uint8_t *buf, uint32_t *len)
47+
{
48+
(void)buf;
49+
(void)len;
50+
}
51+
void dtr_togglingHook(uint8_t *buf, uint32_t *len) __attribute__((weak, alias("__empty_dtr_toggling")));
52+
#endif

0 commit comments

Comments
 (0)