summaryrefslogtreecommitdiff
path: root/bsp/apm32/libraries/APM32F10x_Library/APM32F10x_StdPeriphDriver/inc/apm32f10x_rtc.h
blob: 5b7008f280c1ca90fbedf0653d60467d624fb703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*!
 * @file        apm32f10x_rtc.h
 *
 * @brief       This file contains all the functions prototypes for the RTC firmware library
 *
 * @version     V1.0.4
 *
 * @date        2022-12-01
 *
 * @attention
 *
 *  Copyright (C) 2020-2022 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
 *
 *  The program is only for reference, which is distributed in the hope
 *  that it will be useful and instructional for customers to develop
 *  their software. Unless required by applicable law or agreed to in
 *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
 *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
 *  and limitations under the License.
 */

/* Define to prevent recursive inclusion */
#ifndef __APM32F10X_RTC_H
#define __APM32F10X_RTC_H

/* Includes */
#include "apm32f10x.h"

#ifdef __cplusplus
extern "C" {
#endif

/** @addtogroup APM32F10x_StdPeriphDriver
  @{
*/

/** @addtogroup RTC_Driver RTC Driver
  @{
*/

/** @defgroup RTC_Enumerations Enumerations
  @{
*/

typedef enum
{
    RTC_FLAG_OC    = 0x0020,    /*!< RTC Operation Complete flag */
    RTC_FLAG_RSYNC = 0x0008,    /*!< Registers Synchronized flag */
    RTC_FLAG_OVR   = 0x0004,    /*!< Overflow flag */
    RTC_FLAG_ALR   = 0x0002,    /*!< Alarm flag */
    RTC_FLAG_SEC   = 0x0001     /*!< Second flag */
} RTC_FLAG_T;

typedef enum
{
    RTC_INT_OVR = 0x0004,       /*!< Overflow interrupt */
    RTC_INT_ALR = 0x0002,       /*!< Alarm interrupt */
    RTC_INT_SEC = 0x0001        /*!< Second interrupt */
} RTC_INT_T;

/**@} end of group RTC_Enumerations */

/** @defgroup RTC_Functions Functions
  @{
*/

/* Operation modes */
void RTC_EnableConfigMode(void);
void RTC_DisableConfigMode(void);

/* Configuration */
uint32_t RTC_ReadCounter(void);
void RTC_ConfigCounter(uint32_t value);
void RTC_ConfigPrescaler(uint32_t value);
void RTC_ConfigAlarm(uint32_t value);
uint32_t RTC_ReadDivider(void);
void RTC_WaitForLastTask(void);
void RTC_WaitForSynchro(void);

/* Interrupts and flags */
void RTC_EnableInterrupt(uint16_t interrupt);
void RTC_DisableInterrupt(uint16_t interrupt);
uint8_t RTC_ReadStatusFlag(RTC_FLAG_T flag);
void RTC_ClearStatusFlag(uint16_t flag);
uint8_t RTC_ReadIntFlag(RTC_INT_T flag);
void RTC_ClearIntFlag(uint16_t flag);

/**@} end of group RTC_Functions */
/**@} end of group RTC_Driver */
/**@} end of group APM32F10x_StdPeriphDriver */

#ifdef __cplusplus
}
#endif

#endif /* __APM32F10X_RTC_H */