1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief Public API for boot mode interface 10 */ 11 12 #ifndef ZEPHYR_INCLUDE_RETENTION_BOOTMODE_ 13 #define ZEPHYR_INCLUDE_RETENTION_BOOTMODE_ 14 15 #include <stdint.h> 16 #include <stddef.h> 17 #include <zephyr/kernel.h> 18 #include <zephyr/device.h> 19 #include <zephyr/types.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /** 26 * @brief Boot mode interface 27 * @defgroup boot_mode_interface Boot mode interface 28 * @ingroup retention_api 29 * @{ 30 */ 31 32 enum BOOT_MODE_TYPES { 33 /** Default (normal) boot, to user application */ 34 BOOT_MODE_TYPE_NORMAL = 0x00, 35 36 /** Bootloader boot mode (e.g. serial recovery for MCUboot) */ 37 BOOT_MODE_TYPE_BOOTLOADER, 38 }; 39 40 /** 41 * @brief Checks if the boot mode of the device is set to a specific value. 42 * 43 * @param boot_mode Expected boot mode to check. 44 * 45 * @retval 1 If successful and boot mode matches. 46 * @retval 0 If boot mode does not match. 47 * @retval -errno Error code code. 48 */ 49 int bootmode_check(uint8_t boot_mode); 50 51 /** 52 * @brief Sets boot mode of device. 53 * 54 * @param boot_mode Boot mode value to set. 55 * 56 * @retval 0 If successful. 57 * @retval -errno Error code code. 58 */ 59 int bootmode_set(uint8_t boot_mode); 60 61 /** 62 * @brief Clear boot mode value (sets to 0) - which corresponds to 63 * #BOOT_MODE_TYPE_NORMAL. 64 * 65 * @retval 0 If successful. 66 * @retval -errno Error code code. 67 */ 68 int bootmode_clear(void); 69 70 /** 71 * @} 72 */ 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* ZEPHYR_INCLUDE_RETENTION_BOOTMODE_ */ 79