forked from dccharacter/AHRS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw_config.c
591 lines (493 loc) · 17.1 KB
/
hw_config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
/**
******************************************************************************
* @file hw_config.c
* @author MCD Application Team
* @version V1.1.0
* @date 20-September-2012
* @brief Hardware Configuration & Setup.
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f30x.h"
#include "hw_config.h"
#include "platform_config.h"
#include "stm32f3_discovery.h"
#include "stm32f3_discovery_l3gd20.h"
#include <stdio.h>
#include <stdarg.h>
#ifdef USART_USE_USB
#include "usb_lib.h"
#include "usb_desc.h"
#include "usb_pwr.h"
#include "usb_lib.h"
#endif //#ifdef USART_USE_USB
/** @addtogroup STM32F3-Discovery_Demo
* @{
*/
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
ErrorStatus HSEStartUpStatus;
EXTI_InitTypeDef EXTI_InitStructure;
uint8_t USART_Rx_Buffer [USART_RX_DATA_SIZE];
uint32_t USART_Rx_ptr_in = 0;
uint32_t USART_Rx_ptr_out = 0;
uint32_t USART_Rx_length = 0;
uint8_t USB_Tx_State = 0;
/* Extern variables ----------------------------------------------------------*/
extern __IO uint8_t PrevXferComplete;
/* Private function prototypes -----------------------------------------------*/
#ifdef USART_USE_USB
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len);
#endif //#ifdef USART_USE_USB
/* Private functions ---------------------------------------------------------*/
#ifdef USART_USE_USART
void USART_Config (void);
uint8_t USART_TxBuffer[60];
int16_t USART_printfWithDMA(const char * format, va_list args);
#endif //#ifdef USART_USE_USART
/**
* @brief Configures Main system clocks & power.
* @param None
* @retval None
*/
void Set_System(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f30x.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f30x.c file
*/
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Enable the SYSCFG module clock (used for the USB disconnect feature) */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Enable the USB disconnect GPIO clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIO_DISCONNECT, ENABLE);
/*Set PA11,12 as IN - USB_DM,DP*/
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/*SET PA11,12 for USB: USB_DM,DP*/
GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);
#if defined(USB_USE_EXTERNAL_PULLUP)
/* Enable the USB disconnect GPIO clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIO_DISCONNECT, ENABLE);
/* USB_DISCONNECT used as USB pull-up */
GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
#endif /* USB_USE_EXTERNAL_PULLUP */
/* Configure the Key button in EXTI mode */
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
#ifdef USART_USE_USB
/* Configure the EXTI line 18 connected internally to the USB IP */
EXTI_ClearITPendingBit(EXTI_Line18);
EXTI_InitStructure.EXTI_Line = EXTI_Line18; /*USB resume from suspend mode*/
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
EXTI_ClearITPendingBit(USER_BUTTON_EXTI_LINE);
#endif
#ifdef USART_USE_USART
USART_Config();
#endif //#ifdef USART_USE_USART
}
/**
* @brief Configures all IOs as AIN to reduce the power consumption.
* @param None
* @retval None
*/
void GPIO_AINConfig(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */
/* Enable all GPIOs Clock*/
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ALLGPIO, ENABLE);
/* Configure all GPIO port pins in Analog Input mode (floating input trigger OFF) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* Disable all GPIOs Clock*/
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ALLGPIO, DISABLE);
}
#ifdef USART_USE_USB
/**
* @brief Configures USB Clock input (48MHz).
* @param None
* @retval None
*/
void Set_USBClock(void)
{
/* USBCLK = PLLCLK = 48 MHz */
RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
/* Enable USB clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
}
/**
* @brief Power-off system clocks and power while entering suspend mode.
* @param None
* @retval None
*/
void Enter_LowPowerMode(void)
{
/* Set the device state to suspend */
bDeviceState = SUSPENDED;
/* Clear EXTI Line18 pending bit */
EXTI_ClearITPendingBit(USER_BUTTON_EXTI_LINE);
}
/**
* @brief Restores system clocks and power while exiting suspend mode.
* @param None
* @retval None
*/
void Leave_LowPowerMode(void)
{
DEVICE_INFO *pInfo = &Device_Info;
/* Enable HSE */
RCC_HSEConfig(RCC_HSE_ON);
/* Wait till HSE is ready */
HSEStartUpStatus = RCC_WaitForHSEStartUp();
/* Wait till HSE is ready */
while (RCC_GetFlagStatus(RCC_FLAG_HSERDY) == RESET)
{}
/* Enable PLL1 */
RCC_PLLCmd(ENABLE);
/* Wait till PLL1 is ready */
while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
{}
/* Select PLL as system clock source */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* Wait till PLL is used as system clock source */
while (RCC_GetSYSCLKSource() != 0x08)
{}
/* Set the device state to the correct state */
if (pInfo->Current_Configuration != 0)
{
/* Device configured */
bDeviceState = CONFIGURED;
}
else
{
bDeviceState = ATTACHED;
}
}
/**
* @brief Configures the USB interrupts.
* @param None
* @retval None
*/
void USB_Interrupts_Config(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
/* 2 bit for pre-emption priority, 2 bits for subpriority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
/* Enable the USB interrupt */
#if defined (USB_INT_DEFAULT)
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
#endif
#if defined (USB_INT_REMAP)
NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;
#endif
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USB Wake-up interrupt */
#if defined (USB_INT_DEFAULT)
NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn;
#endif
#if defined (USB_INT_REMAP)
NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_RMP_IRQn;
#endif
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the Key EXTI line Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USER_BUTTON_EXTI_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_Init(&NVIC_InitStructure);
}
/**
* @brief Software Connection/Disconnection of USB Cable.
* @param None
* @retval None
*/
void USB_Cable_Config (FunctionalState NewState)
{
if (NewState != DISABLE)
{
GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
}
else
{
GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
}
}
#ifdef USB_VCP
/*******************************************************************************
* Function Name : Handle_USBAsynchXfer.
* Description : send data to USB.
* Input : None.
* Return : none.
*******************************************************************************/
void Handle_USBAsynchXfer (void)
{
uint16_t USB_Tx_ptr;
uint16_t USB_Tx_length;
if (USART_Rx_ptr_out == USART_RX_DATA_SIZE)
{
USART_Rx_ptr_out = 0;
}
if(USART_Rx_ptr_out == USART_Rx_ptr_in)
{
USB_Tx_State = 0;
return;
}
if(USART_Rx_ptr_out > USART_Rx_ptr_in) /* rollback */
{
USART_Rx_length = USART_RX_DATA_SIZE - USART_Rx_ptr_out;
}
else
{
USART_Rx_length = USART_Rx_ptr_in - USART_Rx_ptr_out;
}
if (USART_Rx_length > VIRTUAL_COM_PORT_DATA_SIZE)
{
USB_Tx_ptr = USART_Rx_ptr_out;
USB_Tx_length = VIRTUAL_COM_PORT_DATA_SIZE;
USART_Rx_ptr_out += VIRTUAL_COM_PORT_DATA_SIZE;
USART_Rx_length -= VIRTUAL_COM_PORT_DATA_SIZE;
}
else
{
USB_Tx_ptr = USART_Rx_ptr_out;
USB_Tx_length = USART_Rx_length;
USART_Rx_ptr_out += USART_Rx_length;
USART_Rx_length = 0;
}
USB_Tx_State = 1;
UserToPMABufferCopy(&USART_Rx_Buffer[USB_Tx_ptr], ENDP1_TXADDR, USB_Tx_length);
SetEPTxCount(ENDP1, USB_Tx_length);
SetEPTxValid(ENDP1);
}
#endif //#ifdef USB_VCP
/*******************************************************************************
* Function Name : UART_To_USB_Send_Data.
* Description : send the received data from UART 0 to USB.
* Input : None.
* Return : none.
*******************************************************************************/
void USB_Send_Data(uint8_t data)
{
USART_Rx_Buffer[USART_Rx_ptr_in] = data;
USART_Rx_ptr_in++;
/* To avoid buffer overflow */
if(USART_Rx_ptr_in >= USART_RX_DATA_SIZE)
{
USART_Rx_ptr_in = 0;
}
}
//âûâîä ñèìâîëîâ â ïîðò
int putchar(int c)
{
USART_Rx_Buffer[USART_Rx_ptr_in] = (uint8_t) c;
USART_Rx_ptr_in++;
/* To avoid buffer overflow */
if(USART_Rx_ptr_in >= USART_RX_DATA_SIZE)
{
USART_Rx_ptr_in = 0;
}
return c;
}
/**
* @brief Create the serial number string descriptor.
* @param None.
* @retval None
*/
void Get_SerialNum(void)
{
uint32_t Device_Serial0, Device_Serial1, Device_Serial2;
Device_Serial0 = *(__IO uint32_t*)(0x1FFFF7E8);
Device_Serial1 = *(__IO uint32_t*)(0x1FFFF7EC);
Device_Serial2 = *(__IO uint32_t*)(0x1FFFF7F0);
Device_Serial0 += Device_Serial2;
if (Device_Serial0 != 0)
{
#ifdef USB_JOYSTICK
IntToUnicode (Device_Serial0, &Joystick_StringSerial[2] , 8);
IntToUnicode (Device_Serial1, &Joystick_StringSerial[18], 4);
#endif //#ifdef USB_JOYSTICK
#ifdef USB_VCP
IntToUnicode (Device_Serial0, &Virtual_Com_Port_StringSerial[2] , 8);
IntToUnicode (Device_Serial1, &Virtual_Com_Port_StringSerial[18], 4);
#endif //#ifdef USB_VCP
}
}
/**
* @brief Convert Hex 32Bits value into char.
* @param value: Data to be converted.
* @param pbuf: pointer to buffer.
* @param len: Data length.
* @retval None
*/
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len)
{
uint8_t idx = 0;
for( idx = 0 ; idx < len ; idx ++)
{
if( ((value >> 28)) < 0xA )
{
pbuf[ 2* idx] = (value >> 28) + '0';
}
else
{
pbuf[2* idx] = (value >> 28) + 'A' - 10;
}
value = value << 4;
pbuf[ 2* idx + 1] = 0;
}
}
#endif //#ifdef USART_USE_USB
#ifdef USART_USE_USART
void USART_Config (void) {
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_7);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
DMA_InitTypeDef DMA_InitStructure;
/* Enable DMA2 clock -------------------------------------------------------*/
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
DMA_DeInit(DMA1_Channel7);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)(&USART2->TDR);
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)USART_TxBuffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 32;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_MemoryDataSize = DMA_PeripheralDataSize_Byte;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel7, &DMA_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_BaudRate = 115200;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2, ENABLE);
USART_DMACmd(USART2, USART_DMAReq_Tx, ENABLE);
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Channel7_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
DMA_ITConfig(DMA1_Channel7, DMA_IT_TC, ENABLE);
DMA_Cmd(DMA1_Channel7, ENABLE);
}
void USART_InitDMATransfer(int16_t bufferSize) {
if (bufferSize < 0) {
//capture error
return;
}
DMA_Cmd(DMA1_Channel7, DISABLE);
DMA1_Channel7->CNDTR = bufferSize;
DMA1_Channel7->CMAR = (uint32_t)USART_TxBuffer;
DMA_Cmd(DMA1_Channel7, ENABLE);
}
int16_t USART_printfWithDMA(const char * format, va_list args) {
int16_t numBytes, dmaDataCounter;
dmaDataCounter = DMA_GetCurrDataCounter(DMA1_Channel7);
if (dmaDataCounter != 0) return -3;
numBytes = vsprintf((char *)USART_TxBuffer, format, args);
USART_InitDMATransfer(numBytes);
return numBytes;
}
#endif //#ifdef USART_USE_USART
int16_t myPrintf(const char * format, ...) {
int16_t numBytes;
va_list args;
va_start(args, format);
#ifdef USART_USE_USART
numBytes = USART_printfWithDMA(format, args);
#else
numBytes = vprintf(format, args);
#endif //#ifdef USART_USE_USART
va_end( args );
return numBytes;
}
void GyroExtiConfig(void) {
//GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
//RCC_AHBPeriphClockCmd(L3GD20_SPI_INT2_GPIO_CLK, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
/* Configure Button pin as input */ //ALREADY CONFIGURED IN Discovery library
/*GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_InitStructure.GPIO_Pin = L3GD20_SPI_INT2_PIN;
GPIO_Init(L3GD20_SPI_INT2_GPIO_PORT, &GPIO_InitStructure);*/
/* Connect Button EXTI Line to Button GPIO Pin */
SYSCFG_EXTILineConfig(L3GD20_SPI_INT2_EXTI_PORT_SOURCE, L3GD20_SPI_INT2_EXTI_PIN_SOURCE);
/* Configure Button EXTI line */
EXTI_InitStructure.EXTI_Line = L3GD20_SPI_INT2_EXTI_LINE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* Enable and set Button EXTI Interrupt to the lowest priority */
NVIC_InitStructure.NVIC_IRQChannel = L3GD20_SPI_INT2_EXTI_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/