1 // Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include <stdint.h> 18 #include "regi2c_apll.h" 19 #include "regi2c_bbpll.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /* Analog function control register */ 26 #define ANA_CONFIG_REG 0x6000E044 27 #define ANA_CONFIG_S (8) 28 #define ANA_CONFIG_M (0x3FF) 29 /* Clear to enable APLL */ 30 #define I2C_APLL_M (BIT(14)) 31 /* Clear to enable BBPLL */ 32 #define I2C_BBPLL_M (BIT(17)) 33 34 /* ROM functions which read/write internal control bus */ 35 uint8_t rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add); 36 uint8_t rom_i2c_readReg_Mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb); 37 void rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data); 38 void rom_i2c_writeReg_Mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb, uint8_t data); 39 40 /* Convenience macros for the above functions, these use register definitions 41 * from regi2c_apll.h/regi2c_bbpll.h header files. 42 */ 43 #define REGI2C_WRITE_MASK(block, reg_add, indata) \ 44 rom_i2c_writeReg_Mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB, indata) 45 46 #define REGI2C_READ_MASK(block, reg_add) \ 47 rom_i2c_readReg_Mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB) 48 49 #define REGI2C_WRITE(block, reg_add, indata) \ 50 rom_i2c_writeReg(block, block##_HOSTID, reg_add, indata) 51 52 #define REGI2C_READ(block, reg_add) \ 53 rom_i2c_readReg(block, block##_HOSTID, reg_add) 54 55 56 #ifdef __cplusplus 57 } 58 #endif 59