STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
← STM32duino documentation
Loading...
Searching...
No Matches
wiring_time.c File Reference

Time functions: millis(), micros(), delay(), delayMicroseconds() and _gettimeofday(). More...

#include "Arduino.h"

Functions

unsigned long millis (void)
 Get the number of milliseconds since the board started.
 
unsigned long micros (void)
 Get the number of microseconds since the board started.
 
void delay (unsigned long ms)
 Pause the program for the given number of milliseconds.
 
void delayMicroseconds (unsigned int us)
 Pause the program for the amount of time (in microseconds) specified as parameter.
 
int _gettimeofday (struct timeval *tv, void *tz)
 Gives the number of seconds and microseconds since the Epoch.
 

Detailed Description

Function Documentation

◆ _gettimeofday()

int _gettimeofday ( struct timeval *  tv,
void *  tz 
)

Gives the number of seconds and microseconds since the Epoch.

Based on milliseconds 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).
Parameters
tvArgument is a struct timeval.
tzArgument is a struct timezone (unused).
Returns
0, always.

◆ delay()

void delay ( unsigned long  ms)

Pause the program for the given number of milliseconds.

Calls yield() while waiting, so cooperative threads can run.

Parameters
msNumber of milliseconds to pause.

◆ delayMicroseconds()

void delayMicroseconds ( unsigned int  us)

Pause the program for the amount of time (in microseconds) specified as parameter.

Parameters
usNumber of microseconds to pause.

◆ micros()

unsigned long micros ( void  )

Get the number of microseconds since the board started.

Interrupt-compatible version.

Returns
Microseconds since startup. Overflows after about 70 minutes.

◆ millis()

unsigned long millis ( void  )

Get the number of milliseconds since the board started.

Note
Interrupts are not disabled while the counter is read, see the ToDo in the implementation.
Returns
Milliseconds since startup. Overflows after about 49 days.