Skip to content

Commit 18703a0

Browse files
committed
[driver] iwr6843aop fixes for review
1 parent 6647786 commit 18703a0

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

examples/linux/iwr6843aop/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
#include <modm/debug/logger.hpp>
1515
#include <modm/platform.hpp>
1616
#include <modm/platform/uart/static_serial_interface.hpp>
17-
#include <string>
1817
#include <modm/driver/radar/iwr6843aop.hpp>
18+
#include <string>
1919

2020
using namespace modm::platform;
2121

examples/linux/iwr6843aop/project.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<modules>
77
<module>modm:platform:core</module>
88
<module>modm:platform:uart</module>
9+
<module>modm:architecture:delay</module>
910
<module>modm:debug</module>
1011
<module>modm:driver:iwr6843aop</module>
1112
<module>modm:build:scons</module>

src/modm/driver/radar/iwr6843aop.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,7 @@ class Iwr6843aop : public iwr6843aop
324324

325325
Duration syncInterval_{Duration{100}};
326326
Duration controlResponseTimeout_{Duration{250}};
327-
Timestamp lastSyncTime_{};
328-
bool hasLastSyncTime_{false};
327+
Timeout syncTimer_{Duration{100}};
329328

330329
Error lastError_{Error::None};
331330

src/modm/driver/radar/iwr6843aop.lb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def prepare(module, options):
2323
module.depends(
2424
":architecture:gpio",
2525
":architecture:uart",
26-
":architecture:delay",
27-
":processing:timer",
26+
":architecture:fiber",
27+
":processing:timer",
2828
":platform:gpio")
2929
return True
3030

src/modm/driver/radar/iwr6843aop_impl.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ Iwr6843aop<ControlUart, DataUart, SyncPin, FrameQueueSize, MaxPointsPerFrame,
3737
MaxParserBufferSize>::setSyncInterval(Duration interval)
3838
{
3939
syncInterval_ = interval;
40+
if (syncInterval_.count() == 0)
41+
{
42+
syncTimer_.stop();
43+
} else
44+
{
45+
syncTimer_.restart(syncInterval_);
46+
}
4047
}
4148

4249
template<class ControlUart, class DataUart, class SyncPin, std::size_t FrameQueueSize,
@@ -236,7 +243,7 @@ Iwr6843aop<ControlUart, DataUart, SyncPin, FrameQueueSize, MaxPointsPerFrame,
236243
return false;
237244
} else
238245
{
239-
modm::delay_us(100);
246+
modm::this_fiber::sleep_for(100us);
240247
}
241248
}
242249

@@ -260,6 +267,7 @@ Iwr6843aop<ControlUart, DataUart, SyncPin, FrameQueueSize, MaxPointsPerFrame,
260267
if (bytesRead == 0) { break; }
261268

262269
if (not appendData(dataReadChunk_.data(), bytesRead)) { return false; }
270+
modm::this_fiber::yield();
263271
}
264272

265273
if (DataUart::hasError())
@@ -354,18 +362,10 @@ Iwr6843aop<ControlUart, DataUart, SyncPin, FrameQueueSize, MaxPointsPerFrame,
354362
{
355363
if (syncInterval_.count() == 0) { return; }
356364

357-
const auto now = Clock::now();
358-
if (not hasLastSyncTime_)
359-
{
360-
lastSyncTime_ = now;
361-
hasLastSyncTime_ = true;
362-
return;
363-
}
364-
365-
if ((now - lastSyncTime_) >= syncInterval_)
365+
if (syncTimer_.isExpired())
366366
{
367367
triggerSyncPulse();
368-
lastSyncTime_ = now;
368+
syncTimer_.restart(syncInterval_);
369369
}
370370
}
371371

@@ -376,7 +376,7 @@ Iwr6843aop<ControlUart, DataUart, SyncPin, FrameQueueSize, MaxPointsPerFrame,
376376
MaxParserBufferSize>::triggerSyncPulse()
377377
{
378378
SyncPin::set();
379-
modm::delay_us(100);
379+
modm::this_fiber::sleep_for(100us);
380380
SyncPin::reset();
381381
}
382382

0 commit comments

Comments
 (0)