|
| 1 | +/**************************************************************************** |
| 2 | + * arch/arm/src/stm32f0l0g0/hardware/stm32_wdg.h |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 7 | + * contributor license agreements. See the NOTICE file distributed with |
| 8 | + * this work for additional information regarding copyright ownership. The |
| 9 | + * ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 10 | + * "License"); you may not use this file except in compliance with the |
| 11 | + * License. You may obtain a copy of the License at |
| 12 | + * |
| 13 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + * |
| 15 | + * Unless required by applicable law or agreed to in writing, software |
| 16 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 18 | + * License for the specific language governing permissions and limitations |
| 19 | + * under the License. |
| 20 | + * |
| 21 | + ****************************************************************************/ |
| 22 | + |
| 23 | +#ifndef __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_WDG_H |
| 24 | +#define __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_WDG_H |
| 25 | + |
| 26 | +/**************************************************************************** |
| 27 | + * Included Files |
| 28 | + ****************************************************************************/ |
| 29 | + |
| 30 | +#include <nuttx/config.h> |
| 31 | + |
| 32 | +#include "chip.h" |
| 33 | + |
| 34 | +/**************************************************************************** |
| 35 | + * Pre-processor Definitions |
| 36 | + ****************************************************************************/ |
| 37 | + |
| 38 | +/* Register Offsets *********************************************************/ |
| 39 | + |
| 40 | +#define STM32_IWDG_KR_OFFSET 0x0000 /* Key register (32-bit) */ |
| 41 | +#define STM32_IWDG_PR_OFFSET 0x0004 /* Prescaler register (32-bit) */ |
| 42 | +#define STM32_IWDG_RLR_OFFSET 0x0008 /* Reload register (32-bit) */ |
| 43 | +#define STM32_IWDG_SR_OFFSET 0x000c /* Status register (32-bit) */ |
| 44 | +#define STM32_IWDG_WINR_OFFSET 0x000c /* Window register (32-bit) */ |
| 45 | + |
| 46 | +#define STM32_WWDG_CR_OFFSET 0x0000 /* Control Register (32-bit) */ |
| 47 | +#define STM32_WWDG_CFR_OFFSET 0x0004 /* Configuration register (32-bit) */ |
| 48 | +#define STM32_WWDG_SR_OFFSET 0x0008 /* Status register (32-bit) */ |
| 49 | + |
| 50 | +/* Register Addresses *******************************************************/ |
| 51 | + |
| 52 | +#define STM32_IWDG_KR (STM32_IWDG_BASE+STM32_IWDG_KR_OFFSET) |
| 53 | +#define STM32_IWDG_PR (STM32_IWDG_BASE+STM32_IWDG_PR_OFFSET) |
| 54 | +#define STM32_IWDG_RLR (STM32_IWDG_BASE+STM32_IWDG_RLR_OFFSET) |
| 55 | +#define STM32_IWDG_SR (STM32_IWDG_BASE+STM32_IWDG_SR_OFFSET) |
| 56 | +#define STM32_IWDG_WINR (STM32_IWDG_BASE+STM32_IWDG_WINR_OFFSET) |
| 57 | + |
| 58 | +#define STM32_WWDG_CR (STM32_WWDG_BASE+STM32_WWDG_CR_OFFSET) |
| 59 | +#define STM32_WWDG_CFR (STM32_WWDG_BASE+STM32_WWDG_CFR_OFFSET) |
| 60 | +#define STM32_WWDG_SR (STM32_WWDG_BASE+STM32_WWDG_SR_OFFSET) |
| 61 | + |
| 62 | +/* Register Bitfield Definitions ********************************************/ |
| 63 | + |
| 64 | +/* Key register (32-bit) */ |
| 65 | + |
| 66 | +#define IWDG_KR_KEY_SHIFT (0) /* Bits 15-0: Key value (write only, read 0000h) */ |
| 67 | +#define IWDG_KR_KEY_MASK (0xffff << IWDG_KR_KEY_SHIFT) |
| 68 | + |
| 69 | +#define IWDG_KR_KEY_ENABLE (0x5555) /* Enable register access */ |
| 70 | +#define IWDG_KR_KEY_DISABLE (0x0000) /* Disable register access */ |
| 71 | +#define IWDG_KR_KEY_RELOAD (0xaaaa) /* Reload the counter */ |
| 72 | +#define IWDG_KR_KEY_START (0xcccc) /* Start the watchdog */ |
| 73 | + |
| 74 | +/* Prescaler register (32-bit) */ |
| 75 | + |
| 76 | +#define IWDG_PR_SHIFT (0) /* Bits 2-0: Prescaler divider */ |
| 77 | +#define IWDG_PR_MASK (7 << IWDG_PR_SHIFT) |
| 78 | +# define IWDG_PR_DIV4 (0 << IWDG_PR_SHIFT) /* 000: divider /4 */ |
| 79 | +# define IWDG_PR_DIV8 (1 << IWDG_PR_SHIFT) /* 001: divider /8 */ |
| 80 | +# define IWDG_PR_DIV16 (2 << IWDG_PR_SHIFT) /* 010: divider /16 */ |
| 81 | +# define IWDG_PR_DIV32 (3 << IWDG_PR_SHIFT) /* 011: divider /32 */ |
| 82 | +# define IWDG_PR_DIV64 (4 << IWDG_PR_SHIFT) /* 100: divider /64 */ |
| 83 | +# define IWDG_PR_DIV128 (5 << IWDG_PR_SHIFT) /* 101: divider /128 */ |
| 84 | +# define IWDG_PR_DIV256 (6 << IWDG_PR_SHIFT) /* 11x: divider /256 */ |
| 85 | + |
| 86 | +/* Reload register (32-bit) */ |
| 87 | + |
| 88 | +#define IWDG_RLR_RL_SHIFT (0) /* Bits11:0 RL[11:0]: Watchdog counter reload value */ |
| 89 | +#define IWDG_RLR_RL_MASK (0x0fff << IWDG_RLR_RL_SHIFT) |
| 90 | + |
| 91 | +#define IWDG_RLR_MAX (0xfff) |
| 92 | + |
| 93 | +/* Status register (32-bit) */ |
| 94 | + |
| 95 | +#define IWDG_SR_PVU (1 << 0) /* Bit 0: Watchdog prescaler value update */ |
| 96 | +#define IWDG_SR_RVU (1 << 1) /* Bit 1: Watchdog counter reload value update */ |
| 97 | +#define IWDG_SR_WVU (1 << 2) /* Bit 2: */ |
| 98 | + |
| 99 | +/* Window register (32-bit) */ |
| 100 | + |
| 101 | +#define IWDG_WINR_SHIFT (0) |
| 102 | +#define IWDG_WINR_MASK (0x0fff << IWDG_WINR_SHIFT) |
| 103 | + |
| 104 | +/* Control Register (32-bit) */ |
| 105 | + |
| 106 | +#define WWDG_CR_T_SHIFT (0) /* Bits 6:0 T[6:0]: 7-bit counter (MSB to LSB) */ |
| 107 | +#define WWDG_CR_T_MASK (0x7f << WWDG_CR_T_SHIFT) |
| 108 | +# define WWDG_CR_T_MAX (0x3f << WWDG_CR_T_SHIFT) |
| 109 | +# define WWDG_CR_T_RESET (0x40 << WWDG_CR_T_SHIFT) |
| 110 | +#define WWDG_CR_WDGA (1 << 7) /* Bit 7: Activation bit */ |
| 111 | + |
| 112 | +/* Configuration register (32-bit) */ |
| 113 | + |
| 114 | +#define WWDG_CFR_W_SHIFT (0) /* Bits 6:0 W[6:0] 7-bit window value */ |
| 115 | +#define WWDG_CFR_W_MASK (0x7f << WWDG_CFR_W_SHIFT) |
| 116 | +#define WWDG_CFR_WDGTB_SHIFT (7) /* Bits 8:7 [1:0]: Timer Base */ |
| 117 | +#define WWDG_CFR_WDGTB_MASK (3 << WWDG_CFR_WDGTB_SHIFT) |
| 118 | +# define WWDG_CFR_PCLK1 (0 << WWDG_CFR_WDGTB_SHIFT) /* 00: CK Counter Clock (PCLK1 div 4096) div 1 */ |
| 119 | +# define WWDG_CFR_PCLK1d2 (1 << WWDG_CFR_WDGTB_SHIFT) /* 01: CK Counter Clock (PCLK1 div 4096) div 2 */ |
| 120 | +# define WWDG_CFR_PCLK1d4 (2 << WWDG_CFR_WDGTB_SHIFT) /* 10: CK Counter Clock (PCLK1 div 4096) div 4 */ |
| 121 | +# define WWDG_CFR_PCLK1d8 (3 << WWDG_CFR_WDGTB_SHIFT) /* 11: CK Counter Clock (PCLK1 div 4096) div 8 */ |
| 122 | + |
| 123 | +#define WWDG_CFR_EWI (1 << 9) /* Bit 9: Early Wakeup Interrupt */ |
| 124 | + |
| 125 | +/* Status register (32-bit) */ |
| 126 | + |
| 127 | +#define WWDG_SR_EWIF (1 << 0) /* Bit 0: Early Wakeup Interrupt Flag */ |
| 128 | + |
| 129 | +/**************************************************************************** |
| 130 | + * Public Types |
| 131 | + ****************************************************************************/ |
| 132 | + |
| 133 | +/**************************************************************************** |
| 134 | + * Public Data |
| 135 | + ****************************************************************************/ |
| 136 | + |
| 137 | +/**************************************************************************** |
| 138 | + * Public Functions Prototypes |
| 139 | + ****************************************************************************/ |
| 140 | + |
| 141 | +#endif /* __ARCH_ARM_SRC_STM32F0L0G0_HARDWARE_STM32_WDG_H */ |
0 commit comments