Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
version.h
Go to the documentation of this file.
1
10#ifndef INFUSE_SDK_INCLUDE_INFUSE_VERSION_H_
11#define INFUSE_SDK_INCLUDE_INFUSE_VERSION_H_
12
13#include <zephyr/dfu/mcuboot.h>
14#include <zephyr/storage/flash_map.h>
15
16#if __has_include("zephyr/app_version.h")
17#include "zephyr/app_version.h"
18#else
19/* Fallback for applications without VERSION file */
20#define APP_VERSION_MAJOR 0
21#define APP_VERSION_MINOR 0
22#define APP_PATCHLEVEL 0
23#define APP_TWEAK 0
24#endif
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
36/* Use MCUboot semantic version definitions */
37#define infuse_version mcuboot_img_sem_ver
38
46#define INFUSE_VERSION_INT(v) \
47 ((((uint32_t)(v)->major) << 24) | (((uint32_t)(v)->minor) << 16) | \
48 ((uint32_t)(v)->revision))
49
56
71static inline int infuse_version_compare(struct infuse_version *a, struct infuse_version *b)
72{
73 uint32_t a_int = INFUSE_VERSION_INT(a);
74 uint32_t b_int = INFUSE_VERSION_INT(b);
75
76 if (a_int < b_int) {
77 return 1;
78 }
79 if (a_int > b_int) {
80 return -1;
81 }
82 return 0;
83}
84
89#ifdef __cplusplus
90}
91#endif
92
93#endif /* INFUSE_SDK_INCLUDE_INFUSE_VERSION_H_ */
static int infuse_version_compare(struct mcuboot_img_sem_ver *a, struct mcuboot_img_sem_ver *b)
Compare two version structures.
Definition version.h:71
struct mcuboot_img_sem_ver application_version_get(void)
Get version of the currently running application.
#define infuse_version
Definition version.h:37
#define INFUSE_VERSION_INT(v)
Convert version struct to sortable integer.
Definition version.h:46