blob: 26949a5724c3288b0ef451ee42f3c1e3dc2b2151 [file] [log] [blame]
Harald Welted1bd5c42019-05-17 16:38:30 +02001/**
2 * \file
3 *
4 * \brief Generic CALENDAR functionality declaration.
5 *
6 * Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
7 *
8 * \asf_license_start
9 *
10 * \page License
11 *
12 * Subject to your compliance with these terms, you may use Microchip
13 * software and any derivatives exclusively with Microchip products.
14 * It is your responsibility to comply with third party license terms applicable
15 * to your use of third party software (including open source software) that
16 * may accompany Microchip software.
17 *
18 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
19 * WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
20 * INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
21 * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
22 * LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
23 * LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
24 * SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
25 * POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
26 * ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
27 * RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
28 * THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
29 *
30 * \asf_license_stop
31 *
32 */
33
34#ifndef _HAL_CALENDER_H_INCLUDED
35#define _HAL_CALENDER_H_INCLUDED
36
37#include "hpl_calendar.h"
38#include <utils_list.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/**
45 * \addtogroup doc_driver_hal_calendar_async
46 *
47 *@{
48 */
49
50/** \brief Prototype of callback on alarm match
51 * \param calendar Pointer to the HAL Calendar instance.
52 */
53typedef void (*calendar_cb_alarm_t)(struct calendar_descriptor *const calendar);
54
55/** \brief Struct for alarm time
56 */
57struct calendar_alarm {
58 struct list_element elem;
59 struct _calendar_alarm cal_alarm;
60 calendar_cb_alarm_t callback;
61};
62
63/** \brief Initialize the Calendar HAL instance and hardware
64 *
65 * \param calendar Pointer to the HAL Calendar instance.
66 * \param hw Pointer to the hardware instance.
67 * \return Operation status of init
68 * \retval 0 Completed successfully.
69 */
70int32_t calendar_init(struct calendar_descriptor *const calendar, const void *hw);
71
72/** \brief Reset the Calendar HAL instance and hardware
73 *
74 * Reset Calendar instance to hardware defaults.
75 *
76 * \param calendar Pointer to the HAL Calendar instance.
77 * \return Operation status of reset.
78 * \retval 0 Completed successfully.
79 */
80int32_t calendar_deinit(struct calendar_descriptor *const calendar);
81
82/** \brief Enable the Calendar HAL instance and hardware
83 *
84 * \param calendar Pointer to the HAL Calendar instance.
85 * \return Operation status of init
86 * \retval 0 Completed successfully.
87 */
88int32_t calendar_enable(struct calendar_descriptor *const calendar);
89
90/** \brief Disable the Calendar HAL instance and hardware
91 *
92 * Disable Calendar instance to hardware defaults.
93 *
94 * \param calendar Pointer to the HAL Calendar instance.
95 * \return Operation status of reset.
96 * \retval 0 Completed successfully.
97 */
98int32_t calendar_disable(struct calendar_descriptor *const calendar);
99
100/** \brief Configure the base year for calendar HAL instance and hardware
101 *
102 * \param calendar Pointer to the HAL Calendar instance.
103 * \param p_base_year The desired base year.
104 * \retval 0 Completed successfully.
105 */
106int32_t calendar_set_baseyear(struct calendar_descriptor *const calendar, const uint32_t p_base_year);
107
108/** \brief Configure the time for calendar HAL instance and hardware
109 *
110 * \param calendar Pointer to the HAL Calendar instance.
111 * \param p_calendar_time Pointer to the time configuration.
112 * \retval 0 Completed successfully.
113 */
114int32_t calendar_set_time(struct calendar_descriptor *const calendar, struct calendar_time *const p_calendar_time);
115
116/** \brief Configure the date for calendar HAL instance and hardware
117 *
118 * \param calendar Pointer to the HAL Calendar instance.
119 * \param p_calendar_date Pointer to the date configuration.
120 * \return Operation status of time set.
121 * \retval 0 Completed successfully.
122 */
123int32_t calendar_set_date(struct calendar_descriptor *const calendar, struct calendar_date *const p_calendar_date);
124
125/** \brief Get the time for calendar HAL instance and hardware
126 *
127 * \param calendar Pointer to the HAL Calendar instance.
128 * \param date_time Pointer to the value that will be filled with the current time.
129 * \return Operation status of time retrieve.
130 * \retval 0 Completed successfully.
131 */
132int32_t calendar_get_date_time(struct calendar_descriptor *const calendar, struct calendar_date_time *const date_time);
133
134/** \brief Config the alarm time for calendar HAL instance and hardware
135 *
136 * Set the alarm time to calendar instance. If the callback is NULL, remove
137 * the alarm if the alarm is already added, otherwise, ignore the alarm.
138 *
139 * \param calendar Pointer to the HAL Calendar instance.
140 * \param alarm Pointer to the configuration.
141 * \param callback Pointer to the callback function.
142 * \return Operation status of alarm time set.
143 * \retval 0 Completed successfully.
144 */
145int32_t calendar_set_alarm(struct calendar_descriptor *const calendar, struct calendar_alarm *const alarm,
146 calendar_cb_alarm_t callback);
147
148/** \brief Retrieve the current driver version
149 * \return Current driver version.
150 */
151uint32_t calendar_get_version(void);
152
153/**@}*/
154
155#ifdef __cplusplus
156}
157#endif
158
159#endif /* _HAL_CALENDER_H_INCLUDED */