Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

276 lines
10 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx.h
  4. * @author MCD Application Team
  5. * @brief CMSIS STM32F1xx Device Peripheral Access Layer Header File.
  6. *
  7. * The file is the unique include file that the application programmer
  8. * is using in the C source code, usually in main.c. This file contains:
  9. * - Configuration section that allows to select:
  10. * - The STM32F1xx device used in the target application
  11. * - To use or not the peripheral’s drivers in application code(i.e.
  12. * code will be based on direct access to peripheral’s registers
  13. * rather than drivers API), this option is controlled by
  14. * "#define USE_HAL_DRIVER"
  15. *
  16. ******************************************************************************
  17. * @attention
  18. *
  19. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  20. * All rights reserved.</center></h2>
  21. *
  22. * This software component is licensed by ST under BSD 3-Clause license,
  23. * the "License"; You may not use this file except in compliance with the
  24. * License. You may obtain a copy of the License at:
  25. * opensource.org/licenses/BSD-3-Clause
  26. *
  27. ******************************************************************************
  28. */
  29. /** @addtogroup CMSIS
  30. * @{
  31. */
  32. /** @addtogroup stm32f1xx
  33. * @{
  34. */
  35. #ifndef __STM32F1XX_H
  36. #define __STM32F1XX_H
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif /* __cplusplus */
  40. /** @addtogroup Library_configuration_section
  41. * @{
  42. */
  43. /**
  44. * @brief STM32 Family
  45. */
  46. #if !defined (STM32F1)
  47. #define STM32F1
  48. #endif /* STM32F1 */
  49. /* Uncomment the line below according to the target STM32L device used in your
  50. application
  51. */
  52. #if !defined (STM32F100xB) && !defined (STM32F100xE) && !defined (STM32F101x6) && \
  53. !defined (STM32F101xB) && !defined (STM32F101xE) && !defined (STM32F101xG) && !defined (STM32F102x6) && !defined (STM32F102xB) && !defined (STM32F103x6) && \
  54. !defined (STM32F103xB) && !defined (STM32F103xE) && !defined (STM32F103xG) && !defined (STM32F105xC) && !defined (STM32F107xC)
  55. /* #define STM32F100xB */ /*!< STM32F100C4, STM32F100R4, STM32F100C6, STM32F100R6, STM32F100C8, STM32F100R8, STM32F100V8, STM32F100CB, STM32F100RB and STM32F100VB */
  56. /* #define STM32F100xE */ /*!< STM32F100RC, STM32F100VC, STM32F100ZC, STM32F100RD, STM32F100VD, STM32F100ZD, STM32F100RE, STM32F100VE and STM32F100ZE */
  57. /* #define STM32F101x6 */ /*!< STM32F101C4, STM32F101R4, STM32F101T4, STM32F101C6, STM32F101R6 and STM32F101T6 Devices */
  58. /* #define STM32F101xB */ /*!< STM32F101C8, STM32F101R8, STM32F101T8, STM32F101V8, STM32F101CB, STM32F101RB, STM32F101TB and STM32F101VB */
  59. /* #define STM32F101xE */ /*!< STM32F101RC, STM32F101VC, STM32F101ZC, STM32F101RD, STM32F101VD, STM32F101ZD, STM32F101RE, STM32F101VE and STM32F101ZE */
  60. /* #define STM32F101xG */ /*!< STM32F101RF, STM32F101VF, STM32F101ZF, STM32F101RG, STM32F101VG and STM32F101ZG */
  61. /* #define STM32F102x6 */ /*!< STM32F102C4, STM32F102R4, STM32F102C6 and STM32F102R6 */
  62. /* #define STM32F102xB */ /*!< STM32F102C8, STM32F102R8, STM32F102CB and STM32F102RB */
  63. /* #define STM32F103x6 */ /*!< STM32F103C4, STM32F103R4, STM32F103T4, STM32F103C6, STM32F103R6 and STM32F103T6 */
  64. /* #define STM32F103xB */ /*!< STM32F103C8, STM32F103R8, STM32F103T8, STM32F103V8, STM32F103CB, STM32F103RB, STM32F103TB and STM32F103VB */
  65. /* #define STM32F103xE */ /*!< STM32F103RC, STM32F103VC, STM32F103ZC, STM32F103RD, STM32F103VD, STM32F103ZD, STM32F103RE, STM32F103VE and STM32F103ZE */
  66. /* #define STM32F103xG */ /*!< STM32F103RF, STM32F103VF, STM32F103ZF, STM32F103RG, STM32F103VG and STM32F103ZG */
  67. /* #define STM32F105xC */ /*!< STM32F105R8, STM32F105V8, STM32F105RB, STM32F105VB, STM32F105RC and STM32F105VC */
  68. /* #define STM32F107xC */ /*!< STM32F107RB, STM32F107VB, STM32F107RC and STM32F107VC */
  69. #endif
  70. /* Tip: To avoid modifying this file each time you need to switch between these
  71. devices, you can define the device in your toolchain compiler preprocessor.
  72. */
  73. #if !defined (USE_HAL_DRIVER)
  74. /**
  75. * @brief Comment the line below if you will not use the peripherals drivers.
  76. In this case, these drivers will not be included and the application code will
  77. be based on direct access to peripherals registers
  78. */
  79. /*#define USE_HAL_DRIVER */
  80. #endif /* USE_HAL_DRIVER */
  81. /**
  82. * @brief CMSIS Device version number V4.3.3
  83. */
  84. #define __STM32F1_CMSIS_VERSION_MAIN (0x04) /*!< [31:24] main version */
  85. #define __STM32F1_CMSIS_VERSION_SUB1 (0x03) /*!< [23:16] sub1 version */
  86. #define __STM32F1_CMSIS_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */
  87. #define __STM32F1_CMSIS_VERSION_RC (0x00) /*!< [7:0] release candidate */
  88. #define __STM32F1_CMSIS_VERSION ((__STM32F1_CMSIS_VERSION_MAIN << 24)\
  89. |(__STM32F1_CMSIS_VERSION_SUB1 << 16)\
  90. |(__STM32F1_CMSIS_VERSION_SUB2 << 8 )\
  91. |(__STM32F1_CMSIS_VERSION_RC))
  92. /**
  93. * @}
  94. */
  95. /** @addtogroup Device_Included
  96. * @{
  97. */
  98. #if defined(STM32F100xB)
  99. #include "stm32f100xb.h"
  100. #elif defined(STM32F100xE)
  101. #include "stm32f100xe.h"
  102. #elif defined(STM32F101x6)
  103. #include "stm32f101x6.h"
  104. #elif defined(STM32F101xB)
  105. #include "stm32f101xb.h"
  106. #elif defined(STM32F101xE)
  107. #include "stm32f101xe.h"
  108. #elif defined(STM32F101xG)
  109. #include "stm32f101xg.h"
  110. #elif defined(STM32F102x6)
  111. #include "stm32f102x6.h"
  112. #elif defined(STM32F102xB)
  113. #include "stm32f102xb.h"
  114. #elif defined(STM32F103x6)
  115. #include "stm32f103x6.h"
  116. #elif defined(STM32F103xB)
  117. #include "stm32f103xb.h"
  118. #elif defined(STM32F103xE)
  119. #include "stm32f103xe.h"
  120. #elif defined(STM32F103xG)
  121. #include "stm32f103xg.h"
  122. #elif defined(STM32F105xC)
  123. #include "stm32f105xc.h"
  124. #elif defined(STM32F107xC)
  125. #include "stm32f107xc.h"
  126. #else
  127. #error "Please select first the target STM32F1xx device used in your application (in stm32f1xx.h file)"
  128. #endif
  129. /**
  130. * @}
  131. */
  132. /** @addtogroup Exported_types
  133. * @{
  134. */
  135. typedef enum
  136. {
  137. RESET = 0,
  138. SET = !RESET
  139. } FlagStatus, ITStatus;
  140. typedef enum
  141. {
  142. DISABLE = 0,
  143. ENABLE = !DISABLE
  144. } FunctionalState;
  145. #define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))
  146. typedef enum
  147. {
  148. SUCCESS = 0U,
  149. ERROR = !SUCCESS
  150. } ErrorStatus;
  151. /**
  152. * @}
  153. */
  154. /** @addtogroup Exported_macros
  155. * @{
  156. */
  157. #define SET_BIT(REG, BIT) ((REG) |= (BIT))
  158. #define CLEAR_BIT(REG, BIT) ((REG) &= ~(BIT))
  159. #define READ_BIT(REG, BIT) ((REG) & (BIT))
  160. #define CLEAR_REG(REG) ((REG) = (0x0))
  161. #define WRITE_REG(REG, VAL) ((REG) = (VAL))
  162. #define READ_REG(REG) ((REG))
  163. #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK)))
  164. #define POSITION_VAL(VAL) (__CLZ(__RBIT(VAL)))
  165. /* Use of CMSIS compiler intrinsics for register exclusive access */
  166. /* Atomic 32-bit register access macro to set one or several bits */
  167. #define ATOMIC_SET_BIT(REG, BIT) \
  168. do { \
  169. uint32_t val; \
  170. do { \
  171. val = __LDREXW((__IO uint32_t *)&(REG)) | (BIT); \
  172. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  173. } while(0)
  174. /* Atomic 32-bit register access macro to clear one or several bits */
  175. #define ATOMIC_CLEAR_BIT(REG, BIT) \
  176. do { \
  177. uint32_t val; \
  178. do { \
  179. val = __LDREXW((__IO uint32_t *)&(REG)) & ~(BIT); \
  180. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  181. } while(0)
  182. /* Atomic 32-bit register access macro to clear and set one or several bits */
  183. #define ATOMIC_MODIFY_REG(REG, CLEARMSK, SETMASK) \
  184. do { \
  185. uint32_t val; \
  186. do { \
  187. val = (__LDREXW((__IO uint32_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  188. } while ((__STREXW(val,(__IO uint32_t *)&(REG))) != 0U); \
  189. } while(0)
  190. /* Atomic 16-bit register access macro to set one or several bits */
  191. #define ATOMIC_SETH_BIT(REG, BIT) \
  192. do { \
  193. uint16_t val; \
  194. do { \
  195. val = __LDREXH((__IO uint16_t *)&(REG)) | (BIT); \
  196. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  197. } while(0)
  198. /* Atomic 16-bit register access macro to clear one or several bits */
  199. #define ATOMIC_CLEARH_BIT(REG, BIT) \
  200. do { \
  201. uint16_t val; \
  202. do { \
  203. val = __LDREXH((__IO uint16_t *)&(REG)) & ~(BIT); \
  204. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  205. } while(0)
  206. /* Atomic 16-bit register access macro to clear and set one or several bits */
  207. #define ATOMIC_MODIFYH_REG(REG, CLEARMSK, SETMASK) \
  208. do { \
  209. uint16_t val; \
  210. do { \
  211. val = (__LDREXH((__IO uint16_t *)&(REG)) & ~(CLEARMSK)) | (SETMASK); \
  212. } while ((__STREXH(val,(__IO uint16_t *)&(REG))) != 0U); \
  213. } while(0)
  214. /**
  215. * @}
  216. */
  217. #if defined (USE_HAL_DRIVER)
  218. #include "stm32f1xx_hal.h"
  219. #endif /* USE_HAL_DRIVER */
  220. #ifdef __cplusplus
  221. }
  222. #endif /* __cplusplus */
  223. #endif /* __STM32F1xx_H */
  224. /**
  225. * @}
  226. */
  227. /**
  228. * @}
  229. */
  230. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/