lpc177x_8x_wwdt.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #ifndef _LPC177X_8X_WWDT_H_
  2. #define _LPC177X_8X_WWDT_H_
  3. /*
  4. * Copyright (C) 2012 by Ole Reinhardt (ole.reinhardt@embedded-it.de)
  5. *
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in the
  16. * documentation and/or other materials provided with the distribution.
  17. * 3. Neither the name of the copyright holders nor the names of
  18. * contributors may be used to endorse or promote products derived
  19. * from this software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  31. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * For additional information see http://www.ethernut.de/
  35. *
  36. **************************************************************************
  37. *
  38. * Parts taken from lpc177x_8x_rtc.h 2011-06-02
  39. * file lpc177x_8x_wwdt.h
  40. * brief Contains all macro definitions and function prototypes
  41. * support forWindow Watchdog Timer firmware library on LPC177x_8x
  42. * version 1.0
  43. * date 02. June. 2011
  44. * author NXP MCU SW Application Team
  45. *
  46. * Copyright(C) 2011, NXP Semiconductor
  47. * All rights reserved.
  48. *
  49. ***********************************************************************
  50. * Software that is described herein is for illustrative purposes only
  51. * which provides customers with programming information regarding the
  52. * products. This software is supplied "AS IS" without any warranties.
  53. * NXP Semiconductors assumes no responsibility or liability for the
  54. * use of the software, conveys no license or title under any patent,
  55. * copyright, or mask work right to the product. NXP Semiconductors
  56. * reserves the right to make changes in the software without
  57. * notification. NXP Semiconductors also make no representation or
  58. * warranty that such application will be suitable for the specified
  59. * use without further testing or modification.
  60. * Permission to use, copy, modify, and distribute this software and its
  61. * documentation is hereby granted, under NXP Semiconductors'
  62. * relevant copyright in the software, without fee, provided that it
  63. * is used in conjunction with NXP Semiconductors microcontrollers. This
  64. * copyright, permission, and disclaimer notice must appear in all copies of
  65. * this code.
  66. **********************************************************************/
  67. /*!
  68. * \verbatim
  69. * $Id: $
  70. * \endverbatim
  71. */
  72. /*============================================================================*
  73. LPC177x_8x Windowed watchdog timer
  74. *============================================================================*/
  75. /*----------------------------------------------------------------------------*
  76. Some macros
  77. *----------------------------------------------------------------------------*/
  78. /* Calculation macros, time is calculated by usec */
  79. #define WDT_GET_FROM_USEC(time) (time/((WDT_US_INDEX * 4)/WDT_OSC))
  80. #define WDT_GET_USEC(counter) (counter * ((WDT_US_INDEX * 4)/WDT_OSC))
  81. /*----------------------------------------------------------------------------*
  82. Bit definitions
  83. *----------------------------------------------------------------------------*/
  84. /* WDT interrupt enable bit */
  85. #define WDT_WDMOD_WDEN _BV(0)
  86. /* WDT interrupt enable bit */
  87. #define WDT_WDMOD_WDRESET _BV(1)
  88. /* WDT time out flag bit */
  89. #define WDT_WDMOD_WDTOF _BV(2)
  90. /* WDT Time Out flag bit */
  91. #define WDT_WDMOD_WDINT _BV(3)
  92. /* WDT Protect flag bit */
  93. #define WDT_WDMOD_WDPROTECT _BV(4)
  94. /* Define divider index for microsecond ( us ) */
  95. #define WDT_US_INDEX 1000000
  96. /* WDT Time out minimum value */
  97. #define WDT_TIMEOUT_MIN 0xFF
  98. /* WDT Time out maximum value */
  99. #define WDT_TIMEOUT_MAX 0x00FFFFFF
  100. /* WDT Warning minimum value */
  101. #define WDT_WARNINT_MIN 0xFF
  102. /* WDT Warning maximum value */
  103. #define WDT_WARNINT_MAX 0x000003FF
  104. /* WDT Windowed minimum value */
  105. #define WDT_WINDOW_MIN 0xFF
  106. /* WDT Windowed minimum value */
  107. #define WDT_WINDOW_MAX 0x00FFFFFF
  108. /* WDT timer constant register mask */
  109. #define WDT_WDTC_MASK 0x00FFFFFF
  110. /* WDT warning value register mask */
  111. #define WDT_WDWARNINT_MASK 0x000003FF
  112. /* WDT feed sequence register mask */
  113. #define WDT_WDFEED_MASK 0x000000FF
  114. /* WDT flag */
  115. #define WDT_WARNINT_FLAG 0
  116. #define WDT_TIMEOUT_FLAG 1
  117. /* WDT mode definitions */
  118. #define WDT_PROTECT_MODE 0
  119. #define WDT_RESET_MODE 1
  120. /* WDT Timer value definition (us) */
  121. #define WDT_TIMEOUT_USEC_MIN ((uint32_t)(WDT_GET_USEC(WDT_TIMEOUT_MIN)))
  122. #define WDT_TIMEOUT_USEC_MAX ((uint32_t)(WDT_GET_USEC(WDT_TIMEOUT_MAX)))
  123. #define WDT_TIMEWARN_USEC_MIN ((uint32_t)(WDT_GET_USEC(WDT_WARNINT_MIN)))
  124. #define WDT_TIMEWARN_USEC_MAX ((uint32_t)(WDT_GET_USEC(WDT_WARNINT_MAX)))
  125. #define WDT_TIMEWINDOWED_USEC_MIN ((uint32_t)(WDT_GET_USEC(WDT_WINDOW_MIN)))
  126. #define WDT_TIMEWINDOWED_USEC_MAX ((uint32_t)(WDT_GET_USEC(WDT_WINDOW_MAX)))
  127. #endif /* _LPC177X_8X_WWDT_H_ */