Skip to main content
LMyle.1
Associate III
September 18, 2020
Question

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

  • September 18, 2020
  • 4 replies
  • 1099 views

..

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
September 18, 2020

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

JW

Tesla DeLorean
Guru
September 18, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
LMyle.1
LMyle.1Author
Associate III
September 18, 2020

STM32F407VGT6 MCU

Sorry Cuble,L4 and F1 repositories where is this?

Tesla DeLorean
Guru
September 18, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
LMyle.1
LMyle.1Author
Associate III
September 18, 2020

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

Tesla DeLorean
Guru
September 18, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..