Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: implement weaked _gettimeofday#2151

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fpistm merged 1 commit intostm32duino:mainfromfpistm:_gettimeofday
Oct 26, 2023
Merged
Changes fromall 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
22 changes: 22 additions & 0 deletionscores/arduino/wiring_time.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@

#include "clock.h"
#include "dwt.h"
#include <sys/time.h> // for struct timeval

#ifdef __cplusplus
extern "C" {
Expand DownExpand Up@@ -86,6 +87,27 @@ static inline void delayMicroseconds(uint32_t us)
#endif
}

/**
* \brief gives the number of seconds and microseconds since the Epoch
*
* based on millisecond since last power on.
*
* \note The function is declared as weak to be overwritten in case of other
* implementations in user file (using RTC values for example).
*
* \param tv argument is a struct timeval
* \param tz argument is a struct timezone (unused)
*
* \return 0
*/
int __attribute__((weak)) _gettimeofday(struct timeval *tv, void *tz)
{
(void)tz;
tv->tv_sec = getCurrentMillis() / 1000;
tv->tv_usec = getCurrentMicros() - (tv->tv_sec * 1000000); // get remaining microseconds
return 0;
}

#ifdef __cplusplus
}
#endif
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp