1 /*
2  * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #pragma once
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 /**
14  * Convenient macros to check current wafer version against a version where some changes are introduced.
15  * Use `ESP_CHIP_REV_ABOVE` for a change introduced before any major versions.
16  * Use `ESP_CHIP_REV_MAJOR_AND_ABOVE` for changes introduced after a major version is added.
17  * For example, on ESP32 we have wafer versions:
18  *
19  * 0.0 -> 1.0 -> 2.0 -> 3.0 -> 3.1 -> N.A.
20  *            |->1.1
21  *
22  * - If we are adding code for a change on 1.1, we should use `ESP_CHIP_REV_MAJOR_AND_ABOVE`
23  *   because there is already major version 2 existing. The condition will be met from 1.1 to 1.99,
24  *   while not inherited by 2.0 and above.
25  *
26  * - If we are adding code for a change on 3.1, we should use `ESP_CHIP_REV_ABOVE`
27  *   because there is no major version 4. The condition will be met from 3.1 to 3.99 and 4.0 and above.
28  *   Even if we add revision 4.0 on this version, the logic will be inherited.
29  */
30 
31 #define ESP_CHIP_REV_ABOVE(rev, min_rev) ((min_rev) <= (rev))
32 #define ESP_CHIP_REV_MAJOR_AND_ABOVE(rev, min_rev) (((rev) / 100 == (min_rev) / 100) && ((rev) >= (min_rev)))
33 
34 #ifdef __cplusplus
35 }
36 #endif
37