NinjaFlight
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
system.h
Go to the documentation of this file.
1 /*
2  * This file is part of Ninjaflight.
3  *
4  * Ninjaflight is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Ninjaflight is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Ninjaflight. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include <stdbool.h>
21 
22 void systemInit(void);
23 
24 #ifndef __linux__
25 void usleep(uint32_t us);
26 #else
27 #include <unistd.h>
28 #include <time.h>
29 // since _XOPEN_SOURCE (or posix 2008) usleep is deprecated and nanosleep should be used instead.
30 #if _XOPEN_SOURCE > 500
31 int usleep(uint32_t us);
32 #endif
33 #endif
34 
35 uint32_t micros(void);
36 uint32_t millis(void);
37 
38 // failure
39 void failureMode(uint8_t mode);
40 
41 // bootloader/IAP
42 void systemReset(void);
43 void systemResetToBootloader(void);
44 bool isMPUSoftReset(void);
45 
47 // current crystal frequency - 8 or 12MHz
48 extern uint32_t hse_value;
49 
50 typedef void extiCallbackHandlerFunc(void);
51 
54 
55 extern uint32_t cachedRccCsrValue;
56 
57 typedef enum {
66 
Definition: system.h:61
void systemReset(void)
Definition: system_stm32f10x.c:29
void unregisterExtiCallbackHandler(int irqn, extiCallbackHandlerFunc *fn)
Definition: system.c:60
Definition: system.h:60
Definition: system.h:63
uint8_t mode
Definition: gimbal.h:49
void registerExtiCallbackHandler(int irqn, extiCallbackHandlerFunc *fn)
Definition: system.c:47
failureMode_e
Definition: system.h:57
void extiCallbackHandlerFunc(void)
Definition: system.h:50
uint32_t millis(void)
Definition: system.c:144
uint32_t hse_value
Definition: system.h:59
void failureMode(uint8_t mode)
Definition: main.c:340
void systemInit(void)
Definition: system.c:149
uint32_t cachedRccCsrValue
Definition: system.c:110
void enableGPIOPowerUsageAndNoiseReductions(void)
Definition: system_stm32f10x.c:45
Definition: system.h:62
Definition: system.h:58
void systemResetToBootloader(void)
Definition: system_stm32f10x.c:35
Definition: system.h:64
void usleep(uint32_t us)
Definition: system.c:192
uint32_t micros(void)
Definition: system.c:127
bool isMPUSoftReset(void)
Definition: system_stm32f10x.c:58