lpc17xx_wdt.h (4983B)
1 /********************************************************************** 2 * $Id$ lpc17xx_wdt.h 2010-05-21 3 *//** 4 * @file lpc17xx_wdt.h 5 * @brief Contains all macro definitions and function prototypes 6 * support for WDT firmware library on LPC17xx 7 * @version 2.0 8 * @date 21. May. 2010 9 * @author NXP MCU SW Application Team 10 * 11 * Copyright(C) 2010, NXP Semiconductor 12 * All rights reserved. 13 * 14 *********************************************************************** 15 * Software that is described herein is for illustrative purposes only 16 * which provides customers with programming information regarding the 17 * products. This software is supplied "AS IS" without any warranties. 18 * NXP Semiconductors assumes no responsibility or liability for the 19 * use of the software, conveys no license or title under any patent, 20 * copyright, or mask work right to the product. NXP Semiconductors 21 * reserves the right to make changes in the software without 22 * notification. NXP Semiconductors also make no representation or 23 * warranty that such application will be suitable for the specified 24 * use without further testing or modification. 25 * Permission to use, copy, modify, and distribute this software and its 26 * documentation is hereby granted, under NXP Semiconductors' 27 * relevant copyright in the software, without fee, provided that it 28 * is used in conjunction with NXP Semiconductors microcontrollers. This 29 * copyright, permission, and disclaimer notice must appear in all copies of 30 * this code. 31 **********************************************************************/ 32 33 /* Peripheral group ----------------------------------------------------------- */ 34 /** @defgroup WDT WDT (Watch-Dog Timer) 35 * @ingroup LPC1700CMSIS_FwLib_Drivers 36 * @{ 37 */ 38 39 #ifndef LPC17XX_WDT_H_ 40 #define LPC17XX_WDT_H_ 41 42 /* Includes ------------------------------------------------------------------- */ 43 #include "LPC17xx.h" 44 #include "lpc_types.h" 45 46 47 #ifdef __cplusplus 48 extern "C" 49 { 50 #endif 51 52 53 /* Private Macros ------------------------------------------------------------- */ 54 /** @defgroup WDT_Private_Macros WDT Private Macros 55 * @{ 56 */ 57 58 /* --------------------- BIT DEFINITIONS -------------------------------------- */ 59 /** WDT interrupt enable bit */ 60 #define WDT_WDMOD_WDEN ((uint32_t)(1<<0)) 61 /** WDT interrupt enable bit */ 62 #define WDT_WDMOD_WDRESET ((uint32_t)(1<<1)) 63 /** WDT time out flag bit */ 64 #define WDT_WDMOD_WDTOF ((uint32_t)(1<<2)) 65 /** WDT Time Out flag bit */ 66 #define WDT_WDMOD_WDINT ((uint32_t)(1<<3)) 67 /** WDT Mode */ 68 #define WDT_WDMOD(n) ((uint32_t)(1<<1)) 69 70 /** Define divider index for microsecond ( us ) */ 71 #define WDT_US_INDEX ((uint32_t)(1000000)) 72 /** WDT Time out minimum value */ 73 #define WDT_TIMEOUT_MIN ((uint32_t)(0xFF)) 74 /** WDT Time out maximum value */ 75 #define WDT_TIMEOUT_MAX ((uint32_t)(0xFFFFFFFF)) 76 77 /** Watchdog mode register mask */ 78 #define WDT_WDMOD_MASK (uint8_t)(0x02) 79 /** Watchdog timer constant register mask */ 80 #define WDT_WDTC_MASK (uint8_t)(0xFFFFFFFF) 81 /** Watchdog feed sequence register mask */ 82 #define WDT_WDFEED_MASK (uint8_t)(0x000000FF) 83 /** Watchdog timer value register mask */ 84 #define WDT_WDCLKSEL_MASK (uint8_t)(0x03) 85 /** Clock selected from internal RC */ 86 #define WDT_WDCLKSEL_RC (uint8_t)(0x00) 87 /** Clock selected from PCLK */ 88 #define WDT_WDCLKSEL_PCLK (uint8_t)(0x01) 89 /** Clock selected from external RTC */ 90 #define WDT_WDCLKSEL_RTC (uint8_t)(0x02) 91 92 /* ---------------- CHECK PARAMETER DEFINITIONS ---------------------------- */ 93 /* Macro check clock source selection */ 94 #define PARAM_WDT_CLK_OPT(OPTION) ((OPTION ==WDT_CLKSRC_IRC)||(OPTION ==WDT_CLKSRC_PCLK)\ 95 ||(OPTION ==WDT_CLKSRC_RTC)) 96 97 /* Macro check WDT mode */ 98 #define PARAM_WDT_MODE_OPT(OPTION) ((OPTION ==WDT_MODE_INT_ONLY)||(OPTION ==WDT_MODE_RESET)) 99 /** 100 * @} 101 */ 102 103 104 /* Public Types --------------------------------------------------------------- */ 105 /** @defgroup WDT_Public_Types WDT Public Types 106 * @{ 107 */ 108 109 /** @brief Clock source option for WDT */ 110 typedef enum { 111 WDT_CLKSRC_IRC = 0, /*!< Clock source from Internal RC oscillator */ 112 WDT_CLKSRC_PCLK = 1, /*!< Selects the APB peripheral clock (PCLK) */ 113 WDT_CLKSRC_RTC = 2 /*!< Selects the RTC oscillator */ 114 } WDT_CLK_OPT; 115 116 /** @brief WDT operation mode */ 117 typedef enum { 118 WDT_MODE_INT_ONLY = 0, /*!< Use WDT to generate interrupt only */ 119 WDT_MODE_RESET = 1 /*!< Use WDT to generate interrupt and reset MCU */ 120 } WDT_MODE_OPT; 121 122 /** 123 * @} 124 */ 125 126 127 /* Public Functions ----------------------------------------------------------- */ 128 /** @defgroup WDT_Public_Functions WDT Public Functions 129 * @{ 130 */ 131 132 void WDT_Init (WDT_CLK_OPT ClkSrc, WDT_MODE_OPT WDTMode); 133 void WDT_Start(uint32_t TimeOut); 134 void WDT_Feed (void); 135 void WDT_UpdateTimeOut ( uint32_t TimeOut); 136 FlagStatus WDT_ReadTimeOutFlag (void); 137 void WDT_ClrTimeOutFlag (void); 138 uint32_t WDT_GetCurrentCount(void); 139 140 /** 141 * @} 142 */ 143 144 #ifdef __cplusplus 145 } 146 #endif 147 148 #endif /* LPC17XX_WDT_H_ */ 149 150 /** 151 * @} 152 */ 153 154 /* --------------------------------- End Of File ------------------------------ */