ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
time.c File Reference
#include "time.h"
#include <libtock/peripherals/rtc.h>

Go to the source code of this file.

Functions

uint32_t epoch (void)
 Gets the current unix epoch timestamp.
 
void set_epoch (uint32_t epoch)
 Sets the current unix epoch timestamp.
 
uint32_t rtc_date_to_epoch (const libtock_rtc_date_t *date)
 Converts tock time to unix epoch time.
 
void epoch_to_rtc_date (uint32_t epoch, libtock_rtc_date_t *date)
 Convert unix epoch to tock time.
 

Function Documentation

◆ epoch_to_rtc_date()

void epoch_to_rtc_date ( uint32_t  epoch,
libtock_rtc_date_t *  date 
)

Convert unix epoch to tock time.

Parameters
epochInput epoch.
dateOutput date

Definition at line 65 of file time.c.

References epoch().

Referenced by set_epoch(), and test_epoch_to_rtc_date().

◆ rtc_date_to_epoch()

uint32_t rtc_date_to_epoch ( const libtock_rtc_date_t *  date)

Converts tock time to unix epoch time.

Parameters
datePointer to date struct.
Returns
Unix epoch time.

Definition at line 31 of file time.c.

Referenced by epoch(), and test_rtc_date_to_epoch().

◆ set_epoch()

void set_epoch ( uint32_t  epoch)

Sets the current unix epoch timestamp.

See also
epoch_to_rtc_date
Parameters
epochUnix epoch.

Definition at line 25 of file time.c.

References epoch(), and epoch_to_rtc_date().

Referenced by lorawan_timesync(), and test_time_epoch().