main.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  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 txBuffer0[2000];
  86. static uint8_t txBuffer1[2000];
  87. static uint32_t i=0, j=0;
  88. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef * htim)
  89. {
  90. if (i == 2000 && j < 2000)
  91. txBuffer1[j++] = cc1200_radio_read_CFM();
  92. else if (i < 2000)
  93. txBuffer0[i++] = cc1200_radio_read_CFM();
  94. else
  95. {
  96. HAL_GPIO_TogglePin(LED_YELLOW_GPIO_Port, LED_YELLOW_Pin);
  97. }
  98. //cc1200_radio_write_CFM(0);
  99. // Toggle LED as heart beat.
  100. static uint32_t toggleCount = 0;
  101. if (toggleCount++ == 40000)
  102. {
  103. HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
  104. toggleCount = 0;
  105. }
  106. }
  107. /* USER CODE END 0 */
  108. /**
  109. * @brief The application entry point.
  110. * @retval int
  111. */
  112. int main(void)
  113. {
  114. /* USER CODE BEGIN 1 */
  115. /* USER CODE END 1 */
  116. /* Enable I-Cache---------------------------------------------------------*/
  117. SCB_EnableICache();
  118. /* Enable D-Cache---------------------------------------------------------*/
  119. SCB_EnableDCache();
  120. /* MCU Configuration--------------------------------------------------------*/
  121. /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  122. HAL_Init();
  123. /* USER CODE BEGIN Init */
  124. /* USER CODE END Init */
  125. /* Configure the system clock */
  126. SystemClock_Config();
  127. /* USER CODE BEGIN SysInit */
  128. /* USER CODE END SysInit */
  129. /* Initialize all configured peripherals */
  130. MX_GPIO_Init();
  131. MX_SPI1_Init();
  132. MX_TIM3_Init();
  133. MX_USB_DEVICE_Init();
  134. /* USER CODE BEGIN 2 */
  135. HAL_StatusTypeDef errCode;
  136. // Manually reset the CC1200.
  137. HAL_GPIO_WritePin(CC1200_RESET_GPIO_Port, CC1200_RESET_Pin, 0);
  138. HAL_Delay(50);
  139. HAL_GPIO_WritePin(CC1200_RESET_GPIO_Port, CC1200_RESET_Pin, 1);
  140. HAL_Delay(50);
  141. // Setup up the 5million registers.
  142. cc1200_radio_init((cc1200_reg_settings_t *)AX25_SETTINGS, sizeof(AX25_SETTINGS)/sizeof(cc1200_reg_settings_t));
  143. // Set frequency
  144. cc1200_radio_frequency(144390000);
  145. // Enable TX/RX
  146. cc1200_radio_rx();
  147. // Start Timer for SPI
  148. errCode = HAL_TIM_Base_Start_IT(&htim3);
  149. /* USER CODE END 2 */
  150. /* Infinite loop */
  151. /* USER CODE BEGIN WHILE */
  152. while (1)
  153. {
  154. if (i >= 2000)
  155. {
  156. if(CDC_Transmit_HS(txBuffer0, 2000) != USBD_OK)
  157. {
  158. HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
  159. }
  160. i = 0;
  161. }
  162. if (j >= 2000)
  163. {
  164. if(CDC_Transmit_HS(txBuffer1, 2000) != USBD_OK)
  165. {
  166. HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
  167. }
  168. j = 0;
  169. }
  170. /* USER CODE END WHILE */
  171. /* USER CODE BEGIN 3 */
  172. }
  173. /* USER CODE END 3 */
  174. }
  175. /**
  176. * @brief System Clock Configuration
  177. * @retval None
  178. */
  179. void SystemClock_Config(void)
  180. {
  181. RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  182. RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  183. /** Supply configuration update enable
  184. */
  185. HAL_PWREx_ConfigSupply(PWR_LDO_SUPPLY);
  186. /** Configure the main internal regulator output voltage
  187. */
  188. __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE0);
  189. while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {}
  190. /** Initializes the RCC Oscillators according to the specified parameters
  191. * in the RCC_OscInitTypeDef structure.
  192. */
  193. RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
  194. RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS;
  195. RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
  196. RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  197. RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  198. RCC_OscInitStruct.PLL.PLLM = 4;
  199. RCC_OscInitStruct.PLL.PLLN = 275;
  200. RCC_OscInitStruct.PLL.PLLP = 1;
  201. RCC_OscInitStruct.PLL.PLLQ = 4;
  202. RCC_OscInitStruct.PLL.PLLR = 2;
  203. RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_1;
  204. RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
  205. RCC_OscInitStruct.PLL.PLLFRACN = 0;
  206. if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  207. {
  208. Error_Handler();
  209. }
  210. /** Initializes the CPU, AHB and APB buses clocks
  211. */
  212. RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
  213. |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
  214. |RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1;
  215. RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  216. RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
  217. RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
  218. RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
  219. RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
  220. RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
  221. RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
  222. if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
  223. {
  224. Error_Handler();
  225. }
  226. }
  227. /**
  228. * @brief SPI1 Initialization Function
  229. * @param None
  230. * @retval None
  231. */
  232. static void MX_SPI1_Init(void)
  233. {
  234. /* USER CODE BEGIN SPI1_Init 0 */
  235. /* USER CODE END SPI1_Init 0 */
  236. LL_SPI_InitTypeDef SPI_InitStruct = {0};
  237. LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
  238. RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
  239. /** Initializes the peripherals clock
  240. */
  241. PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_SPI1;
  242. PeriphClkInitStruct.Spi123ClockSelection = RCC_SPI123CLKSOURCE_PLL;
  243. if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
  244. {
  245. Error_Handler();
  246. }
  247. /* Peripheral clock enable */
  248. LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SPI1);
  249. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOA);
  250. LL_AHB4_GRP1_EnableClock(LL_AHB4_GRP1_PERIPH_GPIOD);
  251. /**SPI1 GPIO Configuration
  252. PA5 ------> SPI1_SCK
  253. PA6 ------> SPI1_MISO
  254. PD7 ------> SPI1_MOSI
  255. */
  256. GPIO_InitStruct.Pin = LL_GPIO_PIN_5|LL_GPIO_PIN_6;
  257. GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
  258. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
  259. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  260. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  261. GPIO_InitStruct.Alternate = LL_GPIO_AF_5;
  262. LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  263. GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
  264. GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
  265. GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
  266. GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
  267. GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
  268. GPIO_InitStruct.Alternate = LL_GPIO_AF_5;
  269. LL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  270. /* USER CODE BEGIN SPI1_Init 1 */
  271. /* USER CODE END SPI1_Init 1 */
  272. /* SPI1 parameter configuration*/
  273. SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
  274. SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
  275. SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
  276. SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW;
  277. SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE;
  278. SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
  279. SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV32;
  280. SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
  281. SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
  282. SPI_InitStruct.CRCPoly = 0x0;
  283. LL_SPI_Init(SPI1, &SPI_InitStruct);
  284. LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
  285. LL_SPI_EnableNSSPulseMgt(SPI1);
  286. /* USER CODE BEGIN SPI1_Init 2 */
  287. /* USER CODE END SPI1_Init 2 */
  288. }
  289. /**
  290. * @brief TIM3 Initialization Function
  291. * @param None
  292. * @retval None
  293. */
  294. static void MX_TIM3_Init(void)
  295. {
  296. /* USER CODE BEGIN TIM3_Init 0 */
  297. /* USER CODE END TIM3_Init 0 */
  298. TIM_ClockConfigTypeDef sClockSourceConfig = {0};
  299. TIM_MasterConfigTypeDef sMasterConfig = {0};
  300. /* USER CODE BEGIN TIM3_Init 1 */
  301. /* USER CODE END TIM3_Init 1 */
  302. htim3.Instance = TIM3;
  303. htim3.Init.Prescaler = 0;
  304. htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
  305. htim3.Init.Period = 6875;
  306. htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  307. htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
  308. if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
  309. {
  310. Error_Handler();
  311. }
  312. sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
  313. if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
  314. {
  315. Error_Handler();
  316. }
  317. sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  318. sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  319. if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
  320. {
  321. Error_Handler();
  322. }
  323. /* USER CODE BEGIN TIM3_Init 2 */
  324. /* USER CODE END TIM3_Init 2 */
  325. }
  326. /**
  327. * @brief GPIO Initialization Function
  328. * @param None
  329. * @retval None
  330. */
  331. static void MX_GPIO_Init(void)
  332. {
  333. GPIO_InitTypeDef GPIO_InitStruct = {0};
  334. /* GPIO Ports Clock Enable */
  335. __HAL_RCC_GPIOC_CLK_ENABLE();
  336. __HAL_RCC_GPIOH_CLK_ENABLE();
  337. __HAL_RCC_GPIOA_CLK_ENABLE();
  338. __HAL_RCC_GPIOB_CLK_ENABLE();
  339. __HAL_RCC_GPIOD_CLK_ENABLE();
  340. __HAL_RCC_GPIOG_CLK_ENABLE();
  341. __HAL_RCC_GPIOE_CLK_ENABLE();
  342. /*Configure GPIO pin Output Level */
  343. HAL_GPIO_WritePin(GPIOB, LED_GREEN_Pin|CC1200_RESET_Pin|LED_RED_Pin, GPIO_PIN_RESET);
  344. /*Configure GPIO pin Output Level */
  345. HAL_GPIO_WritePin(CC1200_TCXO_ENABLE_GPIO_Port, CC1200_TCXO_ENABLE_Pin, GPIO_PIN_SET);
  346. /*Configure GPIO pin Output Level */
  347. HAL_GPIO_WritePin(USB_FS_PWR_EN_GPIO_Port, USB_FS_PWR_EN_Pin, GPIO_PIN_RESET);
  348. /*Configure GPIO pin Output Level */
  349. HAL_GPIO_WritePin(CC1200_CS_GPIO_Port, CC1200_CS_Pin, GPIO_PIN_SET);
  350. /*Configure GPIO pin Output Level */
  351. HAL_GPIO_WritePin(LED_YELLOW_GPIO_Port, LED_YELLOW_Pin, GPIO_PIN_RESET);
  352. /*Configure GPIO pin : B1_Pin */
  353. GPIO_InitStruct.Pin = B1_Pin;
  354. GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  355. GPIO_InitStruct.Pull = GPIO_NOPULL;
  356. HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
  357. /*Configure GPIO pins : PC1 PC4 PC5 */
  358. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_4|GPIO_PIN_5;
  359. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  360. GPIO_InitStruct.Pull = GPIO_NOPULL;
  361. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  362. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  363. HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
  364. /*Configure GPIO pins : PA1 PA2 PA7 */
  365. GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_7;
  366. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  367. GPIO_InitStruct.Pull = GPIO_NOPULL;
  368. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  369. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  370. HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  371. /*Configure GPIO pins : LED_GREEN_Pin LED_RED_Pin */
  372. GPIO_InitStruct.Pin = LED_GREEN_Pin|LED_RED_Pin;
  373. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  374. GPIO_InitStruct.Pull = GPIO_NOPULL;
  375. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  376. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  377. /*Configure GPIO pins : CC1200_RESET_Pin CC1200_TCXO_ENABLE_Pin */
  378. GPIO_InitStruct.Pin = CC1200_RESET_Pin|CC1200_TCXO_ENABLE_Pin;
  379. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  380. GPIO_InitStruct.Pull = GPIO_NOPULL;
  381. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  382. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  383. /*Configure GPIO pin : PB13 */
  384. GPIO_InitStruct.Pin = GPIO_PIN_13;
  385. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  386. GPIO_InitStruct.Pull = GPIO_NOPULL;
  387. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  388. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  389. HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  390. /*Configure GPIO pins : STLK_VCP_RX_Pin STLK_VCP_TX_Pin */
  391. GPIO_InitStruct.Pin = STLK_VCP_RX_Pin|STLK_VCP_TX_Pin;
  392. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  393. GPIO_InitStruct.Pull = GPIO_NOPULL;
  394. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  395. GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  396. HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
  397. /*Configure GPIO pin : USB_FS_PWR_EN_Pin */
  398. GPIO_InitStruct.Pin = USB_FS_PWR_EN_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(USB_FS_PWR_EN_GPIO_Port, &GPIO_InitStruct);
  403. /*Configure GPIO pin : USB_FS_OVCR_Pin */
  404. GPIO_InitStruct.Pin = USB_FS_OVCR_Pin;
  405. GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  406. GPIO_InitStruct.Pull = GPIO_NOPULL;
  407. HAL_GPIO_Init(USB_FS_OVCR_GPIO_Port, &GPIO_InitStruct);
  408. /*Configure GPIO pin : CC1200_CS_Pin */
  409. GPIO_InitStruct.Pin = CC1200_CS_Pin;
  410. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  411. GPIO_InitStruct.Pull = GPIO_NOPULL;
  412. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  413. HAL_GPIO_Init(CC1200_CS_GPIO_Port, &GPIO_InitStruct);
  414. /*Configure GPIO pins : PG11 PG13 */
  415. GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_13;
  416. GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  417. GPIO_InitStruct.Pull = GPIO_NOPULL;
  418. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
  419. GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
  420. HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
  421. /*Configure GPIO pin : LED_YELLOW_Pin */
  422. GPIO_InitStruct.Pin = LED_YELLOW_Pin;
  423. GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  424. GPIO_InitStruct.Pull = GPIO_NOPULL;
  425. GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  426. HAL_GPIO_Init(LED_YELLOW_GPIO_Port, &GPIO_InitStruct);
  427. }
  428. /* USER CODE BEGIN 4 */
  429. /* USER CODE END 4 */
  430. /**
  431. * @brief This function is executed in case of error occurrence.
  432. * @retval None
  433. */
  434. void Error_Handler(void)
  435. {
  436. /* USER CODE BEGIN Error_Handler_Debug */
  437. /* User can add his own implementation to report the HAL error return state */
  438. __disable_irq();
  439. while (1)
  440. {
  441. }
  442. /* USER CODE END Error_Handler_Debug */
  443. }
  444. #ifdef USE_FULL_ASSERT
  445. /**
  446. * @brief Reports the name of the source file and the source line number
  447. * where the assert_param error has occurred.
  448. * @param file: pointer to the source file name
  449. * @param line: assert_param error line source number
  450. * @retval None
  451. */
  452. void assert_failed(uint8_t *file, uint32_t line)
  453. {
  454. /* USER CODE BEGIN 6 */
  455. /* User can add his own implementation to report the file name and line number,
  456. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  457. /* USER CODE END 6 */
  458. }
  459. #endif /* USE_FULL_ASSERT */