//***************************************************************************** // //! Issues an I2C START condition. //! //! \param base is the base address of the I2C instance used. //! //! This function causes the I2C module to generate a start condition. This //! function is only valid when the I2C module specified by the \b base //! parameter is a master. //! //! \return None. // //***************************************************************************** static inline void I2C_sendStartCondition(uint32_t base) { // // Check the arguments. // ASSERT(I2C_isBaseValid(base));

//
// Set the START condition bit.
//
HWREGH(base + I2C_O_MDR) |= I2C_MDR_STT;

}

//***************************************************************************** // //! Issues an I2C STOP condition. //! //! \param base is the base address of the I2C instance used. //! //! This function causes the I2C module to generate a stop condition. This //! function is only valid when the I2C module specified by the \b base //! parameter is a master. //! //! To check on the status of the STOP condition, I2C_getStopConditionStatus() //! can be used. //! //! \return None. // //***************************************************************************** static inline void I2C_sendStopCondition(uint32_t base) { // // Check the arguments. // ASSERT(I2C_isBaseValid(base));

//
// Set the STOP condition bit.
//
HWREGH(base + I2C_O_MDR) |= I2C_MDR_STP;

}

//***************************************************************************** // //! Issues a no-acknowledge (NACK) bit. //! //! \param base is the base address of the I2C instance used. //! //! This function causes the I2C module to generate a NACK bit. This is only //! applicable when the I2C module is acting as a receiver. //! //! \return None. // //***************************************************************************** static inline void I2C_sendNACK(uint32_t base) { // // Check the arguments. // ASSERT(I2C_isBaseValid(base));

//
// Set the NACK mode bit.
//
HWREGH(base + I2C_O_MDR) |= I2C_MDR_NACKMOD;

}

I2C_sendStartCondition, I2C_sendStopCondition, I2C_sendNACK 函数:发送 I2C 起始、停止和 NACK 条件

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

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