Mouse code for the MacroRat
mbed-dev/targets/TARGET_NUVOTON/TARGET_NUC472/device/StdDriver/nuc472_wdt.h@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /**************************************************************************//** |
sahilmgandhi | 18:6a4db94011d3 | 2 | * @file wdt.h |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @version V1.00 |
sahilmgandhi | 18:6a4db94011d3 | 4 | * $Revision: 8 $ |
sahilmgandhi | 18:6a4db94011d3 | 5 | * $Date: 14/05/29 1:13p $ |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @brief NUC472/NUC442 WDT driver header file |
sahilmgandhi | 18:6a4db94011d3 | 7 | * |
sahilmgandhi | 18:6a4db94011d3 | 8 | * @note |
sahilmgandhi | 18:6a4db94011d3 | 9 | * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved. |
sahilmgandhi | 18:6a4db94011d3 | 10 | *****************************************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 11 | #ifndef __WDT_H__ |
sahilmgandhi | 18:6a4db94011d3 | 12 | #define __WDT_H__ |
sahilmgandhi | 18:6a4db94011d3 | 13 | |
sahilmgandhi | 18:6a4db94011d3 | 14 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 15 | extern "C" |
sahilmgandhi | 18:6a4db94011d3 | 16 | { |
sahilmgandhi | 18:6a4db94011d3 | 17 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | |
sahilmgandhi | 18:6a4db94011d3 | 20 | /** @addtogroup NUC472_442_Device_Driver NUC472/NUC442 Device Driver |
sahilmgandhi | 18:6a4db94011d3 | 21 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 22 | */ |
sahilmgandhi | 18:6a4db94011d3 | 23 | |
sahilmgandhi | 18:6a4db94011d3 | 24 | /** @addtogroup NUC472_442_WDT_Driver WDT Driver |
sahilmgandhi | 18:6a4db94011d3 | 25 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 26 | */ |
sahilmgandhi | 18:6a4db94011d3 | 27 | |
sahilmgandhi | 18:6a4db94011d3 | 28 | /** @addtogroup NUC472_442_WDT_EXPORTED_CONSTANTS WDT Exported Constants |
sahilmgandhi | 18:6a4db94011d3 | 29 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 30 | */ |
sahilmgandhi | 18:6a4db94011d3 | 31 | #define WDT_TIMEOUT_2POW4 (0UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^4 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 32 | #define WDT_TIMEOUT_2POW6 (1UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^6 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 33 | #define WDT_TIMEOUT_2POW8 (2UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^8 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 34 | #define WDT_TIMEOUT_2POW10 (3UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^10 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 35 | #define WDT_TIMEOUT_2POW12 (4UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^12 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 36 | #define WDT_TIMEOUT_2POW14 (5UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^14 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 37 | #define WDT_TIMEOUT_2POW16 (6UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^16 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 38 | #define WDT_TIMEOUT_2POW18 (7UL << WDT_CTL_TOUTSEL_Pos) /*!< WDT setting for timeout interval = 2^18 * WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 39 | |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define WDT_RESET_DELAY_3CLK (3UL << WDT_ALTCTL_RSTDSEL_Pos) /*!< WDT setting reset delay to 3 WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 41 | #define WDT_RESET_DELAY_18CLK (2UL << WDT_ALTCTL_RSTDSEL_Pos) /*!< WDT setting reset delay to 18 WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 42 | #define WDT_RESET_DELAY_130CLK (1UL << WDT_ALTCTL_RSTDSEL_Pos) /*!< WDT setting reset delay to 130 WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 43 | #define WDT_RESET_DELAY_1026CLK (0UL << WDT_ALTCTL_RSTDSEL_Pos) /*!< WDT setting reset delay to 1026 WDT clocks \hideinitializer */ |
sahilmgandhi | 18:6a4db94011d3 | 44 | |
sahilmgandhi | 18:6a4db94011d3 | 45 | /*@}*/ /* end of group NUC472_442_WDT_EXPORTED_CONSTANTS */ |
sahilmgandhi | 18:6a4db94011d3 | 46 | |
sahilmgandhi | 18:6a4db94011d3 | 47 | |
sahilmgandhi | 18:6a4db94011d3 | 48 | /** @addtogroup NUC472_442_WDT_EXPORTED_FUNCTIONS WDT Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 49 | @{ |
sahilmgandhi | 18:6a4db94011d3 | 50 | */ |
sahilmgandhi | 18:6a4db94011d3 | 51 | |
sahilmgandhi | 18:6a4db94011d3 | 52 | /** |
sahilmgandhi | 18:6a4db94011d3 | 53 | * @brief This macro clear WDT time-out reset system flag. |
sahilmgandhi | 18:6a4db94011d3 | 54 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 55 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 56 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 57 | */ |
sahilmgandhi | 18:6a4db94011d3 | 58 | #define WDT_CLEAR_RESET_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_IF_Msk | WDT_CTL_WKF_Msk)) | WDT_CTL_RSTF_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 59 | |
sahilmgandhi | 18:6a4db94011d3 | 60 | /** |
sahilmgandhi | 18:6a4db94011d3 | 61 | * @brief This macro clear WDT time-out interrupt flag. |
sahilmgandhi | 18:6a4db94011d3 | 62 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 63 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 64 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 65 | */ |
sahilmgandhi | 18:6a4db94011d3 | 66 | #define WDT_CLEAR_TIMEOUT_INT_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_RSTF_Msk | WDT_CTL_WKF_Msk)) | WDT_CTL_IF_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 67 | |
sahilmgandhi | 18:6a4db94011d3 | 68 | /** |
sahilmgandhi | 18:6a4db94011d3 | 69 | * @brief This macro clear WDT time-out wake-up system flag. |
sahilmgandhi | 18:6a4db94011d3 | 70 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 71 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 72 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 73 | */ |
sahilmgandhi | 18:6a4db94011d3 | 74 | #define WDT_CLEAR_TIMEOUT_WAKEUP_FLAG() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_RSTF_Msk | WDT_CTL_IF_Msk)) | WDT_CTL_WKF_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 75 | |
sahilmgandhi | 18:6a4db94011d3 | 76 | /** |
sahilmgandhi | 18:6a4db94011d3 | 77 | * @brief This macro indicate WDT time-out to reset system or not. |
sahilmgandhi | 18:6a4db94011d3 | 78 | * @return WDT reset system or not |
sahilmgandhi | 18:6a4db94011d3 | 79 | * @retval 0 WDT did not cause system reset |
sahilmgandhi | 18:6a4db94011d3 | 80 | * @retval 1 WDT caused system reset |
sahilmgandhi | 18:6a4db94011d3 | 81 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 82 | */ |
sahilmgandhi | 18:6a4db94011d3 | 83 | #define WDT_GET_RESET_FLAG() (WDT->CTL & WDT_CTL_RSTF_Msk ? 1 : 0) |
sahilmgandhi | 18:6a4db94011d3 | 84 | |
sahilmgandhi | 18:6a4db94011d3 | 85 | /** |
sahilmgandhi | 18:6a4db94011d3 | 86 | * @brief This macro indicate WDT time-out interrupt occurred or not. |
sahilmgandhi | 18:6a4db94011d3 | 87 | * @return WDT time-out interrupt occurred or not |
sahilmgandhi | 18:6a4db94011d3 | 88 | * @retval 0 WDT time-out interrupt did not occur |
sahilmgandhi | 18:6a4db94011d3 | 89 | * @retval 1 WDT time-out interrupt occurred |
sahilmgandhi | 18:6a4db94011d3 | 90 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 91 | */ |
sahilmgandhi | 18:6a4db94011d3 | 92 | #define WDT_GET_TIMEOUT_INT_FLAG() (WDT->CTL & WDT_CTL_IF_Msk ? 1 : 0) |
sahilmgandhi | 18:6a4db94011d3 | 93 | |
sahilmgandhi | 18:6a4db94011d3 | 94 | /** |
sahilmgandhi | 18:6a4db94011d3 | 95 | * @brief This macro indicate WDT time-out waked system up or not |
sahilmgandhi | 18:6a4db94011d3 | 96 | * @return WDT time-out waked system up or not |
sahilmgandhi | 18:6a4db94011d3 | 97 | * @retval 0 WDT did not wake up system |
sahilmgandhi | 18:6a4db94011d3 | 98 | * @retval 1 WDT waked up system |
sahilmgandhi | 18:6a4db94011d3 | 99 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 100 | */ |
sahilmgandhi | 18:6a4db94011d3 | 101 | #define WDT_GET_TIMEOUT_WAKEUP_FLAG() (WDT->CTL & WDT_CTL_WKF_Msk ? 1 : 0) |
sahilmgandhi | 18:6a4db94011d3 | 102 | |
sahilmgandhi | 18:6a4db94011d3 | 103 | /** |
sahilmgandhi | 18:6a4db94011d3 | 104 | * @brief This macro is used to reset 18-bit WDT counter. |
sahilmgandhi | 18:6a4db94011d3 | 105 | * @details If WDT is activated and enabled to reset system, software must reset WDT counter |
sahilmgandhi | 18:6a4db94011d3 | 106 | * before WDT time-out plus reset delay reached. Or WDT generate a reset signal. |
sahilmgandhi | 18:6a4db94011d3 | 107 | * \hideinitializer |
sahilmgandhi | 18:6a4db94011d3 | 108 | */ |
sahilmgandhi | 18:6a4db94011d3 | 109 | #define WDT_RESET_COUNTER() (WDT->CTL = (WDT->CTL & ~(WDT_CTL_IF_Msk | WDT_CTL_WKF_Msk | WDT_CTL_RSTF_Msk)) | WDT_CTL_RSTCNT_Msk) |
sahilmgandhi | 18:6a4db94011d3 | 110 | |
sahilmgandhi | 18:6a4db94011d3 | 111 | /** |
sahilmgandhi | 18:6a4db94011d3 | 112 | * @brief This function stops WDT counting and disable WDT module |
sahilmgandhi | 18:6a4db94011d3 | 113 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 114 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 115 | */ |
sahilmgandhi | 18:6a4db94011d3 | 116 | __STATIC_INLINE void WDT_Close(void) |
sahilmgandhi | 18:6a4db94011d3 | 117 | { |
sahilmgandhi | 18:6a4db94011d3 | 118 | WDT->CTL = 0; |
sahilmgandhi | 18:6a4db94011d3 | 119 | return; |
sahilmgandhi | 18:6a4db94011d3 | 120 | } |
sahilmgandhi | 18:6a4db94011d3 | 121 | |
sahilmgandhi | 18:6a4db94011d3 | 122 | /** |
sahilmgandhi | 18:6a4db94011d3 | 123 | * @brief This function enables the WDT time-out interrupt |
sahilmgandhi | 18:6a4db94011d3 | 124 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 125 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 126 | */ |
sahilmgandhi | 18:6a4db94011d3 | 127 | __STATIC_INLINE void WDT_EnableInt(void) |
sahilmgandhi | 18:6a4db94011d3 | 128 | { |
sahilmgandhi | 18:6a4db94011d3 | 129 | WDT->CTL |= WDT_CTL_INTEN_Msk; |
sahilmgandhi | 18:6a4db94011d3 | 130 | return; |
sahilmgandhi | 18:6a4db94011d3 | 131 | } |
sahilmgandhi | 18:6a4db94011d3 | 132 | |
sahilmgandhi | 18:6a4db94011d3 | 133 | /** |
sahilmgandhi | 18:6a4db94011d3 | 134 | * @brief This function disables the WDT time-out interrupt |
sahilmgandhi | 18:6a4db94011d3 | 135 | * @param None |
sahilmgandhi | 18:6a4db94011d3 | 136 | * @return None |
sahilmgandhi | 18:6a4db94011d3 | 137 | */ |
sahilmgandhi | 18:6a4db94011d3 | 138 | __STATIC_INLINE void WDT_DisableInt(void) |
sahilmgandhi | 18:6a4db94011d3 | 139 | { |
sahilmgandhi | 18:6a4db94011d3 | 140 | // Do not touch write 1 clear bits |
sahilmgandhi | 18:6a4db94011d3 | 141 | WDT->CTL &= ~(WDT_CTL_INTEN_Msk | WDT_CTL_RSTF_Msk | WDT_CTL_IF_Msk) ; |
sahilmgandhi | 18:6a4db94011d3 | 142 | return; |
sahilmgandhi | 18:6a4db94011d3 | 143 | } |
sahilmgandhi | 18:6a4db94011d3 | 144 | |
sahilmgandhi | 18:6a4db94011d3 | 145 | void WDT_Open(uint32_t u32TimeoutInterval, |
sahilmgandhi | 18:6a4db94011d3 | 146 | uint32_t u32ResetDelay, |
sahilmgandhi | 18:6a4db94011d3 | 147 | uint32_t u32EnableReset, |
sahilmgandhi | 18:6a4db94011d3 | 148 | uint32_t u32EnableWakeup); |
sahilmgandhi | 18:6a4db94011d3 | 149 | |
sahilmgandhi | 18:6a4db94011d3 | 150 | /*@}*/ /* end of group NUC472_442_WDT_EXPORTED_FUNCTIONS */ |
sahilmgandhi | 18:6a4db94011d3 | 151 | |
sahilmgandhi | 18:6a4db94011d3 | 152 | /*@}*/ /* end of group NUC472_442_WDT_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 153 | |
sahilmgandhi | 18:6a4db94011d3 | 154 | /*@}*/ /* end of group NUC472_442_Device_Driver */ |
sahilmgandhi | 18:6a4db94011d3 | 155 | |
sahilmgandhi | 18:6a4db94011d3 | 156 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 157 | } |
sahilmgandhi | 18:6a4db94011d3 | 158 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 159 | |
sahilmgandhi | 18:6a4db94011d3 | 160 | #endif //__WDT_H__ |
sahilmgandhi | 18:6a4db94011d3 | 161 | |
sahilmgandhi | 18:6a4db94011d3 | 162 | /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/ |