|
13 | 13 | extern "C" { |
14 | 14 | #endif |
15 | 15 |
|
| 16 | +typedef struct CCRSysUpdateState CCRSysUpdateState; |
| 17 | + |
16 | 18 | typedef enum CCRSysPairingState |
17 | 19 | { |
18 | | - //! Pairing is complete / hasn't started yet |
19 | | - CCR_SYS_PAIRING_FINISHED = 0, |
20 | | - //! Pairing is in progress |
21 | | - CCR_SYS_PAIRING_IN_PROGRESS = 1, |
22 | | - //! Pairing timed out |
23 | | - CCR_SYS_PAIRING_TIMED_OUT = 2, |
| 20 | + //! Pairing is complete / hasn't started yet |
| 21 | + CCR_SYS_PAIRING_FINISHED = 0, |
| 22 | + //! Pairing is in progress |
| 23 | + CCR_SYS_PAIRING_IN_PROGRESS = 1, |
| 24 | + //! Pairing timed out |
| 25 | + CCR_SYS_PAIRING_TIMED_OUT = 2, |
24 | 26 | } CCRSysPairingState; |
25 | 27 |
|
| 28 | +struct CCRSysUpdateState |
| 29 | +{ |
| 30 | + uint32_t state; |
| 31 | + //! Progress from 0-100 |
| 32 | + uint32_t progress; |
| 33 | +}; |
| 34 | + |
26 | 35 | void |
27 | 36 | CCRSysInit(void); |
28 | 37 |
|
@@ -118,6 +127,148 @@ CCRSysGetPincode(uint32_t *pin); |
118 | 127 | int32_t |
119 | 128 | CCRSysSetSystemTime(OSTime time); |
120 | 129 |
|
| 130 | +/** |
| 131 | + * Check if a DRC firmware update is needed. |
| 132 | + * This function additionally verifies the DRC area compared to \link __CCRSysNeedsDRCFWUpdate \endlink. |
| 133 | + * |
| 134 | + * \param drcSlot |
| 135 | + * Slot from 0 to 1. |
| 136 | + * |
| 137 | + * \param outNeedsUpdate |
| 138 | + * Pointer to store the result to. |
| 139 | + * |
| 140 | + * \return |
| 141 | + * 0 on success. |
| 142 | + */ |
| 143 | +int32_t |
| 144 | +CCRSysNeedsDRCFWUpdate(uint32_t drcSlot, |
| 145 | + BOOL *outNeedsUpdate); |
| 146 | + |
| 147 | +/** |
| 148 | + * Check if a DRC firmware update is needed. |
| 149 | + * |
| 150 | + * \param drcSlot |
| 151 | + * Slot from 0 to 1. |
| 152 | + * |
| 153 | + * \param outNeedsUpdate |
| 154 | + * Pointer to store the result to. |
| 155 | + * |
| 156 | + * \param allowDowngrade |
| 157 | + * Only check if the installed version doesn't match the running version, |
| 158 | + * instead of checking that it's greater. |
| 159 | + * |
| 160 | + * \return |
| 161 | + * 0 on success. |
| 162 | + */ |
| 163 | +int32_t |
| 164 | +__CCRSysNeedsDRCFWUpdate(uint32_t drcSlot, |
| 165 | + BOOL *outNeedsUpdate, |
| 166 | + BOOL allowDowngrade); |
| 167 | + |
| 168 | +/** |
| 169 | + * Starts a DRC firmware update if necessary and region matches. |
| 170 | + * |
| 171 | + * \note |
| 172 | + * This function will wait for \link CCRSysDRCFWUpdateForward \endlink to be called once done. |
| 173 | + * See \link CCRSysGetUpdateState \endlink for status and progress. |
| 174 | + * |
| 175 | + * \param drcSlot |
| 176 | + * Slot from 0 to 1. |
| 177 | + * |
| 178 | + * \return |
| 179 | + * 0 on success. |
| 180 | + */ |
| 181 | +int32_t |
| 182 | +CCRSysDRCFWUpdate(uint32_t drcSlot); |
| 183 | + |
| 184 | +/** |
| 185 | + * Starts a DRC firmware update if necessary. |
| 186 | + * |
| 187 | + * \note |
| 188 | + * This function will wait for \link CCRSysDRCFWUpdateForward \endlink to be called once done. |
| 189 | + * See \link CCRSysGetUpdateState \endlink for status and progress. |
| 190 | + * |
| 191 | + * \param drcSlot |
| 192 | + * Slot from 0 to 1. |
| 193 | + * |
| 194 | + * \param allowDowngrade |
| 195 | + * Only check if the installed version doesn't match the running version, |
| 196 | + * instead of checking that it's greater. |
| 197 | + * There are additional checks on the IOS side and this doesn't actually allow downgrading the firmware. |
| 198 | + * |
| 199 | + * \return |
| 200 | + * 0 on success. |
| 201 | + */ |
| 202 | +int32_t |
| 203 | +__CCRSysDRCFWUpdate(uint32_t drcSlot, |
| 204 | + BOOL allowDowngrade); |
| 205 | + |
| 206 | + |
| 207 | +/** |
| 208 | + * Finish a pending DRC firmware update. |
| 209 | + */ |
| 210 | +void |
| 211 | +CCRSysDRCFWUpdateForward(void); |
| 212 | + |
| 213 | +/** |
| 214 | + * Get the update state during a pending DRC firmware update. |
| 215 | + * |
| 216 | + * \param outUpdateState |
| 217 | + * Pointer to store the state to. |
| 218 | + */ |
| 219 | +void |
| 220 | +CCRSysGetUpdateState(CCRSysUpdateState *outUpdateState); |
| 221 | + |
| 222 | +/** |
| 223 | + * Initialize a DRC reattach. |
| 224 | + * |
| 225 | + * \param drcSlot |
| 226 | + * Slot from 0 to 1. |
| 227 | + */ |
| 228 | +void |
| 229 | +__CCRSysInitReattach(uint32_t drcSlot); |
| 230 | + |
| 231 | +/** |
| 232 | + * Wait for the DRC to reattach. |
| 233 | + * This returns once the DRC disconnects and reconnects or a timeout is reached. |
| 234 | + * |
| 235 | + * \param drcSlot |
| 236 | + * Slot from 0 to 1. |
| 237 | + * |
| 238 | + * \return |
| 239 | + * 0 on success. |
| 240 | + */ |
| 241 | +int32_t |
| 242 | +__CCRSysWaitReattach(uint32_t drcSlot, |
| 243 | + BOOL unknown); |
| 244 | + |
| 245 | +/** |
| 246 | + * Get the version check flag. |
| 247 | + * |
| 248 | + * \param outFlag |
| 249 | + * Pointer to write the flag to. |
| 250 | + * |
| 251 | + * \return |
| 252 | + * 0 on success. |
| 253 | + */ |
| 254 | +int32_t |
| 255 | +CCRSysGetVersionCheckFlag(uint32_t *outFlag); |
| 256 | + |
| 257 | +/** |
| 258 | + * Set the version check flag. |
| 259 | + * |
| 260 | + * \param outFlag |
| 261 | + * The flag to set. |
| 262 | + * |
| 263 | + * \return |
| 264 | + * 0 on success. |
| 265 | + */ |
| 266 | +int32_t |
| 267 | +CCRSysSetVersionCheckFlag(uint32_t flag); |
| 268 | + |
| 269 | +int32_t |
| 270 | +CCRSysCaffeineSetCaffeineSlot(uint32_t slot); |
| 271 | + |
121 | 272 | #ifdef __cplusplus |
122 | 273 | } |
123 | 274 | #endif |
|
0 commit comments