2015-04-20 01:50 AM
Hello
According to the page 18 of the ov2640 datasheet(version 1.6), device slave address is 0x60 for write and 0x61 for read, but in the camera_to_usbdisk project, only the write address is defined and used for both read and write operations.#define CAMERA_I2C_ADDRESS 0x60Please guide me through this.Thanks.2015-04-20 05:56 AM
Isn't the low order bit set/cleared deeper into the support code depending if it's a read or write? This is a standard 7-bit I2C addressing mechanism.
2015-04-20 06:08 AM
Do you mean that because of shifting 1 bit to right, the LSB will be excluded ?
2015-04-20 09:14 AM
Do you mean that because of shifting 1 bit to right, the LSB will be excluded ?
No, I mean that the bit is controlled deeper in the implementation, 0x60 is the base address. I have no interest digging into the HAL/Cube implementation, but on the SPL side this explicitly handled in the library code./**
* @brief Transmits the address byte to select the slave device.
* @param I2Cx: where x can be 1, 2 or 3 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 |= I2C_OAR1_ADD0;
}
else
{
/* Reset the address bit0 for write */
Address &= (uint8_t)~((uint8_t)I2C_OAR1_ADD0);
}
/* Send the address */
I2Cx->DR = Address;
}