Skip to content

spresense: Fix port_get_raw_ticks #2987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions ports/cxd56/supervisor/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <sys/boardctl.h>
#include <sys/time.h>

#include <cxd56_rtc.h>

#include "sched/sched.h"

#include "boards/board.h"
Expand All @@ -45,7 +47,8 @@
safe_mode_t port_init(void) {
boardctl(BOARDIOC_INIT, 0);

board_init();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either the call to board_init() should remain, or board_init() should be removed everywhere in this port.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

board_init is called here:

board_init();

Why should we call this function twice?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's my mistake, thanks. This was moved in 1004099 but the fix was not applied to cxd56 port.

// Wait until RTC is available
while (g_rtc_enabled == false);

if (board_requests_safe_mode()) {
return USER_SAFE_MODE;
Expand Down Expand Up @@ -121,14 +124,10 @@ void board_timerhook(void)
}

uint64_t port_get_raw_ticks(uint8_t* subticks) {
struct timeval tv;
gettimeofday(&tv, NULL);
long computed_subticks = tv.tv_usec * 1024 * 32 / 1000000;
if (subticks != NULL) {
*subticks = computed_subticks % 32;
}
uint64_t count = cxd56_rtc_count();
*subticks = count % 32;

return tv.tv_sec * 1024 + computed_subticks / 32;
return count / 32;
}

// Enable 1/1024 second tick.
Expand Down