00001 #ifndef _LPC177X_8X_WWDT_H_ 00002 #define _LPC177X_8X_WWDT_H_ 00003 00004 /* 00005 * Copyright (C) 2012 by Ole Reinhardt (ole.reinhardt@embedded-it.de) 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 3. Neither the name of the copyright holders nor the names of 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00029 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00030 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00031 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00032 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00033 * SUCH DAMAGE. 00034 * 00035 * For additional information see http://www.ethernut.de/ 00036 * 00037 ************************************************************************** 00038 * 00039 * Parts taken from lpc177x_8x_rtc.h 2011-06-02 00040 * file lpc177x_8x_wwdt.h 00041 * brief Contains all macro definitions and function prototypes 00042 * support forWindow Watchdog Timer firmware library on LPC177x_8x 00043 * version 1.0 00044 * date 02. June. 2011 00045 * author NXP MCU SW Application Team 00046 * 00047 * Copyright(C) 2011, NXP Semiconductor 00048 * All rights reserved. 00049 * 00050 *********************************************************************** 00051 * Software that is described herein is for illustrative purposes only 00052 * which provides customers with programming information regarding the 00053 * products. This software is supplied "AS IS" without any warranties. 00054 * NXP Semiconductors assumes no responsibility or liability for the 00055 * use of the software, conveys no license or title under any patent, 00056 * copyright, or mask work right to the product. NXP Semiconductors 00057 * reserves the right to make changes in the software without 00058 * notification. NXP Semiconductors also make no representation or 00059 * warranty that such application will be suitable for the specified 00060 * use without further testing or modification. 00061 * Permission to use, copy, modify, and distribute this software and its 00062 * documentation is hereby granted, under NXP Semiconductors' 00063 * relevant copyright in the software, without fee, provided that it 00064 * is used in conjunction with NXP Semiconductors microcontrollers. This 00065 * copyright, permission, and disclaimer notice must appear in all copies of 00066 * this code. 00067 **********************************************************************/ 00068 00076 /*============================================================================* 00077 LPC177x_8x Windowed watchdog timer 00078 *============================================================================*/ 00079 00080 /*----------------------------------------------------------------------------* 00081 Some macros 00082 *----------------------------------------------------------------------------*/ 00083 00084 /* Calculation macros, time is calculated by usec */ 00085 #define WDT_GET_FROM_USEC(time) (time/((WDT_US_INDEX * 4)/WDT_OSC)) 00086 #define WDT_GET_USEC(counter) (counter * ((WDT_US_INDEX * 4)/WDT_OSC)) 00087 00088 00089 /*----------------------------------------------------------------------------* 00090 Bit definitions 00091 *----------------------------------------------------------------------------*/ 00092 00093 /* WDT interrupt enable bit */ 00094 #define WDT_WDMOD_WDEN _BV(0) 00095 /* WDT interrupt enable bit */ 00096 #define WDT_WDMOD_WDRESET _BV(1) 00097 /* WDT time out flag bit */ 00098 #define WDT_WDMOD_WDTOF _BV(2) 00099 /* WDT Time Out flag bit */ 00100 #define WDT_WDMOD_WDINT _BV(3) 00101 /* WDT Protect flag bit */ 00102 #define WDT_WDMOD_WDPROTECT _BV(4) 00103 00104 /* Define divider index for microsecond ( us ) */ 00105 #define WDT_US_INDEX 1000000 00106 00107 /* WDT Time out minimum value */ 00108 #define WDT_TIMEOUT_MIN 0xFF 00109 /* WDT Time out maximum value */ 00110 #define WDT_TIMEOUT_MAX 0x00FFFFFF 00111 00112 /* WDT Warning minimum value */ 00113 #define WDT_WARNINT_MIN 0xFF 00114 /* WDT Warning maximum value */ 00115 #define WDT_WARNINT_MAX 0x000003FF 00116 00117 /* WDT Windowed minimum value */ 00118 #define WDT_WINDOW_MIN 0xFF 00119 /* WDT Windowed minimum value */ 00120 #define WDT_WINDOW_MAX 0x00FFFFFF 00121 00122 /* WDT timer constant register mask */ 00123 #define WDT_WDTC_MASK 0x00FFFFFF 00124 /* WDT warning value register mask */ 00125 #define WDT_WDWARNINT_MASK 0x000003FF 00126 /* WDT feed sequence register mask */ 00127 #define WDT_WDFEED_MASK 0x000000FF 00128 00129 /* WDT flag */ 00130 #define WDT_WARNINT_FLAG 0 00131 #define WDT_TIMEOUT_FLAG 1 00132 00133 /* WDT mode definitions */ 00134 #define WDT_PROTECT_MODE 0 00135 #define WDT_RESET_MODE 1 00136 00137 00138 /* WDT Timer value definition (us) */ 00139 #define WDT_TIMEOUT_USEC_MIN ((uint32_t)(WDT_GET_USEC(WDT_TIMEOUT_MIN))) 00140 #define WDT_TIMEOUT_USEC_MAX ((uint32_t)(WDT_GET_USEC(WDT_TIMEOUT_MAX))) 00141 00142 #define WDT_TIMEWARN_USEC_MIN ((uint32_t)(WDT_GET_USEC(WDT_WARNINT_MIN))) 00143 #define WDT_TIMEWARN_USEC_MAX ((uint32_t)(WDT_GET_USEC(WDT_WARNINT_MAX))) 00144 00145 #define WDT_TIMEWINDOWED_USEC_MIN ((uint32_t)(WDT_GET_USEC(WDT_WINDOW_MIN))) 00146 #define WDT_TIMEWINDOWED_USEC_MAX ((uint32_t)(WDT_GET_USEC(WDT_WINDOW_MAX))) 00147 00148 #endif /* _LPC177X_8X_WWDT_H_ */