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.
 
 
 
 
 
 

247 lines
6.0 KiB

  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : stm32l1xx_hal_msp.c
  5. * Description : This file provides code for the MSP Initialization
  6. * and de-Initialization codes.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "main.h"
  23. /* USER CODE BEGIN Includes */
  24. /* USER CODE END Includes */
  25. /* Private typedef -----------------------------------------------------------*/
  26. /* USER CODE BEGIN TD */
  27. /* USER CODE END TD */
  28. /* Private define ------------------------------------------------------------*/
  29. /* USER CODE BEGIN Define */
  30. /* USER CODE END Define */
  31. /* Private macro -------------------------------------------------------------*/
  32. /* USER CODE BEGIN Macro */
  33. /* USER CODE END Macro */
  34. /* Private variables ---------------------------------------------------------*/
  35. /* USER CODE BEGIN PV */
  36. /* USER CODE END PV */
  37. /* Private function prototypes -----------------------------------------------*/
  38. /* USER CODE BEGIN PFP */
  39. /* USER CODE END PFP */
  40. /* External functions --------------------------------------------------------*/
  41. /* USER CODE BEGIN ExternalFunctions */
  42. /* USER CODE END ExternalFunctions */
  43. /* USER CODE BEGIN 0 */
  44. /* USER CODE END 0 */
  45. /**
  46. * Initializes the Global MSP.
  47. */
  48. void HAL_MspInit(void)
  49. {
  50. /* USER CODE BEGIN MspInit 0 */
  51. /* USER CODE END MspInit 0 */
  52. __HAL_RCC_COMP_CLK_ENABLE();
  53. __HAL_RCC_SYSCFG_CLK_ENABLE();
  54. __HAL_RCC_PWR_CLK_ENABLE();
  55. /* System interrupt init*/
  56. /* USER CODE BEGIN MspInit 1 */
  57. /* USER CODE END MspInit 1 */
  58. }
  59. /**
  60. * @brief RTC MSP Initialization
  61. * This function configures the hardware resources used in this example
  62. * @param hrtc: RTC handle pointer
  63. * @retval None
  64. */
  65. void HAL_RTC_MspInit(RTC_HandleTypeDef* hrtc)
  66. {
  67. if(hrtc->Instance==RTC)
  68. {
  69. /* USER CODE BEGIN RTC_MspInit 0 */
  70. /* USER CODE END RTC_MspInit 0 */
  71. /* Peripheral clock enable */
  72. __HAL_RCC_RTC_ENABLE();
  73. /* USER CODE BEGIN RTC_MspInit 1 */
  74. /* USER CODE END RTC_MspInit 1 */
  75. }
  76. }
  77. /**
  78. * @brief RTC MSP De-Initialization
  79. * This function freeze the hardware resources used in this example
  80. * @param hrtc: RTC handle pointer
  81. * @retval None
  82. */
  83. void HAL_RTC_MspDeInit(RTC_HandleTypeDef* hrtc)
  84. {
  85. if(hrtc->Instance==RTC)
  86. {
  87. /* USER CODE BEGIN RTC_MspDeInit 0 */
  88. /* USER CODE END RTC_MspDeInit 0 */
  89. /* Peripheral clock disable */
  90. __HAL_RCC_RTC_DISABLE();
  91. /* USER CODE BEGIN RTC_MspDeInit 1 */
  92. /* USER CODE END RTC_MspDeInit 1 */
  93. }
  94. }
  95. /**
  96. * @brief SPI MSP Initialization
  97. * This function configures the hardware resources used in this example
  98. * @param hspi: SPI handle pointer
  99. * @retval None
  100. */
  101. void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
  102. {
  103. GPIO_InitTypeDef GPIO_InitStruct = {0};
  104. if(hspi->Instance==SPI1)
  105. {
  106. /* USER CODE BEGIN SPI1_MspInit 0 */
  107. /* USER CODE END SPI1_MspInit 0 */
  108. /* Peripheral clock enable */
  109. __HAL_RCC_SPI1_CLK_ENABLE();
  110. __HAL_RCC_GPIOA_CLK_ENABLE();
  111. /**SPI1 GPIO Configuration
  112. PA5 ------> SPI1_SCK
  113. PA6 ------> SPI1_MISO
  114. PA7 ------> SPI1_MOSI
  115. */
  116. GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
  117. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  118. GPIO_InitStruct.Pull = GPIO_NOPULL;
  119. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  120. GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
  121. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  122. /* USER CODE BEGIN SPI1_MspInit 1 */
  123. /* USER CODE END SPI1_MspInit 1 */
  124. }
  125. }
  126. /**
  127. * @brief SPI MSP De-Initialization
  128. * This function freeze the hardware resources used in this example
  129. * @param hspi: SPI handle pointer
  130. * @retval None
  131. */
  132. void HAL_SPI_MspDeInit(SPI_HandleTypeDef* hspi)
  133. {
  134. if(hspi->Instance==SPI1)
  135. {
  136. /* USER CODE BEGIN SPI1_MspDeInit 0 */
  137. /* USER CODE END SPI1_MspDeInit 0 */
  138. /* Peripheral clock disable */
  139. __HAL_RCC_SPI1_CLK_DISABLE();
  140. /**SPI1 GPIO Configuration
  141. PA5 ------> SPI1_SCK
  142. PA6 ------> SPI1_MISO
  143. PA7 ------> SPI1_MOSI
  144. */
  145. HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7);
  146. /* USER CODE BEGIN SPI1_MspDeInit 1 */
  147. /* USER CODE END SPI1_MspDeInit 1 */
  148. }
  149. }
  150. /**
  151. * @brief TIM_Base MSP Initialization
  152. * This function configures the hardware resources used in this example
  153. * @param htim_base: TIM_Base handle pointer
  154. * @retval None
  155. */
  156. void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
  157. {
  158. if(htim_base->Instance==TIM4)
  159. {
  160. /* USER CODE BEGIN TIM4_MspInit 0 */
  161. /* USER CODE END TIM4_MspInit 0 */
  162. /* Peripheral clock enable */
  163. __HAL_RCC_TIM4_CLK_ENABLE();
  164. /* TIM4 interrupt Init */
  165. HAL_NVIC_SetPriority(TIM4_IRQn, 2, 0);
  166. HAL_NVIC_EnableIRQ(TIM4_IRQn);
  167. /* USER CODE BEGIN TIM4_MspInit 1 */
  168. /* USER CODE END TIM4_MspInit 1 */
  169. }
  170. }
  171. /**
  172. * @brief TIM_Base MSP De-Initialization
  173. * This function freeze the hardware resources used in this example
  174. * @param htim_base: TIM_Base handle pointer
  175. * @retval None
  176. */
  177. void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
  178. {
  179. if(htim_base->Instance==TIM4)
  180. {
  181. /* USER CODE BEGIN TIM4_MspDeInit 0 */
  182. /* USER CODE END TIM4_MspDeInit 0 */
  183. /* Peripheral clock disable */
  184. __HAL_RCC_TIM4_CLK_DISABLE();
  185. /* TIM4 interrupt DeInit */
  186. HAL_NVIC_DisableIRQ(TIM4_IRQn);
  187. /* USER CODE BEGIN TIM4_MspDeInit 1 */
  188. /* USER CODE END TIM4_MspDeInit 1 */
  189. }
  190. }
  191. /* USER CODE BEGIN 1 */
  192. /* USER CODE END 1 */
  193. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/