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
,
45 FAILURE_SDCARD_REQUIRED
,
48 #define WARNING_FLASH_DURATION_MS 50
49 #define WARNING_FLASH_COUNT 5
50 #define WARNING_PAUSE_DURATION_MS 500
51 #define WARNING_CODE_DURATION_LONG_MS 250
52 #define WARNING_CODE_DURATION_SHORT_MS 50
55 BOOTLOADER_REQUEST_ROM
,
56 BOOTLOADER_REQUEST_FLASH
,
57 } bootloaderRequestType_e
;
60 void indicateFailure(failureMode_e mode
, int repeatCount
);
61 void failureMode(failureMode_e mode
);
64 void systemReset(void);
65 void systemResetToBootloader(bootloaderRequestType_e requestType
);
66 bool isMPUSoftReset(void);
67 void cycleCounterInit(void);
68 uint32_t clockCyclesToMicros(uint32_t clockCycles
);
69 uint32_t getCycleCounter(void);
70 #if defined(STM32H7) || defined(STM32G4)
71 void systemCheckResetReason(void);
74 void initialiseMemorySections(void);
76 void initialiseD2MemorySections(void);
79 void enableGPIOPowerUsageAndNoiseReductions(void);
80 // current crystal frequency - 8 or 12MHz
82 extern uint32_t hse_value
;
83 extern uint32_t cachedRccCsrValue
;
85 typedef void extiCallbackHandlerFunc(void);
87 void registerExtiCallbackHandler(IRQn_Type irqn
, extiCallbackHandlerFunc
*fn
);void unregisterExtiCallbackHandler(IRQn_Type irqn
, extiCallbackHandlerFunc
*fn
);
89 void unusedPinsInit(void);