main(3557).c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. ** This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * COPYRIGHT(c) 2019 STMicroelectronics
  14. *
  15. * Redistribution and use in source and binary forms, with or without modification,
  16. * are permitted provided that the following conditions are met:
  17. * 1. Redistributions of source code must retain the above copyright notice,
  18. * this list of conditions and the following disclaimer.
  19. * 2. Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  23. * may be used to endorse or promote products derived from this software
  24. * without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  29. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  30. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  32. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  33. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  34. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. ******************************************************************************
  38. */
  39. /* USER CODE END Header */
  40. /* Includes ------------------------------------------------------------------*/
  41. #include "main.h"
  42. /* Private includes ----------------------------------------------------------*/
  43. /* USER CODE BEGIN Includes */
  44. /* USER CODE END Includes */
  45. /* Private typedef -----------------------------------------------------------*/
  46. /* USER CODE BEGIN PTD */
  47. uint8_t rx2_data[1];
  48. uint8_t rx1_data[1];
  49. uint8_t ring_buf[buf_size];
  50. volatile uint8_t count_in1 = 0;//, count_out = 0;
  51. volatile uint8_t count_in2 = 0;//, count_out = 0;
  52. uint8_t UartDataisReved;
  53. volatile uint32_t UartTimerCnt = 0;
  54. uint32_t LedTimerCnt = 0;
  55. uint8_t buf[buf_size] = {0,};
  56. /* USER CODE END PTD */
  57. /* Private define ------------------------------------------------------------*/
  58. /* USER CODE BEGIN PD */
  59. /* USER CODE END PD */
  60. /* Private macro -------------------------------------------------------------*/
  61. /* USER CODE BEGIN PM */
  62. /* USER CODE END PM */
  63. /* Private variables ---------------------------------------------------------*/
  64. I2C_HandleTypeDef hi2c1;
  65. TIM_HandleTypeDef htim7;
  66. UART_HandleTypeDef huart1;
  67. UART_HandleTypeDef huart2;
  68. /* USER CODE BEGIN PV */
  69. /* USER CODE END PV */
  70. /* Private function prototypes -----------------------------------------------*/
  71. void SystemClock_Config(void);
  72. static void MX_GPIO_Init(void);
  73. static void MX_USART1_UART_Init(void);
  74. static void MX_USART2_UART_Init(void);
  75. static void MX_TIM7_Init(void);
  76. static void MX_I2C1_Init(void);
  77. static void MX_NVIC_Init(void);
  78. /* USER CODE BEGIN PFP */
  79. void UartDataRecvSet(uint8_t val);
  80. uint8_t UartDataRecvGet(void);
  81. /* USER CODE END PFP */
  82. /* Private user code ---------------------------------------------------------*/
  83. /* USER CODE BEGIN 0 */
  84. void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
  85. {
  86. if(huart->Instance == USART1){
  87. buf[count_in1] = rx1_data[0];//(uint8_t)USART2->DR;
  88. if(buf[count_in1++] == 0xEB){
  89. if(buf[Bluecell_Length] == (count_in1 - 3))
  90. UartDataRecvSet(1);
  91. else
  92. count_in1 = 0;
  93. }
  94. HAL_UART_Receive_IT(&huart1,&rx1_data[0],1);
  95. }
  96. if(huart->Instance == USART2){
  97. buf[count_in2] = rx2_data[0];
  98. if(buf[count_in2++] == 0xEB){
  99. if(buf[Bluecell_Length] == (count_in2 - 3))
  100. UartDataRecvSet(2);
  101. else
  102. count_in2 = 0;
  103. }
  104. HAL_UART_Receive_IT(&huart2,&rx2_data[0],1);
  105. }
  106. }
  107. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
  108. {
  109. if(htim->Instance == TIM7){
  110. UartTimerCnt++;
  111. LedTimerCnt++;
  112. }
  113. }
  114. void UartDataRecvSet(uint8_t val){
  115. UartDataisReved = val;
  116. }
  117. uint8_t UartDataRecvGet(void){
  118. return UartDataisReved;
  119. }
  120. int _write (int file, uint8_t *ptr, uint16_t len)
  121. {
  122. HAL_UART_Transmit (&huart1, ptr, len, 10);
  123. return len;
  124. }
  125. void Uart1_Data_Send(uint8_t* data,uint8_t size){ //Firmware Download Cable
  126. HAL_UART_Transmit(&huart1, data,size, 10);
  127. }
  128. void Uart2_Data_Send(uint8_t* data,uint8_t size){ // Controller Comunication Cable
  129. HAL_UART_Transmit(&huart2, data,size, 10);
  130. }
  131. void Uart_dataCheck(uint8_t* cnt){
  132. etError crccheck = 0;
  133. #if 1 // PYJ.2019.03.17_BEGIN --
  134. for(uint8_t i = 0; i < (* cnt); i++){
  135. printf("%02x ",buf[i]);
  136. }
  137. printf("\r\n");
  138. #endif // PYJ.2019.03.17_END --
  139. crccheck = STH30_CheckCrc(&buf[Bluecell_Type],buf[Bluecell_Length],buf[buf[Bluecell_Length] + 1]);
  140. if(crccheck == CHECKSUM_ERROR){
  141. for(uint8_t i = 0; i < (*cnt); i++){
  142. printf("%02x ",buf[i]);
  143. }
  144. printf("Original CRC : %02x RecvCRC : %02x \r\n",crccheck,buf[buf[Bluecell_Length] + 1]);
  145. }
  146. else if(crccheck == NO_ERROR){
  147. RGB_Sensor_Func(&buf[blucell_stx]);
  148. }
  149. else{
  150. printf("What Happen?\r\n");
  151. }
  152. *cnt = 0;
  153. UartDataRecvSet(0);
  154. memset(buf,0x00,buf_size);
  155. }
  156. #define ADDR_FLASH_PAGE_TEST ((uint32_t)0x08007FF0) /* Base @ of Page 127, 1 Kbytes */
  157. #define FLASH_USER_START_ADDR ADDR_FLASH_PAGE_TEST /* Start @ of user Flash area */
  158. #define FLASH_USER_END_ADDR ADDR_FLASH_PAGE_TEST //+ ((uint32_t)0x0000000F) /* End @ of user Flash area */
  159. void Flash_write(uint8_t* data) // ?“°ê¸°í•¨?ˆ˜
  160. {
  161. /*Variable used for Erase procedure*/
  162. static FLASH_EraseInitTypeDef EraseInitStruct;
  163. uint32_t Address = 0, PAGEError = 0;
  164. uint16_t dataret = data[blucell_srcid] & 0x00FF;
  165. /* Fill EraseInit structure*/
  166. EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
  167. EraseInitStruct.PageAddress = FLASH_USER_START_ADDR;
  168. EraseInitStruct.Banks = FLASH_BANK_1;
  169. EraseInitStruct.NbPages = (FLASH_USER_END_ADDR - FLASH_USER_START_ADDR) / FLASH_PAGE_SIZE;
  170. Address = FLASH_USER_START_ADDR;
  171. __HAL_RCC_TIM7_CLK_DISABLE(); // 매ì�¸???�´ë¨¸ë?? ? •ì§??•©?‹ˆ?‹¤
  172. if(HAL_FLASH_Unlock() == HAL_OK) // lock ??�
  173. printf("Flash Unlock Success\r\n");
  174. else
  175. printf("Flash Unlock Failed\r\n");
  176. __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPERR);
  177. if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK){
  178. printf("Erase Failed \r\n");
  179. }else{
  180. printf("Erase Success \r\n");
  181. }
  182. if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,Address , (uint16_t)dataret) == HAL_OK){
  183. printf("Flash Write Success\r\n");
  184. }else{
  185. printf("Flash Write Failed\r\n");
  186. }
  187. if(HAL_FLASH_Lock() == HAL_OK) // lock ?ž ê·¸ê¸°
  188. printf("Flash lock Success\r\n");
  189. else
  190. printf("Flash lock Failed\r\n");
  191. __HAL_RCC_TIM7_CLK_ENABLE(); // 매ì�¸???�´ë¨¸ë?? ?ž¬?‹œ?ž‘?•©?‹ˆ?‹¤
  192. }
  193. void Flash_RGB_IDData_Write(uint32_t Addr,uint8_t* data){
  194. uint16_t temp_Red = 0,temp_Green = 0,temp_Blue = 0,temp_ret1 = 0,temp_ret2 = 0;
  195. HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,Addr + 0 , (uint16_t)temp_Red);
  196. }
  197. void Flash_InitRead(void) // ?“°ê¸°í•¨?ˆ˜
  198. {
  199. uint32_t Address = 0;
  200. Address = FLASH_USER_START_ADDR;
  201. My_RGB_ID = (*(uint16_t*)Address);
  202. printf("My id is %d ",My_RGB_ID);
  203. printf("%08x : %04X \n",Address ,*(uint16_t*)Address);
  204. }
  205. /* USER CODE END 0 */
  206. /**
  207. * @brief The application entry point.
  208. * @retval int
  209. */
  210. int main(void)
  211. {
  212. /* USER CODE BEGIN 1 */
  213. uint8_t tempdata[100] = {0,};
  214. /* USER CODE END 1 */
  215. /* MCU Configuration--------------------------------------------------------*/
  216. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  217. HAL_Init();
  218. /* USER CODE BEGIN Init */
  219. /* USER CODE END Init */
  220. /* Configure the system clock */
  221. SystemClock_Config();
  222. /* USER CODE BEGIN SysInit */
  223. /* USER CODE END SysInit */
  224. /* Initialize all configured peripherals */
  225. MX_GPIO_Init();
  226. MX_USART1_UART_Init();
  227. MX_USART2_UART_Init();
  228. MX_TIM7_Init();
  229. MX_I2C1_Init();
  230. /* Initialize interrupts */
  231. MX_NVIC_Init();
  232. /* USER CODE BEGIN 2 */
  233. HAL_TIM_Base_Start_IT(&htim7);
  234. HAL_UART_Receive_IT(&huart1, &rx1_data,1);
  235. HAL_UART_Receive_IT(&huart2, &rx2_data,1);
  236. setbuf(stdout, NULL); // \n ?��?��?��, printf �???????��?���?????? ?��?��?��
  237. #if 1 // PYJ.2019.03.04_BEGIN --
  238. printf("****************************************\r\n");
  239. printf("RGB Sensor Project\r\n");
  240. printf("Build at %s %s\r\n", __DATE__, __TIME__);
  241. printf("Copyright (c) 2019. BLUECELL\r\n");
  242. printf("****************************************\r\n");
  243. #endif // PYJ.2019.03.04_END --
  244. printf("My ID %02x \r\n",My_RGB_ID);
  245. // TCS34725_init();
  246. TCS34725_enable();
  247. uint8_t uartdatarecv = 0;
  248. /* USER CODE END 2 */
  249. /* Infinite loop */
  250. /* USER CODE BEGIN WHILE */
  251. while (1)
  252. {
  253. // HAL_Delay(500);
  254. // TCS34725_getrawdata();
  255. #if 1 // PYJ.2019.03.15_BEGIN --
  256. uartdatarecv = UartDataRecvGet();
  257. if(uartdatarecv != 0){
  258. if(uartdatarecv == 1){
  259. Uart_dataCheck(&count_in1);
  260. }else if(uartdatarecv == 2){
  261. Uart_dataCheck(&count_in2);
  262. }
  263. }
  264. else{
  265. if(LedTimerCnt > 100){
  266. TCS34725_getrawdata();
  267. HAL_GPIO_TogglePin(GPIOC,GPIO_PIN_15);
  268. LedTimerCnt = 0;
  269. }
  270. }
  271. #endif // PYJ.2019.03.15_END --
  272. /* USER CODE END WHILE */
  273. /* USER CODE BEGIN 3 */
  274. }
  275. /* USER CODE END 3 */
  276. }
  277. /**
  278. * @brief System Clock Configuration
  279. * @retval None
  280. */
  281. void SystemClock_Config(void)
  282. {
  283. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  284. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  285. /**Initializes the CPU, AHB and APB busses clocks
  286. */
  287. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  288. RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  289. RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  290. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  291. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  292. {
  293. Error_Handler();
  294. }
  295. /**Initializes the CPU, AHB and APB busses clocks
  296. */
  297. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  298. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  299. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  300. RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  301. RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  302. RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
  303. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  304. {
  305. Error_Handler();
  306. }
  307. }
  308. /**
  309. * @brief NVIC Configuration.
  310. * @retval None
  311. */
  312. static void MX_NVIC_Init(void)
  313. {
  314. /* USART1_IRQn interrupt configuration */
  315. HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
  316. HAL_NVIC_EnableIRQ(USART1_IRQn);
  317. /* USART2_IRQn interrupt configuration */
  318. HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
  319. HAL_NVIC_EnableIRQ(USART2_IRQn);
  320. /* TIM7_IRQn interrupt configuration */
  321. HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0);
  322. HAL_NVIC_EnableIRQ(TIM7_IRQn);
  323. }
  324. /**
  325. * @brief I2C1 Initialization Function
  326. * @param None
  327. * @retval None
  328. */
  329. static void MX_I2C1_Init(void)
  330. {
  331. /* USER CODE BEGIN I2C1_Init 0 */
  332. /* USER CODE END I2C1_Init 0 */
  333. /* USER CODE BEGIN I2C1_Init 1 */
  334. /* USER CODE END I2C1_Init 1 */
  335. hi2c1.Instance = I2C1;
  336. hi2c1.Init.ClockSpeed = 100000;
  337. hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  338. hi2c1.Init.OwnAddress1 = 0;
  339. hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  340. hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  341. hi2c1.Init.OwnAddress2 = 0;
  342. hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  343. hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  344. if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  345. {
  346. Error_Handler();
  347. }
  348. /* USER CODE BEGIN I2C1_Init 2 */
  349. /* USER CODE END I2C1_Init 2 */
  350. }
  351. /**
  352. * @brief TIM7 Initialization Function
  353. * @param None
  354. * @retval None
  355. */
  356. static void MX_TIM7_Init(void)
  357. {
  358. /* USER CODE BEGIN TIM7_Init 0 */
  359. /* USER CODE END TIM7_Init 0 */
  360. TIM_MasterConfigTypeDef sMasterConfig = {0};
  361. /* USER CODE BEGIN TIM7_Init 1 */
  362. /* USER CODE END TIM7_Init 1 */
  363. htim7.Instance = TIM7;
  364. htim7.Init.Prescaler = 800 - 1;
  365. htim7.Init.CounterMode = TIM_COUNTERMODE_UP;
  366. htim7.Init.Period = 10- 1;
  367. htim7.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
  368. if (HAL_TIM_Base_Init(&htim7) != HAL_OK)
  369. {
  370. Error_Handler();
  371. }
  372. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  373. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  374. if (HAL_TIMEx_MasterConfigSynchronization(&htim7, &sMasterConfig) != HAL_OK)
  375. {
  376. Error_Handler();
  377. }
  378. /* USER CODE BEGIN TIM7_Init 2 */
  379. /* USER CODE END TIM7_Init 2 */
  380. }
  381. /**
  382. * @brief USART1 Initialization Function
  383. * @param None
  384. * @retval None
  385. */
  386. static void MX_USART1_UART_Init(void)
  387. {
  388. /* USER CODE BEGIN USART1_Init 0 */
  389. /* USER CODE END USART1_Init 0 */
  390. /* USER CODE BEGIN USART1_Init 1 */
  391. /* USER CODE END USART1_Init 1 */
  392. huart1.Instance = USART1;
  393. huart1.Init.BaudRate = 115200;
  394. huart1.Init.WordLength = UART_WORDLENGTH_8B;
  395. huart1.Init.StopBits = UART_STOPBITS_1;
  396. huart1.Init.Parity = UART_PARITY_NONE;
  397. huart1.Init.Mode = UART_MODE_TX_RX;
  398. huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  399. huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  400. if (HAL_UART_Init(&huart1) != HAL_OK)
  401. {
  402. Error_Handler();
  403. }
  404. /* USER CODE BEGIN USART1_Init 2 */
  405. /* USER CODE END USART1_Init 2 */
  406. }
  407. /**
  408. * @brief USART2 Initialization Function
  409. * @param None
  410. * @retval None
  411. */
  412. static void MX_USART2_UART_Init(void)
  413. {
  414. /* USER CODE BEGIN USART2_Init 0 */
  415. /* USER CODE END USART2_Init 0 */
  416. /* USER CODE BEGIN USART2_Init 1 */
  417. /* USER CODE END USART2_Init 1 */
  418. huart2.Instance = USART2;
  419. huart2.Init.BaudRate = 115200;
  420. huart2.Init.WordLength = UART_WORDLENGTH_8B;
  421. huart2.Init.StopBits = UART_STOPBITS_1;
  422. huart2.Init.Parity = UART_PARITY_NONE;
  423. huart2.Init.Mode = UART_MODE_TX_RX;
  424. huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  425. huart2.Init.OverSampling = UART_OVERSAMPLING_16;
  426. if (HAL_UART_Init(&huart2) != HAL_OK)
  427. {
  428. Error_Handler();
  429. }
  430. /* USER CODE BEGIN USART2_Init 2 */
  431. /* USER CODE END USART2_Init 2 */
  432. }
  433. /**
  434. * @brief GPIO Initialization Function
  435. * @param None
  436. * @retval None
  437. */
  438. static void MX_GPIO_Init(void)
  439. {
  440. GPIO_InitTypeDef GPIO_InitStruct = {0};
  441. /* GPIO Ports Clock Enable */
  442. __HAL_RCC_GPIOC_CLK_ENABLE();
  443. __HAL_RCC_GPIOA_CLK_ENABLE();
  444. __HAL_RCC_GPIOB_CLK_ENABLE();
  445. /*Configure GPIO pin Output Level */
  446. HAL_GPIO_WritePin(GPIOC, GPIO_PIN_15, GPIO_PIN_RESET);
  447. /*Configure GPIO pin Output Level */
  448. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8|GPIO_PIN_15, GPIO_PIN_RESET);
  449. /*Configure GPIO pin Output Level */
  450. HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5, GPIO_PIN_RESET);
  451. /*Configure GPIO pin : PC15 */
  452. GPIO_InitStruct.Pin = GPIO_PIN_15;
  453. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  454. GPIO_InitStruct.Pull = GPIO_NOPULL;
  455. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  456. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  457. /*Configure GPIO pins : PA8 PA15 */
  458. GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_15;
  459. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  460. GPIO_InitStruct.Pull = GPIO_NOPULL;
  461. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  462. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  463. /*Configure GPIO pins : PB3 PB4 PB5 */
  464. GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5;
  465. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  466. GPIO_InitStruct.Pull = GPIO_NOPULL;
  467. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  468. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  469. }
  470. /* USER CODE BEGIN 4 */
  471. /* USER CODE END 4 */
  472. /**
  473. * @brief This function is executed in case of error occurrence.
  474. * @retval None
  475. */
  476. void Error_Handler(void)
  477. {
  478. /* USER CODE BEGIN Error_Handler_Debug */
  479. /* User can add his own implementation to report the HAL error return state */
  480. /* USER CODE END Error_Handler_Debug */
  481. }
  482. #ifdef USE_FULL_ASSERT
  483. /**
  484. * @brief Reports the name of the source file and the source line number
  485. * where the assert_param error has occurred.
  486. * @param file: pointer to the source file name
  487. * @param line: assert_param error line source number
  488. * @retval None
  489. */
  490. void assert_failed(uint8_t *file, uint32_t line)
  491. {
  492. /* USER CODE BEGIN 6 */
  493. /* User can add his own implementation to report the file name and line number,
  494. tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  495. /* USER CODE END 6 */
  496. }
  497. #endif /* USE_FULL_ASSERT */
  498. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/