main.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. /**
  2. ******************************************************************************
  3. * @file : main.c
  4. * @brief : Main program body
  5. ******************************************************************************
  6. ******************************************************************************
  7. */
  8. /* Includes ------------------------------------------------------------------*/
  9. #include "main.h"
  10. #include "stm32f1xx_hal.h"
  11. #include "spi.h"
  12. #include "usart.h"
  13. #include "gpio.h"
  14. /* USER CODE BEGIN Includes */
  15. #include "EPD_Test.h"
  16. /* USER CODE END Includes */
  17. /* Private variables ---------------------------------------------------------*/
  18. /* USER CODE BEGIN PV */
  19. /* Private variables ---------------------------------------------------------*/
  20. /* USER CODE END PV */
  21. /* Private function prototypes -----------------------------------------------*/
  22. void SystemClock_Config(void);
  23. /* USER CODE BEGIN PFP */
  24. /* Private function prototypes -----------------------------------------------*/
  25. /* USER CODE END PFP */
  26. /* USER CODE BEGIN 0 */
  27. /* USER CODE END 0 */
  28. /**
  29. * @brief The application entry point.
  30. *
  31. * @retval None
  32. */
  33. int main(void)
  34. {
  35. /* USER CODE BEGIN 1 */
  36. /* USER CODE END 1 */
  37. /* MCU Configuration----------------------------------------------------------*/
  38. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  39. HAL_Init();
  40. /* USER CODE BEGIN Init */
  41. /* USER CODE END Init */
  42. /* Configure the system clock */
  43. SystemClock_Config();
  44. /* USER CODE BEGIN SysInit */
  45. /* USER CODE END SysInit */
  46. /* Initialize all configured peripherals */
  47. MX_GPIO_Init();
  48. MX_USART1_UART_Init();
  49. MX_SPI1_Init();
  50. /* USER CODE BEGIN 2 */
  51. // EPD_1in02d_test();
  52. // EPD_1in54_test();
  53. // EPD_1in54_V2_test();
  54. // EPD_1in54b_test();
  55. // EPD_1in54b_V2_test();
  56. // EPD_1in54c_test();
  57. // EPD_2in7_test();
  58. // EPD_2in7b_test();
  59. // EPD_2in9_test();
  60. // EPD_2in9_V2_test();
  61. // EPD_2in9bc_test();
  62. // EPD_2in9b_V3_test();
  63. // EPD_2in9d_test();
  64. // EPD_2in13_test();
  65. // EPD_2in13_V2_test();
  66. // EPD_2in13bc_test();
  67. // EPD_2in13b_V3_test();
  68. // EPD_2in13d_test();
  69. // EPD_2in66_test();
  70. // EPD_2in66b_test();
  71. // EPD_3in7_test();
  72. // EPD_4in01f_test();
  73. // EPD_4in2_test();
  74. // EPD_4in2bc_test();
  75. // EPD_4in2b_V2_test();
  76. // EPD_5in65f_test();
  77. // EPD_5in83_test();
  78. // EPD_5in83_V2_test();
  79. // EPD_5in83bc_test();
  80. // EPD_5in83b_V2_test();
  81. // EPD_7in5_test();
  82. // EPD_7in5_V2_test();
  83. // EPD_7in5bc_test();
  84. // EPD_7in5b_V2_test();
  85. // EPD_7in5_HD_test();
  86. // EPD_7in5b_HD_test();
  87. /* USER CODE END 2 */
  88. /* Infinite loop */
  89. /* USER CODE BEGIN WHILE */
  90. while (1) {
  91. /* USER CODE END WHILE */
  92. /* USER CODE BEGIN 3 */
  93. HAL_Delay(10000);
  94. }
  95. /* USER CODE END 3 */
  96. }
  97. /**
  98. * @brief System Clock Configuration
  99. * @retval None
  100. */
  101. void SystemClock_Config(void)
  102. {
  103. RCC_OscInitTypeDef RCC_OscInitStruct;
  104. RCC_ClkInitTypeDef RCC_ClkInitStruct;
  105. /**Initializes the CPU, AHB and APB busses clocks
  106. */
  107. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  108. RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  109. RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
  110. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  111. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  112. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  113. RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
  114. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
  115. _Error_Handler(__FILE__, __LINE__);
  116. }
  117. /**Initializes the CPU, AHB and APB busses clocks
  118. */
  119. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  120. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  121. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  122. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  123. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  124. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  125. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
  126. _Error_Handler(__FILE__, __LINE__);
  127. }
  128. /**Configure the Systick interrupt time
  129. */
  130. HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
  131. /**Configure the Systick
  132. */
  133. HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
  134. /* SysTick_IRQn interrupt configuration */
  135. HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
  136. }
  137. /* USER CODE BEGIN 4 */
  138. /* USER CODE END 4 */
  139. /**
  140. * @brief This function is executed in case of error occurrence.
  141. * @param file: The file name as string.
  142. * @param line: The line in file as a number.
  143. * @retval None
  144. */
  145. void _Error_Handler(char *file, int line)
  146. {
  147. /* USER CODE BEGIN Error_Handler_Debug */
  148. /* User can add his own implementation to report the HAL error return state */
  149. while(1) {
  150. printf("_Error_Handler\r\n");
  151. }
  152. /* USER CODE END Error_Handler_Debug */
  153. }
  154. #ifdef USE_FULL_ASSERT
  155. /**
  156. * @brief Reports the name of the source file and the source line number
  157. * where the assert_param error has occurred.
  158. * @param file: pointer to the source file name
  159. * @param line: assert_param error line source number
  160. * @retval None
  161. */
  162. void assert_failed(uint8_t* file, uint32_t line)
  163. {
  164. /* USER CODE BEGIN 6 */
  165. /* User can add his own implementation to report the file name and line number,
  166. tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  167. /* USER CODE END 6 */
  168. }
  169. #endif /* USE_FULL_ASSERT */
  170. /**
  171. * @}
  172. */
  173. /**
  174. * @}
  175. */
  176. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/