HAL  v0.6.1
Hardware Abstraction Layer
Loading...
Searching...
No Matches
RTC

Real-Time Clock & Calendar. More...

Collaboration diagram for RTC:

Data Structures

struct  rtc_datetime_attr_t
 
struct  rtc_alarm_attr_t
 
struct  rtc_channel_attr_t
 
struct  rtc_handle_t
 

Typedefs

typedef void(* hal_rtc_callback) (const uint8_t channel)
 RTC alarm callback function prototype.
 

Enumerations

enum  rtc_result_t {
  RTC_RESULT_OK ,
  RTC_RESULT_INVALID ,
  RTC_RESULT_UNSUPPORTED ,
  RTC_RESULT_ERR ,
  TOTAL_RTC_RESULT
}
 
enum  rtc_status_t {
  RTC_STATUS_UNKNOWN ,
  RTC_STATUS_OK ,
  RTC_STATUS_BUSY ,
  RTC_STATUS_STOP ,
  RTC_STATUS_ERR ,
  TOTAL_RTC_STATUS
}
 
enum  rtc_time_format_t {
  RTC_TIME_FORMAT_12H ,
  RTC_TIME_FORMAT_24H ,
  TOTAL_RTC_TIME_FORMAT
}
 

Functions

rtc_result_t hal_rtc_init (rtc_handle_t *handle, const rtc_channel_attr_t attr)
 Initialize RTC channel.
 
rtc_result_t hal_rtc_start (rtc_handle_t *handle)
 Start RTC channel.
 
rtc_result_t hal_rtc_get_datetime (rtc_handle_t *handle, rtc_datetime_attr_t *datetime)
 Retrieve current date and time.
 
rtc_result_t hal_rtc_set_alarm (rtc_handle_t *handle, const rtc_alarm_attr_t attr, const hal_rtc_callback callback)
 Set alarm date and time.
 
rtc_result_t hal_rtc_stop (rtc_handle_t *handle)
 Stop RTC channel.
 

Detailed Description

Real-Time Clock & Calendar.

Typedef Documentation

◆ hal_rtc_callback

typedef void(* hal_rtc_callback) (const uint8_t channel)

#include <rtc/public_inc/hal_rtc.h>

RTC alarm callback function prototype.

Parameters
[in]channelRTC channel

Enumeration Type Documentation

◆ rtc_result_t

#include <rtc/public_inc/hal_rtc.h>

Enumerator
RTC_RESULT_OK 

No error.

RTC_RESULT_INVALID 

Operation invalid.

RTC_RESULT_UNSUPPORTED 

Operation not supported.

RTC_RESULT_ERR 

Error occurred.

TOTAL_RTC_RESULT 

◆ rtc_status_t

#include <rtc/public_inc/hal_rtc.h>

Enumerator
RTC_STATUS_UNKNOWN 

RTC status unknown.

RTC_STATUS_OK 

No error.

RTC_STATUS_BUSY 

RTC busy.

RTC_STATUS_STOP 

RTC stopped.

RTC_STATUS_ERR 

Error occurred.

TOTAL_RTC_STATUS 

◆ rtc_time_format_t

#include <rtc/public_inc/hal_rtc.h>

Enumerator
RTC_TIME_FORMAT_12H 
RTC_TIME_FORMAT_24H 
TOTAL_RTC_TIME_FORMAT 

Function Documentation

◆ hal_rtc_get_datetime()

rtc_result_t hal_rtc_get_datetime ( rtc_handle_t * handle,
rtc_datetime_attr_t * datetime )

#include <rtc/public_inc/hal_rtc.h>

Retrieve current date and time.

rtc_result_t result = hal_rtc_get_datetime( &handle, &datetime );
rtc_result_t
Definition hal_rtc.h:44
rtc_result_t hal_rtc_get_datetime(rtc_handle_t *handle, rtc_datetime_attr_t *datetime)
Retrieve current date and time.
Definition hal_rtc.h:73
Parameters
[in,out]handleRTC handler
[out]datetimePointer to current datetime
Return values
RTC_RESULT_OKSuccessfully retrieve datetime
RTC_RESULT_ERRFailed to get datetime

◆ hal_rtc_init()

rtc_result_t hal_rtc_init ( rtc_handle_t * handle,
const rtc_channel_attr_t attr )

#include <rtc/public_inc/hal_rtc.h>

Initialize RTC channel.

rtc_handle_t handle = { .channel = BSP_RTC_CHANNEL_0 };
.datetime = {
.year = 2021,
.month = 12,
.day = 30,
.hour = 13,
.minute = 0,
.second = 0
},
};
rtc_result_t result = hal_rtc_init( &handle, attr );
rtc_result_t hal_rtc_init(rtc_handle_t *handle, const rtc_channel_attr_t attr)
Initialize RTC channel.
@ RTC_TIME_FORMAT_24H
Definition hal_rtc.h:67
Definition hal_rtc.h:92
rtc_datetime_attr_t datetime
initial date and time
Definition hal_rtc.h:93
uint16_t year
Definition hal_rtc.h:74
Definition hal_rtc.h:99
uint8_t channel
RTC channel.
Definition hal_rtc.h:100
Parameters
[in,out]handleRTC handler
[in]attrRTC channel attribute
Return values
RTC_RESULT_OKSuccess configure RTC channel setup
RTC_RESULT_INVALIDConfiguration attributes invalid
RTC_RESULT_UNSUPPORTEDOperation not supported
RTC_RESULT_ERRFailed configure RTC channel

◆ hal_rtc_set_alarm()

rtc_result_t hal_rtc_set_alarm ( rtc_handle_t * handle,
const rtc_alarm_attr_t attr,
const hal_rtc_callback callback )

#include <rtc/public_inc/hal_rtc.h>

Set alarm date and time.

void callback( const uint8_t channel );
.datetime = {
.year = 2021,
.month = 12,
.day = 31,
.hour = 8,
.minute = 0,
.second = 10
},
.repeat = true,
.frequency = 3U
};
rtc_result_t result = hal_rtc_set_alarm( &handle, attr, &callback );
rtc_result_t hal_rtc_set_alarm(rtc_handle_t *handle, const rtc_alarm_attr_t attr, const hal_rtc_callback callback)
Set alarm date and time.
Definition hal_rtc.h:84
rtc_datetime_attr_t datetime
start alarm datetime
Definition hal_rtc.h:85
Parameters
[in,out]handleRTC handler
[in]attrAlarm occurence, start time and frequency
[in]callbackCallback function when alarm timeout
Return values
RTC_RESULT_OKNew alarm time set successfully
RTC_RESULT_ERRFailed to set new alarm time

◆ hal_rtc_start()

rtc_result_t hal_rtc_start ( rtc_handle_t * handle)

#include <rtc/public_inc/hal_rtc.h>

Start RTC channel.

rtc_result_t result = hal_rtc_start( &handle );
rtc_result_t hal_rtc_start(rtc_handle_t *handle)
Start RTC channel.
Parameters
[in,out]handleRTC handler
Return values
RTC_RESULT_OKRTC successfully started
RTC_RESULT_ERRFailed to start RTC count

◆ hal_rtc_stop()

rtc_result_t hal_rtc_stop ( rtc_handle_t * handle)

#include <rtc/public_inc/hal_rtc.h>

Stop RTC channel.

rtc_result_t result = hal_rtc_stop( &handle );
rtc_result_t hal_rtc_stop(rtc_handle_t *handle)
Stop RTC channel.
Parameters
[in,out]handleRTC handler
Return values
RTC_RESULT_OKRTC stopped successfully
RTC_RESULT_ERRFailed to stop RTC count