n32g45x_iwdg.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*****************************************************************************
  2. * Copyright (c) 2019, Nations Technologies Inc.
  3. *
  4. * All rights reserved.
  5. * ****************************************************************************
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the disclaimer below.
  12. *
  13. * Nations' name may not be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. *
  16. * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  19. * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  22. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. * ****************************************************************************/
  27. /**
  28. * @file n32g45x_iwdg.h
  29. * @author Nations
  30. * @version v1.0.0
  31. *
  32. * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
  33. */
  34. #ifndef __N32G45X_IWDG_H__
  35. #define __N32G45X_IWDG_H__
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #include "n32g45x.h"
  40. /** @addtogroup N32G45X_StdPeriph_Driver
  41. * @{
  42. */
  43. /** @addtogroup IWDG
  44. * @{
  45. */
  46. /** @addtogroup IWDG_Exported_Types
  47. * @{
  48. */
  49. /**
  50. * @}
  51. */
  52. /** @addtogroup IWDG_Exported_Constants
  53. * @{
  54. */
  55. /** @addtogroup IWDG_WriteAccess
  56. * @{
  57. */
  58. #define IWDG_WRITE_ENABLE ((uint16_t)0x5555)
  59. #define IWDG_WRITE_DISABLE ((uint16_t)0x0000)
  60. #define IS_IWDG_WRITE(ACCESS) (((ACCESS) == IWDG_WRITE_ENABLE) || ((ACCESS) == IWDG_WRITE_DISABLE))
  61. /**
  62. * @}
  63. */
  64. /** @addtogroup IWDG_prescaler
  65. * @{
  66. */
  67. #define IWDG_PRESCALER_DIV4 ((uint8_t)0x00)
  68. #define IWDG_PRESCALER_DIV8 ((uint8_t)0x01)
  69. #define IWDG_PRESCALER_DIV16 ((uint8_t)0x02)
  70. #define IWDG_PRESCALER_DIV32 ((uint8_t)0x03)
  71. #define IWDG_PRESCALER_DIV64 ((uint8_t)0x04)
  72. #define IWDG_PRESCALER_DIV128 ((uint8_t)0x05)
  73. #define IWDG_PRESCALER_DIV256 ((uint8_t)0x06)
  74. #define IS_IWDG_PRESCALER_DIV(PRESCALER) \
  75. (((PRESCALER) == IWDG_PRESCALER_DIV4) || ((PRESCALER) == IWDG_PRESCALER_DIV8) \
  76. || ((PRESCALER) == IWDG_PRESCALER_DIV16) || ((PRESCALER) == IWDG_PRESCALER_DIV32) \
  77. || ((PRESCALER) == IWDG_PRESCALER_DIV64) || ((PRESCALER) == IWDG_PRESCALER_DIV128) \
  78. || ((PRESCALER) == IWDG_PRESCALER_DIV256))
  79. /**
  80. * @}
  81. */
  82. /** @addtogroup IWDG_Flag
  83. * @{
  84. */
  85. #define IWDG_PVU_FLAG ((uint16_t)0x0001)
  86. #define IWDG_CRVU_FLAG ((uint16_t)0x0002)
  87. #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_PVU_FLAG) || ((FLAG) == IWDG_CRVU_FLAG))
  88. #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF)
  89. /**
  90. * @}
  91. */
  92. /**
  93. * @}
  94. */
  95. /** @addtogroup IWDG_Exported_Macros
  96. * @{
  97. */
  98. /**
  99. * @}
  100. */
  101. /** @addtogroup IWDG_Exported_Functions
  102. * @{
  103. */
  104. void IWDG_WriteConfig(uint16_t IWDG_WriteAccess);
  105. void IWDG_SetPrescalerDiv(uint8_t IWDG_Prescaler);
  106. void IWDG_CntReload(uint16_t Reload);
  107. void IWDG_ReloadKey(void);
  108. void IWDG_Enable(void);
  109. FlagStatus IWDG_GetStatus(uint16_t IWDG_FLAG);
  110. #ifdef __cplusplus
  111. }
  112. #endif
  113. #endif /* __N32G45X_IWDG_H__ */
  114. /**
  115. * @}
  116. */
  117. /**
  118. * @}
  119. */
  120. /**
  121. * @}
  122. */