FreeRTOS: POSIX
Return to main page ↑
FreeRTOS_POSIX_timer.c File Reference

Implementation of timer functions in time.h. More...

#include <stddef.h>
#include "FreeRTOS_POSIX.h"
#include "FreeRTOS_POSIX/errno.h"
#include "FreeRTOS_POSIX/pthread.h"
#include "FreeRTOS_POSIX/signal.h"
#include "FreeRTOS_POSIX/time.h"
#include "FreeRTOS_POSIX/utils.h"
#include "timers.h"

Data Structures

struct  timer_internal_t
 Internal timer structure. More...
 

Macros

#define TIMESPEC_IS_ZERO(xTimespec)   ( xTimespec.tv_sec == 0 && xTimespec.tv_nsec == 0 )
 
#define TIMESPEC_IS_NOT_ZERO(xTimespec)   ( !( TIMESPEC_IS_ZERO( xTimespec ) ) )
 

Functions

void prvTimerCallback (TimerHandle_t xOpaqueTimerHandle)
 
int timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid)
 Create a per-process timer. More...
 
int timer_delete (timer_t timerid)
 Delete a per-process timer. More...
 
int timer_getoverrun (timer_t timerid)
 Get the timer overrun count. More...
 
int timer_settime (timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue)
 Set the time until the next expiration of the timer. More...
 
int timer_gettime (timer_t timerid, struct itimerspec *value)
 Get the amount of time until the timer expires. More...
 

Detailed Description

Implementation of timer functions in time.h.

Macro Definition Documentation

◆ TIMESPEC_IS_ZERO

#define TIMESPEC_IS_ZERO (   xTimespec)    ( xTimespec.tv_sec == 0 && xTimespec.tv_nsec == 0 )

Check for 0.

◆ TIMESPEC_IS_NOT_ZERO

#define TIMESPEC_IS_NOT_ZERO (   xTimespec)    ( !( TIMESPEC_IS_ZERO( xTimespec ) ) )

Check for not 0.

Function Documentation

◆ timer_create()

int timer_create ( clockid_t  clockid,
struct sigevent evp,
timer_t timerid 
)

Create a per-process timer.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html

Note
clock_id is ignored, as this function used the FreeRTOS tick count as its clock.
evp.sigev_notify must be set to SIGEV_THREAD, since signals are currently not supported.
Return values
0- Upon successful completion, with location referenced by timerid updated.
-1- If an error occurs. errno is also set.
Side Effects Possible errno values

ENOTSUP - If evp is NULL OR evp->sigen_notify == SIGEV_SIGNAL.
EAGAIN - The system lacks sufficient signal queuing resources to honor the request.

◆ timer_delete()

int timer_delete ( timer_t  timerid)

Delete a per-process timer.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html

Return values
0- Upon successful completion.

◆ timer_getoverrun()

int timer_getoverrun ( timer_t  timerid)

Get the timer overrun count.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html

Return values
0- Always return 0, since signals are not supported.

◆ timer_settime()

int timer_settime ( timer_t  timerid,
int  flags,
const struct itimerspec value,
struct itimerspec ovalue 
)

Set the time until the next expiration of the timer.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html

Return values
0- Upon successful completion.
-1- An error occurred, errno is also set.
Side Effects Possible errno values

EINVAL - A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million, AND the it_value member of that structure did not specify zero seconds and nanoseconds.

◆ timer_gettime()

int timer_gettime ( timer_t  timerid,
struct itimerspec value 
)

Get the amount of time until the timer expires.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.html

Return values
0- Upon successful completion.