1 /** 2 ****************************************************************************** 3 * @file timer_reg.h 4 * @version V1.0 5 * @date 2022-08-03 6 * @brief This file is the description of.IP register 7 ****************************************************************************** 8 * @attention 9 * 10 * <h2><center>© COPYRIGHT(c) 2020 Bouffalo Lab</center></h2> 11 * 12 * Redistribution and use in source and binary forms, with or without modification, 13 * are permitted provided that the following conditions are met: 14 * 1. Redistributions of source code must retain the above copyright notice, 15 * this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright notice, 17 * this list of conditions and the following disclaimer in the documentation 18 * and/or other materials provided with the distribution. 19 * 3. Neither the name of Bouffalo Lab nor the names of its contributors 20 * may be used to endorse or promote products derived from this software 21 * without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 ****************************************************************************** 35 */ 36 #ifndef __HARDWARE_TIMER_H__ 37 #define __HARDWARE_TIMER_H__ 38 39 /**************************************************************************** 40 * Pre-processor Definitions 41 ****************************************************************************/ 42 43 /* Register offsets *********************************************************/ 44 45 #define TIMER_TCCR_OFFSET (0x0) /* Timer Clock Source */ 46 #define TIMER_TMR0_0_OFFSET (0x10) /* Timer0 Match Value 0 */ 47 #define TIMER_TMR0_1_OFFSET (0x14) /* Timer0 Match Value 1 */ 48 #define TIMER_TMR0_2_OFFSET (0x18) /* Timer0 Match Value 2 */ 49 #define TIMER_TMR1_0_OFFSET (0x1C) /* Timer1 Match Value 0 */ 50 #define TIMER_TMR1_1_OFFSET (0x20) /* Timer1 Match Value 1 */ 51 #define TIMER_TMR1_2_OFFSET (0x24) /* Timer1 Match Value 2 */ 52 #define TIMER_TCR0_OFFSET (0x2C) /* Timer0 Counter Value */ 53 #define TIMER_TCR1_OFFSET (0x30) /* Timer1 Counter Value */ 54 #define TIMER_TSR0_OFFSET (0x38) /* Timer0 Match Status */ 55 #define TIMER_TSR1_OFFSET (0x3C) /* Timer1 Match Status */ 56 #define TIMER_TIER0_OFFSET (0x44) /* Timer0 Match Interrupt Enable */ 57 #define TIMER_TIER1_OFFSET (0x48) /* Timer1 Match Interrupt Enable */ 58 #define TIMER_TPLVR0_OFFSET (0x50) /* Timer0 Pre-Load Value */ 59 #define TIMER_TPLVR1_OFFSET (0x54) /* Timer1 Pre-Load Value */ 60 #define TIMER_TPLCR0_OFFSET (0x5C) /* Timer0 Pre-Load Control */ 61 #define TIMER_TPLCR1_OFFSET (0x60) /* Timer1 Pre-Load Control */ 62 #define TIMER_WMER_OFFSET (0x64) /* Watch-dog reset/interrupt Mode */ 63 #define TIMER_WMR_OFFSET (0x68) /* Watch-dog Match Value */ 64 #define TIMER_WVR_OFFSET (0x6C) /* Watch-dog Counter Value */ 65 #define TIMER_WSR_OFFSET (0x70) /* Watch-dog Reset Status */ 66 #define TIMER_TICR0_OFFSET (0x78) /* Timer0 Interrupt Clear */ 67 #define TIMER_TICR1_OFFSET (0x7C) /* Timer1 Interrupt Clear */ 68 #define TIMER_WICR_OFFSET (0x80) /* WDT Interrupt Clear */ 69 #define TIMER_TCER_OFFSET (0x84) /* Timer Counter Enable/Clear */ 70 #define TIMER_TCMR_OFFSET (0x88) /* Timer Counter Mode */ 71 #define TIMER_TILR0_OFFSET (0x90) /* Timer0 Match Interrupt Mode */ 72 #define TIMER_TILR1_OFFSET (0x94) /* Timer1 Match Interrupt Mode */ 73 #define TIMER_WCR_OFFSET (0x98) /* WDT Counter Reset */ 74 #define TIMER_WFAR_OFFSET (0x9C) /* WDT Access Key1 */ 75 #define TIMER_WSAR_OFFSET (0xA0) /* WDT Access Key2 */ 76 #define TIMER_TCVWR0_OFFSET (0xA8) /* Timer0 Counter Latch Value */ 77 #define TIMER_TCVWR1_OFFSET (0xAC) /* Timer1 Counter Latch Value */ 78 #define TIMER_TCVSYN0_OFFSET (0xB4) /* Timer0 Counter Sync Value */ 79 #define TIMER_TCVSYN1_OFFSET (0xB8) /* Timer1 Counter Sync Value */ 80 #define TIMER_TCDR_OFFSET (0xBC) /* Timer Division */ 81 #if !defined(BL702) || !defined(BL602) 82 #define TIMER_GPIO_OFFSET (0xC0) /* GPIO Mode */ 83 #define TIMER_GPIO_LAT1_OFFSET (0xC4) /* GPIO Latch Value1 */ 84 #define TIMER_GPIO_LAT2_OFFSET (0xC8) /* GPIO Latch Value2 */ 85 #define TIMER_TCDR_FORCE_OFFSET (0xCC) /* Timer Division Force */ 86 #endif 87 88 /* Register Bitfield definitions *****************************************************/ 89 90 /* 0x0 : Timer Clock Source */ 91 #if defined(BL702) || defined(BL602) 92 #define TIMER_CS_0_SHIFT (2U) 93 #define TIMER_CS_0_MASK (0x3 << TIMER_CS_0_SHIFT) 94 #define TIMER_CS_1_SHIFT (5U) 95 #define TIMER_CS_1_MASK (0x3 << TIMER_CS_1_SHIFT) 96 #define TIMER_CS_WDT_SHIFT (8U) 97 #define TIMER_CS_WDT_MASK (0x3 << TIMER_CS_WDT_SHIFT) 98 #else 99 #define TIMER_CS_0_SHIFT (0U) 100 #define TIMER_CS_0_MASK (0xf << TIMER_CS_0_SHIFT) 101 #define TIMER_CS_1_SHIFT (4U) 102 #define TIMER_CS_1_MASK (0xf << TIMER_CS_1_SHIFT) 103 #define TIMER_CS_WDT_SHIFT (8U) 104 #define TIMER_CS_WDT_MASK (0xf << TIMER_CS_WDT_SHIFT) 105 #define TIMER_ID_SHIFT (24U) 106 #define TIMER_ID_MASK (0xff << TIMER_ID_SHIFT) 107 #endif 108 109 /* 0x10 : Timer0 Match Value 0 */ 110 #define TIMER_TMR0_0_SHIFT (0U) 111 #define TIMER_TMR0_0_MASK (0xffffffff << TIMER_TMR0_0_SHIFT) 112 113 /* 0x14 : Timer0 Match Value 1 */ 114 #define TIMER_TMR0_1_SHIFT (0U) 115 #define TIMER_TMR0_1_MASK (0xffffffff << TIMER_TMR0_1_SHIFT) 116 117 /* 0x18 : Timer0 Match Value 2 */ 118 #define TIMER_TMR0_2_SHIFT (0U) 119 #define TIMER_TMR0_2_MASK (0xffffffff << TIMER_TMR0_2_SHIFT) 120 121 /* 0x1C : Timer1 Match Value 0 */ 122 #define TIMER_TMR1_0_SHIFT (0U) 123 #define TIMER_TMR1_0_MASK (0xffffffff << TIMER_TMR1_0_SHIFT) 124 125 /* 0x20 : Timer1 Match Value 1 */ 126 #define TIMER_TMR1_1_SHIFT (0U) 127 #define TIMER_TMR1_1_MASK (0xffffffff << TIMER_TMR1_1_SHIFT) 128 129 /* 0x24 : Timer1 Match Value 2 */ 130 #define TIMER_TMR1_2_SHIFT (0U) 131 #define TIMER_TMR1_2_MASK (0xffffffff << TIMER_TMR1_2_SHIFT) 132 133 /* 0x2C : Timer0 Counter Value */ 134 #define TIMER_TCR0_CNT_SHIFT (0U) 135 #define TIMER_TCR0_CNT_MASK (0xffffffff << TIMER_TCR0_CNT_SHIFT) 136 137 /* 0x30 : Timer1 Counter Value */ 138 #define TIMER_TCR1_CNT_SHIFT (0U) 139 #define TIMER_TCR1_CNT_MASK (0xffffffff << TIMER_TCR1_CNT_SHIFT) 140 141 /* 0x38 : Timer0 Match Status */ 142 #define TIMER_TSR0_0 (1 << 0U) 143 #define TIMER_TSR0_1 (1 << 1U) 144 #define TIMER_TSR0_2 (1 << 2U) 145 146 /* 0x3C : Timer1 Match Status */ 147 #define TIMER_TSR1_0 (1 << 0U) 148 #define TIMER_TSR1_1 (1 << 1U) 149 #define TIMER_TSR1_2 (1 << 2U) 150 151 /* 0x44 : Timer0 Match Interrupt Enable */ 152 #define TIMER_TIER0_0 (1 << 0U) 153 #define TIMER_TIER0_1 (1 << 1U) 154 #define TIMER_TIER0_2 (1 << 2U) 155 156 /* 0x48 : Timer1 Match Interrupt Enable */ 157 #define TIMER_TIER1_0 (1 << 0U) 158 #define TIMER_TIER1_1 (1 << 1U) 159 #define TIMER_TIER1_2 (1 << 2U) 160 161 /* 0x50 : Timer0 Pre-Load Value */ 162 #define TIMER_TPLVR0_SHIFT (0U) 163 #define TIMER_TPLVR0_MASK (0xffffffff << TIMER_TPLVR0_SHIFT) 164 165 /* 0x54 : Timer1 Pre-Load Value */ 166 #define TIMER_TPLVR1_SHIFT (0U) 167 #define TIMER_TPLVR1_MASK (0xffffffff << TIMER_TPLVR1_SHIFT) 168 169 /* 0x5C : Timer0 Pre-Load Control */ 170 #define TIMER_TPLCR0_SHIFT (0U) 171 #define TIMER_TPLCR0_MASK (0x3 << TIMER_TPLCR0_SHIFT) 172 173 /* 0x60 : Timer1 Pre-Load Control */ 174 #define TIMER_TPLCR1_SHIFT (0U) 175 #define TIMER_TPLCR1_MASK (0x3 << TIMER_TPLCR1_SHIFT) 176 177 /* 0x64 : Watch-dog reset/interrupt Mode */ 178 #define TIMER_WE (1 << 0U) 179 #define TIMER_WRIE (1 << 1U) 180 181 /* 0x68 : Watch-dog Match Value */ 182 #define TIMER_WMR_SHIFT (0U) 183 #define TIMER_WMR_MASK (0xffff << TIMER_WMR_SHIFT) 184 #define TIMER_WDT_ALIGN (1 << 16U) 185 186 /* 0x6C : Watch-dog Counter Value */ 187 #define TIMER_WDT_CNT_SHIFT (0U) 188 #define TIMER_WDT_CNT_MASK (0xffff << TIMER_WDT_CNT_SHIFT) 189 190 /* 0x70 : Watch-dog Reset Status */ 191 #define TIMER_WTS (1 << 0U) 192 193 /* 0x78 : Timer0 Interrupt Clear */ 194 #define TIMER_TCLR0_0 (1 << 0U) 195 #define TIMER_TCLR0_1 (1 << 1U) 196 #define TIMER_TCLR0_2 (1 << 2U) 197 198 /* 0x7C : Timer1 Interrupt Clear */ 199 #define TIMER_TCLR1_0 (1 << 0U) 200 #define TIMER_TCLR1_1 (1 << 1U) 201 #define TIMER_TCLR1_2 (1 << 2U) 202 203 /* 0x80 : WDT Interrupt Clear */ 204 #define TIMER_WICLR (1 << 0U) 205 206 /* 0x84 : Timer Counter Enable/Clear */ 207 #define TIMER0_EN (1 << 1U) 208 #define TIMER1_EN (1 << 2U) 209 #define TIMER_TCR0_CNT_CLR (1 << 5U) 210 #define TIMER_TCR1_CNT_CLR (1 << 6U) 211 212 /* 0x88 : Timer Counter Mode */ 213 #define TIMER0_MODE (1 << 1U) 214 #define TIMER1_MODE (1 << 2U) 215 #define TIMER0_ALIGN (1 << 5U) 216 #define TIMER1_ALIGN (1 << 6U) 217 218 /* 0x90 : Timer0 Match Interrupt Mode */ 219 #define TIMER_TILR0_0 (1 << 0U) 220 #define TIMER_TILR0_1 (1 << 1U) 221 #define TIMER_TILR0_2 (1 << 2U) 222 223 /* 0x94 : Timer1 Match Interrupt Mode */ 224 #define TIMER_TILR1_0 (1 << 0U) 225 #define TIMER_TILR1_1 (1 << 1U) 226 #define TIMER_TILR1_2 (1 << 2U) 227 228 /* 0x98 : WDT Counter Reset */ 229 #define TIMER_WCR (1 << 0U) 230 231 /* 0x9C : WDT Access Key1 */ 232 #define TIMER_WFAR_SHIFT (0U) 233 #define TIMER_WFAR_MASK (0xffff << TIMER_WFAR_SHIFT) 234 235 /* 0xA0 : WDT Access Key2 */ 236 #define TIMER_WSAR_SHIFT (0U) 237 #define TIMER_WSAR_MASK (0xffff << TIMER_WSAR_SHIFT) 238 239 /* 0xA8 : Timer0 Counter Latch Value */ 240 #define TIMER_TCR0_CNT_LAT_SHIFT (0U) 241 #define TIMER_TCR0_CNT_LAT_MASK (0xffffffff << TIMER_TCR0_CNT_LAT_SHIFT) 242 243 /* 0xAC : Timer1 Counter Latch Value */ 244 #define TIMER_TCR1_CNT_LAT_SHIFT (0U) 245 #define TIMER_TCR1_CNT_LAT_MASK (0xffffffff << TIMER_TCR1_CNT_LAT_SHIFT) 246 247 /* 0xB4 : Timer0 Counter Sync Value */ 248 #define TIMER_TCR0_CNT_SYNC_SHIFT (0U) 249 #define TIMER_TCR0_CNT_SYNC_MASK (0xffffffff << TIMER_TCR0_CNT_SYNC_SHIFT) 250 251 /* 0xB8 : Timer1 Counter Sync Value */ 252 #define TIMER_TCR1_CNT_SYNC_SHIFT (0U) 253 #define TIMER_TCR1_CNT_SYNC_MASK (0xffffffff << TIMER_TCR1_CNT_SYNC_SHIFT) 254 255 /* 0xBC : Timer Division */ 256 #define TIMER_TCDR0_SHIFT (8U) 257 #define TIMER_TCDR0_MASK (0xff << TIMER_TCDR0_SHIFT) 258 #define TIMER_TCDR1_SHIFT (16U) 259 #define TIMER_TCDR1_MASK (0xff << TIMER_TCDR1_SHIFT) 260 #define TIMER_WCDR_SHIFT (24U) 261 #define TIMER_WCDR_MASK (0xff << TIMER_WCDR_SHIFT) 262 263 #if !defined(BL702) || !defined(BL602) 264 /* 0xC0 : GPIO Mode */ 265 #define TIMER0_GPIO_EN (1 << 1U) 266 #define TIMER0_GPIO_INV (1 << 5U) 267 #define TIMER1_GPIO_INV (1 << 6U) 268 #define TIMER_WDT_GPIO_INV (1 << 7U) 269 #define TIMER_GPIO_LAT_OK (1 << 31U) 270 271 /* 0xC4 : GPIO Latch Value1 */ 272 #define TIMER_GPIO_LAT1_SHIFT (0U) 273 #define TIMER_GPIO_LAT1_MASK (0xffffffff << TIMER_GPIO_LAT1_SHIFT) 274 275 /* 0xC8 : GPIO Latch Value2 */ 276 #define TIMER_GPIO_LAT2_SHIFT (0U) 277 #define TIMER_GPIO_LAT2_MASK (0xffffffff << TIMER_GPIO_LAT2_SHIFT) 278 279 /* 0xCC : Timer Division Force */ 280 #define TIMER_TCDR0_FORCE (1 << 1U) 281 #define TIMER_TCDR1_FORCE (1 << 2U) 282 #define TIMER_WCDR_FORCE (1 << 4U) 283 #endif 284 285 #endif /* __HARDWARE_TIMER_H__ */ 286