cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any basic 12c code available I can use to configure with a proximity / photo diode/vcsel sensor Best Regards, Luke

LMyle.1
Associate III
 
6 REPLIES 6

What is "12c code", and what is exactly a "proximity/photo diode/vcsel sensor"?

JW

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
LMyle.1
Associate III

STM32F407VGT6 MCU

Sorry Cuble,L4 and F1 repositories where is this?

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

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
LMyle.1
Associate III

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

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);

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..