/
stm32f407xx.h
622 lines (521 loc) · 21.1 KB
/
stm32f407xx.h
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
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
/*
* stm3f407xx.h
*
* Created on: Jan 29, 2019
* Author: admin
*/
#ifndef INC_STM3F407XX_H_
#define INC_STM3F407XX_H_
#include<stddef.h>
#include<stdint.h>
#define __vo volatile
#define __weak __attribute__((weak))
/**********************************START:Processor Specific Details **********************************/
/*
* ARM Cortex Mx Processor NVIC ISERx register Addresses
*/
#define NVIC_ISER0 ( (__vo uint32_t*)0xE000E100 )
#define NVIC_ISER1 ( (__vo uint32_t*)0xE000E104 )
#define NVIC_ISER2 ( (__vo uint32_t*)0xE000E108 )
#define NVIC_ISER3 ( (__vo uint32_t*)0xE000E10c )
/*
* ARM Cortex Mx Processor NVIC ICERx register Addresses
*/
#define NVIC_ICER0 ((__vo uint32_t*)0XE000E180)
#define NVIC_ICER1 ((__vo uint32_t*)0XE000E184)
#define NVIC_ICER2 ((__vo uint32_t*)0XE000E188)
#define NVIC_ICER3 ((__vo uint32_t*)0XE000E18C)
/*
* ARM Cortex Mx Processor Priority Register Address Calculation
*/
#define NVIC_PR_BASE_ADDR ((__vo uint32_t*)0xE000E400)
/*
* ARM Cortex Mx Processor number of priority bits implemented in Priority Register
*/
#define NO_PR_BITS_IMPLEMENTED 4
/*
* base addresses of Flash and SRAM memories
*/
#define FLASH_BASEADDR 0x08000000U /*!<explain this macro briefly here */
#define SRAM1_BASEADDR 0x20000000U /*!<explain this macro briefly here */
#define SRAM2_BASEADDR 0x2001C000U /*!<explain this macro briefly here */
#define ROM_BASEADDR 0x1FFF0000U
#define SRAM SRAM1_BASEADDR
/*
* AHBx and APBx Bus Peripheral base addresses
*/
#define PERIPH_BASEADDR 0x40000000U
#define APB1PERIPH_BASEADDR PERIPH_BASEADDR
#define APB2PERIPH_BASEADDR 0x40010000U
#define AHB1PERIPH_BASEADDR 0x40020000U
#define AHB2PERIPH_BASEADDR 0x50000000U
/*
* Base addresses of peripherals which are hanging on AHB1 bus
* TODO : Complete for all other peripherals
*/
#define GPIOA_BASEADDR (AHB1PERIPH_BASEADDR + 0x0000)
#define GPIOB_BASEADDR (AHB1PERIPH_BASEADDR + 0x0400)
#define GPIOC_BASEADDR (AHB1PERIPH_BASEADDR + 0x0800)
#define GPIOD_BASEADDR (AHB1PERIPH_BASEADDR + 0x0C00)
#define GPIOE_BASEADDR (AHB1PERIPH_BASEADDR + 0x1000)
#define GPIOF_BASEADDR (AHB1PERIPH_BASEADDR + 0x1400)
#define GPIOG_BASEADDR (AHB1PERIPH_BASEADDR + 0x1800)
#define GPIOH_BASEADDR (AHB1PERIPH_BASEADDR + 0x1C00)
#define GPIOI_BASEADDR (AHB1PERIPH_BASEADDR + 0x2000)
#define RCC_BASEADDR (AHB1PERIPH_BASEADDR + 0x3800)
/*
* Base addresses of peripherals which are hanging on APB1 bus
* TODO : Complete for all other peripherals
*/
#define I2C1_BASEADDR (APB1PERIPH_BASEADDR + 0x5400)
#define I2C2_BASEADDR (APB1PERIPH_BASEADDR + 0x5800)
#define I2C3_BASEADDR (APB1PERIPH_BASEADDR + 0x5C00)
#define SPI2_BASEADDR (APB1PERIPH_BASEADDR + 0x3800)
#define SPI3_BASEADDR (APB1PERIPH_BASEADDR + 0x3C00)
#define USART2_BASEADDR (APB1PERIPH_BASEADDR + 0x4400)
#define USART3_BASEADDR (APB1PERIPH_BASEADDR + 0x4800)
#define UART4_BASEADDR (APB1PERIPH_BASEADDR + 0x4C00)
#define UART5_BASEADDR (APB1PERIPH_BASEADDR + 0x5000)
/*
* Base addresses of peripherals which are hanging on APB2 bus
* TODO : Complete for all other peripherals
*/
#define EXTI_BASEADDR (APB2PERIPH_BASEADDR + 0x3C00)
#define SPI1_BASEADDR (APB2PERIPH_BASEADDR + 0x3000)
#define SYSCFG_BASEADDR (APB2PERIPH_BASEADDR + 0x3800)
#define USART1_BASEADDR (APB2PERIPH_BASEADDR + 0x1000)
#define USART6_BASEADDR (APB2PERIPH_BASEADDR + 0x1400)
/**********************************peripheral register definition structures **********************************/
/*
* Note : Registers of a peripheral are specific to MCU
* e.g : Number of Registers of SPI peripheral of STM32F4x family of MCUs may be different(more or less)
* Compared to number of registers of SPI peripheral of STM32Lx or STM32F0x family of MCUs
* Please check your Device RM
*/
typedef struct
{
__vo uint32_t MODER; /*!< GPIO port mode register, Address offset: 0x00 */
__vo uint32_t OTYPER; /*!< TODO, Address offset: 0x04 */
__vo uint32_t OSPEEDR;
__vo uint32_t PUPDR;
__vo uint32_t IDR;
__vo uint32_t ODR;
__vo uint32_t BSRR;
__vo uint32_t LCKR;
__vo uint32_t AFR[2]; /*!< AFR[0] : GPIO alternate function low register, AF[1] : GPIO alternate function high register Address offset: 0x20-0x24 */
}GPIO_RegDef_t;
/*
* peripheral register definition structure for RCC
*/
typedef struct
{
__vo uint32_t CR; /*!< TODO, Address offset: 0x00 */
__vo uint32_t PLLCFGR; /*!< TODO, Address offset: 0x04 */
__vo uint32_t CFGR; /*!< TODO, Address offset: 0x08 */
__vo uint32_t CIR; /*!< TODO, Address offset: 0x0C */
__vo uint32_t AHB1RSTR; /*!< TODO, Address offset: 0x10 */
__vo uint32_t AHB2RSTR; /*!< TODO, Address offset: 0x14 */
__vo uint32_t AHB3RSTR; /*!< TODO, Address offset: 0x18 */
uint32_t RESERVED0; /*!< Reserved, 0x1C */
__vo uint32_t APB1RSTR; /*!< TODO, Address offset: 0x20 */
__vo uint32_t APB2RSTR; /*!< TODO, Address offset: 0x24 */
uint32_t RESERVED1[2]; /*!< Reserved, 0x28-0x2C */
__vo uint32_t AHB1ENR; /*!< TODO, Address offset: 0x30 */
__vo uint32_t AHB2ENR; /*!< TODO, Address offset: 0x34 */
__vo uint32_t AHB3ENR; /*!< TODO, Address offset: 0x38 */
uint32_t RESERVED2; /*!< Reserved, 0x3C */
__vo uint32_t APB1ENR; /*!< TODO, Address offset: 0x40 */
__vo uint32_t APB2ENR; /*!< TODO, Address offset: 0x44 */
uint32_t RESERVED3[2]; /*!< Reserved, 0x48-0x4C */
__vo uint32_t AHB1LPENR; /*!< TODO, Address offset: 0x50 */
__vo uint32_t AHB2LPENR; /*!< TODO, Address offset: 0x54 */
__vo uint32_t AHB3LPENR; /*!< TODO, Address offset: 0x58 */
uint32_t RESERVED4; /*!< Reserved, 0x5C */
__vo uint32_t APB1LPENR; /*!< TODO, Address offset: 0x60 */
__vo uint32_t APB2LPENR; /*!< RTODO, Address offset: 0x64 */
uint32_t RESERVED5[2]; /*!< Reserved, 0x68-0x6C */
__vo uint32_t BDCR; /*!< TODO, Address offset: 0x70 */
__vo uint32_t CSR; /*!< TODO, Address offset: 0x74 */
uint32_t RESERVED6[2]; /*!< Reserved, 0x78-0x7C */
__vo uint32_t SSCGR; /*!< TODO, Address offset: 0x80 */
__vo uint32_t PLLI2SCFGR; /*!< TODO, Address offset: 0x84 */
__vo uint32_t PLLSAICFGR; /*!< TODO, Address offset: 0x88 */
__vo uint32_t DCKCFGR; /*!< TODO, Address offset: 0x8C */
__vo uint32_t CKGATENR; /*!< TODO, Address offset: 0x90 */
__vo uint32_t DCKCFGR2; /*!< TODO, Address offset: 0x94 */
} RCC_RegDef_t;
/*
* peripheral register definition structure for EXTI
*/
typedef struct
{
__vo uint32_t IMR; /*!< Give a short description, Address offset: 0x00 */
__vo uint32_t EMR; /*!< TODO, Address offset: 0x04 */
__vo uint32_t RTSR; /*!< TODO, Address offset: 0x08 */
__vo uint32_t FTSR; /*!< TODO, Address offset: 0x0C */
__vo uint32_t SWIER; /*!< TODO, Address offset: 0x10 */
__vo uint32_t PR; /*!< TODO, Address offset: 0x14 */
}EXTI_RegDef_t;
/*
* peripheral register definition structure for SPI
*/
typedef struct
{
__vo uint32_t CR1; /*!< TODO, Address offset: 0x00 */
__vo uint32_t CR2; /*!< TODO, Address offset: 0x04 */
__vo uint32_t SR; /*!< TODO, Address offset: 0x08 */
__vo uint32_t DR; /*!< TODO, Address offset: 0x0C */
__vo uint32_t CRCPR; /*!< TODO, Address offset: 0x10 */
__vo uint32_t RXCRCR; /*!< TODO, Address offset: 0x14 */
__vo uint32_t TXCRCR; /*!< TODO, Address offset: 0x18 */
__vo uint32_t I2SCFGR; /*!< TODO, Address offset: 0x1C */
__vo uint32_t I2SPR; /*!< TODO, Address offset: 0x20 */
} SPI_RegDef_t;
/*
* peripheral register definition structure for SYSCFG
*/
typedef struct
{
__vo uint32_t MEMRMP; /*!< Give a short description, Address offset: 0x00 */
__vo uint32_t PMC; /*!< TODO, Address offset: 0x04 */
__vo uint32_t EXTICR[4]; /*!< TODO , Address offset: 0x08-0x14 */
uint32_t RESERVED1[2]; /*!< TODO Reserved, 0x18-0x1C */
__vo uint32_t CMPCR; /*!< TODO Address offset: 0x20 */
uint32_t RESERVED2[2]; /*!< Reserved, 0x24-0x28 */
__vo uint32_t CFGR; /*!< TODO Address offset: 0x2C */
} SYSCFG_RegDef_t;
/*
* peripheral register definition structure for I2C
*/
typedef struct
{
__vo uint32_t CR1; /*!< TODO, Address offset: 0x00 */
__vo uint32_t CR2; /*!< TODO, Address offset: 0x04 */
__vo uint32_t OAR1; /*!< TODO, Address offset: 0x08 */
__vo uint32_t OAR2; /*!< TODO, Address offset: 0x0C */
__vo uint32_t DR; /*!< TODO, Address offset: 0x10 */
__vo uint32_t SR1; /*!< TODO, Address offset: 0x14 */
__vo uint32_t SR2; /*!< TODO, Address offset: 0x18 */
__vo uint32_t CCR; /*!< TODO, Address offset: 0x1C */
__vo uint32_t TRISE; /*!< TODO, Address offset: 0x20 */
__vo uint32_t FLTR; /*!< TODO, Address offset: 0x24 */
}I2C_RegDef_t;
/*
* peripheral register definition structure for USART
*/
typedef struct
{
__vo uint32_t SR; /*!< TODO, Address offset: 0x00 */
__vo uint32_t DR; /*!< TODO, Address offset: 0x04 */
__vo uint32_t BRR; /*!< TODO, Address offset: 0x08 */
__vo uint32_t CR1; /*!< TODO, Address offset: 0x0C */
__vo uint32_t CR2; /*!< TODO, Address offset: 0x10 */
__vo uint32_t CR3; /*!< TODO, Address offset: 0x14 */
__vo uint32_t GTPR; /*!< TODO, Address offset: 0x18 */
} USART_RegDef_t;
/*
* peripheral definitions ( Peripheral base addresses typecasted to xxx_RegDef_t)
*/
#define GPIOA ((GPIO_RegDef_t*)GPIOA_BASEADDR)
#define GPIOB ((GPIO_RegDef_t*)GPIOB_BASEADDR)
#define GPIOC ((GPIO_RegDef_t*)GPIOC_BASEADDR)
#define GPIOD ((GPIO_RegDef_t*)GPIOD_BASEADDR)
#define GPIOE ((GPIO_RegDef_t*)GPIOE_BASEADDR)
#define GPIOF ((GPIO_RegDef_t*)GPIOF_BASEADDR)
#define GPIOG ((GPIO_RegDef_t*)GPIOG_BASEADDR)
#define GPIOH ((GPIO_RegDef_t*)GPIOH_BASEADDR)
#define GPIOI ((GPIO_RegDef_t*)GPIOI_BASEADDR)
#define RCC ((RCC_RegDef_t*)RCC_BASEADDR)
#define EXTI ((EXTI_RegDef_t*)EXTI_BASEADDR)
#define SYSCFG ((SYSCFG_RegDef_t*)SYSCFG_BASEADDR)
#define SPI1 ((SPI_RegDef_t*)SPI1_BASEADDR)
#define SPI2 ((SPI_RegDef_t*)SPI2_BASEADDR)
#define SPI3 ((SPI_RegDef_t*)SPI3_BASEADDR)
#define I2C1 ((I2C_RegDef_t*)I2C1_BASEADDR)
#define I2C2 ((I2C_RegDef_t*)I2C2_BASEADDR)
#define I2C3 ((I2C_RegDef_t*)I2C3_BASEADDR)
#define USART1 ((USART_RegDef_t*)USART1_BASEADDR)
#define USART2 ((USART_RegDef_t*)USART2_BASEADDR)
#define USART3 ((USART_RegDef_t*)USART3_BASEADDR)
#define UART4 ((USART_RegDef_t*)UART4_BASEADDR)
#define UART5 ((USART_RegDef_t*)UART5_BASEADDR)
#define USART6 ((USART_RegDef_t*)USART6_BASEADDR)
/*
* Clock Enable Macros for GPIOx peripherals
*/
#define GPIOA_PCLK_EN() (RCC->AHB1ENR |= (1 << 0))
#define GPIOB_PCLK_EN() (RCC->AHB1ENR |= (1 << 1))
#define GPIOC_PCLK_EN() (RCC->AHB1ENR |= (1 << 2))
#define GPIOD_PCLK_EN() (RCC->AHB1ENR |= (1 << 3))
#define GPIOE_PCLK_EN() (RCC->AHB1ENR |= (1 << 4))
#define GPIOF_PCLK_EN() (RCC->AHB1ENR |= (1 << 5))
#define GPIOG_PCLK_EN() (RCC->AHB1ENR |= (1 << 6))
#define GPIOH_PCLK_EN() (RCC->AHB1ENR |= (1 << 7))
#define GPIOI_PCLK_EN() (RCC->AHB1ENR |= (1 << 8))
/*
* Clock Enable Macros for I2Cx peripherals
*/
#define I2C1_PCLK_EN() (RCC->APB1ENR |= (1 << 21))
#define I2C2_PCLK_EN() (RCC->APB1ENR |= (1 << 22))
#define I2C3_PCLK_EN() (RCC->APB1ENR |= (1 << 23))
/*
* Clock Enable Macros for SPIx peripheralsbu
*/
#define SPI1_PCLK_EN() (RCC->APB2ENR |= (1 << 12))
#define SPI2_PCLK_EN() (RCC->APB1ENR |= (1 << 14))
#define SPI3_PCLK_EN() (RCC->APB1ENR |= (1 << 15))
#define SPI4_PCLK_EN() (RCC->APB2ENR |= (1 << 13))
/*
* Clock Enable Macros for USARTx peripherals
*/
#define USART1_PCCK_EN() (RCC->APB2ENR |= (1 << 4))
#define USART2_PCCK_EN() (RCC->APB1ENR |= (1 << 17))
#define USART3_PCCK_EN() (RCC->APB1ENR |= (1 << 18))
#define UART4_PCCK_EN() (RCC->APB1ENR |= (1 << 19))
#define UART5_PCCK_EN() (RCC->APB1ENR |= (1 << 20))
#define USART6_PCCK_EN() (RCC->APB1ENR |= (1 << 5))
/*
* Clock Enable Macros for SYSCFG peripheral
*/
#define SYSCFG_PCLK_EN() (RCC->APB2ENR |= (1 << 14))
/*
* Clock Disable Macros for GPIOx peripherals
*/
#define GPIOA_PCLK_DI()
/*
* Clock Disable Macros for SPIx peripherals
*/
/*
* Clock Disable Macros for USARTx peripherals
*/
/*
* Clock Disable Macros for SYSCFG peripheral
*/
/*
* Macros to reset GPIOx peripherals
*/
#define GPIOA_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 0)); (RCC->AHB1RSTR &= ~(1 << 0)); }while(0)
#define GPIOB_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 1)); (RCC->AHB1RSTR &= ~(1 << 1)); }while(0)
#define GPIOC_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 2)); (RCC->AHB1RSTR &= ~(1 << 2)); }while(0)
#define GPIOD_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 3)); (RCC->AHB1RSTR &= ~(1 << 3)); }while(0)
#define GPIOE_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 4)); (RCC->AHB1RSTR &= ~(1 << 4)); }while(0)
#define GPIOF_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 5)); (RCC->AHB1RSTR &= ~(1 << 5)); }while(0)
#define GPIOG_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 6)); (RCC->AHB1RSTR &= ~(1 << 6)); }while(0)
#define GPIOH_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 7)); (RCC->AHB1RSTR &= ~(1 << 7)); }while(0)
#define GPIOI_REG_RESET() do{ (RCC->AHB1RSTR |= (1 << 8)); (RCC->AHB1RSTR &= ~(1 << 8)); }while(0)
/*
* returns port code for given GPIOx base address
*/
/*
* This macro returns a code( between 0 to 7) for a given GPIO base address(x)
*/
#define GPIO_BASEADDR_TO_CODE(x) ( (x == GPIOA)?0:\
(x == GPIOB)?1:\
(x == GPIOC)?2:\
(x == GPIOD)?3:\
(x == GPIOE)?4:\
(x == GPIOF)?5:\
(x == GPIOG)?6:\
(x == GPIOH)?7: \
(x == GPIOI)?8:0)
/*
* IRQ(Interrupt Request) Numbers of STM32F407x MCU
* NOTE: update these macros with valid values according to your MCU
* TODO: You may complete this list for other peripherals
*/
#define IRQ_NO_EXTI0 6
#define IRQ_NO_EXTI1 7
#define IRQ_NO_EXTI2 8
#define IRQ_NO_EXTI3 9
#define IRQ_NO_EXTI4 10
#define IRQ_NO_EXTI9_5 23
#define IRQ_NO_EXTI15_10 40
#define IRQ_NO_SPI1 35
#define IRQ_NO_SPI2 36
#define IRQ_NO_SPI3 51
#define IRQ_NO_SPI4
#define IRQ_NO_I2C1_EV 31
#define IRQ_NO_I2C1_ER 32
#define IRQ_NO_USART1 37
#define IRQ_NO_USART2 38
#define IRQ_NO_USART3 39
#define IRQ_NO_UART4 52
#define IRQ_NO_UART5 53
#define IRQ_NO_USART6 71
/*
* macros for all the possible priority levels
*/
#define NVIC_IRQ_PRI0 0
#define NVIC_IRQ_PRI15 15
//some generic macros
#define ENABLE 1
#define DISABLE 0
#define SET ENABLE
#define RESET DISABLE
#define GPIO_PIN_SET SET
#define GPIO_PIN_RESET RESET
#define FLAG_RESET RESET
#define FLAG_SET SET
/******************************************************************************************
*Bit position definitions of SPI peripheral
******************************************************************************************/
/*
* Bit position definitions SPI_CR1
*/
#define SPI_CR1_CPHA 0
#define SPI_CR1_CPOL 1
#define SPI_CR1_MSTR 2
#define SPI_CR1_BR 3
#define SPI_CR1_SPE 6
#define SPI_CR1_LSBFIRST 7
#define SPI_CR1_SSI 8
#define SPI_CR1_SSM 9
#define SPI_CR1_RXONLY 10
#define SPI_CR1_DFF 11
#define SPI_CR1_CRCNEXT 12
#define SPI_CR1_CRCEN 13
#define SPI_CR1_BIDIOE 14
#define SPI_CR1_BIDIMODE 15
/*
* Bit position definitions SPI_CR2
*/
#define SPI_CR2_RXDMAEN 0
#define SPI_CR2_TXDMAEN 1
#define SPI_CR2_SSOE 2
#define SPI_CR2_FRF 4
#define SPI_CR2_ERRIE 5
#define SPI_CR2_RXNEIE 6
#define SPI_CR2_TXEIE 7
/*
* Bit position definitions SPI_SR
*/
#define SPI_SR_RXNE 0
#define SPI_SR_TXE 1
#define SPI_SR_CHSIDE 2
#define SPI_SR_UDR 3
#define SPI_SR_CRCERR 4
#define SPI_SR_MODF 5
#define SPI_SR_OVR 6
#define SPI_SR_BSY 7
#define SPI_SR_FRE 8
/******************************************************************************************
*Bit position definitions of I2C peripheral
******************************************************************************************/
/*
* Bit position definitions I2C_CR1
*/
#define I2C_CR1_PE 0
#define I2C_CR1_NOSTRETCH 7
#define I2C_CR1_START 8
#define I2C_CR1_STOP 9
#define I2C_CR1_ACK 10
#define I2C_CR1_SWRST 15
/*
* Bit position definitions I2C_CR2
*/
#define I2C_CR2_FREQ 0
#define I2C_CR2_ITERREN 8
#define I2C_CR2_ITEVTEN 9
#define I2C_CR2_ITBUFEN 10
/*
* Bit position definitions I2C_OAR1
*/
#define I2C_OAR1_ADD0 0
#define I2C_OAR1_ADD71 1
#define I2C_OAR1_ADD98 8
#define I2C_OAR1_ADDMODE 15
/*
* Bit position definitions I2C_SR1
*/
#define I2C_SR1_SB 0
#define I2C_SR1_ADDR 1
#define I2C_SR1_BTF 2
#define I2C_SR1_ADD10 3
#define I2C_SR1_STOPF 4
#define I2C_SR1_RXNE 6
#define I2C_SR1_TXE 7
#define I2C_SR1_BERR 8
#define I2C_SR1_ARLO 9
#define I2C_SR1_AF 10
#define I2C_SR1_OVR 11
#define I2C_SR1_TIMEOUT 14
/*
* Bit position definitions I2C_SR2
*/
#define I2C_SR2_MSL 0
#define I2C_SR2_BUSY 1
#define I2C_SR2_TRA 2
#define I2C_SR2_GENCALL 4
#define I2C_SR2_DUALF 7
/*
* Bit position definitions I2C_CCR
*/
#define I2C_CCR_CCR 0
#define I2C_CCR_DUTY 14
#define I2C_CCR_FS 15
/******************************************************************************************
*Bit position definitions of USART peripheral
******************************************************************************************/
/*
* Bit position definitions USART_CR1
*/
#define USART_CR1_SBK 0
#define USART_CR1_RWU 1
#define USART_CR1_RE 2
#define USART_CR1_TE 3
#define USART_CR1_IDLEIE 4
#define USART_CR1_RXNEIE 5
#define USART_CR1_TCIE 6
#define USART_CR1_TXEIE 7
#define USART_CR1_PEIE 8
#define USART_CR1_PS 9
#define USART_CR1_PCE 10
#define USART_CR1_WAKE 11
#define USART_CR1_M 12
#define USART_CR1_UE 13
#define USART_CR1_OVER8 15
/*
* Bit position definitions USART_CR2
*/
#define USART_CR2_ADD 0
#define USART_CR2_LBDL 5
#define USART_CR2_LBDIE 6
#define USART_CR2_LBCL 8
#define USART_CR2_CPHA 9
#define USART_CR2_CPOL 10
#define USART_CR2_STOP 12
#define USART_CR2_LINEN 14
/*
* Bit position definitions USART_CR3
*/
#define USART_CR3_EIE 0
#define USART_CR3_IREN 1
#define USART_CR3_IRLP 2
#define USART_CR3_HDSEL 3
#define USART_CR3_NACK 4
#define USART_CR3_SCEN 5
#define USART_CR3_DMAR 6
#define USART_CR3_DMAT 7
#define USART_CR3_RTSE 8
#define USART_CR3_CTSE 9
#define USART_CR3_CTSIE 10
#define USART_CR3_ONEBIT 11
/*
* Bit position definitions USART_SR
*/
#define USART_SR_PE 0
#define USART_SR_FE 1
#define USART_SR_NE 2
#define USART_SR_ORE 3
#define USART_SR_IDLE 4
#define USART_SR_RXNE 5
#define USART_SR_TC 6
#define USART_SR_TXE 7
#define USART_SR_LBD 8
#define USART_SR_CTS 9
#include "stm32f407xx_gpio_driver.h"
#include "stm32f407xx_spi_driver.h"
#include "stm32f407xx_i2c_driver.h"
#include "stm32f407xx_usart_driver.h"
#include "stm32f407xx_rcc_driver.h"
#endif /* INC_STM3F407XX_H_ */