drv_system.h
Go to the documentation of this file.
1 /*
2  drv_sytem.h : system utilities (init, reset, delay, etc.) for STM32F103CB
3 
4  Adapted from https://github.com/multiwii/baseflight/blob/master/src/drv_system.h
5 
6  This file is part of BreezySTM32.
7 
8  BreezySTM32 is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  BreezySTM32 is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #pragma once
23 
24 #define BKP_SOFTRESET (0x50F7B007)
25 
26 //#define GYRO
27 //#define ACC
28 //#define BUZZER
29 #define LED0
30 #define LED1
31 #define INVERTER
32 
33 #define LED0_GPIO GPIOB
34 #define LED0_PIN Pin_3 // PB3 (LED)
35 #define LED1_GPIO GPIOB
36 #define LED1_PIN Pin_4 // PB4 (LED)
37 #define INV_PIN Pin_2 // PB2 (BOOT1) abused as inverter select GPIO
38 #define INV_GPIO GPIOB
39 
40 #ifdef LED0
41 #define LED0_TOGGLE digitalToggle(LED0_GPIO, LED0_PIN);
42 #define LED0_OFF digitalHi(LED0_GPIO, LED0_PIN);
43 #define LED0_ON digitalLo(LED0_GPIO, LED0_PIN);
44 #else
45 #define LED0_TOGGLE
46 #define LED0_OFF
47 #define LED0_ON
48 #endif
49 
50 #ifdef LED1
51 #define LED1_TOGGLE digitalToggle(LED1_GPIO, LED1_PIN);
52 #define LED1_OFF digitalHi(LED1_GPIO, LED1_PIN);
53 #define LED1_ON digitalLo(LED1_GPIO, LED1_PIN);
54 #else
55 #define LED1_TOGGLE
56 #define LED1_OFF
57 #define LED1_ON
58 #endif
59 
60 #ifdef INV_GPIO
61 #define INV_OFF digitalLo(INV_GPIO, INV_PIN);
62 #define INV_ON digitalHi(INV_GPIO, INV_PIN);
63 #else
64 #define INV_OFF ;
65 #define INV_ON ;
66 #endif
67 
68 void systemInit(void);
69 void delayMicroseconds(uint32_t us);
70 void delay(uint32_t ms);
71 
72 uint64_t micros(void);
73 uint32_t millis(void);
74 
75 // Backup SRAM R/W
76 uint32_t rccReadBkpDr(void);
77 void rccWriteBkpDr(uint32_t value);
78 
79 // failure
80 void failureMode();
81 
82 // bootloader/IAP
83 void systemReset(bool toBootloader);
84 
uint64_t micros(void)
Definition: system.c:44
void systemInit(void)
Definition: system.c:55
uint32_t rccReadBkpDr(void)
Definition: drv_system.c:139
void delayMicroseconds(uint32_t us)
Definition: system.c:91
void rccWriteBkpDr(uint32_t value)
Definition: drv_system.c:144
void systemReset(bool toBootloader)
Definition: drv_system.c:155
void failureMode()
Definition: drv_system.c:132
uint32_t millis(void)
Definition: system.c:50
void delay(uint32_t ms)
Definition: system.c:98


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:18