1*6b8177c5SMatthias Ringwald /* USER CODE BEGIN Header */
2*6b8177c5SMatthias Ringwald /**
3*6b8177c5SMatthias Ringwald ******************************************************************************
4*6b8177c5SMatthias Ringwald * @file : main.c
5*6b8177c5SMatthias Ringwald * @brief : Main program body
6*6b8177c5SMatthias Ringwald ******************************************************************************
7*6b8177c5SMatthias Ringwald * @attention
8*6b8177c5SMatthias Ringwald *
9*6b8177c5SMatthias Ringwald * <h2><center>© Copyright (c) 2020 STMicroelectronics.
10*6b8177c5SMatthias Ringwald * All rights reserved.</center></h2>
11*6b8177c5SMatthias Ringwald *
12*6b8177c5SMatthias Ringwald * This software component is licensed by ST under BSD 3-Clause license,
13*6b8177c5SMatthias Ringwald * the "License"; You may not use this file except in compliance with the
14*6b8177c5SMatthias Ringwald * License. You may obtain a copy of the License at:
15*6b8177c5SMatthias Ringwald * opensource.org/licenses/BSD-3-Clause
16*6b8177c5SMatthias Ringwald *
17*6b8177c5SMatthias Ringwald ******************************************************************************
18*6b8177c5SMatthias Ringwald */
19*6b8177c5SMatthias Ringwald /* USER CODE END Header */
20*6b8177c5SMatthias Ringwald /* Includes ------------------------------------------------------------------*/
21*6b8177c5SMatthias Ringwald #include "main.h"
22*6b8177c5SMatthias Ringwald
23*6b8177c5SMatthias Ringwald /* Private includes ----------------------------------------------------------*/
24*6b8177c5SMatthias Ringwald /* USER CODE BEGIN Includes */
25*6b8177c5SMatthias Ringwald #include "SEGGER_RTT.h"
26*6b8177c5SMatthias Ringwald #include <stdio.h>
27*6b8177c5SMatthias Ringwald #include "sx1280-hal.h"
28*6b8177c5SMatthias Ringwald
29*6b8177c5SMatthias Ringwald /* USER CODE END Includes */
30*6b8177c5SMatthias Ringwald
31*6b8177c5SMatthias Ringwald /* Private typedef -----------------------------------------------------------*/
32*6b8177c5SMatthias Ringwald /* USER CODE BEGIN PTD */
33*6b8177c5SMatthias Ringwald
34*6b8177c5SMatthias Ringwald /* USER CODE END PTD */
35*6b8177c5SMatthias Ringwald
36*6b8177c5SMatthias Ringwald /* Private define ------------------------------------------------------------*/
37*6b8177c5SMatthias Ringwald /* USER CODE BEGIN PD */
38*6b8177c5SMatthias Ringwald /* USER CODE END PD */
39*6b8177c5SMatthias Ringwald
40*6b8177c5SMatthias Ringwald /* Private macro -------------------------------------------------------------*/
41*6b8177c5SMatthias Ringwald /* USER CODE BEGIN PM */
42*6b8177c5SMatthias Ringwald #define printf(format, ...) SEGGER_RTT_printf(0, format, ## __VA_ARGS__)
43*6b8177c5SMatthias Ringwald
44*6b8177c5SMatthias Ringwald /* USER CODE END PM */
45*6b8177c5SMatthias Ringwald
46*6b8177c5SMatthias Ringwald /* Private variables ---------------------------------------------------------*/
47*6b8177c5SMatthias Ringwald LPTIM_HandleTypeDef hlptim1;
48*6b8177c5SMatthias Ringwald
49*6b8177c5SMatthias Ringwald SPI_HandleTypeDef hspi1;
50*6b8177c5SMatthias Ringwald DMA_HandleTypeDef hdma_spi1_rx;
51*6b8177c5SMatthias Ringwald DMA_HandleTypeDef hdma_spi1_tx;
52*6b8177c5SMatthias Ringwald
53*6b8177c5SMatthias Ringwald UART_HandleTypeDef huart2;
54*6b8177c5SMatthias Ringwald
55*6b8177c5SMatthias Ringwald /* USER CODE BEGIN PV */
56*6b8177c5SMatthias Ringwald
57*6b8177c5SMatthias Ringwald /* USER CODE END PV */
58*6b8177c5SMatthias Ringwald
59*6b8177c5SMatthias Ringwald /* Private function prototypes -----------------------------------------------*/
60*6b8177c5SMatthias Ringwald void SystemClock_Config(void);
61*6b8177c5SMatthias Ringwald static void MX_GPIO_Init(void);
62*6b8177c5SMatthias Ringwald static void MX_DMA_Init(void);
63*6b8177c5SMatthias Ringwald static void MX_LPTIM1_Init(void);
64*6b8177c5SMatthias Ringwald static void MX_SPI1_Init(void);
65*6b8177c5SMatthias Ringwald static void MX_USART2_UART_Init(void);
66*6b8177c5SMatthias Ringwald /* USER CODE BEGIN PFP */
67*6b8177c5SMatthias Ringwald void btstack_port(void);
68*6b8177c5SMatthias Ringwald /* USER CODE END PFP */
69*6b8177c5SMatthias Ringwald
70*6b8177c5SMatthias Ringwald /* Private user code ---------------------------------------------------------*/
71*6b8177c5SMatthias Ringwald /* USER CODE BEGIN 0 */
72*6b8177c5SMatthias Ringwald
73*6b8177c5SMatthias Ringwald /* USER CODE END 0 */
74*6b8177c5SMatthias Ringwald
75*6b8177c5SMatthias Ringwald /**
76*6b8177c5SMatthias Ringwald * @brief The application entry point.
77*6b8177c5SMatthias Ringwald * @retval int
78*6b8177c5SMatthias Ringwald */
main(void)79*6b8177c5SMatthias Ringwald int main(void)
80*6b8177c5SMatthias Ringwald {
81*6b8177c5SMatthias Ringwald /* USER CODE BEGIN 1 */
82*6b8177c5SMatthias Ringwald
83*6b8177c5SMatthias Ringwald /* USER CODE END 1 */
84*6b8177c5SMatthias Ringwald
85*6b8177c5SMatthias Ringwald /* MCU Configuration--------------------------------------------------------*/
86*6b8177c5SMatthias Ringwald
87*6b8177c5SMatthias Ringwald /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
88*6b8177c5SMatthias Ringwald HAL_Init();
89*6b8177c5SMatthias Ringwald
90*6b8177c5SMatthias Ringwald /* USER CODE BEGIN Init */
91*6b8177c5SMatthias Ringwald
92*6b8177c5SMatthias Ringwald /* USER CODE END Init */
93*6b8177c5SMatthias Ringwald
94*6b8177c5SMatthias Ringwald /* Configure the system clock */
95*6b8177c5SMatthias Ringwald SystemClock_Config();
96*6b8177c5SMatthias Ringwald
97*6b8177c5SMatthias Ringwald /* USER CODE BEGIN SysInit */
98*6b8177c5SMatthias Ringwald
99*6b8177c5SMatthias Ringwald /* USER CODE END SysInit */
100*6b8177c5SMatthias Ringwald
101*6b8177c5SMatthias Ringwald /* Initialize all configured peripherals */
102*6b8177c5SMatthias Ringwald MX_GPIO_Init();
103*6b8177c5SMatthias Ringwald MX_DMA_Init();
104*6b8177c5SMatthias Ringwald MX_LPTIM1_Init();
105*6b8177c5SMatthias Ringwald MX_SPI1_Init();
106*6b8177c5SMatthias Ringwald MX_USART2_UART_Init();
107*6b8177c5SMatthias Ringwald /* USER CODE BEGIN 2 */
108*6b8177c5SMatthias Ringwald
109*6b8177c5SMatthias Ringwald // HAL_LPTIM_Counter_Start_IT same as HAL_LPTIM_Counter_Start but also enables IRQs
110*6b8177c5SMatthias Ringwald HAL_LPTIM_Counter_Start_IT(&hlptim1, 0xffff);
111*6b8177c5SMatthias Ringwald
112*6b8177c5SMatthias Ringwald btstack_port();
113*6b8177c5SMatthias Ringwald
114*6b8177c5SMatthias Ringwald /* USER CODE END 2 */
115*6b8177c5SMatthias Ringwald
116*6b8177c5SMatthias Ringwald /* Infinite loop */
117*6b8177c5SMatthias Ringwald /* USER CODE BEGIN WHILE */
118*6b8177c5SMatthias Ringwald while (1)
119*6b8177c5SMatthias Ringwald {
120*6b8177c5SMatthias Ringwald /* USER CODE END WHILE */
121*6b8177c5SMatthias Ringwald
122*6b8177c5SMatthias Ringwald /* USER CODE BEGIN 3 */
123*6b8177c5SMatthias Ringwald }
124*6b8177c5SMatthias Ringwald /* USER CODE END 3 */
125*6b8177c5SMatthias Ringwald }
126*6b8177c5SMatthias Ringwald
127*6b8177c5SMatthias Ringwald /**
128*6b8177c5SMatthias Ringwald * @brief System Clock Configuration
129*6b8177c5SMatthias Ringwald * @retval None
130*6b8177c5SMatthias Ringwald */
SystemClock_Config(void)131*6b8177c5SMatthias Ringwald void SystemClock_Config(void)
132*6b8177c5SMatthias Ringwald {
133*6b8177c5SMatthias Ringwald RCC_OscInitTypeDef RCC_OscInitStruct = {0};
134*6b8177c5SMatthias Ringwald RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
135*6b8177c5SMatthias Ringwald RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
136*6b8177c5SMatthias Ringwald
137*6b8177c5SMatthias Ringwald /** Configure LSE Drive Capability
138*6b8177c5SMatthias Ringwald */
139*6b8177c5SMatthias Ringwald HAL_PWR_EnableBkUpAccess();
140*6b8177c5SMatthias Ringwald __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
141*6b8177c5SMatthias Ringwald /** Initializes the RCC Oscillators according to the specified parameters
142*6b8177c5SMatthias Ringwald * in the RCC_OscInitTypeDef structure.
143*6b8177c5SMatthias Ringwald */
144*6b8177c5SMatthias Ringwald RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE|RCC_OSCILLATORTYPE_MSI;
145*6b8177c5SMatthias Ringwald RCC_OscInitStruct.LSEState = RCC_LSE_ON;
146*6b8177c5SMatthias Ringwald RCC_OscInitStruct.MSIState = RCC_MSI_ON;
147*6b8177c5SMatthias Ringwald RCC_OscInitStruct.MSICalibrationValue = 0;
148*6b8177c5SMatthias Ringwald RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
149*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
150*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
151*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLM = 1;
152*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLN = 36;
153*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
154*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
155*6b8177c5SMatthias Ringwald RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
156*6b8177c5SMatthias Ringwald if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
157*6b8177c5SMatthias Ringwald {
158*6b8177c5SMatthias Ringwald Error_Handler();
159*6b8177c5SMatthias Ringwald }
160*6b8177c5SMatthias Ringwald /** Initializes the CPU, AHB and APB buses clocks
161*6b8177c5SMatthias Ringwald */
162*6b8177c5SMatthias Ringwald RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
163*6b8177c5SMatthias Ringwald |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
164*6b8177c5SMatthias Ringwald RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
165*6b8177c5SMatthias Ringwald RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
166*6b8177c5SMatthias Ringwald RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
167*6b8177c5SMatthias Ringwald RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
168*6b8177c5SMatthias Ringwald
169*6b8177c5SMatthias Ringwald if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
170*6b8177c5SMatthias Ringwald {
171*6b8177c5SMatthias Ringwald Error_Handler();
172*6b8177c5SMatthias Ringwald }
173*6b8177c5SMatthias Ringwald PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_LPTIM1;
174*6b8177c5SMatthias Ringwald PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
175*6b8177c5SMatthias Ringwald PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_LSE;
176*6b8177c5SMatthias Ringwald if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
177*6b8177c5SMatthias Ringwald {
178*6b8177c5SMatthias Ringwald Error_Handler();
179*6b8177c5SMatthias Ringwald }
180*6b8177c5SMatthias Ringwald /** Configure the main internal regulator output voltage
181*6b8177c5SMatthias Ringwald */
182*6b8177c5SMatthias Ringwald if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
183*6b8177c5SMatthias Ringwald {
184*6b8177c5SMatthias Ringwald Error_Handler();
185*6b8177c5SMatthias Ringwald }
186*6b8177c5SMatthias Ringwald /** Enable MSI Auto calibration
187*6b8177c5SMatthias Ringwald */
188*6b8177c5SMatthias Ringwald HAL_RCCEx_EnableMSIPLLMode();
189*6b8177c5SMatthias Ringwald }
190*6b8177c5SMatthias Ringwald
191*6b8177c5SMatthias Ringwald /**
192*6b8177c5SMatthias Ringwald * @brief LPTIM1 Initialization Function
193*6b8177c5SMatthias Ringwald * @param None
194*6b8177c5SMatthias Ringwald * @retval None
195*6b8177c5SMatthias Ringwald */
MX_LPTIM1_Init(void)196*6b8177c5SMatthias Ringwald static void MX_LPTIM1_Init(void)
197*6b8177c5SMatthias Ringwald {
198*6b8177c5SMatthias Ringwald
199*6b8177c5SMatthias Ringwald /* USER CODE BEGIN LPTIM1_Init 0 */
200*6b8177c5SMatthias Ringwald
201*6b8177c5SMatthias Ringwald /* USER CODE END LPTIM1_Init 0 */
202*6b8177c5SMatthias Ringwald
203*6b8177c5SMatthias Ringwald /* USER CODE BEGIN LPTIM1_Init 1 */
204*6b8177c5SMatthias Ringwald
205*6b8177c5SMatthias Ringwald /* USER CODE END LPTIM1_Init 1 */
206*6b8177c5SMatthias Ringwald hlptim1.Instance = LPTIM1;
207*6b8177c5SMatthias Ringwald hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
208*6b8177c5SMatthias Ringwald hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
209*6b8177c5SMatthias Ringwald hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
210*6b8177c5SMatthias Ringwald hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;
211*6b8177c5SMatthias Ringwald hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
212*6b8177c5SMatthias Ringwald hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;
213*6b8177c5SMatthias Ringwald hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO;
214*6b8177c5SMatthias Ringwald hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO;
215*6b8177c5SMatthias Ringwald if (HAL_LPTIM_Init(&hlptim1) != HAL_OK)
216*6b8177c5SMatthias Ringwald {
217*6b8177c5SMatthias Ringwald Error_Handler();
218*6b8177c5SMatthias Ringwald }
219*6b8177c5SMatthias Ringwald /* USER CODE BEGIN LPTIM1_Init 2 */
220*6b8177c5SMatthias Ringwald
221*6b8177c5SMatthias Ringwald /* USER CODE END LPTIM1_Init 2 */
222*6b8177c5SMatthias Ringwald
223*6b8177c5SMatthias Ringwald }
224*6b8177c5SMatthias Ringwald
225*6b8177c5SMatthias Ringwald /**
226*6b8177c5SMatthias Ringwald * @brief SPI1 Initialization Function
227*6b8177c5SMatthias Ringwald * @param None
228*6b8177c5SMatthias Ringwald * @retval None
229*6b8177c5SMatthias Ringwald */
MX_SPI1_Init(void)230*6b8177c5SMatthias Ringwald static void MX_SPI1_Init(void)
231*6b8177c5SMatthias Ringwald {
232*6b8177c5SMatthias Ringwald
233*6b8177c5SMatthias Ringwald /* USER CODE BEGIN SPI1_Init 0 */
234*6b8177c5SMatthias Ringwald
235*6b8177c5SMatthias Ringwald /* USER CODE END SPI1_Init 0 */
236*6b8177c5SMatthias Ringwald
237*6b8177c5SMatthias Ringwald /* USER CODE BEGIN SPI1_Init 1 */
238*6b8177c5SMatthias Ringwald
239*6b8177c5SMatthias Ringwald /* USER CODE END SPI1_Init 1 */
240*6b8177c5SMatthias Ringwald /* SPI1 parameter configuration*/
241*6b8177c5SMatthias Ringwald hspi1.Instance = SPI1;
242*6b8177c5SMatthias Ringwald hspi1.Init.Mode = SPI_MODE_MASTER;
243*6b8177c5SMatthias Ringwald hspi1.Init.Direction = SPI_DIRECTION_2LINES;
244*6b8177c5SMatthias Ringwald hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
245*6b8177c5SMatthias Ringwald hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
246*6b8177c5SMatthias Ringwald hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
247*6b8177c5SMatthias Ringwald hspi1.Init.NSS = SPI_NSS_SOFT;
248*6b8177c5SMatthias Ringwald hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
249*6b8177c5SMatthias Ringwald hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
250*6b8177c5SMatthias Ringwald hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
251*6b8177c5SMatthias Ringwald hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
252*6b8177c5SMatthias Ringwald hspi1.Init.CRCPolynomial = 7;
253*6b8177c5SMatthias Ringwald hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
254*6b8177c5SMatthias Ringwald hspi1.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
255*6b8177c5SMatthias Ringwald if (HAL_SPI_Init(&hspi1) != HAL_OK)
256*6b8177c5SMatthias Ringwald {
257*6b8177c5SMatthias Ringwald Error_Handler();
258*6b8177c5SMatthias Ringwald }
259*6b8177c5SMatthias Ringwald /* USER CODE BEGIN SPI1_Init 2 */
260*6b8177c5SMatthias Ringwald
261*6b8177c5SMatthias Ringwald /* USER CODE END SPI1_Init 2 */
262*6b8177c5SMatthias Ringwald
263*6b8177c5SMatthias Ringwald }
264*6b8177c5SMatthias Ringwald
265*6b8177c5SMatthias Ringwald /**
266*6b8177c5SMatthias Ringwald * @brief USART2 Initialization Function
267*6b8177c5SMatthias Ringwald * @param None
268*6b8177c5SMatthias Ringwald * @retval None
269*6b8177c5SMatthias Ringwald */
MX_USART2_UART_Init(void)270*6b8177c5SMatthias Ringwald static void MX_USART2_UART_Init(void)
271*6b8177c5SMatthias Ringwald {
272*6b8177c5SMatthias Ringwald
273*6b8177c5SMatthias Ringwald /* USER CODE BEGIN USART2_Init 0 */
274*6b8177c5SMatthias Ringwald
275*6b8177c5SMatthias Ringwald /* USER CODE END USART2_Init 0 */
276*6b8177c5SMatthias Ringwald
277*6b8177c5SMatthias Ringwald /* USER CODE BEGIN USART2_Init 1 */
278*6b8177c5SMatthias Ringwald
279*6b8177c5SMatthias Ringwald /* USER CODE END USART2_Init 1 */
280*6b8177c5SMatthias Ringwald huart2.Instance = USART2;
281*6b8177c5SMatthias Ringwald huart2.Init.BaudRate = 115200;
282*6b8177c5SMatthias Ringwald huart2.Init.WordLength = UART_WORDLENGTH_8B;
283*6b8177c5SMatthias Ringwald huart2.Init.StopBits = UART_STOPBITS_1;
284*6b8177c5SMatthias Ringwald huart2.Init.Parity = UART_PARITY_NONE;
285*6b8177c5SMatthias Ringwald huart2.Init.Mode = UART_MODE_TX_RX;
286*6b8177c5SMatthias Ringwald huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
287*6b8177c5SMatthias Ringwald huart2.Init.OverSampling = UART_OVERSAMPLING_16;
288*6b8177c5SMatthias Ringwald huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
289*6b8177c5SMatthias Ringwald huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
290*6b8177c5SMatthias Ringwald if (HAL_UART_Init(&huart2) != HAL_OK)
291*6b8177c5SMatthias Ringwald {
292*6b8177c5SMatthias Ringwald Error_Handler();
293*6b8177c5SMatthias Ringwald }
294*6b8177c5SMatthias Ringwald /* USER CODE BEGIN USART2_Init 2 */
295*6b8177c5SMatthias Ringwald
296*6b8177c5SMatthias Ringwald /* USER CODE END USART2_Init 2 */
297*6b8177c5SMatthias Ringwald
298*6b8177c5SMatthias Ringwald }
299*6b8177c5SMatthias Ringwald
300*6b8177c5SMatthias Ringwald /**
301*6b8177c5SMatthias Ringwald * Enable DMA controller clock
302*6b8177c5SMatthias Ringwald */
MX_DMA_Init(void)303*6b8177c5SMatthias Ringwald static void MX_DMA_Init(void)
304*6b8177c5SMatthias Ringwald {
305*6b8177c5SMatthias Ringwald
306*6b8177c5SMatthias Ringwald /* DMA controller clock enable */
307*6b8177c5SMatthias Ringwald __HAL_RCC_DMA1_CLK_ENABLE();
308*6b8177c5SMatthias Ringwald
309*6b8177c5SMatthias Ringwald /* DMA interrupt init */
310*6b8177c5SMatthias Ringwald /* DMA1_Channel2_IRQn interrupt configuration */
311*6b8177c5SMatthias Ringwald HAL_NVIC_SetPriority(DMA1_Channel2_IRQn, 0, 0);
312*6b8177c5SMatthias Ringwald HAL_NVIC_EnableIRQ(DMA1_Channel2_IRQn);
313*6b8177c5SMatthias Ringwald /* DMA1_Channel3_IRQn interrupt configuration */
314*6b8177c5SMatthias Ringwald HAL_NVIC_SetPriority(DMA1_Channel3_IRQn, 0, 0);
315*6b8177c5SMatthias Ringwald HAL_NVIC_EnableIRQ(DMA1_Channel3_IRQn);
316*6b8177c5SMatthias Ringwald
317*6b8177c5SMatthias Ringwald }
318*6b8177c5SMatthias Ringwald
319*6b8177c5SMatthias Ringwald /**
320*6b8177c5SMatthias Ringwald * @brief GPIO Initialization Function
321*6b8177c5SMatthias Ringwald * @param None
322*6b8177c5SMatthias Ringwald * @retval None
323*6b8177c5SMatthias Ringwald */
MX_GPIO_Init(void)324*6b8177c5SMatthias Ringwald static void MX_GPIO_Init(void)
325*6b8177c5SMatthias Ringwald {
326*6b8177c5SMatthias Ringwald GPIO_InitTypeDef GPIO_InitStruct = {0};
327*6b8177c5SMatthias Ringwald
328*6b8177c5SMatthias Ringwald /* GPIO Ports Clock Enable */
329*6b8177c5SMatthias Ringwald __HAL_RCC_GPIOC_CLK_ENABLE();
330*6b8177c5SMatthias Ringwald __HAL_RCC_GPIOH_CLK_ENABLE();
331*6b8177c5SMatthias Ringwald __HAL_RCC_GPIOA_CLK_ENABLE();
332*6b8177c5SMatthias Ringwald __HAL_RCC_GPIOB_CLK_ENABLE();
333*6b8177c5SMatthias Ringwald
334*6b8177c5SMatthias Ringwald /*Configure GPIO pin Output Level */
335*6b8177c5SMatthias Ringwald HAL_GPIO_WritePin(GPIOC, LED_RX_Pin|LED_TX_Pin, GPIO_PIN_RESET);
336*6b8177c5SMatthias Ringwald
337*6b8177c5SMatthias Ringwald /*Configure GPIO pin Output Level */
338*6b8177c5SMatthias Ringwald HAL_GPIO_WritePin(GPIOA, RADIO_nRESET_Pin|RADIO_NSS_Pin, GPIO_PIN_RESET);
339*6b8177c5SMatthias Ringwald
340*6b8177c5SMatthias Ringwald /*Configure GPIO pin : B1_Pin */
341*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pin = B1_Pin;
342*6b8177c5SMatthias Ringwald GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
343*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pull = GPIO_NOPULL;
344*6b8177c5SMatthias Ringwald HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
345*6b8177c5SMatthias Ringwald
346*6b8177c5SMatthias Ringwald /*Configure GPIO pins : LED_RX_Pin LED_TX_Pin */
347*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pin = LED_RX_Pin|LED_TX_Pin;
348*6b8177c5SMatthias Ringwald GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
349*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pull = GPIO_NOPULL;
350*6b8177c5SMatthias Ringwald GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
351*6b8177c5SMatthias Ringwald HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
352*6b8177c5SMatthias Ringwald
353*6b8177c5SMatthias Ringwald /*Configure GPIO pins : RADIO_nRESET_Pin RADIO_NSS_Pin */
354*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pin = RADIO_nRESET_Pin|RADIO_NSS_Pin;
355*6b8177c5SMatthias Ringwald GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
356*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pull = GPIO_NOPULL;
357*6b8177c5SMatthias Ringwald GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
358*6b8177c5SMatthias Ringwald HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
359*6b8177c5SMatthias Ringwald
360*6b8177c5SMatthias Ringwald /*Configure GPIO pin : RADIO_BUSY_Pin */
361*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pin = RADIO_BUSY_Pin;
362*6b8177c5SMatthias Ringwald GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
363*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pull = GPIO_NOPULL;
364*6b8177c5SMatthias Ringwald HAL_GPIO_Init(RADIO_BUSY_GPIO_Port, &GPIO_InitStruct);
365*6b8177c5SMatthias Ringwald
366*6b8177c5SMatthias Ringwald /*Configure GPIO pin : RADIO_DIO1_Pin */
367*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pin = RADIO_DIO1_Pin;
368*6b8177c5SMatthias Ringwald GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
369*6b8177c5SMatthias Ringwald GPIO_InitStruct.Pull = GPIO_NOPULL;
370*6b8177c5SMatthias Ringwald HAL_GPIO_Init(RADIO_DIO1_GPIO_Port, &GPIO_InitStruct);
371*6b8177c5SMatthias Ringwald
372*6b8177c5SMatthias Ringwald /* EXTI interrupt init*/
373*6b8177c5SMatthias Ringwald HAL_NVIC_SetPriority(EXTI4_IRQn, 0, 0);
374*6b8177c5SMatthias Ringwald HAL_NVIC_EnableIRQ(EXTI4_IRQn);
375*6b8177c5SMatthias Ringwald
376*6b8177c5SMatthias Ringwald }
377*6b8177c5SMatthias Ringwald
378*6b8177c5SMatthias Ringwald /* USER CODE BEGIN 4 */
379*6b8177c5SMatthias Ringwald
380*6b8177c5SMatthias Ringwald /* USER CODE END 4 */
381*6b8177c5SMatthias Ringwald
382*6b8177c5SMatthias Ringwald /**
383*6b8177c5SMatthias Ringwald * @brief This function is executed in case of error occurrence.
384*6b8177c5SMatthias Ringwald * @retval None
385*6b8177c5SMatthias Ringwald */
Error_Handler(void)386*6b8177c5SMatthias Ringwald void Error_Handler(void)
387*6b8177c5SMatthias Ringwald {
388*6b8177c5SMatthias Ringwald /* USER CODE BEGIN Error_Handler_Debug */
389*6b8177c5SMatthias Ringwald /* User can add his own implementation to report the HAL error return state */
390*6b8177c5SMatthias Ringwald
391*6b8177c5SMatthias Ringwald /* USER CODE END Error_Handler_Debug */
392*6b8177c5SMatthias Ringwald }
393*6b8177c5SMatthias Ringwald
394*6b8177c5SMatthias Ringwald #ifdef USE_FULL_ASSERT
395*6b8177c5SMatthias Ringwald /**
396*6b8177c5SMatthias Ringwald * @brief Reports the name of the source file and the source line number
397*6b8177c5SMatthias Ringwald * where the assert_param error has occurred.
398*6b8177c5SMatthias Ringwald * @param file: pointer to the source file name
399*6b8177c5SMatthias Ringwald * @param line: assert_param error line source number
400*6b8177c5SMatthias Ringwald * @retval None
401*6b8177c5SMatthias Ringwald */
assert_failed(uint8_t * file,uint32_t line)402*6b8177c5SMatthias Ringwald void assert_failed(uint8_t *file, uint32_t line)
403*6b8177c5SMatthias Ringwald {
404*6b8177c5SMatthias Ringwald /* USER CODE BEGIN 6 */
405*6b8177c5SMatthias Ringwald /* User can add his own implementation to report the file name and line number,
406*6b8177c5SMatthias Ringwald tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
407*6b8177c5SMatthias Ringwald /* USER CODE END 6 */
408*6b8177c5SMatthias Ringwald }
409*6b8177c5SMatthias Ringwald #endif /* USE_FULL_ASSERT */
410*6b8177c5SMatthias Ringwald
411*6b8177c5SMatthias Ringwald /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
412