• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2   ****************************************************************************************
3   * @file    gr55xx_hal_calendar.c
4   * @author  BLE Driver Team
5   * @brief   CALENDAR HAL module driver.
6   ****************************************************************************************
7   * @attention
8   #####Copyright (c) 2019 GOODIX
9    All rights reserved.
10 
11    Redistribution and use in source and binary forms, with or without
12    modification, are permitted provided that the following conditions are met:
13    * Redistributions of source code must retain the above copyright
14     notice, this list of conditions and the following disclaimer.
15    * Redistributions in binary form must reproduce the above copyright
16      notice, this list of conditions and the following disclaimer in the
17      documentation and/or other materials provided with the distribution.
18    * Neither the name of GOODIX nor the names of its contributors may be used
19      to endorse or promote products derived from this software without
20      specific prior written permission.
21 
22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25    ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
26    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32    POSSIBILITY OF SUCH DAMAGE.
33   ****************************************************************************************
34   */
35 
36 /* Includes ------------------------------------------------------------------*/
37 #include <string.h>
38 #include "gr55xx_hal.h"
39 #include "gr55xx_rom_symbol.h"
40 
41 #if defined(HAL_CALENDAR_MODULE_ENABLED) && (defined(GR5515_D) || defined(GR5515_E))
42 
43 /* Private variables -------------------------------------------------------*/
44 
45 static hal_calendar_callback_t calendar_callback = {
46     .calendar_alarm_callback = hal_calendar_alarm_callback,
47     .calendar_tick_callback  = hal_calendar_tick_callback,
48     .calendar_overflow_callback = hal_calendar_overflow_callback,
49 };
50 
51 /* Private function prototypes ---------------------------------------------*/
52 
hal_calendar_init(calendar_handle_t * p_calendar)53 hal_status_t hal_calendar_init(calendar_handle_t *p_calendar)
54 {
55     hal_calendar_register_callback(&calendar_callback);
56 
57     hal_status_t ret;
58     GLOBAL_EXCEPTION_DISABLE();
59     ret = hal_calendar_init_ext(p_calendar);
60     GLOBAL_EXCEPTION_ENABLE();
61 
62     return ret;
63 }
64 
hal_calendar_deinit(calendar_handle_t * p_calendar)65 hal_status_t hal_calendar_deinit(calendar_handle_t *p_calendar)
66 {
67     hal_calendar_register_callback(&calendar_callback);
68 
69     hal_status_t ret;
70     GLOBAL_EXCEPTION_DISABLE();
71     ret = hal_calendar_deinit_ext(p_calendar);
72     GLOBAL_EXCEPTION_ENABLE();
73 
74     return ret;
75 }
76 
hal_calendar_alarm_callback(calendar_handle_t * p_calendar)77 __WEAK void hal_calendar_alarm_callback(calendar_handle_t *p_calendar)
78 {
79     /* Prevent unused argument(s) compilation warning */
80     UNUSED(p_calendar);
81 
82     /* NOTE: This function should not be modified, when the callback is needed,
83              the hal_calendar_alarm_callback could be implemented in the user file
84     */
85 }
86 
hal_calendar_tick_callback(calendar_handle_t * p_calendar)87 __WEAK void hal_calendar_tick_callback(calendar_handle_t *p_calendar)
88 {
89     /* Prevent unused argument(s) compilation warning */
90     UNUSED(p_calendar);
91 
92     /* NOTE: This function should not be modified, when the callback is needed,
93              the hal_calendar_interval_callback could be implemented in the user file
94     */
95 }
96 
hal_calendar_overflow_callback(calendar_handle_t * p_calendar)97 __WEAK void hal_calendar_overflow_callback(calendar_handle_t *p_calendar)
98 {
99     /* Prevent unused argument(s) compilation warning */
100     UNUSED(p_calendar);
101 
102     /* NOTE: This function should not be modified, when the callback is needed,
103              the hal_calendar_overflow_callback could be implemented in the user file
104     */
105 }
106 
107 #endif /* HAL_CALENDAR_MODULE_ENABLED */
108