17
17
#include < modm/processing/timer.hpp>
18
18
19
19
using namespace modm ::platform;
20
+ using namespace std ::chrono_literals;
20
21
21
22
typedef GpioOutputB0 LedGreen;
22
23
typedef GpioOutputB1 LedRed;
@@ -37,13 +38,13 @@ class BlinkingLightGreen : public modm::pt::Protothread
37
38
{
38
39
LedGreen::set ();
39
40
40
- this -> timeout .restart (100 );
41
- PT_WAIT_UNTIL (this -> timeout .isExpired ());
41
+ timeout.restart (100ms );
42
+ PT_WAIT_UNTIL (timeout.isExpired ());
42
43
43
44
LedGreen::reset ();
44
45
45
- this -> timeout .restart (600 );
46
- PT_WAIT_UNTIL (this -> timeout .isExpired ());
46
+ timeout.restart (600ms );
47
+ PT_WAIT_UNTIL (timeout.isExpired ());
47
48
}
48
49
49
50
PT_END ();
@@ -69,23 +70,23 @@ class BlinkingLightRed : public modm::pt::Protothread
69
70
{
70
71
LedRed::set ();
71
72
72
- this -> timeout .restart (200 );
73
- PT_WAIT_UNTIL (this -> timeout .isExpired ());
73
+ timeout.restart (200ms );
74
+ PT_WAIT_UNTIL (timeout.isExpired ());
74
75
75
76
LedRed::reset ();
76
77
77
- this -> timeout .restart (300 );
78
- PT_WAIT_UNTIL (this -> timeout .isExpired ());
78
+ timeout.restart (300ms );
79
+ PT_WAIT_UNTIL (timeout.isExpired ());
79
80
80
81
LedRed::set ();
81
82
82
- this -> timeout .restart (200 );
83
- PT_WAIT_UNTIL (this -> timeout .isExpired ());
83
+ timeout.restart (200ms );
84
+ PT_WAIT_UNTIL (timeout.isExpired ());
84
85
85
86
LedRed::reset ();
86
87
87
- this -> timeout .restart (1000 );
88
- PT_WAIT_UNTIL (this -> timeout .isExpired ());
88
+ timeout.restart (1s );
89
+ PT_WAIT_UNTIL (timeout.isExpired ());
89
90
}
90
91
91
92
PT_END ();
@@ -95,22 +96,10 @@ class BlinkingLightRed : public modm::pt::Protothread
95
96
modm::ShortTimeout timeout;
96
97
};
97
98
98
- // timer interrupt routine
99
- MODM_ISR (TIMER2_COMPA)
100
- {
101
- modm::Clock::increment ();
102
- }
103
-
104
99
int
105
100
main ()
106
101
{
107
- // timeout initialization
108
- // compare-match-interrupt every 1 ms at 14.7456 MHz
109
- TCCR2A = (1 << WGM21);
110
- TCCR2B = (1 << CS22);
111
- TIMSK2 = (1 << OCIE2A);
112
- OCR2A = 230 ;
113
-
102
+ SystemClock::enable ();
114
103
enableInterrupts ();
115
104
116
105
BlinkingLightGreen greenLight;
0 commit comments