1 /*
2  * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 #pragma once
7 
8 /**
9  * When compiling G0-layer only, we can't depend on `esp_hw_support` component.
10  * However, `esp_private/regi2c_ctrl.h` is part of that component.
11  * Thus, if we don't have this header file in our compilation unit, we should use
12  * ROM functions.
13  * The main difference is that `regi2c_ctrl.h` implementation protects the functions
14  * with mutex. ROM functions must be protected explicitly by the user.
15  */
16 #if __has_include("esp_private/regi2c_ctrl.h")
17     #include "esp_private/regi2c_ctrl.h"
18 #else
19     #include "esp_rom_regi2c.h"
20 
21     #define REGI2C_WRITE_MASK(block, reg_add, indata) \
22         esp_rom_regi2c_write_mask(block, block##_HOSTID,  reg_add,  reg_add##_MSB,  reg_add##_LSB,  indata)
23 
24     #define REGI2C_WRITE(block, reg_add, indata) \
25         esp_rom_regi2c_write(block, block##_HOSTID,  reg_add, indata)
26 
27     #define REGI2C_READ_MASK(block, reg_add) \
28         esp_rom_regi2c_read_mask(block, block##_HOSTID,  reg_add,  reg_add##_MSB,  reg_add##_LSB)
29 
30     #define REGI2C_READ(block, reg_add) \
31         esp_rom_regi2c_read(block, block##_HOSTID,  reg_add)
32 #endif
33