FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_rtc.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Common IO V1.0.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
26 /*******************************************************************************
27  * @file iot_rtc.h
28  *
29  * @brief HAL APIs for RTC
30  *******************************************************************************
31  */
32 
38 #ifndef _IOT_RTC_H_
39 #define _IOT_RTC_H_
40 
49 #define IOT_RTC_SUCCESS ( 0 )
50 #define IOT_RTC_INVALID_VALUE ( 1 )
51 #define IOT_RTC_NOT_STARTED ( 2 )
52 #define IOT_RTC_GET_FAILED ( 3 )
53 #define IOT_RTC_SET_FAILED ( 4 )
54 #define IOT_RTC_FUNCTION_NOT_SUPPORTED ( 5 )
59 typedef enum
60 {
66 
70 typedef struct IotRtcDatetime
71 {
72  uint8_t ucSecond;
73  uint8_t ucMinute;
74  uint8_t ucHour;
75  uint8_t ucDay;
76  uint8_t ucMonth;
77  uint16_t usYear;
78  uint8_t ucWday;
80 
86 typedef enum IotRtcIoctlRequest
87 {
97 
101 struct IotRtcDescriptor_t;
102 
108 typedef struct IotRtcDescriptor_t * IotRtcHandle_t;
109 
120 typedef void ( * IotRtcCallback_t)( IotRtcStatus_t xStatus, void * pvUserContext );
121 
134 IotRtcHandle_t iot_rtc_open( int32_t lRtcInstance );
135 
150 void iot_rtc_set_callback( IotRtcHandle_t const pxRtcHandle,
151  IotRtcCallback_t xCallback,
152  void * pvUserContext );
153 
175 int32_t iot_rtc_ioctl( IotRtcHandle_t const pxRtcHandle,
176  IotRtcIoctlRequest_t xRequest,
177  void * const pvBuffer );
178 
192 int32_t iot_rtc_set_datetime( IotRtcHandle_t const pxRtcHandle,
193  const IotRtcDatetime_t * pxDatetime );
194 
209 int32_t iot_rtc_get_datetime( IotRtcHandle_t const pxRtcHandle,
210  IotRtcDatetime_t * pxDatetime );
211 
224 int32_t iot_rtc_close( IotRtcHandle_t const pxRtcHandle );
225 
230 #endif /* ifndef _IOT_RTC_H_ */
Definition: iot_rtc.h:94
int32_t iot_rtc_ioctl(IotRtcHandle_t const pxRtcHandle, IotRtcIoctlRequest_t xRequest, void *const pvBuffer)
iot_rtc_ioctl is used to set RTC configuration and RTC properties like Wakeup time, alarms etc. Supported IOCTL requests are defined in iot_RtcIoctlRequest_t
RTC date and time format info.
Definition: iot_rtc.h:70
Definition: iot_rtc.h:95
IotRtcIoctlRequest_t
Ioctl request types.
Definition: iot_rtc.h:86
int32_t iot_rtc_set_datetime(IotRtcHandle_t const pxRtcHandle, const IotRtcDatetime_t *pxDatetime)
iot_rtc_set_date_time is used to set the current time as a reference in RTC timer counter...
int32_t iot_rtc_close(IotRtcHandle_t const pxRtcHandle)
iot_rtc_close is used to de-Initialize RTC Timer. it resets the RTC timer and may stop the timer...
uint16_t usYear
Definition: iot_rtc.h:77
void(* IotRtcCallback_t)(IotRtcStatus_t xStatus, void *pvUserContext)
RTC notification callback type. This callback is passed to the driver by using iot_rtc_set_callback A...
Definition: iot_rtc.h:120
uint8_t ucMonth
Definition: iot_rtc.h:76
uint8_t ucDay
Definition: iot_rtc.h:75
Definition: iot_rtc.h:88
Definition: iot_rtc.h:63
struct IotRtcDescriptor_t * IotRtcHandle_t
IotRtcHandle_t type is the RTC handle returned by calling iot_rtc_open() this is initialized in open ...
Definition: iot_rtc.h:108
Definition: iot_rtc.h:61
IotRtcStatus_t
RTC driver status values.
Definition: iot_rtc.h:59
IotRtcHandle_t iot_rtc_open(int32_t lRtcInstance)
iot_rtc_open is used to initialize the RTC timer. It usually resets the RTC timer, sets up the clock for RTC etc...
Definition: iot_rtc.h:62
Definition: iot_rtc.h:92
Definition: iot_rtc.h:93
uint8_t ucSecond
Definition: iot_rtc.h:72
Definition: iot_rtc.h:91
Definition: iot_rtc.h:64
uint8_t ucMinute
Definition: iot_rtc.h:73
uint8_t ucHour
Definition: iot_rtc.h:74
void iot_rtc_set_callback(IotRtcHandle_t const pxRtcHandle, IotRtcCallback_t xCallback, void *pvUserContext)
iot_rtc_set_callback is used to set the callback to be called when alarmTime triggers. The caller must set the Alarm time using IOCTL to get the callback.
Definition: iot_rtc.h:90
uint8_t ucWday
Definition: iot_rtc.h:78
int32_t iot_rtc_get_datetime(IotRtcHandle_t const pxRtcHandle, IotRtcDatetime_t *pxDatetime)
iot_rtc_get_datetime is used to get the current time from the RTC counter. The time must be set first...