提交 | 用户 | age
|
bfc108
|
1 |
/**
|
Q |
2 |
******************************************************************************
|
|
3 |
* @file : BSP.c
|
|
4 |
* @brief : Board Speciafic program
|
|
5 |
******************************************************************************
|
|
6 |
*
|
|
7 |
******************************************************************************
|
|
8 |
*/
|
|
9 |
/* Includes ------------------------------------------------------------------*/
|
|
10 |
|
|
11 |
#include "BSP.h"
|
|
12 |
|
|
13 |
#include "Globaldef.h"
|
|
14 |
#include "Functions.h"
|
f4f290
|
15 |
#if (BOARD_TYPE == 14)
|
Q |
16 |
#include "fp0.h"
|
|
17 |
#endif
|
bfc108
|
18 |
|
Q |
19 |
/*
|
|
20 |
if ((nCurTick &0xff) ==0)
|
|
21 |
{
|
|
22 |
if (freqdir) { freq+=1+freq/10;if (freq>=1500) {freq=1500;freqdir=0;}}
|
|
23 |
else {freq-=1+freq/10;if (freq<=10) {freq=10;freqdir=1;} }
|
|
24 |
}
|
|
25 |
*/
|
|
26 |
|
|
27 |
/*
|
|
28 |
static int outputsum=0;
|
|
29 |
static int freq=10;
|
|
30 |
static int freqdir=1;
|
|
31 |
static int phase=0;
|
|
32 |
static int somb=0;
|
|
33 |
static int len=0;
|
|
34 |
static int curbb=0;
|
|
35 |
|
|
36 |
if ((nCurTick &0x3ff) ==1)
|
|
37 |
{
|
|
38 |
curbb++;
|
|
39 |
if (curbb+1==len)
|
|
40 |
{
|
|
41 |
// freq=0;
|
|
42 |
}else if (curbb>=len)
|
|
43 |
{
|
|
44 |
somb=musictab1[cur_musicpos*2];
|
|
45 |
len=musictab1[cur_musicpos*2+1];
|
|
46 |
freq=freqtab[somb];
|
|
47 |
curbb=0;cur_musicpos++; if (cur_musicpos >= Totalmusiccount) {cur_musicpos=0;}
|
|
48 |
}
|
|
49 |
}
|
|
50 |
if ((nCurTick &0x3ff) ==0x1ff)
|
|
51 |
{
|
|
52 |
if (curbb+1==len)
|
|
53 |
{
|
|
54 |
freq=0;
|
|
55 |
}
|
|
56 |
}
|
|
57 |
phase+=freq;
|
|
58 |
if (phase>=5000) {phase-=5000;}
|
|
59 |
|
|
60 |
|
|
61 |
if (outtype==1)
|
|
62 |
{
|
|
63 |
outputsum+=freq;
|
|
64 |
if (outputsum>=5000)
|
|
65 |
{
|
|
66 |
//LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_3);
|
|
67 |
LL_GPIO_TogglePin(GPIOB,LL_GPIO_PIN_3);
|
|
68 |
outputsum-=5000;
|
|
69 |
}
|
|
70 |
else
|
|
71 |
{
|
|
72 |
//LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_3);
|
|
73 |
}
|
|
74 |
}else if (outtype==2)
|
|
75 |
{
|
|
76 |
const int volume = 2500;
|
|
77 |
int amp;
|
|
78 |
if (phase<1250)
|
|
79 |
{
|
|
80 |
amp=2500+sintab[(phase -0)*256/1250]*volume/256;
|
|
81 |
|
|
82 |
}else if (phase <2500)
|
|
83 |
{
|
|
84 |
amp=2500+sintab[(2500-1-phase)*256/1250]*volume/256;
|
|
85 |
}else if (phase <3750)
|
|
86 |
{
|
|
87 |
amp=2500-sintab[(phase-2500)*256/1250]*volume/256;
|
|
88 |
}else
|
|
89 |
{
|
|
90 |
amp=2500-sintab[(5000-1-phase)*256/1250]*volume/256;
|
|
91 |
}
|
|
92 |
outputsum+=amp;
|
|
93 |
if (outputsum>=5000)
|
|
94 |
{
|
|
95 |
LL_GPIO_SetOutputPin(GPIOB,LL_GPIO_PIN_3);
|
|
96 |
//LL_GPIO_TogglePin(GPIOB,LL_GPIO_PIN_3);
|
|
97 |
outputsum-=5000;
|
|
98 |
}
|
|
99 |
else
|
|
100 |
{
|
|
101 |
LL_GPIO_ResetOutputPin(GPIOB,LL_GPIO_PIN_3);
|
|
102 |
}
|
|
103 |
}
|
|
104 |
*/
|
|
105 |
|
|
106 |
|
|
107 |
/**
|
|
108 |
* @brief System Clock Configuration
|
|
109 |
* @retval None
|
|
110 |
*/
|
a7db3c
|
111 |
|
bfc108
|
112 |
void SystemClock_Config(void)
|
Q |
113 |
{
|
|
114 |
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
|
115 |
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
|
116 |
|
|
117 |
/** Initializes the CPU, AHB and APB busses clocks
|
|
118 |
*/
|
|
119 |
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
120 |
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
121 |
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
|
122 |
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
a7db3c
|
123 |
// RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
|
0aeaad
|
124 |
|
Q |
125 |
#if (XLAT_FREQ == 12)
|
a7db3c
|
126 |
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV3;
|
0aeaad
|
127 |
#else
|
a7db3c
|
128 |
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV2;
|
0aeaad
|
129 |
#endif
|
a7db3c
|
130 |
|
Q |
131 |
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;
|
bfc108
|
132 |
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
Q |
133 |
{
|
|
134 |
Error_Handler();
|
|
135 |
}
|
|
136 |
/** Initializes the CPU, AHB and APB busses clocks
|
|
137 |
*/
|
|
138 |
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
|
139 |
|RCC_CLOCKTYPE_PCLK1;
|
|
140 |
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|
141 |
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
142 |
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
|
143 |
|
|
144 |
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
|
145 |
{
|
|
146 |
Error_Handler();
|
|
147 |
}
|
|
148 |
|
|
149 |
//RCC_OscInitTypeDef RCC_OscInitStruct;
|
|
150 |
//RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
|
151 |
RCC_PeriphCLKInitTypeDef PeriphClkInit;
|
|
152 |
|
|
153 |
/**Initializes the CPU, AHB and APB busses clocks
|
|
154 |
*/
|
|
155 |
|
|
156 |
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1;
|
|
157 |
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_SYSCLK;
|
|
158 |
|
|
159 |
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
|
|
160 |
{
|
|
161 |
_Error_Handler(__FILE__, __LINE__);
|
|
162 |
}
|
|
163 |
|
|
164 |
/**Configure the Systick interrupt time
|
|
165 |
*/
|
a7db3c
|
166 |
// HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/10000);
|
Q |
167 |
HAL_SYSTICK_Config(48000000/10000);
|
bfc108
|
168 |
|
Q |
169 |
/**Configure the Systick
|
|
170 |
*/
|
|
171 |
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
|
|
172 |
|
|
173 |
/* SysTick_IRQn interrupt configuration */
|
|
174 |
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
|
175 |
}
|
|
176 |
|
|
177 |
void MX_IWDG_Init(void)
|
|
178 |
{
|
|
179 |
|
|
180 |
/* USER CODE BEGIN IWDG_Init 0 */
|
|
181 |
|
|
182 |
/* USER CODE END IWDG_Init 0 */
|
|
183 |
|
|
184 |
/* USER CODE BEGIN IWDG_Init 1 */
|
|
185 |
|
|
186 |
/* USER CODE END IWDG_Init 1 */
|
|
187 |
LL_IWDG_Enable(IWDG);
|
|
188 |
LL_IWDG_EnableWriteAccess(IWDG);
|
|
189 |
LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_64);
|
|
190 |
LL_IWDG_SetReloadCounter(IWDG, 4095);
|
|
191 |
while (LL_IWDG_IsReady(IWDG) != 1)
|
|
192 |
{
|
|
193 |
}
|
|
194 |
|
|
195 |
LL_IWDG_SetWindow(IWDG, 4095);
|
|
196 |
LL_IWDG_ReloadCounter(IWDG);
|
|
197 |
/* USER CODE BEGIN IWDG_Init 2 */
|
|
198 |
|
|
199 |
/* USER CODE END IWDG_Init 2 */
|
|
200 |
|
|
201 |
}
|
a7db3c
|
202 |
/**
|
Q |
203 |
* @brief TIM6 Initialization Function
|
|
204 |
* @param None
|
|
205 |
* @retval None
|
|
206 |
*/
|
|
207 |
void MX_TIM6_Init(void)
|
|
208 |
{
|
bfc108
|
209 |
|
a7db3c
|
210 |
/* USER CODE BEGIN TIM6_Init 0 */
|
Q |
211 |
|
|
212 |
/* USER CODE END TIM6_Init 0 */
|
|
213 |
|
|
214 |
LL_TIM_InitTypeDef TIM_InitStruct = {0};
|
|
215 |
|
|
216 |
/* Peripheral clock enable */
|
|
217 |
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM6);
|
|
218 |
|
|
219 |
/* TIM6 interrupt Init */
|
|
220 |
NVIC_SetPriority(TIM6_IRQn, 0);
|
|
221 |
NVIC_EnableIRQ(TIM6_IRQn);
|
|
222 |
|
|
223 |
/* USER CODE BEGIN TIM6_Init 1 */
|
|
224 |
|
|
225 |
/* USER CODE END TIM6_Init 1 */
|
|
226 |
TIM_InitStruct.Prescaler = 47;
|
|
227 |
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
|
228 |
TIM_InitStruct.Autoreload = 999;
|
|
229 |
LL_TIM_Init(TIM6, &TIM_InitStruct);
|
|
230 |
LL_TIM_DisableARRPreload(TIM6);
|
|
231 |
/* USER CODE BEGIN TIM6_Init 2 */
|
|
232 |
LL_TIM_EnableIT_UPDATE(TIM6);
|
|
233 |
/* USER CODE END TIM6_Init 2 */
|
|
234 |
|
|
235 |
}
|
bfc108
|
236 |
/* ADC init function */
|
Q |
237 |
void MX_ADC_Init(void)
|
|
238 |
{
|
|
239 |
|
|
240 |
LL_ADC_InitTypeDef ADC_InitStruct;
|
|
241 |
LL_ADC_REG_InitTypeDef ADC_REG_InitStruct;
|
|
242 |
|
|
243 |
/* Peripheral clock enable */
|
|
244 |
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_ADC1);
|
|
245 |
|
|
246 |
/**Configure Regular Channel
|
|
247 |
*/
|
0aeaad
|
248 |
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_0|LL_ADC_CHANNEL_1);
|
bfc108
|
249 |
|
Q |
250 |
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR|LL_ADC_PATH_INTERNAL_VREFINT);
|
|
251 |
|
|
252 |
/**Configure Regular Channel
|
|
253 |
*/
|
|
254 |
LL_ADC_REG_SetSequencerChAdd(ADC1, LL_ADC_CHANNEL_TEMPSENSOR|LL_ADC_CHANNEL_VREFINT);
|
|
255 |
|
|
256 |
LL_ADC_SetCommonPathInternalCh(__LL_ADC_COMMON_INSTANCE(ADC1), LL_ADC_PATH_INTERNAL_TEMPSENSOR|LL_ADC_PATH_INTERNAL_VREFINT);
|
|
257 |
|
|
258 |
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
|
|
259 |
*/
|
|
260 |
ADC_InitStruct.Clock = LL_ADC_CLOCK_ASYNC;
|
|
261 |
ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B;
|
|
262 |
ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
|
|
263 |
ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE;
|
|
264 |
LL_ADC_Init(ADC1, &ADC_InitStruct);
|
|
265 |
|
|
266 |
ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE;
|
|
267 |
ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
|
|
268 |
ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_SINGLE;
|
|
269 |
ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_LIMITED;
|
|
270 |
ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED;
|
|
271 |
LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct);
|
|
272 |
|
|
273 |
LL_ADC_REG_SetSequencerScanDirection(ADC1, LL_ADC_REG_SEQ_SCAN_DIR_FORWARD);
|
|
274 |
|
0aeaad
|
275 |
LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_28CYCLES_5);
|
bfc108
|
276 |
|
Q |
277 |
LL_ADC_EnableIT_EOC(ADC1);
|
|
278 |
|
|
279 |
LL_ADC_DisableIT_EOS(ADC1);
|
|
280 |
|
|
281 |
LL_ADC_StartCalibration(ADC1);
|
|
282 |
|
|
283 |
// LL_ADC_EnableInternalRegulator(ADC1);
|
|
284 |
|
|
285 |
// ADC_TempSensorCmd(ENABLE);//?????????
|
|
286 |
// ADC_VrefintCmd(ENABLE); //????????
|
|
287 |
|
|
288 |
|
|
289 |
//ADC_TempSensorCmd(ENABLE);//
|
|
290 |
//ADC_ChannelConfig();
|
|
291 |
//ADC_VrefintCmd(ENABLE); //
|
|
292 |
|
|
293 |
while( LL_ADC_IsCalibrationOnGoing(ADC1));
|
|
294 |
LL_ADC_Enable(ADC1);
|
|
295 |
/*
|
|
296 |
LL_ADC_REG_SetDMATransfer(ADC1,LL_ADC_REG_DMA_TRANSFER_UNLIMITED);
|
|
297 |
LL_ADC_REG_StartConversion(ADC1);
|
|
298 |
*/
|
|
299 |
}
|
|
300 |
|
|
301 |
/* SPI1 init function */
|
|
302 |
void MX_SPI1_Init(void)
|
|
303 |
{
|
|
304 |
|
a7db3c
|
305 |
LL_SPI_InitTypeDef SPI_InitStruct = {0};
|
bfc108
|
306 |
|
a7db3c
|
307 |
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
bfc108
|
308 |
|
Q |
309 |
/* Peripheral clock enable */
|
|
310 |
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_SPI1);
|
|
311 |
|
|
312 |
/**SPI1 GPIO Configuration
|
|
313 |
PA5 ------> SPI1_SCK
|
|
314 |
PA6 ------> SPI1_MISO
|
|
315 |
PA7 ------> SPI1_MOSI
|
|
316 |
*/
|
|
317 |
// GPIO_InitStruct.Pin = LL_GPIO_PIN_5;
|
|
318 |
// GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
319 |
// GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
320 |
// GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
321 |
// GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
322 |
// GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
323 |
// LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
324 |
|
|
325 |
// GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
|
|
326 |
// GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
327 |
// GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
328 |
// GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
329 |
// GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
330 |
// GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
331 |
// LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
332 |
|
|
333 |
// GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
|
|
334 |
// GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
335 |
// GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
336 |
// GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
337 |
// GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
338 |
// GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
339 |
// LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
340 |
|
|
341 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
|
|
342 |
/**SPI1 GPIO Configuration
|
|
343 |
PB3 ------> SPI1_SCK
|
|
344 |
PB4 ------> SPI1_MISO
|
|
345 |
PB5 ------> SPI1_MOSI
|
|
346 |
*/
|
|
347 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_3;
|
|
348 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
349 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
350 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
351 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
352 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
353 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
354 |
|
|
355 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_4;
|
|
356 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
357 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
358 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
a7db3c
|
359 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
bfc108
|
360 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
Q |
361 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
362 |
|
|
363 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_5;
|
|
364 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
365 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
366 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
367 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
368 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
369 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
370 |
|
|
371 |
/* SPI1 interrupt Init */
|
|
372 |
NVIC_SetPriority(SPI1_IRQn, 0);
|
f4f290
|
373 |
// NVIC_EnableIRQ(SPI1_IRQn);
|
bfc108
|
374 |
/* USER CODE BEGIN SPI1_Init 1 */
|
Q |
375 |
|
f4f290
|
376 |
#if (BOARD_TYPE == 13)
|
a7db3c
|
377 |
|
f4f290
|
378 |
NVIC_EnableIRQ(SPI1_IRQn);
|
a7db3c
|
379 |
SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
|
Q |
380 |
SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
|
|
381 |
SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
|
|
382 |
SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_HIGH; //LL_SPI_POLARITY_LOW;
|
|
383 |
SPI_InitStruct.ClockPhase = LL_SPI_PHASE_2EDGE ; //LL_SPI_PHASE_1EDGE;
|
|
384 |
SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
|
|
385 |
SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;
|
|
386 |
SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
|
|
387 |
SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
|
|
388 |
SPI_InitStruct.CRCPoly = 7;
|
|
389 |
LL_SPI_Init(SPI1, &SPI_InitStruct);
|
|
390 |
|
|
391 |
LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
|
|
392 |
|
|
393 |
LL_SPI_SetRxFIFOThreshold(SPI1,LL_SPI_RX_FIFO_TH_QUARTER);
|
|
394 |
// LL_SPI_EnableNSSPulseMgt(SPI1);
|
|
395 |
|
f4f290
|
396 |
#elif (BOARD_TYPE == 14)
|
Q |
397 |
|
|
398 |
NVIC_EnableIRQ(SPI1_IRQn);
|
|
399 |
SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
|
|
400 |
SPI_InitStruct.Mode = LL_SPI_MODE_SLAVE;
|
|
401 |
SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
|
|
402 |
SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; //LL_SPI_POLARITY_LOW;
|
|
403 |
SPI_InitStruct.ClockPhase = LL_SPI_PHASE_2EDGE ; //LL_SPI_PHASE_1EDGE;
|
|
404 |
SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
|
|
405 |
SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV4;
|
|
406 |
SPI_InitStruct.BitOrder = LL_SPI_LSB_FIRST;
|
|
407 |
SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
|
|
408 |
SPI_InitStruct.CRCPoly = 7;
|
|
409 |
LL_SPI_Init(SPI1, &SPI_InitStruct);
|
|
410 |
|
|
411 |
LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
|
|
412 |
LL_SPI_DisableNSSPulseMgt(SPI1);
|
|
413 |
LL_SPI_SetRxFIFOThreshold(SPI1,LL_SPI_RX_FIFO_TH_QUARTER);
|
|
414 |
// LL_SPI_EnableNSSPulseMgt(SPI1);
|
|
415 |
|
a7db3c
|
416 |
#else
|
Q |
417 |
|
f4f290
|
418 |
/* USER CODE END SPI1_Init 1 */
|
Q |
419 |
|
|
420 |
/* SPI1 parameter configuration*/
|
bfc108
|
421 |
SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
|
Q |
422 |
SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
|
|
423 |
SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
|
|
424 |
SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW;
|
|
425 |
SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE;
|
|
426 |
SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
|
|
427 |
SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV4;
|
|
428 |
SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
|
|
429 |
SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
|
|
430 |
SPI_InitStruct.CRCPoly = 7;
|
|
431 |
LL_SPI_Init(SPI1, &SPI_InitStruct);
|
|
432 |
|
|
433 |
LL_SPI_SetStandard(SPI1, LL_SPI_PROTOCOL_MOTOROLA);
|
f4f290
|
434 |
|
a7db3c
|
435 |
LL_SPI_SetRxFIFOThreshold(SPI1,LL_SPI_RX_FIFO_TH_QUARTER);
|
f4f290
|
436 |
// LL_SPI_EnableNSSPulseMgt(SPI1);
|
Q |
437 |
|
|
438 |
/* USER CODE BEGIN SPI1_Init 2 */
|
a7db3c
|
439 |
|
Q |
440 |
#endif
|
|
441 |
|
0aeaad
|
442 |
LL_SPI_Enable(SPI1);
|
bfc108
|
443 |
/* USER CODE END SPI1_Init 2 */
|
Q |
444 |
}
|
0aeaad
|
445 |
|
Q |
446 |
/* SPI2 init function */
|
|
447 |
void MX_SPI2_Init(void)
|
|
448 |
{
|
|
449 |
|
|
450 |
LL_SPI_InitTypeDef SPI_InitStruct = {0};
|
|
451 |
|
|
452 |
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
453 |
|
|
454 |
/* Peripheral clock enable */
|
|
455 |
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI2);
|
|
456 |
|
|
457 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
|
|
458 |
/**SPI2 GPIO Configuration
|
|
459 |
PB13 ------> SPI2_SCK
|
|
460 |
PB14 ------> SPI2_MISO
|
|
461 |
PB15 ------> SPI2_MOSI
|
|
462 |
*/
|
|
463 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_13;
|
|
464 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
465 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
466 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
467 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
468 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
469 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
470 |
|
|
471 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_14;
|
|
472 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
473 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
474 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
475 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
476 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
477 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
478 |
|
|
479 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_15;
|
|
480 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
481 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
482 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
483 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
484 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
|
|
485 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
486 |
|
|
487 |
/* SPI2 interrupt Init */
|
|
488 |
//NVIC_SetPriority(SPI2_IRQn, 0);
|
|
489 |
//NVIC_EnableIRQ(SPI2_IRQn);
|
|
490 |
/* USER CODE BEGIN SPI2_Init 1 */
|
|
491 |
|
|
492 |
/* USER CODE END SPI2_Init 1 */
|
|
493 |
|
|
494 |
/* SPI2 parameter configuration*/
|
|
495 |
SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
|
|
496 |
SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
|
|
497 |
SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
|
|
498 |
SPI_InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW; //LL_SPI_POLARITY_HIGH;//LL_SPI_POLARITY_LOW;
|
|
499 |
SPI_InitStruct.ClockPhase = LL_SPI_PHASE_1EDGE; //LL_SPI_PHASE_1EDGE;
|
|
500 |
SPI_InitStruct.NSS = LL_SPI_NSS_SOFT;
|
|
501 |
SPI_InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;
|
|
502 |
SPI_InitStruct.BitOrder = LL_SPI_MSB_FIRST;
|
|
503 |
SPI_InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
|
|
504 |
SPI_InitStruct.CRCPoly = 7;
|
|
505 |
LL_SPI_Init(SPI2, &SPI_InitStruct);
|
|
506 |
LL_SPI_SetStandard(SPI2, LL_SPI_PROTOCOL_MOTOROLA);
|
|
507 |
LL_SPI_EnableNSSPulseMgt(SPI2);
|
|
508 |
/* USER CODE BEGIN SP21_Init 2 */
|
|
509 |
LL_SPI_Enable(SPI2);
|
|
510 |
/* USER CODE END SPI2_Init 2 */
|
|
511 |
}
|
|
512 |
|
bfc108
|
513 |
|
Q |
514 |
/* USART1 init function */
|
|
515 |
void MX_USART1_UART_Init(void)
|
|
516 |
{
|
|
517 |
|
|
518 |
LL_USART_InitTypeDef USART_InitStruct;
|
|
519 |
|
|
520 |
LL_GPIO_InitTypeDef GPIO_InitStruct;
|
|
521 |
|
|
522 |
/* Peripheral clock enable */
|
|
523 |
LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_USART1);
|
|
524 |
|
|
525 |
/**USART1 GPIO Configuration
|
|
526 |
// PA1 ------> USART1_DE
|
|
527 |
PA9 ------> USART1_TX
|
|
528 |
PA10 ------> USART1_RX
|
|
529 |
*/
|
|
530 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_9|LL_GPIO_PIN_10;
|
|
531 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
532 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
533 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
534 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
535 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_1;
|
|
536 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
537 |
|
|
538 |
/* USART1 DMA Init */
|
|
539 |
|
|
540 |
/* USART1_TX Init */
|
|
541 |
LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_2, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
|
|
542 |
LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_2, LL_DMA_PRIORITY_LOW);
|
|
543 |
LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_2, LL_DMA_MODE_NORMAL);
|
|
544 |
LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_2, LL_DMA_PERIPH_NOINCREMENT);
|
|
545 |
LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_2, LL_DMA_MEMORY_INCREMENT);
|
|
546 |
LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_2, LL_DMA_PDATAALIGN_BYTE);
|
|
547 |
LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_2, LL_DMA_MDATAALIGN_BYTE);
|
|
548 |
|
|
549 |
/* USART1_RX Init */
|
|
550 |
LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_3, LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
|
|
551 |
LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_3, LL_DMA_PRIORITY_LOW);
|
|
552 |
LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_3, LL_DMA_MODE_NORMAL);
|
|
553 |
LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_3, LL_DMA_PERIPH_NOINCREMENT);
|
|
554 |
LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_3, LL_DMA_MEMORY_INCREMENT);
|
|
555 |
LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_3, LL_DMA_PDATAALIGN_BYTE);
|
|
556 |
LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_3, LL_DMA_MDATAALIGN_BYTE);
|
|
557 |
|
|
558 |
/* USART1 interrupt Init */
|
|
559 |
NVIC_SetPriority(USART1_IRQn, 0);
|
|
560 |
NVIC_EnableIRQ(USART1_IRQn);
|
|
561 |
|
|
562 |
USART_InitStruct.BaudRate = Uart1Baud;
|
|
563 |
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
|
564 |
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
|
565 |
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
|
|
566 |
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
|
|
567 |
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
|
|
568 |
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16;
|
|
569 |
LL_USART_Init(USART1, &USART_InitStruct);
|
|
570 |
// LL_USART_EnableDEMode(USART1);
|
|
571 |
// LL_USART_SetDESignalPolarity(USART1, LL_USART_DE_POLARITY_LOW);
|
|
572 |
// LL_USART_SetDEAssertionTime(USART1, 1);
|
|
573 |
// LL_USART_SetDEDeassertionTime(USART1, 1);
|
|
574 |
// LL_USART_EnableOneBitSamp(USART1);
|
|
575 |
LL_USART_EnableAutoBaudRate(USART1);
|
|
576 |
LL_USART_SetAutoBaudRateMode(USART1, LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE);
|
|
577 |
LL_USART_DisableOverrunDetect(USART1);
|
|
578 |
LL_USART_ConfigAsyncMode(USART1);
|
|
579 |
LL_USART_Enable(USART1);
|
|
580 |
}
|
|
581 |
|
|
582 |
|
|
583 |
/* USART2 init function */
|
|
584 |
void MX_USART2_UART_Init(void)
|
|
585 |
{
|
|
586 |
|
|
587 |
LL_USART_InitTypeDef USART_InitStruct = {0};
|
|
588 |
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
589 |
|
|
590 |
/* Peripheral clock enable */
|
|
591 |
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
|
|
592 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
|
|
593 |
|
|
594 |
/**USART2 GPIO Configuration
|
|
595 |
PA1 ------> USART2_DE
|
|
596 |
PA2 ------> USART2_TX
|
|
597 |
PA3 ------> USART2_RX
|
|
598 |
*/
|
|
599 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_3;
|
|
600 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
601 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
602 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
603 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
604 |
GPIO_InitStruct.Alternate = LL_GPIO_AF_1;
|
|
605 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
606 |
|
|
607 |
/* USART2 DMA Init */
|
|
608 |
|
|
609 |
/* USART2_TX Init */
|
|
610 |
LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_4, LL_DMA_DIRECTION_MEMORY_TO_PERIPH);
|
|
611 |
LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_4, LL_DMA_PRIORITY_LOW);
|
|
612 |
LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_4, LL_DMA_MODE_NORMAL);
|
|
613 |
LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_4, LL_DMA_PERIPH_NOINCREMENT);
|
|
614 |
LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_4, LL_DMA_MEMORY_INCREMENT);
|
|
615 |
LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_4, LL_DMA_PDATAALIGN_BYTE);
|
|
616 |
LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_4, LL_DMA_MDATAALIGN_BYTE);
|
|
617 |
|
|
618 |
/* USART2_RX Init */
|
|
619 |
LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_5, LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
|
|
620 |
LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_5, LL_DMA_PRIORITY_LOW);
|
|
621 |
LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_5, LL_DMA_MODE_NORMAL);
|
|
622 |
LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_5, LL_DMA_PERIPH_NOINCREMENT);
|
|
623 |
LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_5, LL_DMA_MEMORY_INCREMENT);
|
|
624 |
LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_5, LL_DMA_PDATAALIGN_BYTE);
|
|
625 |
LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_5, LL_DMA_MDATAALIGN_BYTE);
|
|
626 |
|
|
627 |
/* USART2 interrupt Init */
|
|
628 |
NVIC_SetPriority(USART2_IRQn, 0);
|
|
629 |
NVIC_EnableIRQ(USART2_IRQn);
|
|
630 |
|
|
631 |
NVIC_SetPriority(PendSV_IRQn, 255);
|
|
632 |
NVIC_EnableIRQ(PendSV_IRQn);
|
|
633 |
// NVIC_SetPendingIRQ(PendSV_IRQn);
|
|
634 |
|
|
635 |
USART_InitStruct.BaudRate = Uart2Baud;
|
|
636 |
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
|
637 |
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
|
638 |
USART_InitStruct.Parity = LL_USART_PARITY_NONE;
|
|
639 |
USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX;
|
|
640 |
USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
|
|
641 |
USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_8;
|
|
642 |
LL_USART_Init(USART2, &USART_InitStruct);
|
|
643 |
|
|
644 |
LL_USART_EnableDEMode(USART2);
|
|
645 |
LL_USART_SetDESignalPolarity(USART2, LL_USART_DE_POLARITY_LOW);
|
|
646 |
// LL_USART_SetDESignalPolarity(USART2, LL_USART_DE_POLARITY_HIGH);
|
|
647 |
LL_USART_SetDEAssertionTime(USART2, 3);
|
|
648 |
LL_USART_SetDEDeassertionTime(USART2, 3);
|
a7db3c
|
649 |
// LL_USART_EnableOneBitSamp(USART2);
|
bfc108
|
650 |
// LL_USART_EnableAutoBaudRate(USART2);
|
Q |
651 |
// LL_USART_SetAutoBaudRateMode(USART2, LL_USART_AUTOBAUD_DETECT_ON_FALLINGEDGE);
|
|
652 |
LL_USART_DisableOverrunDetect(USART2);
|
|
653 |
LL_USART_ConfigAsyncMode(USART2);
|
|
654 |
LL_USART_Enable(USART2);
|
|
655 |
}
|
|
656 |
|
|
657 |
/**
|
|
658 |
* Enable DMA controller clock
|
|
659 |
*/
|
|
660 |
void MX_DMA_Init(void)
|
|
661 |
{
|
|
662 |
/* Init with LL driver */
|
|
663 |
/* DMA controller clock enable */
|
|
664 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1);
|
|
665 |
|
|
666 |
/* DMA interrupt init */
|
|
667 |
/* DMA1_Channel2_3_IRQn interrupt configuration */
|
|
668 |
NVIC_SetPriority(DMA1_Channel2_3_IRQn, 0);
|
|
669 |
NVIC_EnableIRQ(DMA1_Channel2_3_IRQn);
|
|
670 |
NVIC_SetPriority(DMA1_Channel4_5_IRQn, 0);
|
|
671 |
NVIC_EnableIRQ(DMA1_Channel4_5_IRQn);
|
|
672 |
}
|
|
673 |
|
|
674 |
/** Configure pins as
|
|
675 |
* Analog
|
|
676 |
* Input
|
|
677 |
* Output
|
|
678 |
* EVENT_OUT
|
|
679 |
* EXTI
|
|
680 |
*/
|
|
681 |
void MX_GPIO_Init(void)
|
|
682 |
{
|
|
683 |
|
|
684 |
LL_GPIO_InitTypeDef GPIO_InitStruct;
|
|
685 |
|
|
686 |
/* GPIO Ports Clock Enable */
|
|
687 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
|
|
688 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
|
|
689 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOC);
|
a7db3c
|
690 |
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOF);
|
bfc108
|
691 |
/**/
|
Q |
692 |
|
|
693 |
|
|
694 |
/**/
|
a7db3c
|
695 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_6 |LL_GPIO_PIN_7;
|
bfc108
|
696 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
Q |
697 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
698 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
699 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
700 |
|
|
701 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_7 ;
|
|
702 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
703 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
704 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
705 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
706 |
|
|
707 |
|
|
708 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_8|LL_GPIO_PIN_11;
|
|
709 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
710 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
711 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
712 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
713 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
714 |
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_8);
|
|
715 |
|
|
716 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_9|LL_GPIO_PIN_10;
|
|
717 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
718 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
719 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
720 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
721 |
|
|
722 |
|
|
723 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10;
|
|
724 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
725 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
726 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
727 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
728 |
|
|
729 |
if (GetBoardType()==2)
|
|
730 |
{
|
|
731 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
a7db3c
|
732 |
LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15;
|
bfc108
|
733 |
|
Q |
734 |
}
|
f4f290
|
735 |
else if (GetBoardType()==9 || GetBoardType()==10 || GetBoardType()==15 )
|
bfc108
|
736 |
{
|
a7db3c
|
737 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
Q |
738 |
LL_GPIO_PIN_11|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10|
|
|
739 |
LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15;
|
bfc108
|
740 |
}
|
0aeaad
|
741 |
else if ( GetBoardType() == 11 )
|
Q |
742 |
{
|
|
743 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
a7db3c
|
744 |
LL_GPIO_PIN_2|LL_GPIO_PIN_10|LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15;
|
Q |
745 |
} else if (BOARD_TYPE == 14)
|
bfc108
|
746 |
{
|
a7db3c
|
747 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
Q |
748 |
LL_GPIO_PIN_10|LL_GPIO_PIN_11|LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_14|LL_GPIO_PIN_15;
|
|
749 |
} else
|
|
750 |
{
|
bfc108
|
751 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_3|LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7|
|
a7db3c
|
752 |
LL_GPIO_PIN_0|LL_GPIO_PIN_1|LL_GPIO_PIN_2|LL_GPIO_PIN_10|
|
Q |
753 |
LL_GPIO_PIN_12|LL_GPIO_PIN_13|LL_GPIO_PIN_15;
|
|
754 |
}
|
bfc108
|
755 |
|
Q |
756 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
757 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
758 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
759 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
760 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
761 |
|
a7db3c
|
762 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_13|LL_GPIO_PIN_14|LL_GPIO_PIN_15;
|
bfc108
|
763 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
Q |
764 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_LOW;
|
|
765 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
766 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
767 |
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
768 |
|
|
769 |
// RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC|RCC_APB2Periph_AFIO,ENABLE );
|
|
770 |
// PWR_BackupAccessCmd( ENABLE );/* ????RTC??????*/
|
|
771 |
// RCC_LSEConfig( RCC_LSE_OFF ); /* ????????,PC14+PC15??????IO*/
|
|
772 |
// BKP_TamperPinCmd(DISABLE); /* ????????,PC13??????IO*/
|
f4f290
|
773 |
|
Q |
774 |
#if (BORAD_TYPE == 13)
|
|
775 |
|
|
776 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_15 ;
|
|
777 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
778 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
779 |
GPIO_InitStruct.Pull = LL_GPIO_OUTPUT_PUSHPULL;
|
|
780 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
781 |
|
|
782 |
#elif (BOARD_TYPE == 14)
|
a7db3c
|
783 |
|
Q |
784 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_4|LL_GPIO_PIN_5|LL_GPIO_PIN_6|LL_GPIO_PIN_7;
|
|
785 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
786 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
787 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
788 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
789 |
LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_8);
|
|
790 |
|
|
791 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_9 ; //RST_PIN in
|
|
792 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
793 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
794 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
795 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
796 |
|
|
797 |
GPIO_InitStruct.Pin = SYN_PIN ; //SYN_PIN Pin in
|
|
798 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
799 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
800 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
801 |
LL_GPIO_Init(SYN_PORT, &GPIO_InitStruct);
|
|
802 |
|
|
803 |
GPIO_InitStruct.Pin = ACK_PIN ; //ACK_PIN Pin out
|
|
804 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
805 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
806 |
GPIO_InitStruct.Pull = LL_GPIO_OUTPUT_PUSHPULL;
|
|
807 |
LL_GPIO_Init(ACK_PORT, &GPIO_InitStruct);
|
|
808 |
|
|
809 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_7 ; //485DE Pin out
|
|
810 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
811 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
812 |
GPIO_InitStruct.Pull = LL_GPIO_OUTPUT_PUSHPULL;
|
|
813 |
LL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
|
814 |
|
|
815 |
GPIO_InitStruct.Pin = OE_PIN ; // OE Pin in
|
|
816 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
817 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
818 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
|
819 |
LL_GPIO_Init(OE_PORT, &GPIO_InitStruct);
|
|
820 |
|
f4f290
|
821 |
#elif (BOARD_TYPE == 15)
|
a7db3c
|
822 |
|
f4f290
|
823 |
// Radio Pins
|
Q |
824 |
// busy pin
|
|
825 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_7;
|
|
826 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
a7db3c
|
827 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
f4f290
|
828 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
Q |
829 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
830 |
|
|
831 |
// Dio 1 pin
|
|
832 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_12;
|
|
833 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT;
|
|
834 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
835 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
a7db3c
|
836 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
f4f290
|
837 |
|
Q |
838 |
|
|
839 |
//Sel pin
|
|
840 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_15;
|
|
841 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
842 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
843 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
844 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
845 |
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
846 |
|
|
847 |
|
|
848 |
//RST pin
|
|
849 |
GPIO_InitStruct.Pin = LL_GPIO_PIN_6;
|
|
850 |
GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT;
|
|
851 |
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH;
|
|
852 |
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
853 |
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
|
854 |
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
a7db3c
|
855 |
|
Q |
856 |
#endif
|
bfc108
|
857 |
|
Q |
858 |
}
|