hw_conf.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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 by CPU2 to prevent the CPU1 to either write or erase data in flash
  31. * The CPU1 shall not either write or erase in flash when this semaphore is taken by the CPU2
  32. * When the CPU1 needs to either write or erase in flash, it shall first get the semaphore and release it just
  33. * after writing a raw (64bits data) or erasing one sector.
  34. * Once the Semaphore has been released, there shall be at least 1us before it can be taken again. This is required
  35. * to give the opportunity to CPU2 to take it.
  36. * On v1.4.0 and older CPU2 wireless firmware, this semaphore is unused and CPU2 is using PES bit.
  37. * By default, CPU2 is using the PES bit to protect its timing. The CPU1 may request the CPU2 to use the semaphore
  38. * instead of the PES bit by sending the system command SHCI_C2_SetFlashActivityControl()
  39. */
  40. #define CFG_HW_BLOCK_FLASH_REQ_BY_CPU2_SEMID 7
  41. /**
  42. * Index of the semaphore used by CPU1 to prevent the CPU2 to either write or erase data in flash
  43. * In order to protect its timing, the CPU1 may get this semaphore to prevent the CPU2 to either
  44. * write or erase in flash (as this will stall both CPUs)
  45. * The PES bit shall not be used as this may stall the CPU2 in some cases.
  46. */
  47. #define CFG_HW_BLOCK_FLASH_REQ_BY_CPU1_SEMID 6
  48. /**
  49. * Index of the semaphore used to manage the CLK48 clock configuration
  50. * When the USB is required, this semaphore shall be taken before configuring te CLK48 for USB
  51. * and should be released after the application switch OFF the clock when the USB is not used anymore
  52. * When using the RNG, it is good enough to use CFG_HW_RNG_SEMID to control CLK48.
  53. * More details in AN5289
  54. */
  55. #define CFG_HW_CLK48_CONFIG_SEMID 5
  56. /* Index of the semaphore used to manage the entry Stop Mode procedure */
  57. #define CFG_HW_ENTRY_STOP_MODE_SEMID 4
  58. /* Index of the semaphore used to access the RCC */
  59. #define CFG_HW_RCC_SEMID 3
  60. /* Index of the semaphore used to access the FLASH */
  61. #define CFG_HW_FLASH_SEMID 2
  62. /* Index of the semaphore used to access the PKA */
  63. #define CFG_HW_PKA_SEMID 1
  64. /* Index of the semaphore used to access the RNG */
  65. #define CFG_HW_RNG_SEMID 0
  66. /******************************************************************************
  67. * HW TIMER SERVER
  68. *****************************************************************************/
  69. /**
  70. * The user may define the maximum number of virtual timers supported.
  71. * It shall not exceed 255
  72. */
  73. #define CFG_HW_TS_MAX_NBR_CONCURRENT_TIMER 6
  74. /**
  75. * The user may define the priority in the NVIC of the RTC_WKUP interrupt handler that is used to manage the
  76. * wakeup timer.
  77. * This setting is the preemptpriority part of the NVIC.
  78. */
  79. #define CFG_HW_TS_NVIC_RTC_WAKEUP_IT_PREEMPTPRIO (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1) /* FreeRTOS requirement */
  80. /**
  81. * The user may define the priority in the NVIC of the RTC_WKUP interrupt handler that is used to manage the
  82. * wakeup timer.
  83. * This setting is the subpriority part of the NVIC. It does not exist on all processors. When it is not supported
  84. * on the CPU, the setting is ignored
  85. */
  86. #define CFG_HW_TS_NVIC_RTC_WAKEUP_IT_SUBPRIO 0
  87. /**
  88. * Define a critical section in the Timer server
  89. * The Timer server does not support the API to be nested
  90. * The Application shall either:
  91. * a) Ensure this will never happen
  92. * b) Define the critical section
  93. * The default implementations is masking all interrupts using the PRIMASK bit
  94. * The TimerServer driver uses critical sections to avoid context corruption. This is achieved with the macro
  95. * TIMER_ENTER_CRITICAL_SECTION and TIMER_EXIT_CRITICAL_SECTION. When CFG_HW_TS_USE_PRIMASK_AS_CRITICAL_SECTION is set
  96. * to 1, all STM32 interrupts are masked with the PRIMASK bit of the CortexM CPU. It is possible to use the BASEPRI
  97. * register of the CortexM CPU to keep allowed some interrupts with high priority. In that case, the user shall
  98. * re-implement TIMER_ENTER_CRITICAL_SECTION and TIMER_EXIT_CRITICAL_SECTION and shall make sure that no TimerServer
  99. * API are called when the TIMER critical section is entered
  100. */
  101. #define CFG_HW_TS_USE_PRIMASK_AS_CRITICAL_SECTION 1
  102. /**
  103. * This value shall reflect the maximum delay there could be in the application between the time the RTC interrupt
  104. * is generated by the Hardware and the time when the RTC interrupt handler is called. This time is measured in
  105. * number of RTCCLK ticks.
  106. * A relaxed timing would be 10ms
  107. * When the value is too short, the timerserver will not be able to count properly and all timeout may be random.
  108. * When the value is too long, the device may wake up more often than the most optimal configuration. However, the
  109. * impact on power consumption would be marginal (unless the value selected is extremely too long). It is strongly
  110. * recommended to select a value large enough to make sure it is not too short to ensure reliability of the system
  111. * as this will have marginal impact on low power mode
  112. */
  113. #define CFG_HW_TS_RTC_HANDLER_MAX_DELAY ( 10 * (LSI_VALUE/1000) )
  114. /**
  115. * Interrupt ID in the NVIC of the RTC Wakeup interrupt handler
  116. * It shall be type of IRQn_Type
  117. */
  118. #define CFG_HW_TS_RTC_WAKEUP_HANDLER_ID RTC_WKUP_IRQn
  119. /******************************************************************************
  120. * HW UART
  121. *****************************************************************************/
  122. #define CFG_HW_LPUART1_ENABLED 0
  123. #define CFG_HW_LPUART1_DMA_TX_SUPPORTED 0
  124. #define CFG_HW_USART1_ENABLED 1
  125. #define CFG_HW_USART1_DMA_TX_SUPPORTED 1
  126. /**
  127. * UART1
  128. */
  129. #define CFG_HW_USART1_PREEMPTPRIORITY 0x0F
  130. #define CFG_HW_USART1_SUBPRIORITY 0
  131. /** < The application shall check the selected source clock is enable */
  132. #define CFG_HW_USART1_SOURCE_CLOCK RCC_USART1CLKSOURCE_SYSCLK
  133. #define CFG_HW_USART1_BAUDRATE 115200
  134. #define CFG_HW_USART1_WORDLENGTH UART_WORDLENGTH_8B
  135. #define CFG_HW_USART1_STOPBITS UART_STOPBITS_1
  136. #define CFG_HW_USART1_PARITY UART_PARITY_NONE
  137. #define CFG_HW_USART1_HWFLOWCTL UART_HWCONTROL_NONE
  138. #define CFG_HW_USART1_MODE UART_MODE_TX_RX
  139. #define CFG_HW_USART1_ADVFEATUREINIT UART_ADVFEATURE_NO_INIT
  140. #define CFG_HW_USART1_OVERSAMPLING UART_OVERSAMPLING_8
  141. #define CFG_HW_USART1_TX_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
  142. #define CFG_HW_USART1_TX_PORT GPIOB
  143. #define CFG_HW_USART1_TX_PIN GPIO_PIN_6
  144. #define CFG_HW_USART1_TX_MODE GPIO_MODE_AF_PP
  145. #define CFG_HW_USART1_TX_PULL GPIO_NOPULL
  146. #define CFG_HW_USART1_TX_SPEED GPIO_SPEED_FREQ_VERY_HIGH
  147. #define CFG_HW_USART1_TX_ALTERNATE GPIO_AF7_USART1
  148. #define CFG_HW_USART1_RX_PORT_CLK_ENABLE __HAL_RCC_GPIOB_CLK_ENABLE
  149. #define CFG_HW_USART1_RX_PORT GPIOB
  150. #define CFG_HW_USART1_RX_PIN GPIO_PIN_7
  151. #define CFG_HW_USART1_RX_MODE GPIO_MODE_AF_PP
  152. #define CFG_HW_USART1_RX_PULL GPIO_NOPULL
  153. #define CFG_HW_USART1_RX_SPEED GPIO_SPEED_FREQ_VERY_HIGH
  154. #define CFG_HW_USART1_RX_ALTERNATE GPIO_AF7_USART1
  155. #define CFG_HW_USART1_CTS_PORT_CLK_ENABLE __HAL_RCC_GPIOA_CLK_ENABLE
  156. #define CFG_HW_USART1_CTS_PORT GPIOA
  157. #define CFG_HW_USART1_CTS_PIN GPIO_PIN_11
  158. #define CFG_HW_USART1_CTS_MODE GPIO_MODE_AF_PP
  159. #define CFG_HW_USART1_CTS_PULL GPIO_PULLDOWN
  160. #define CFG_HW_USART1_CTS_SPEED GPIO_SPEED_FREQ_VERY_HIGH
  161. #define CFG_HW_USART1_CTS_ALTERNATE GPIO_AF7_USART1
  162. #define CFG_HW_USART1_DMA_TX_PREEMPTPRIORITY 0x0F
  163. #define CFG_HW_USART1_DMA_TX_SUBPRIORITY 0
  164. #define CFG_HW_USART1_DMAMUX_CLK_ENABLE __HAL_RCC_DMAMUX1_CLK_ENABLE
  165. #define CFG_HW_USART1_DMA_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE
  166. #define CFG_HW_USART1_TX_DMA_REQ DMA_REQUEST_USART1_TX
  167. #define CFG_HW_USART1_TX_DMA_CHANNEL DMA2_Channel4
  168. #define CFG_HW_USART1_TX_DMA_IRQn DMA2_Channel4_IRQn
  169. #define CFG_HW_USART1_DMA_TX_IRQHandler DMA2_Channel4_IRQHandler
  170. #endif /*HW_CONF_H */
  171. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/