2020-09-18 07:35 AM
2020-09-18 08:21 AM
What is "12c code", and what is exactly a "proximity/photo diode/vcsel sensor"?
JW
2020-09-18 08:30 AM
What STM32? On what board?
There should be I2C (i2c) examples under the CubeL4, CubeF1 repositories.
The specific sensor will have an address and register, check the Data Sheet for details.
Cite specific boards and sensors, or use generic examples and port.
2020-09-18 08:42 AM
STM32F407VGT6 MCU
Sorry Cuble,L4 and F1 repositories where is this?
2020-09-18 08:50 AM
If you're not using CubeMX / CubeIDE you can fetch and unpack the archive directly
CubeF4
https://www.st.com/en/embedded-software/stm32cubef4.html
https://github.com/STMicroelectronics/STM32CubeF4
2020-09-18 09:05 AM
Code used to interface a microcontroller with a peripheral via I2C.
and here is a link to the sensor : https://www.vishay.com/videos/optoelectronics/vcnl36687s-proximity-sensor-product-overview.html
2020-09-18 09:37 AM
https://www.vishay.com/docs/84907/vcnl36687s.pdf
Would likely take the following form..
#define VCNL36686_I2C_ADDR (0x60 << 1)
uint8_t CommandCode, Value;
HAL_StatusTypeDef status = HAL_OK;
status = HAL_I2C_Mem_Read(&I2CHandle, VCNL36686_I2C_ADDR, (uint16_t)CommandCode, I2C_MEMADD_SIZE_8BIT, &Value, 1, 100);
status = HAL_I2C_Mem_Write(&I2CHandle, VCNL36686_I2C_ADDR, (uint16_t)CommandCode, I2C_MEMADD_SIZE_8BIT, &Value, 1, 100);