! Sets I2C emulation mode!! param base is the base address of the I2C instance used! param mode is the emulation mode!! This function sets the behavior of the I2C operation when an emulation! suspend
static inline void I2C_setEmulationMode(uint32_t base, I2C_EmulationMode mode) { // 检查传入的I2C模块基地址是否合法 ASSERT(I2C_isBaseValid(base));
// 将传入的模式参数写入MDR寄存器的对应位
HWREGH(base + I2C_O_MDR) = (HWREGH(base + I2C_O_MDR) & ~I2C_MDR_FREE) |
(uint16_t)mode;
}
该函数用于设置I2C模块的仿真模式,即在仿真暂停时,I2C模块的操作行为。传入参数mode可以是以下两种模式之一:
- I2C_EMULATION_STOP_SCL_LOW - 当断点发生时,如果SCL为低电平,则I2C模块立即停止。如果SCL为高电平,则I2C模块等待SCL变为低电平后再停止。
- I2C_EMULATION_FREE_RUN - 无论是否发生暂停,I2C操作都将继续执行。
该函数首先检查传入的I2C模块基地址是否合法,然后将传入的模式参数写入I2C模块的MDR寄存器的相应位中,以设置I2C模块的仿真模式。
原文地址: https://www.cveoy.top/t/topic/bozy 著作权归作者所有。请勿转载和采集!