main.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * @file : main.c
  5. * @brief : Main program body
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2022 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* USER CODE END Header */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "main.h"
  21. #include "usb_device.h"
  22. /* Private includes ----------------------------------------------------------*/
  23. /* USER CODE BEGIN Includes */
  24. //#include "cc1200.h"
  25. //#include "cc1200_protocol.h"
  26. #include "usbd_cdc_if.h"
  27. #include "cc1200.h"
  28. #include "cc1200_protocol.h"
  29. /* USER CODE END Includes */
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* USER CODE BEGIN PTD */
  32. /* USER CODE END PTD */
  33. /* Private define ------------------------------------------------------------*/
  34. /* USER CODE BEGIN PD */
  35. /* USER CODE END PD */
  36. /* Private macro -------------------------------------------------------------*/
  37. /* USER CODE BEGIN PM */
  38. /* USER CODE END PM */
  39. /* Private variables ---------------------------------------------------------*/
  40. TIM_HandleTypeDef htim3;
  41. /* USER CODE BEGIN PV */
  42. /* USER CODE END PV */
  43. /* Private function prototypes -----------------------------------------------*/
  44. void SystemClock_Config(void);
  45. static void MX_GPIO_Init(void);
  46. static void MX_SPI1_Init(void);
  47. static void MX_TIM3_Init(void);
  48. /* USER CODE BEGIN PFP */
  49. /* USER CODE END PFP */
  50. /* Private user code ---------------------------------------------------------*/
  51. /* USER CODE BEGIN 0 */
  52. static void SPI1_TransmitBytes(uint8_t *p_buf, uint8_t len)
  53. {
  54. LL_SPI_SetTransferSize(SPI1, len);
  55. LL_SPI_Enable(SPI1);
  56. LL_SPI_StartMasterTransfer(SPI1);
  57. switch(len)
  58. {
  59. case 1:
  60. LL_SPI_TransmitData8(SPI1, *p_buf);
  61. break;
  62. case 2:
  63. LL_SPI_TransmitData16(SPI1, *(uint16_t *)p_buf);
  64. break;
  65. default:
  66. assert(0);
  67. }
  68. // Wait until the transmission is complete
  69. while( LL_SPI_IsActiveFlag_EOT(SPI1) == 0);
  70. SPI1->IFCR = UINT32_MAX;
  71. LL_SPI_Disable(SPI1);
  72. }
  73. static uint8_t SPI1_ReceiveByte(void)
  74. {
  75. LL_SPI_SetTransferSize(SPI1, 1);
  76. LL_SPI_Enable(SPI1);
  77. LL_SPI_StartMasterTransfer(SPI1);
  78. LL_SPI_TransmitData8(SPI1, 0);
  79. // Wait until the transmission is complete
  80. while( LL_SPI_IsActiveFlag_EOT(SPI1) == 0);
  81. SPI1->IFCR = UINT32_MAX;
  82. LL_SPI_Disable(SPI1);
  83. return LL_SPI_ReceiveData8(SPI1);
  84. }
  85. static uint8_t txBuffer;
  86. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef * htim)
  87. {
  88. txBuffer = cc1200_radio_read_CFM();
  89. //cc1200_radio_write_CFM(0);
  90. CDC_Transmit_HS(&txBuffer, 1);
  91. // Toggle LED as heart beat.
  92. static uint32_t toggleCount = 0;
  93. if (toggleCount++ == 40000)
  94. {
  95. HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
  96. toggleCount = 0;
  97. }
  98. }
  99. /* USER CODE END 0 */
  100. /**
  101. * @brief The application entry point.
  102. * @retval int
  103. */
  104. int main(void)
  105. {
  106. /* USER CODE BEGIN 1 */
  107. /* USER CODE END 1 */
  108. /* Enable I-Cache---------------------------------------------------------*/
  109. SCB_EnableICache();
  110. /* Enable D-Cache---------------------------------------------------------*/
  111. SCB_EnableDCache();
  112. /* MCU Configuration--------------------------------------------------------*/
  113. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  114. HAL_Init();
  115. /* USER CODE BEGIN Init */
  116. /* USER CODE END Init */
  117. /* Configure the system clock */
  118. SystemClock_Config();
  119. /* USER CODE BEGIN SysInit */
  120. /* USER CODE END SysInit */
  121. /* Initialize all configured peripherals */
  122. MX_GPIO_Init();
  123. MX_SPI1_Init();
  124. MX_TIM3_Init();
  125. MX_USB_DEVICE_Init();
  126. /* USER CODE BEGIN 2 */
  127. HAL_StatusTypeDef errCode;
  128. // Manually reset the CC1200.
  129. HAL_GPIO_WritePin(CC1200_RESET_GPIO_Port, CC1200_RESET_Pin, 0);
  130. HAL_Delay(50);
  131. HAL_GPIO_WritePin(CC1200_RESET_GPIO_Port, CC1200_RESET_Pin, 1);
  132. HAL_Delay(50);
  133. // Setup up the 5million registers.
  134. cc1200_radio_init((cc1200_reg_settings_t *)AX25_SETTINGS, sizeof(AX25_SETTINGS)/sizeof(cc1200_reg_settings_t));
  135. // Set frequency
  136. cc1200_radio_frequency(144390000);
  137. // Enable TX/RX
  138. cc1200_radio_rx();
  139. // Start Timer for SPI
  140. errCode = HAL_TIM_Base_Start_IT(&htim3);
  141. /* USER CODE END 2 */
  142. /* Infinite loop */
  143. /* USER CODE BEGIN WHILE */
  144. while (1)
  145. {
  146. /* USER CODE END WHILE */
  147. /* USER CODE BEGIN 3 */
  148. }
  149. /* USER CODE END 3 */
  150. }
  151. /**
  152. * @brief System Clock Configuration
  153. * @retval None
  154. */
  155. void SystemClock_Config(void)
  156. {
  157. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  158. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  159. /** Supply configuration update enable
  160. */
  161. HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
  162. /** Configure the main internal regulator output voltage
  163. */
  164. __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
  165. while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
  166. /** Initializes the RCC Oscillators according to the specified parameters
  167. * in the RCC_OscInitTypeDef structure.
  168. */
  169. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
  170. RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  171. RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
  172. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  173. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  174. RCC_OscInitStruct.PLL.PLLM = 4;
  175. RCC_OscInitStruct.PLL.PLLN = 275;
  176. RCC_OscInitStruct.PLL.PLLP = 1;
  177. RCC_OscInitStruct.PLL.PLLQ = 4;
  178. RCC_OscInitStruct.PLL.PLLR = 2;
  179. RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_1;
  180. RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
  181. RCC_OscInitStruct.PLL.PLLFRACN = 0;
  182. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  183. {
  184. Error_Handler();
  185. }
  186. /** Initializes the CPU, AHB and APB buses clocks
  187. */
  188. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  189. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
  190. |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
  191. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  192. RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
  193. RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
  194. RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
  195. RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
  196. RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
  197. RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
  198. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
  199. {
  200. Error_Handler();
  201. }
  202. }
  203. /**
  204. * @brief SPI1 Initialization Function
  205. * @param None
  206. * @retval None
  207. */
  208. static void MX_SPI1_Init(void)
  209. {
  210. /* USER CODE BEGIN SPI1_Init 0 */
  211. /* USER CODE END SPI1_Init 0 */
  212. LL_SPI_InitTypeDef SPI_InitStruct = {0};
  213. LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
  214. RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
  215. /** Initializes the peripherals clock
  216. */
  217. PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI1;
  218. PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
  219. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
  220. {
  221. Error_Handler();
  222. }
  223. /* Peripheral clock enable */
  224. LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1);
  225. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOA);
  226. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOD);
  227. /**SPI1 GPIO Configuration
  228. PA5 ------> SPI1_SCK
  229. PA6 ------> SPI1_MISO
  230. PD7 ------> SPI1_MOSI
  231. */
  232. GPIO_InitStruct.Pin = LL_GPIO_PIN_5|LL_GPIO_PIN_6;
  233. GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
  234. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
  235. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  236. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  237. GPIO_InitStruct.Alternate = LL_GPIO_AF_5;
  238. LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  239. GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
  240. GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
  241. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
  242. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  243. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  244. GPIO_InitStruct.Alternate = LL_GPIO_AF_5;
  245. LL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  246. /* USER CODE BEGIN SPI1_Init 1 */
  247. /* USER CODE END SPI1_Init 1 */
  248. /* SPI1 parameter configuration*/
  249. SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
  250. SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
  251. SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
  252. SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW;
  253. SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE;
  254. SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
  255. SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32;
  256. SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
  257. SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
  258. SPI_InitStruct.CRCPoly = 0x0;
  259. LL_SPI_Init(SPI1, &SPI_InitStruct);
  260. LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
  261. LL_SPI_EnableNSSPulseMgt(SPI1);
  262. /* USER CODE BEGIN SPI1_Init 2 */
  263. /* USER CODE END SPI1_Init 2 */
  264. }
  265. /**
  266. * @brief TIM3 Initialization Function
  267. * @param None
  268. * @retval None
  269. */
  270. static void MX_TIM3_Init(void)
  271. {
  272. /* USER CODE BEGIN TIM3_Init 0 */
  273. /* USER CODE END TIM3_Init 0 */
  274. TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  275. TIM_MasterConfigTypeDef sMasterConfig = {0};
  276. /* USER CODE BEGIN TIM3_Init 1 */
  277. /* USER CODE END TIM3_Init 1 */
  278. htim3.Instance = TIM3;
  279. htim3.Init.Prescaler = 0;
  280. htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  281. htim3.Init.Period = 6875;
  282. htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  283. htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
  284. if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
  285. {
  286. Error_Handler();
  287. }
  288. sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  289. if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
  290. {
  291. Error_Handler();
  292. }
  293. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  294. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  295. if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  296. {
  297. Error_Handler();
  298. }
  299. /* USER CODE BEGIN TIM3_Init 2 */
  300. /* USER CODE END TIM3_Init 2 */
  301. }
  302. /**
  303. * @brief GPIO Initialization Function
  304. * @param None
  305. * @retval None
  306. */
  307. static void MX_GPIO_Init(void)
  308. {
  309. GPIO_InitTypeDef GPIO_InitStruct = {0};
  310. /* GPIO Ports Clock Enable */
  311. __HAL_RCC_GPIOC_CLK_ENABLE();
  312. __HAL_RCC_GPIOH_CLK_ENABLE();
  313. __HAL_RCC_GPIOA_CLK_ENABLE();
  314. __HAL_RCC_GPIOB_CLK_ENABLE();
  315. __HAL_RCC_GPIOD_CLK_ENABLE();
  316. __HAL_RCC_GPIOG_CLK_ENABLE();
  317. __HAL_RCC_GPIOE_CLK_ENABLE();
  318. /*Configure GPIO pin Output Level */
  319. HAL_GPIO_WritePin(GPIOB, LED_GREEN_Pin|CC1200_RESET_Pin|LED_RED_Pin, GPIO_PIN_RESET);
  320. /*Configure GPIO pin Output Level */
  321. HAL_GPIO_WritePin(CC1200_TCXO_ENABLE_GPIO_Port, CC1200_TCXO_ENABLE_Pin, GPIO_PIN_SET);
  322. /*Configure GPIO pin Output Level */
  323. HAL_GPIO_WritePin(USB_FS_PWR_EN_GPIO_Port, USB_FS_PWR_EN_Pin, GPIO_PIN_RESET);
  324. /*Configure GPIO pin Output Level */
  325. HAL_GPIO_WritePin(CC1200_CS_GPIO_Port, CC1200_CS_Pin, GPIO_PIN_SET);
  326. /*Configure GPIO pin Output Level */
  327. HAL_GPIO_WritePin(LED_YELLOW_GPIO_Port, LED_YELLOW_Pin, GPIO_PIN_RESET);
  328. /*Configure GPIO pin : B1_Pin */
  329. GPIO_InitStruct.Pin = B1_Pin;
  330. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  331. GPIO_InitStruct.Pull = GPIO_NOPULL;
  332. HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  333. /*Configure GPIO pins : PC1 PC4 PC5 */
  334. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
  335. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  336. GPIO_InitStruct.Pull = GPIO_NOPULL;
  337. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  338. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  339. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  340. /*Configure GPIO pins : PA1 PA2 PA7 */
  341. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
  342. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  343. GPIO_InitStruct.Pull = GPIO_NOPULL;
  344. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  345. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  346. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  347. /*Configure GPIO pins : LED_GREEN_Pin LED_RED_Pin */
  348. GPIO_InitStruct.Pin = LED_GREEN_Pin|LED_RED_Pin;
  349. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  350. GPIO_InitStruct.Pull = GPIO_NOPULL;
  351. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  352. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  353. /*Configure GPIO pins : CC1200_RESET_Pin CC1200_TCXO_ENABLE_Pin */
  354. GPIO_InitStruct.Pin = CC1200_RESET_Pin|CC1200_TCXO_ENABLE_Pin;
  355. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  356. GPIO_InitStruct.Pull = GPIO_NOPULL;
  357. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  358. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  359. /*Configure GPIO pin : PB13 */
  360. GPIO_InitStruct.Pin = GPIO_PIN_13;
  361. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  362. GPIO_InitStruct.Pull = GPIO_NOPULL;
  363. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  364. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  365. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  366. /*Configure GPIO pins : STLK_VCP_RX_Pin STLK_VCP_TX_Pin */
  367. GPIO_InitStruct.Pin = STLK_VCP_RX_Pin|STLK_VCP_TX_Pin;
  368. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  369. GPIO_InitStruct.Pull = GPIO_NOPULL;
  370. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  371. GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  372. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  373. /*Configure GPIO pin : USB_FS_PWR_EN_Pin */
  374. GPIO_InitStruct.Pin = USB_FS_PWR_EN_Pin;
  375. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  376. GPIO_InitStruct.Pull = GPIO_NOPULL;
  377. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  378. HAL_GPIO_Init(USB_FS_PWR_EN_GPIO_Port, &GPIO_InitStruct);
  379. /*Configure GPIO pin : USB_FS_OVCR_Pin */
  380. GPIO_InitStruct.Pin = USB_FS_OVCR_Pin;
  381. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  382. GPIO_InitStruct.Pull = GPIO_NOPULL;
  383. HAL_GPIO_Init(USB_FS_OVCR_GPIO_Port, &GPIO_InitStruct);
  384. /*Configure GPIO pin : CC1200_CS_Pin */
  385. GPIO_InitStruct.Pin = CC1200_CS_Pin;
  386. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  387. GPIO_InitStruct.Pull = GPIO_NOPULL;
  388. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  389. HAL_GPIO_Init(CC1200_CS_GPIO_Port, &GPIO_InitStruct);
  390. /*Configure GPIO pins : PG11 PG13 */
  391. GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_13;
  392. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  393. GPIO_InitStruct.Pull = GPIO_NOPULL;
  394. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  395. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  396. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  397. /*Configure GPIO pin : LED_YELLOW_Pin */
  398. GPIO_InitStruct.Pin = LED_YELLOW_Pin;
  399. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  400. GPIO_InitStruct.Pull = GPIO_NOPULL;
  401. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  402. HAL_GPIO_Init(LED_YELLOW_GPIO_Port, &GPIO_InitStruct);
  403. }
  404. /* USER CODE BEGIN 4 */
  405. /* USER CODE END 4 */
  406. /**
  407. * @brief This function is executed in case of error occurrence.
  408. * @retval None
  409. */
  410. void Error_Handler(void)
  411. {
  412. /* USER CODE BEGIN Error_Handler_Debug */
  413. /* User can add his own implementation to report the HAL error return state */
  414. __disable_irq();
  415. while (1)
  416. {
  417. }
  418. /* USER CODE END Error_Handler_Debug */
  419. }
  420. #ifdef USE_FULL_ASSERT
  421. /**
  422. * @brief Reports the name of the source file and the source line number
  423. * where the assert_param error has occurred.
  424. * @param file: pointer to the source file name
  425. * @param line: assert_param error line source number
  426. * @retval None
  427. */
  428. void assert_failed(uint8_t *file, uint32_t line)
  429. {
  430. /* USER CODE BEGIN 6 */
  431. /* User can add his own implementation to report the file name and line number,
  432. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  433. /* USER CODE END 6 */
  434. }
  435. #endif /* USE_FULL_ASSERT */