forked from simondlevy/BreezySTM32
-
Notifications
You must be signed in to change notification settings - Fork 5
/
drv_system.h
84 lines (66 loc) · 2.33 KB
/
drv_system.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
/*
drv_sytem.h : system utilities (init, reset, delay, etc.) for STM32F103CB
Adapted from https://github.com/multiwii/baseflight/blob/master/src/drv_system.h
This file is part of BreezySTM32.
BreezySTM32 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BreezySTM32 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define BKP_SOFTRESET (0x50F7B007)
//#define GYRO
//#define ACC
//#define BUZZER
#define LED0
#define LED1
#define INVERTER
#define LED0_GPIO GPIOB
#define LED0_PIN Pin_3 // PB3 (LED)
#define LED1_GPIO GPIOB
#define LED1_PIN Pin_4 // PB4 (LED)
#define INV_PIN Pin_2 // PB2 (BOOT1) abused as inverter select GPIO
#define INV_GPIO GPIOB
#ifdef LED0
#define LED0_TOGGLE digitalToggle(LED0_GPIO, LED0_PIN);
#define LED0_OFF digitalHi(LED0_GPIO, LED0_PIN);
#define LED0_ON digitalLo(LED0_GPIO, LED0_PIN);
#else
#define LED0_TOGGLE
#define LED0_OFF
#define LED0_ON
#endif
#ifdef LED1
#define LED1_TOGGLE digitalToggle(LED1_GPIO, LED1_PIN);
#define LED1_OFF digitalHi(LED1_GPIO, LED1_PIN);
#define LED1_ON digitalLo(LED1_GPIO, LED1_PIN);
#else
#define LED1_TOGGLE
#define LED1_OFF
#define LED1_ON
#endif
#ifdef INV_GPIO
#define INV_OFF digitalLo(INV_GPIO, INV_PIN);
#define INV_ON digitalHi(INV_GPIO, INV_PIN);
#else
#define INV_OFF ;
#define INV_ON ;
#endif
void systemInit(void);
void delayMicroseconds(uint32_t us);
void delay(uint32_t ms);
uint64_t micros(void);
uint32_t millis(void);
// Backup SRAM R/W
uint32_t rccReadBkpDr(void);
void rccWriteBkpDr(uint32_t value);
// failure
void failureMode();
// bootloader/IAP
void systemReset(bool toBootloader);