Nut/OS  5.0.5
API Reference
lpc176x_wdt.h
Go to the documentation of this file.
00001 #ifndef _LPC176X_WDT_H_
00002 #define _LPC176X_WDT_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 lpc17xx_wdt.h
00040  *
00041  * file     : lpc17xx_wdt.h
00042  * brief    : Contains all macro definitions and function prototypes
00043  *              support for WDT firmware library on LPC17xx
00044  * version  : 1.0
00045  * date     : 9. April. 2009
00046  * author   : HieuNguyen
00047  **************************************************************************
00048  * Software that is described herein is for illustrative purposes only
00049  * which provides customers with programming information regarding the
00050  * products. This software is supplied "AS IS" without any warranties.
00051  * NXP Semiconductors assumes no responsibility or liability for the
00052  * use of the software, conveys no license or title under any patent,
00053  * copyright, or mask work right to the product. NXP Semiconductors
00054  * reserves the right to make changes in the software without
00055  * notification. NXP Semiconductors also make no representation or
00056  * warranty that such application will be suitable for the specified
00057  * use without further testing or modification.
00058  **************************************************************************/
00059 
00067 /*============================================================================*
00068   LPC177x_8x Windowed watchdog timer
00069  *============================================================================*/
00070 
00071 /*----------------------------------------------------------------------------*
00072   Some macros
00073  *----------------------------------------------------------------------------*/
00074 
00075 #define PPCLK_WDT   4000000
00076 
00077 /* Calculation macros, time is calculated by usec */
00078 #define WDT_GET_FROM_USEC(time)     (time/((WDT_US_INDEX * 4)/PPCLK_WDT))
00079 #define WDT_GET_USEC(counter)       (counter * ((WDT_US_INDEX * 4)/PPCLK_WDT))
00080 
00081 /*----------------------------------------------------------------------------*
00082   WDT Control register
00083  *----------------------------------------------------------------------------*/
00084 
00085 /* WDT interrupt enable bit */
00086 #define WDT_WDMOD_WDEN              _BV(0)
00087 /* WDT interrupt enable bit */
00088 #define WDT_WDMOD_WDRESET           _BV(1)
00089 /* WDT time out flag bit */
00090 #define WDT_WDMOD_WDTOF             _BV(2)
00091 /* WDT Time Out flag bit */
00092 #define WDT_WDMOD_WDINT             _BV(3)
00093 /* WDT Mode */
00094 #define WDT_WDMOD(n)                _BV(1)
00095 
00096 
00097 /*----------------------------------------------------------------------------*
00098   Some defines
00099  *----------------------------------------------------------------------------*/
00100 
00101 /* Define divider index for microsecond ( us ) */
00102 #define WDT_US_INDEX                1000000
00103 /* WDT Time out minimum value */
00104 #define WDT_TIMEOUT_MIN             0xFF
00105 /* WDT Time out maximum value */
00106 #define WDT_TIMEOUT_MAX             0xFFFFFFFF
00107 
00108 
00109 /* Watchdog mode register mask */
00110 #define WDT_WDMOD_MASK              0x02
00111 /* Watchdog timer constant register mask */
00112 #define WDT_WDTC_MASK               0xFFFFFFFF
00113 /* Watchdog feed sequence register mask */
00114 #define WDT_WDFEED_MASK             0x000000FF
00115 /* Watchdog timer value register mask */
00116 #define WDT_WDCLKSEL_MASK           0x03
00117 /* Clock selected from internal RC */
00118 #define WDT_WDCLKSEL_RC             0x00
00119 /* Clock selected from PCLK */
00120 #define WDT_WDCLKSEL_PCLK           0x01
00121 /* Clock selected from external RTC */
00122 #define WDT_WDCLKSEL_RTC            0x02
00123 
00124 
00125 /*----------------------------------------------------------------------------*
00126   WDT enums
00127  *----------------------------------------------------------------------------*/
00128 
00129 
00130 /* Clock source option for WDT */
00131 typedef enum {
00132     WDT_CLKSRC_IRC  = 0,   
00133     WDT_CLKSRC_PCLK = 1,   
00134     WDT_CLKSRC_RTC  = 2    
00135 } WDT_CLK_OPT;
00136 
00137 #define PARAM_WDT_CLK_OPT(OPTION) ((OPTION ==WDT_CLKSRC_IRC)||\
00138                                   (OPTION ==WDT_CLKSRC_IRC)||\
00139                                   (OPTION ==WDT_CLKSRC_IRC))
00140 
00141 /* WDT operation mode */
00142 typedef enum {
00143     WDT_MODE_INT_ONLY = 0, 
00144     WDT_MODE_RESET    = 1  
00145 } WDT_MODE_OPT;
00146 
00147 #define PARAM_WDT_MODE_OPT(OPTION)  ((OPTION ==WDT_MODE_INT_ONLY)||\
00148                                   (OPTION ==WDT_MODE_RESET))
00149 
00150 #endif /* _LPC176X_WDT_H_ */