2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
26 void systemInit(void);
29 FAILURE_DEVELOPER
= 0,
32 FAILURE_ACC_INCOMPATIBLE
,
33 FAILURE_INVALID_EEPROM_CONTENTS
,
34 FAILURE_CONFIG_STORE_FAILURE
,
35 FAILURE_GYRO_INIT_FAILED
,
36 FAILURE_FLASH_READ_FAILED
,
37 FAILURE_FLASH_WRITE_FAILED
,
38 FAILURE_FLASH_INIT_FAILED
, // RESERVED
39 FAILURE_EXTERNAL_FLASH_READ_FAILED
, // RESERVED
40 FAILURE_EXTERNAL_FLASH_WRITE_FAILED
, // RESERVED
41 FAILURE_EXTERNAL_FLASH_INIT_FAILED
,
42 FAILURE_SDCARD_READ_FAILED
,
43 FAILURE_SDCARD_WRITE_FAILED
,
44 FAILURE_SDCARD_INITIALISATION_FAILED
,
47 #define WARNING_FLASH_DURATION_MS 50
48 #define WARNING_FLASH_COUNT 5
49 #define WARNING_PAUSE_DURATION_MS 500
50 #define WARNING_CODE_DURATION_LONG_MS 250
51 #define WARNING_CODE_DURATION_SHORT_MS 50
54 BOOTLOADER_REQUEST_ROM
,
55 BOOTLOADER_REQUEST_FLASH
,
56 } bootloaderRequestType_e
;
59 void indicateFailure(failureMode_e mode
, int repeatCount
);
60 void failureMode(failureMode_e mode
);
63 void systemReset(void);
64 void systemResetToBootloader(bootloaderRequestType_e requestType
);
65 bool isMPUSoftReset(void);
66 void cycleCounterInit(void);
67 uint32_t clockCyclesToMicros(uint32_t clockCycles
);
68 uint32_t getCycleCounter(void);
69 #if defined(STM32H7) || defined(STM32G4)
70 void systemCheckResetReason(void);
73 void initialiseMemorySections(void);
75 void enableGPIOPowerUsageAndNoiseReductions(void);
76 // current crystal frequency - 8 or 12MHz
78 extern uint32_t hse_value
;
79 extern uint32_t cachedRccCsrValue
;
81 typedef void extiCallbackHandlerFunc(void);
83 void registerExtiCallbackHandler(IRQn_Type irqn
, extiCallbackHandlerFunc
*fn
);void unregisterExtiCallbackHandler(IRQn_Type irqn
, extiCallbackHandlerFunc
*fn
);
85 void unusedPinsInit(void);