Skip to content

Commit 2db93b2

Browse files
DeepikaCruz Monrreal II
authored andcommitted
Separate version header file to get version updates in Mbed OS
1 parent e85b05e commit 2db93b2

File tree

2 files changed

+72
-16
lines changed

2 files changed

+72
-16
lines changed

mbed.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,8 @@
1616
#ifndef MBED_H
1717
#define MBED_H
1818

19-
#define MBED_LIBRARY_VERSION 163
19+
#include "platform/mbed_version.h"
2020

21-
#if MBED_CONF_RTOS_PRESENT
22-
// RTOS present, this is valid only for mbed OS 5
23-
#define MBED_MAJOR_VERSION 5
24-
#define MBED_MINOR_VERSION 9
25-
#define MBED_PATCH_VERSION 2
26-
27-
#else
28-
// mbed 2
29-
#define MBED_MAJOR_VERSION 2
30-
#define MBED_MINOR_VERSION 0
31-
#define MBED_PATCH_VERSION MBED_LIBRARY_VERSION
32-
#endif
33-
34-
#define MBED_ENCODE_VERSION(major, minor, patch) ((major)*10000 + (minor)*100 + (patch))
35-
#define MBED_VERSION MBED_ENCODE_VERSION(MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION)
3621
#if MBED_CONF_RTOS_PRESENT
3722
#include "rtos/rtos.h"
3823
#endif

platform/mbed_version.h

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
2+
/** \addtogroup platform */
3+
/** @{*/
4+
/**
5+
* \defgroup platform_version Version macros
6+
* @{
7+
*/
8+
/* mbed Microcontroller Library
9+
* Copyright (c) 2018 ARM Limited
10+
*
11+
* Licensed under the Apache License, Version 2.0 (the "License");
12+
* you may not use this file except in compliance with the License.
13+
* You may obtain a copy of the License at
14+
*
15+
* http://www.apache.org/licenses/LICENSE-2.0
16+
*
17+
* Unless required by applicable law or agreed to in writing, software
18+
* distributed under the License is distributed on an "AS IS" BASIS,
19+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
* See the License for the specific language governing permissions and
21+
* limitations under the License.
22+
*/
23+
24+
#ifndef MBED_VERSION_H
25+
#define MBED_VERSION_H
26+
27+
/** MBED_MAJOR_VERSION
28+
* Mbed OS major version
29+
*
30+
* @note 99 is default value for development version (master branch)
31+
*/
32+
#define MBED_MAJOR_VERSION 99
33+
34+
/** MBED_MINOR_VERSION
35+
* Mbed OS minor version
36+
*
37+
* @note 99 is default value for development version (master branch)
38+
*/
39+
#define MBED_MINOR_VERSION 99
40+
41+
/** MBED_PATCH_VERSION
42+
* Mbed OS patch version
43+
*
44+
* @note 99 is default value for development version (master branch)
45+
*/
46+
#define MBED_PATCH_VERSION 99
47+
48+
#define MBED_ENCODE_VERSION(major, minor, patch) ((major)*10000 + (minor)*100 + (patch))
49+
50+
/** MBED_VERSION
51+
* Mbed OS 5 version (MMmmpp - M(Major); m(minor); p(patch))
52+
*
53+
* @note 999999 is default value for development version (master branch)
54+
*/
55+
#define MBED_VERSION MBED_ENCODE_VERSION(MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION)
56+
57+
/** MBED_VERSION_CHECK
58+
* Macro can be used to check minimum Mbed OS version required for feature/library. If current version
59+
* is less than required, it will assert.
60+
*
61+
* @note: Version of master branch will be 999999 as default, hence no assert/warning is provided for
62+
* master branch code
63+
*/
64+
#define MBED_VERSION_CHECK(major, minor, patch) do { \
65+
MBED_STATIC_ASSERT((MBED_VERSION >= MBED_ENCODE_VERSION((major),(minor),(patch))), "Incompatible mbed-os version detected!!"); \
66+
} while(0)
67+
68+
#endif
69+
70+
/** @}*/
71+
/** @}*/

0 commit comments

Comments
 (0)