File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #include < Taskfun.h>
1+ #include " Taskfun.h"
22
33// synchronize access to this shared global variable
44SyncVar<bool > _on;
@@ -18,7 +18,7 @@ void Off(int) {
1818 while (1 ) {
1919 if (!_on) {
2020 digitalWrite (LED_BUILTIN , LOW );
21- delay (1000 );
21+ delay (1000 );
2222 _on = true ;
2323 }
2424 }
Original file line number Diff line number Diff line change @@ -51,7 +51,9 @@ bool BTaskSwitcher::disable() {
5151 return sreg & _BV (SREG_I );
5252}
5353
54- void __attribute__ ((naked)) BTaskSwitcher::switch_context() {
54+ // not a static class function to avoid compiler warning
55+ void __attribute__ ((naked)) avr_switch_context()
56+ {
5557 asm volatile (" push r0" );
5658 asm volatile (" in r0, __SREG__" );
5759 asm volatile (" push r0" );
@@ -90,7 +92,7 @@ void __attribute__((naked)) BTaskSwitcher::switch_context() {
9092 asm volatile (" in r25, __SP_H__" );
9193 asm volatile (" call %x0"
9294 :
93- : " i" (swap_stack));
95+ : " i" (BTaskSwitcher:: swap_stack));
9496 asm volatile (" out __SP_L__, r24" );
9597 asm volatile (" out __SP_H__, r25" );
9698 asm volatile (" pop r31" );
@@ -127,7 +129,11 @@ void __attribute__((naked)) BTaskSwitcher::switch_context() {
127129 asm volatile (" pop r0" );
128130 asm volatile (" out __SREG__, r0" );
129131 asm volatile (" pop r0" );
130- asm volatile (" ret" );
132+ asm volatile (" ret" );
133+ }
134+
135+ void BTaskSwitcher::switch_context () {
136+ avr_switch_context ();
131137}
132138
133139void BTaskSwitcher::init_task (BTaskInfoBase* taskInfo, BTaskWrapper wrapper) {
Original file line number Diff line number Diff line change 44 extern "C" void TIMER0_COMPA_vect();
55
66#define __BTASKSWITCHER_ARCH_CLASS__ \
7+ friend void avr_switch_context(); \
78 friend void ::TIMER0_COMPA_vect();
89
910#endif
You can’t perform that action at this time.
0 commit comments