hw_conf.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file hw_conf.h
  5. * @author MCD Application Team
  6. * @brief Configuration of hardware interface
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under Ultimate Liberty license
  14. * SLA0044, the "License"; You may not use this file except in compliance with
  15. * the License. You may obtain a copy of the License at:
  16. * www.st.com/SLA0044
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef HW_CONF_H
  23. #define HW_CONF_H
  24. #include "FreeRTOSConfig.h"
  25. /******************************************************************************
  26. * Semaphores
  27. * THIS SHALL NO BE CHANGED AS THESE SEMAPHORES ARE USED AS WELL ON THE CM0+
  28. *****************************************************************************/
  29. /**
  30. * Index of the semaphore used the prevent conflicts after standby sleep.
  31. * Each CPUs takes this semaphore at standby wakeup until conclicting elements are restored.
  32. */
  33. #define CFG_HW_PWR_STANDBY_SEMID 10
  34. /**
  35. * The CPU2 may be configured to store the Thread persistent data either in internal NVM storage on CPU2 or in
  36. * SRAM2 buffer provided by the user application. This can be configured with the system command SHCI_C2_Config()
  37. * When the CPU2 is requested to store persistent data in SRAM2, it can write data in this buffer at any time when needed.
  38. * In order to read consistent data with the CPU1 from the SRAM2 buffer, the flow should be:
  39. * + CPU1 takes CFG_HW_THREAD_NVM_SRAM_SEMID semaphore
  40. * + CPU1 reads all persistent data from SRAM2 (most of the time, the goal is to write these data into an NVM managed by CPU1)
  41. * + CPU1 releases CFG_HW_THREAD_NVM_SRAM_SEMID semaphore
  42. * CFG_HW_THREAD_NVM_SRAM_SEMID semaphore makes sure CPU2 does not update the persistent data in SRAM2 at the same time CPU1 is reading them.
  43. * There is no timing constraint on how long this semaphore can be kept.
  44. */
  45. #define CFG_HW_THREAD_NVM_SRAM_SEMID 9
  46. /**
  47. * The CPU2 may be configured to store the BLE persistent data either in internal NVM storage on CPU2 or in
  48. * SRAM2 buffer provided by the user application. This can be configured with the system command SHCI_C2_Config()
  49. * When the CPU2 is requested to store persistent data in SRAM2, it can write data in this buffer at any time when needed.
  50. * In order to read consistent data with the CPU1 from the SRAM2 buffer, the flow should be:
  51. * + CPU1 takes CFG_HW_BLE_NVM_SRAM_SEMID semaphore
  52. * + CPU1 reads all persistent data from SRAM2 (most of the time, the goal is to write these data into an NVM managed by CPU1)
  53. * + CPU1 releases CFG_HW_BLE_NVM_SRAM_SEMID semaphore
  54. * CFG_HW_BLE_NVM_SRAM_SEMID semaphore makes sure CPU2 does not update the persistent data in SRAM2 at the same time CPU1 is reading them.
  55. * There is no timing constraint on how long this semaphore can be kept.
  56. */
  57. #define CFG_HW_BLE_NVM_SRAM_SEMID 8
  58. /**
  59. * Index of the semaphore used by CPU2 to prevent the CPU1 to either write or erase data in flash
  60. * The CPU1 shall not either write or erase in flash when this semaphore is taken by the CPU2
  61. * When the CPU1 needs to either write or erase in flash, it shall first get the semaphore and release it just
  62. * after writing a raw (64bits data) or erasing one sector.
  63. * Once the Semaphore has been released, there shall be at least 1us before it can be taken again. This is required
  64. * to give the opportunity to CPU2 to take it.
  65. * On v1.4.0 and older CPU2 wireless firmware, this semaphore is unused and CPU2 is using PES bit.
  66. * By default, CPU2 is using the PES bit to protect its timing. The CPU1 may request the CPU2 to use the semaphore
  67. * instead of the PES bit by sending the system command SHCI_C2_SetFlashActivityControl()
  68. */
  69. #define CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID 7
  70. /**
  71. * Index of the semaphore used by CPU1 to prevent the CPU2 to either write or erase data in flash
  72. * In order to protect its timing, the CPU1 may get this semaphore to prevent the CPU2 to either
  73. * write or erase in flash (as this will stall both CPUs)
  74. * The PES bit shall not be used as this may stall the CPU2 in some cases.
  75. */
  76. #define CFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID 6
  77. /**
  78. * Index of the semaphore used to manage the CLK48 clock configuration
  79. * When the USB is required, this semaphore shall be taken before configuring te CLK48 for USB
  80. * and should be released after the application switch OFF the clock when the USB is not used anymore
  81. * When using the RNG, it is good enough to use CFG_HW_RNG_SEMID to control CLK48.
  82. * More details in AN5289
  83. */
  84. #define CFG_HW_CLK48_CONFIG_SEMID 5
  85. /* Index of the semaphore used to manage the entry Stop Mode procedure */
  86. #define CFG_HW_ENTRY_STOP_MODE_SEMID 4
  87. /* Index of the semaphore used to access the RCC */
  88. #define CFG_HW_RCC_SEMID 3
  89. /* Index of the semaphore used to access the FLASH */
  90. #define CFG_HW_FLASH_SEMID 2
  91. /* Index of the semaphore used to access the PKA */
  92. #define CFG_HW_PKA_SEMID 1
  93. /* Index of the semaphore used to access the RNG */
  94. #define CFG_HW_RNG_SEMID 0
  95. /******************************************************************************
  96. * HW TIMER SERVER
  97. *****************************************************************************/
  98. /**
  99. * The user may define the maximum number of virtual timers supported.
  100. * It shall not exceed 255
  101. */
  102. #define CFG_HW_TS_MAX_NBR_CONCURRENT_TIMER 6
  103. /**
  104. * The user may define the priority in the NVIC of the RTC_WKUP interrupt handler that is used to manage the
  105. * wakeup timer.
  106. * This setting is the preemptpriority part of the NVIC.
  107. */
  108. #define CFG_HW_TS_NVIC_RTC_WAKEUP_IT_PREEMPTPRIO \
  109. (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1) /* FreeRTOS requirement */
  110. /**
  111. * The user may define the priority in the NVIC of the RTC_WKUP interrupt handler that is used to manage the
  112. * wakeup timer.
  113. * This setting is the subpriority part of the NVIC. It does not exist on all processors. When it is not supported
  114. * on the CPU, the setting is ignored
  115. */
  116. #define CFG_HW_TS_NVIC_RTC_WAKEUP_IT_SUBPRIO 0
  117. /**
  118. * Define a critical section in the Timer server
  119. * The Timer server does not support the API to be nested
  120. * The Application shall either:
  121. * a) Ensure this will never happen
  122. * b) Define the critical section
  123. * The default implementations is masking all interrupts using the PRIMASK bit
  124. * The TimerServer driver uses critical sections to avoid context corruption. This is achieved with the macro
  125. * TIMER_ENTER_CRITICAL_SECTION and TIMER_EXIT_CRITICAL_SECTION. When CFG_HW_TS_USE_PRIMASK_AS_CRITICAL_SECTION is set
  126. * to 1, all STM32 interrupts are masked with the PRIMASK bit of the CortexM CPU. It is possible to use the BASEPRI
  127. * register of the CortexM CPU to keep allowed some interrupts with high priority. In that case, the user shall
  128. * re-implement TIMER_ENTER_CRITICAL_SECTION and TIMER_EXIT_CRITICAL_SECTION and shall make sure that no TimerServer
  129. * API are called when the TIMER critical section is entered
  130. */
  131. #define CFG_HW_TS_USE_PRIMASK_AS_CRITICAL_SECTION 1
  132. /**
  133. * This value shall reflect the maximum delay there could be in the application between the time the RTC interrupt
  134. * is generated by the Hardware and the time when the RTC interrupt handler is called. This time is measured in
  135. * number of RTCCLK ticks.
  136. * A relaxed timing would be 10ms
  137. * When the value is too short, the timerserver will not be able to count properly and all timeout may be random.
  138. * When the value is too long, the device may wake up more often than the most optimal configuration. However, the
  139. * impact on power consumption would be marginal (unless the value selected is extremely too long). It is strongly
  140. * recommended to select a value large enough to make sure it is not too short to ensure reliability of the system
  141. * as this will have marginal impact on low power mode
  142. */
  143. #define CFG_HW_TS_RTC_HANDLER_MAX_DELAY (10 * (LSI_VALUE / 1000))
  144. /**
  145. * Interrupt ID in the NVIC of the RTC Wakeup interrupt handler
  146. * It shall be type of IRQn_Type
  147. */
  148. #define CFG_HW_TS_RTC_WAKEUP_HANDLER_ID RTC_WKUP_IRQn
  149. /******************************************************************************
  150. * HW UART
  151. *****************************************************************************/
  152. #define CFG_HW_LPUART1_ENABLED 0
  153. #define CFG_HW_LPUART1_DMA_TX_SUPPORTED 0
  154. #define CFG_HW_USART1_ENABLED 1
  155. #define CFG_HW_USART1_DMA_TX_SUPPORTED 1
  156. /**
  157. * UART1
  158. */
  159. #define CFG_HW_USART1_PREEMPTPRIORITY 0x0F
  160. #define CFG_HW_USART1_SUBPRIORITY 0
  161. /** < The application shall check the selected source clock is enable */
  162. #define CFG_HW_USART1_SOURCE_CLOCK RCC_USART1CLKSOURCE_SYSCLK
  163. #define CFG_HW_USART1_BAUDRATE 115200
  164. #define CFG_HW_USART1_WORDLENGTH UART_WORDLENGTH_8B
  165. #define CFG_HW_USART1_STOPBITS UART_STOPBITS_1
  166. #define CFG_HW_USART1_PARITY UART_PARITY_NONE
  167. #define CFG_HW_USART1_HWFLOWCTL UART_HWCONTROL_NONE
  168. #define CFG_HW_USART1_MODE UART_MODE_TX_RX
  169. #define CFG_HW_USART1_ADVFEATUREINIT UART_ADVFEATURE_NO_INIT
  170. #define CFG_HW_USART1_OVERSAMPLING UART_OVERSAMPLING_8
  171. #define CFG_HW_USART1_TX_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
  172. #define CFG_HW_USART1_TX_PORT GPIOB
  173. #define CFG_HW_USART1_TX_PIN GPIO_PIN_6
  174. #define CFG_HW_USART1_TX_MODE GPIO_MODE_AF_PP
  175. #define CFG_HW_USART1_TX_PULL GPIO_NOPULL
  176. #define CFG_HW_USART1_TX_SPEED GPIO_SPEED_FREQ_VERY_HIGH
  177. #define CFG_HW_USART1_TX_ALTERNATE GPIO_AF7_USART1
  178. #define CFG_HW_USART1_RX_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
  179. #define CFG_HW_USART1_RX_PORT GPIOB
  180. #define CFG_HW_USART1_RX_PIN GPIO_PIN_7
  181. #define CFG_HW_USART1_RX_MODE GPIO_MODE_AF_PP
  182. #define CFG_HW_USART1_RX_PULL GPIO_NOPULL
  183. #define CFG_HW_USART1_RX_SPEED GPIO_SPEED_FREQ_VERY_HIGH
  184. #define CFG_HW_USART1_RX_ALTERNATE GPIO_AF7_USART1
  185. #define CFG_HW_USART1_CTS_PORT_CLK_ENABLE __HAL_RCC_GPIOA_CLK_ENABLE
  186. #define CFG_HW_USART1_CTS_PORT GPIOA
  187. #define CFG_HW_USART1_CTS_PIN GPIO_PIN_11
  188. #define CFG_HW_USART1_CTS_MODE GPIO_MODE_AF_PP
  189. #define CFG_HW_USART1_CTS_PULL GPIO_PULLDOWN
  190. #define CFG_HW_USART1_CTS_SPEED GPIO_SPEED_FREQ_VERY_HIGH
  191. #define CFG_HW_USART1_CTS_ALTERNATE GPIO_AF7_USART1
  192. #define CFG_HW_USART1_DMA_TX_PREEMPTPRIORITY 0x0F
  193. #define CFG_HW_USART1_DMA_TX_SUBPRIORITY 0
  194. #define CFG_HW_USART1_DMAMUX_CLK_ENABLE __HAL_RCC_DMAMUX1_CLK_ENABLE
  195. #define CFG_HW_USART1_DMA_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
  196. #define CFG_HW_USART1_TX_DMA_REQ DMA_REQUEST_USART1_TX
  197. #define CFG_HW_USART1_TX_DMA_CHANNEL DMA2_Channel4
  198. #define CFG_HW_USART1_TX_DMA_IRQn DMA2_Channel4_IRQn
  199. #define CFG_HW_USART1_DMA_TX_IRQHandler DMA2_Channel4_IRQHandler
  200. #endif /*HW_CONF_H */
  201. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/