1 /***************************************************************************** 2 * Copyright (c) 2022, Nations Technologies Inc. 3 * 4 * All rights reserved. 5 * **************************************************************************** 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * - Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the disclaimer below. 12 * 13 * Nations' name may not be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE 19 * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 22 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 25 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * ****************************************************************************/ 27 28 /** 29 * @file n32l43x_iwdg.h 30 * @author Nations 31 * @version v1.2.0 32 * 33 * @copyright Copyright (c) 2022, Nations Technologies Inc. All rights reserved. 34 */ 35 #ifndef __N32L43X_IWDG_H__ 36 #define __N32L43X_IWDG_H__ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #include "n32l43x.h" 43 44 /** @addtogroup n32l43x_StdPeriph_Driver 45 * @{ 46 */ 47 48 /** @addtogroup IWDG 49 * @{ 50 */ 51 52 /** @addtogroup IWDG_Exported_Types 53 * @{ 54 */ 55 56 /** 57 * @} 58 */ 59 60 /** @addtogroup IWDG_Exported_Constants 61 * @{ 62 */ 63 64 /** @addtogroup IWDG_WriteAccess 65 * @{ 66 */ 67 68 #define IWDG_WRITE_ENABLE ((uint16_t)0x5555) 69 #define IWDG_WRITE_DISABLE ((uint16_t)0x0000) 70 #define IS_IWDG_WRITE(ACCESS) (((ACCESS) == IWDG_WRITE_ENABLE) || ((ACCESS) == IWDG_WRITE_DISABLE)) 71 /** 72 * @} 73 */ 74 75 /** @addtogroup IWDG_prescaler 76 * @{ 77 */ 78 79 #define IWDG_PRESCALER_DIV4 ((uint8_t)0x00) 80 #define IWDG_PRESCALER_DIV8 ((uint8_t)0x01) 81 #define IWDG_PRESCALER_DIV16 ((uint8_t)0x02) 82 #define IWDG_PRESCALER_DIV32 ((uint8_t)0x03) 83 #define IWDG_PRESCALER_DIV64 ((uint8_t)0x04) 84 #define IWDG_PRESCALER_DIV128 ((uint8_t)0x05) 85 #define IWDG_PRESCALER_DIV256 ((uint8_t)0x06) 86 #define IS_IWDG_PRESCALER_DIV(PRESCALER) \ 87 (((PRESCALER) == IWDG_PRESCALER_DIV4) || ((PRESCALER) == IWDG_PRESCALER_DIV8) \ 88 || ((PRESCALER) == IWDG_PRESCALER_DIV16) || ((PRESCALER) == IWDG_PRESCALER_DIV32) \ 89 || ((PRESCALER) == IWDG_PRESCALER_DIV64) || ((PRESCALER) == IWDG_PRESCALER_DIV128) \ 90 || ((PRESCALER) == IWDG_PRESCALER_DIV256)) 91 /** 92 * @} 93 */ 94 95 /** @addtogroup IWDG_Flag 96 * @{ 97 */ 98 99 #define IWDG_PVU_FLAG ((uint16_t)0x0001) 100 #define IWDG_CRVU_FLAG ((uint16_t)0x0002) 101 #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_PVU_FLAG) || ((FLAG) == IWDG_CRVU_FLAG)) 102 #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) 103 /** 104 * @} 105 */ 106 107 /** 108 * @} 109 */ 110 111 /** @addtogroup IWDG_Exported_Macros 112 * @{ 113 */ 114 115 /** 116 * @} 117 */ 118 119 /** @addtogroup IWDG_Exported_Functions 120 * @{ 121 */ 122 123 void IWDG_WriteConfig(uint16_t IWDG_WriteAccess); 124 void IWDG_SetPrescalerDiv(uint8_t IWDG_Prescaler); 125 void IWDG_CntReload(uint16_t Reload); 126 void IWDG_ReloadKey(void); 127 void IWDG_Enable(void); 128 FlagStatus IWDG_GetStatus(uint16_t IWDG_FLAG); 129 130 #ifdef __cplusplus 131 } 132 #endif 133 134 #endif /* __N32L43X_IWDG_H__ */ 135 /** 136 * @} 137 */ 138 139 /** 140 * @} 141 */ 142 143 /** 144 * @} 145 */ 146