Skip to content

Commit 9e66b92

Browse files
Fixes the sorry state I left the timer sample in
Signed-off-by: Taylor Lineman <git@actuallytaylor.com>
1 parent 58e02fa commit 9e66b92

1 file changed

Lines changed: 16 additions & 20 deletions

File tree

samples/timer/main.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,26 @@
1010

1111
namespace io = core::io;
1212
namespace dev = core::dev;
13-
namespace log = core::log;
1413

1514
io::GPIO* ledGPIO;
1615
io::GPIO* interruptGPIO2Hz;
1716
io::GPIO* interruptGPIOStopStart;
1817
io::GPIO* reloadGPIO;
1918

2019
void timer2IRQHandler(void* context, void* htim) {
21-
// io::GPIO::State state = ledGPIO->readPin();
22-
// io::GPIO::State toggleState = state == io::GPIO::State::HIGH ? io::GPIO::State::LOW : io::GPIO::State::HIGH;
23-
// ledGPIO->writePin(toggleState);
24-
// interruptGPIO2Hz->writePin(toggleState);
25-
io::UART* uart = (io::UART*) context;
26-
27-
uart->printf("Starting log test\n\r");
20+
io::GPIO::State state = ledGPIO->readPin();
21+
io::GPIO::State toggleState = state == io::GPIO::State::HIGH ? io::GPIO::State::LOW : io::GPIO::State::HIGH;
22+
ledGPIO->writePin(toggleState);
23+
interruptGPIO2Hz->writePin(toggleState);
2824
}
2925

30-
void timer15IRQHandler(void* htim) {
26+
void timer15IRQHandler(void* context, void* htim) {
3127
io::GPIO::State state = interruptGPIOStopStart->readPin();
3228
io::GPIO::State toggleState = state == io::GPIO::State::HIGH ? io::GPIO::State::LOW : io::GPIO::State::HIGH;
3329
interruptGPIOStopStart->writePin(toggleState);
3430
}
3531

36-
void timer16IRQHandler(void* htim) {
32+
void timer16IRQHandler(void* context, void* htim) {
3733
io::GPIO::State state = reloadGPIO->readPin();
3834
io::GPIO::State toggleState = state == io::GPIO::State::HIGH ? io::GPIO::State::LOW : io::GPIO::State::HIGH;
3935
reloadGPIO->writePin(toggleState);
@@ -68,19 +64,19 @@ int main() {
6864
dev::Timer& sampleTimer2 = dev::getTimer<dev::MCUTimer::Timer11>(200);
6965
dev::Timer& sampleTimer3 = dev::getTimer<dev::MCUTimer::Timer12>(200);
7066
#else
71-
// dev::Timer& sampleTimer2 = dev::getTimer<dev::MCUTimer::Timer15>(1000);
72-
// dev::Timer& sampleTimer3 = dev::getTimer<dev::MCUTimer::Timer16>(1000);
67+
dev::Timer& sampleTimer2 = dev::getTimer<dev::MCUTimer::Timer15>(1000);
68+
dev::Timer& sampleTimer3 = dev::getTimer<dev::MCUTimer::Timer16>(1000);
7369
#endif
7470

75-
sampleTimer1.startTimer(timer2IRQHandler, &uart);
76-
// sampleTimer2.startTimer(timer15IRQHandler);
77-
// sampleTimer3.startTimer(timer16IRQHandler);
71+
sampleTimer1.startTimer(timer2IRQHandler, nullptr);
72+
sampleTimer2.startTimer(timer15IRQHandler, nullptr);
73+
sampleTimer3.startTimer(timer16IRQHandler, nullptr);
7874

7975
while (1) {
80-
// core::time::wait(500);
81-
// sampleTimer2.stopTimer();
82-
// sampleTimer3.reloadTimer();
83-
// core::time::wait(500);
84-
// sampleTimer2.startTimer();
76+
core::time::wait(500);
77+
sampleTimer2.stopTimer();
78+
sampleTimer3.reloadTimer();
79+
core::time::wait(500);
80+
sampleTimer2.startTimer();
8581
}
8682
}

0 commit comments

Comments
 (0)