Flipper Zero Firmware
Loading...
Searching...
No Matches
ble_glue.h
1#pragma once
2
3#include <stdint.h>
4#include <stdbool.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10/*
11 * Low-level interface to Core2 - startup, shutdown, mode switching, FUS commands.
12 */
13
14typedef enum {
15 BleGlueC2ModeUnknown = 0,
16 BleGlueC2ModeFUS,
17 BleGlueC2ModeStack,
18} BleGlueC2Mode;
19
20#define BLE_MAX_VERSION_STRING_LEN (20)
21typedef struct {
22 BleGlueC2Mode mode;
26 uint8_t VersionMajor;
27 uint8_t VersionMinor;
28 uint8_t VersionSub;
29 uint8_t VersionBranch;
30 uint8_t VersionReleaseType;
31 uint8_t MemorySizeSram2B; /*< Multiple of 1K */
32 uint8_t MemorySizeSram2A; /*< Multiple of 1K */
33 uint8_t MemorySizeSram1; /*< Multiple of 1K */
34 uint8_t MemorySizeFlash; /*< Multiple of 4K */
35 uint8_t StackType;
36 char StackTypeString[BLE_MAX_VERSION_STRING_LEN];
41 uint8_t FusVersionMinor;
42 uint8_t FusVersionSub;
43 uint8_t FusMemorySizeSram2B; /*< Multiple of 1K */
44 uint8_t FusMemorySizeSram2A; /*< Multiple of 1K */
45 uint8_t FusMemorySizeFlash; /*< Multiple of 4K */
47
48typedef enum {
49 // Stage 1: core2 startup and FUS
50 BleGlueStatusStartup,
51 BleGlueStatusBroken,
52 BleGlueStatusC2Started,
53 // Stage 2: radio stack
54 BleGlueStatusRadioStackRunning,
55 BleGlueStatusRadioStackMissing
56} BleGlueStatus;
57
58typedef void (
59 *BleGlueKeyStorageChangedCallback)(uint8_t* change_addr_start, uint16_t size, void* context);
60
62void ble_glue_init(void);
63
68bool ble_glue_start(void);
69
70void ble_glue_stop(void);
71
76bool ble_glue_is_alive(void);
77
82bool ble_glue_wait_for_c2_start(int32_t timeout_ms);
83
84BleGlueStatus ble_glue_get_c2_status(void);
85
86const BleGlueC2Info* ble_glue_get_c2_info(void);
87
92bool ble_glue_is_radio_stack_ready(void);
93
99void ble_glue_set_key_storage_changed_callback(
100 BleGlueKeyStorageChangedCallback callback,
101 void* context);
102
103bool ble_glue_reinit_c2(void);
104
105typedef enum {
106 BleGlueCommandResultUnknown,
107 BleGlueCommandResultOK,
108 BleGlueCommandResultError,
109 BleGlueCommandResultRestartPending,
110 BleGlueCommandResultOperationOngoing,
111} BleGlueCommandResult;
112
117BleGlueCommandResult ble_glue_force_c2_mode(BleGlueC2Mode mode);
118
119BleGlueCommandResult ble_glue_fus_stack_delete(void);
120
121BleGlueCommandResult ble_glue_fus_stack_install(uint32_t src_addr, uint32_t dst_addr);
122
123BleGlueCommandResult ble_glue_fus_get_status(void);
124
125BleGlueCommandResult ble_glue_fus_wait_operation(void);
126
127typedef struct {
128 uint32_t magic;
129 uint32_t source_pc;
130 uint32_t source_lr;
131 uint32_t source_sp;
133
138const BleGlueHardfaultInfo* ble_glue_get_hardfault_info(void);
139
140#ifdef __cplusplus
141}
142#endif
Definition ble_glue.h:21
uint8_t VersionMajor
Wireless Info.
Definition ble_glue.h:26
uint8_t FusVersionMajor
Fus Info.
Definition ble_glue.h:40
Definition ble_glue.h:127