//***************************************************************************** // //! 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) { // // Check the arguments. // ASSERT(I2C_isBaseValid(base));

//
// Write the appropriate value to the address expansion bit.
//
HWREGH(base + I2C_O_MDR) = (HWREGH(base + I2C_O_MDR) & ~I2C_MDR_XA) |
                           (uint16_t)mode;

}

//***************************************************************************** // //! 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) { // // Check the arguments. // ASSERT(I2C_isBaseValid(base));

//
// Write the desired emulation mode to the register.
//
HWREGH(base + I2C_O_MDR) = (HWREGH(base + I2C_O_MDR) & ~I2C_MDR_FREE) |
                           (uint16_t)mode;

}

I2C Address Mode and Emulation Mode Configuration

原文地址: https://www.cveoy.top/t/topic/mRfC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录