HPM SDK
HPMicro Software Development Kit
RTC driver APIs

RTC driver APIs. More...

Data Structures

struct  rtc_alarm_config_t
 RTC alarm configuration. More...
 

Macros

#define RTC_ALARM_TYPE_ONE_SHOT   (0U)
 RTC Alarm type. More...
 
#define RTC_ALARM_TYPE_PERIODIC   (1U)
 
#define RTC_ALARM_TYPE_ABSOLUTE_TIME_ONE_SHOT   (2U)
 
#define ALARM_PERIOD_ONE_SEC   (1UL)
 Typical RTC alarm period definitions. More...
 
#define ALARM_PERIOD_ONE_MIN   (60UL)
 
#define ALARM_PERIOD_ONE_HOUR   (3600U)
 
#define ALARM_PERIOD_ONE_DAY   (ALARM_PERIOD_ONE_HOUR * 24UL)
 

Functions

hpm_stat_t rtc_config_time (RTC_Type *base, time_t time)
 Configure the RTC time. More...
 
hpm_stat_t rtc_config_alarm (RTC_Type *base, rtc_alarm_config_t *config)
 Configure RTC Alarm. More...
 
time_t rtc_get_time (RTC_Type *base)
 Get the time returned by RTC module. More...
 
struct timeval rtc_get_timeval (RTC_Type *base)
 Get accurate time return by RTC module. More...
 
static void rtc_enable_alarm_interrupt (RTC_Type *base, uint32_t index, bool enable)
 Enable RTC alarm interrupt. More...
 
static void rtc_clear_alarm_flag (RTC_Type *base, uint32_t index)
 Clear RTC alarm flag based on alarm index. More...
 
static void rtc_clear_alarm_flags (RTC_Type *base, uint32_t masks)
 Clear RTC alarm flags based on flag masks. More...
 
static bool rtc_is_alarm_flag_asserted (RTC_Type *base, uint32_t index)
 Check whether RTC alarm flag is set or not. More...
 
static uint32_t rtc_get_alarm_flags (RTC_Type *base)
 Get the RTC alarm flags. More...
 

Detailed Description

RTC driver APIs.

Macro Definition Documentation

◆ ALARM_PERIOD_ONE_DAY

#define ALARM_PERIOD_ONE_DAY   (ALARM_PERIOD_ONE_HOUR * 24UL)

#include <drivers/inc/hpm_rtc_drv.h>

Alarm period: 1 day

◆ ALARM_PERIOD_ONE_HOUR

#define ALARM_PERIOD_ONE_HOUR   (3600U)

#include <drivers/inc/hpm_rtc_drv.h>

Alarm period: 1 hour

◆ ALARM_PERIOD_ONE_MIN

#define ALARM_PERIOD_ONE_MIN   (60UL)

#include <drivers/inc/hpm_rtc_drv.h>

Alarm period: 1 minute

◆ ALARM_PERIOD_ONE_SEC

#define ALARM_PERIOD_ONE_SEC   (1UL)

#include <drivers/inc/hpm_rtc_drv.h>

Typical RTC alarm period definitions.

Alarm period: 1 second

◆ RTC_ALARM_TYPE_ABSOLUTE_TIME_ONE_SHOT

#define RTC_ALARM_TYPE_ABSOLUTE_TIME_ONE_SHOT   (2U)

#include <drivers/inc/hpm_rtc_drv.h>

The RTC alarm will be triggered via the absolute time provided via period

◆ RTC_ALARM_TYPE_ONE_SHOT

#define RTC_ALARM_TYPE_ONE_SHOT   (0U)

#include <drivers/inc/hpm_rtc_drv.h>

RTC Alarm type.

The RTC alarm will be triggered only once

◆ RTC_ALARM_TYPE_PERIODIC

#define RTC_ALARM_TYPE_PERIODIC   (1U)

#include <drivers/inc/hpm_rtc_drv.h>

The RTC alarm will be triggered periodically

Function Documentation

◆ rtc_clear_alarm_flag()

static void rtc_clear_alarm_flag ( RTC_Type base,
uint32_t  index 
)
inlinestatic

#include <drivers/inc/hpm_rtc_drv.h>

Clear RTC alarm flag based on alarm index.

Parameters
[in]baseRTC base address
[in]indexRTC alarm index, valid value is 0 or 1

◆ rtc_clear_alarm_flags()

static void rtc_clear_alarm_flags ( RTC_Type base,
uint32_t  masks 
)
inlinestatic

#include <drivers/inc/hpm_rtc_drv.h>

Clear RTC alarm flags based on flag masks.

Parameters
[in]baseRTC base address
[in]masksRTC alarm masks

◆ rtc_config_alarm()

hpm_stat_t rtc_config_alarm ( RTC_Type base,
rtc_alarm_config_t config 
)

#include <drivers/inc/hpm_rtc_drv.h>

Configure RTC Alarm.

Parameters
[in]baseRTC base address
[in]configRTC alarm configuration pointer
Return values
APIexecution status status_success or status_invalid_argument;

◆ rtc_config_time()

hpm_stat_t rtc_config_time ( RTC_Type base,
time_t  time 
)

#include <drivers/inc/hpm_rtc_drv.h>

Configure the RTC time.

Parameters
[in]baseRTC base address
[in]timeseconds since 1970.1.1, 0:0:0
Return values
APIexecution status status_success or status_invalid_argument

◆ rtc_enable_alarm_interrupt()

static void rtc_enable_alarm_interrupt ( RTC_Type base,
uint32_t  index,
bool  enable 
)
inlinestatic

#include <drivers/inc/hpm_rtc_drv.h>

Enable RTC alarm interrupt.

Parameters
[in]baseRTC base address
[in]indexRTC alarm index, valid value is 0 or 1
[in]enableRTC alarm enable flag
  • true Enable specified RTC alarm
  • false Disable specified RTC alarm

◆ rtc_get_alarm_flags()

static uint32_t rtc_get_alarm_flags ( RTC_Type base)
inlinestatic

#include <drivers/inc/hpm_rtc_drv.h>

Get the RTC alarm flags.

Parameters
[in]baseRTC base address
Returns
RTC alarm flags

◆ rtc_get_time()

time_t rtc_get_time ( RTC_Type base)

#include <drivers/inc/hpm_rtc_drv.h>

Get the time returned by RTC module.

Parameters
[in]baseRTC base address
Return values
RTCtime

◆ rtc_get_timeval()

struct timeval rtc_get_timeval ( RTC_Type base)

#include <drivers/inc/hpm_rtc_drv.h>

Get accurate time return by RTC module.

Parameters
[in]baseRTC base address
Returns
accurate time(including second and subsecond)

◆ rtc_is_alarm_flag_asserted()

static bool rtc_is_alarm_flag_asserted ( RTC_Type base,
uint32_t  index 
)
inlinestatic

#include <drivers/inc/hpm_rtc_drv.h>

Check whether RTC alarm flag is set or not.

Parameters
[in]baseRTC base address
[in]indexRTC alarm index, valid value is 0 or 1
Return values
RTCalarm flag. Valid value is true or false