1 /** 2 * 3 * Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries. 4 * 5 * \asf_license_start 6 * 7 * \page License 8 * 9 * SPDX-License-Identifier: Apache-2.0 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); you may 12 * not use this file except in compliance with the License. 13 * You may obtain a copy of the Licence at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 19 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 * 23 * \asf_license_stop 24 * 25 */ 26 27 /** @file rtc.h 28 *MEC1501 Real Time Clock definitions 29 */ 30 /** @defgroup MEC1501 Peripherals RTC 31 */ 32 33 #ifndef _RTC_H 34 #define _RTC_H 35 36 #include <stdint.h> 37 #include <stddef.h> 38 39 #include "regaccess.h" 40 41 /* =========================================================================*/ 42 /* ================ RTC =================== */ 43 /* =========================================================================*/ 44 45 /* Hours register */ 46 #define MCHP_RTC_HOURS_REG_OFS 0x04u 47 #define MCHP_RTC_HOURS_MASK 0x7fu 48 #define MCHP_RTC_HOURS_AM_PM_MASK 0x80u 49 #define MCHP_RTC_HOURS_PM 0x80u 50 51 /* RegA */ 52 #define MCHP_RTC_REGA_REG_OFS 0x0au 53 #define MCHP_RTC_REGA_MASK 0xffu 54 #define MCHP_RTC_REGA_RATE_SEL_POS 0 55 #define MCHP_RTC_REGA_RATE_SEL_MASK0 0x0fu 56 #define MCHP_RTC_REGA_RATE_SEL_MASK 0x0fu 57 #define MCHP_RTC_REGA_RATE_NONE 0x00u 58 #define MCHP_RTC_REGA_RATE_3906250_NS 0x01u 59 #define MCHP_RTC_REGA_RATE_7812500_NS 0x02u 60 #define MCHP_RTC_REGA_RATE_122070_NS 0x03u 61 #define MCHP_RTC_REGA_RATE_244141_NS 0x04u 62 #define MCHP_RTC_REGA_RATE_488281_NS 0x05u 63 #define MCHP_RTC_REGA_RATE_976563_NS 0x06u 64 #define MCHP_RTC_REGA_RATE_1953125_NS 0x07u 65 #define MCHP_RTC_REGA_RATE_3906250_NS_ALT 0x08u 66 #define MCHP_RTC_REGA_RATE_7812500_NS_ALT 0x09u 67 #define MCHP_RTC_REGA_RATE_15625_US 0x0au 68 #define MCHP_RTC_REGA_RATE_31250_US 0x0bu 69 #define MCHP_RTC_REGA_RATE_62500_US 0x0cu 70 #define MCHP_RTC_REGA_RATE_125000_US 0x0du 71 #define MCHP_RTC_REGA_RATE_250000_US 0x0du 72 #define MCHP_RTC_REGA_RATE_500000_US 0x0du 73 #define MCHP_RTC_REGA_DIVC_SEL_POS 4 74 #define MCHP_RTC_REGA_DIVC_SEL_MASK0 0x07u 75 #define MCHP_RTC_REGA_DIVC_SEL_MASK 0x70u 76 #define MCHP_RTC_REGA_DIVC_SEL_NORM (0x02u << 4) 77 #define MCHP_RTC_REGA_DIVC_SEL_HALT (0x03u << 4) 78 /* bit[7] is read-only status */ 79 #define MCHP_RTC_REGA_UPDATE_IN_PROGESS_POS 7 80 #define MCHP_RTC_REGA_UPDATE_IN_PROGESS 0x80 81 82 /* RegB */ 83 #define MCHP_RTC_REGB_REG_OFS 0x0bu 84 #define MCHP_RTC_REGB_MASK 0xf7u 85 #define MCHP_RTC_REGB_DS_EN 0x01u 86 #define MCHP_RTC_REGB_FMT_12H 0x00u 87 #define MCHP_RTC_REGB_FMT_24H 0x02u 88 #define MCHP_RTC_REGB_DATA_BCD 0x00u 89 #define MCHP_RTC_REGB_DATA_BIN 0x04u 90 #define MCHP_RTC_REGB_UPDATE_DONE_IEN 0x10u 91 #define MCHP_RTC_REGB_ALARM_IEN 0x20u 92 #define MCHP_RTC_REGB_PERIODIC_IEN 0x40u 93 #define MCHP_RTC_REGB_UPDATE_INHIBIT 0x80u 94 95 /* RegC contains read-to-clear status */ 96 #define MCHP_RTC_REGC_REG_OFS 0x0cu 97 #define MCHP_RTC_REGC_MASK 0xf0u 98 #define MCHP_RTC_REGC_UPDATE_DONE_STS 0x10u 99 #define MCHP_RTC_REGC_ALARM_STS 0x20u 100 #define MCHP_RTC_REGC_PERIODIC_STS 0x40u 101 #define MCHP_RTC_REGC_INT_REQ_STS 0x80u 102 103 /* RegD */ 104 #define MCHP_RTC_REGD_REG_OFS 0x0du 105 #define MCHP_RTC_REGD_MASK 0x3fu 106 #define MCHP_RTC_REGD_DATE_ALARM_MASK 0x3fu 107 108 /* Control */ 109 #define MCHP_RTC_CTRL_REG_OFS 0x10u 110 #define MCHP_RTC_CTRL_MASK 0x0fu 111 #define MCHP_RTC_CTRL_BLK_EN 0x01u 112 #define MCHP_RTC_CTRL_SRST 0x02u 113 #define MCHP_RTC_CTRL_RSVD2 0x04u 114 #define MCHP_RTC_CTRL_ALARM_EN 0x08u 115 116 /* Daylight savings forward (DLSF) and backward (DLSB) registers */ 117 #define MCHP_RTC_DLSF_REG_OFS 0x18u 118 #define MCHP_RTC_DLSB_REG_OFS 0x1cu 119 #define MCHP_RTC_DLS_MASK 0xff0707ffu 120 #define MCHP_RTC_DLS_MON_POS 0 121 #define MCHP_RTC_DLS_MON_MASK 0xffu 122 #define MCHP_RTC_DLS_DOFW_POS 8 123 #define MCHP_RTC_DLS_DOFW_MASK (0x07u << 8) 124 #define MCHP_RTC_DLS_WEEK_POS 16 125 #define MCHP_RTC_DLS_WEEK_MASK (0x07u << 16) 126 #define MCHP_RTC_DLS_WEEK_1 (1u << 16) 127 #define MCHP_RTC_DLS_WEEK_2 (2u << 16) 128 #define MCHP_RTC_DLS_WEEK_3 (3u << 16) 129 #define MCHP_RTC_DLS_WEEK_4 (4u << 16) 130 #define MCHP_RTC_DLS_WEEK_LAST (5u << 16) 131 #define MCHP_RTC_DLS_HOUR_POS 24 132 #define MCHP_RTC_DLS_HOUR_MASK (0x3fu << 24) 133 #define MCHP_RTC_DLS_AM_PM_POS 31 134 #define MCHP_RTC_DLS_PM (1u << 31) 135 136 137 /** 138 * @brief Real Time Clock (RTC) 139 */ 140 typedef struct rtc_regs { 141 __IOM uint8_t SECONDS; /*! (@ 0x0000) RTC seconds */ 142 __IOM uint8_t SEC_ALARM; /*! (@ 0x0001) RTC seconds alarm */ 143 __IOM uint8_t MINUTES; /*! (@ 0x0002) RTC minutes */ 144 __IOM uint8_t MIN_ALARM; /*! (@ 0x0003) RTC minutes alarm */ 145 __IOM uint8_t HOURS; /*! (@ 0x0004) RTC hours */ 146 __IOM uint8_t HOURS_ALARM; /*! (@ 0x0005) RTC hours alarm */ 147 __IOM uint8_t DAY_OF_WEEK; /*! (@ 0x0006) RTC day of week */ 148 __IOM uint8_t DAY_OF_MONTH; /*! (@ 0x0007) RTC day of month */ 149 __IOM uint8_t MONTH; /*! (@ 0x0008) RTC month */ 150 __IOM uint8_t YEAR; /*! (@ 0x0009) RTC year */ 151 __IOM uint8_t REGA; /*! (@ 0x000a) RTC Reg A */ 152 __IOM uint8_t REGB; /*! (@ 0x000b) RTC Reg B */ 153 __IOM uint8_t REGC; /*! (@ 0x000c) RTC Reg C */ 154 __IOM uint8_t REGD; /*! (@ 0x000d) RTC Reg D */ 155 uint8_t RSVD1[2]; 156 __IOM uint8_t CONTROL; /*! (@ 0x0010) RTC Control */ 157 uint8_t RSVD2[3]; 158 __IOM uint8_t WEEK_ALARM; /*! (@ 0x0014) RTC Alarm day of week */ 159 uint8_t RSVD3[3]; 160 __IOM uint32_t DLSF; /*! (@ 0x0018) RTC Daylight savings forward */ 161 __IOM uint32_t DLSB; /*! (@ 0x0018) RTC Daylight savings backward */ 162 } RTC_Type; 163 164 #endif /* #ifndef _RTC_H */ 165 /* end rtc.h */ 166 /** @} 167 */ 168