I2C 设置地址模式和模拟模式
/**
-
\brief Sets the addressing mode to either 7-bit or 10-bit.
-
\param base is the base address of the I2C instance used.
-
\param mode is the address mode, 7-bit or 10-bit.
-
This function configures the I2C module for either a 7-bit address
-
(default) or a 10-bit address. The \e mode parameter configures the address
-
length to 10 bits when its value is \b I2C_ADDR_MODE_10BITS and 7 bits when
-
\b I2C_ADDR_MODE_7BITS.
-
\return None. */ static inline void I2C_setAddressMode(uint32_t base, I2C_AddressMode mode) { // 检查参数是否合法 ASSERT(I2C_isBaseValid(base));
// 写入地址模式到地址扩展位 HWREGH(base + I2C_O_MDR) = (HWREGH(base + I2C_O_MDR) & ~I2C_MDR_XA) | (uint16_t)mode; }
/**
-
\brief 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 occurs. The \e mode parameter can be one of the following:
-
- \b I2C_EMULATION_STOP_SCL_LOW - If SCL is low when the breakpoint occurs,
-
the I2C module stops immediately. If SCL is high, the I2C module waits
-
until SCL becomes low and then stops.
-
- \b I2C_EMULATION_FREE_RUN - I2C operation continues regardless of a
-
the suspend.
-
\return None. */ static inline void I2C_setEmulationMode(uint32_t base, I2C_EmulationMode mode) { // 检查参数是否合法 ASSERT(I2C_isBaseValid(base));
// 写入模拟模式到寄存器 HWREGH(base + I2C_O_MDR) = (HWREGH(base + I2C_O_MDR) & ~I2C_MDR_FREE) | (uint16_t)mode; }
原文地址: https://www.cveoy.top/t/topic/mRhP 著作权归作者所有。请勿转载和采集!