/**
* [url=home.php?mod=space&uid=247401]@brief[/url] Transmits the address byte to select the slave device.
* @param I2Cx: where x can be 1 or 2 to select the I2C peripheral.
* @param Address: specifies the slave address which will be transmitted
* @param I2C_Direction: specifies whether the I2C device will be a
* Transmitter or a Receiver. This parameter can be one of the following values
* @arg I2C_Direction_Transmitter: Transmitter mode
* @arg I2C_Direction_Receiver: Receiver mode
* @retval None.
*/
void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction)
{
/* Check the parameters */
assert_param(IS_I2C_ALL_PERIPH(I2Cx));
assert_param(IS_I2C_DIRECTION(I2C_Direction));
/* Test on the direction to set/reset the read/write bit */
if (I2C_Direction != I2C_Direction_Transmitter)
{
/* Set the address bit0 for read */
Address |= OAR1_ADD0_Set;
}
else
{
/* Reset the address bit0 for write */
Address &= OAR1_ADD0_Reset;
}
/* Send the address */
I2Cx->DR = Address;
}
以上是STM32 V3.5的固件库中关于I2C的一个函数
函数体前面的注释说:
I2C_Direction: specifies whether the I2C device will be a
Transmitter or a Receiver. This parameter can be one of the following values
我想请问,这里所说的I2C device 是指stm32单片机,还是我要操作的24C02 (这里用stm32向24C02读写数据为例), 我个人理解应该是指24C02,但是如果这样的话,
假设24C02选择Transmitter(即函数的参数为 I2C_Direction_Transmitter ),意味着stm32应该是Receiver,按照stm32的参考手册,I2C主模式中,
● 在7位地址模式时,
─ 要进入发送器模式,主设备发送从地址时置最低位为’0’。
─ 要进入接收器模式,主设备发送从地址时置最低位为’1’。
就是说从地址的最低为应该为1,
但是这个库函数却设置成了0
请问是不是我对于I2C device的理解有误呢? 请各位指教! 谢谢! |