zephyr/samples/sensor/vcnl4040
Keith Packard 0b90fd5adf samples, tests, boards: Switch main return type from void to int
As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.

Most of these changes were automated using coccinelle with the following
script:

@@
@@
- void
+ int
main(...) {
	...
-	return;
+	return 0;
	...
}

Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.

Signed-off-by: Keith Packard <keithp@keithp.com>
2023-04-14 07:49:41 +09:00
..
boards samples: sensors: Remove label property from devicetree overlays 2022-07-19 08:23:35 -05:00
src samples, tests, boards: Switch main return type from void to int 2023-04-14 07:49:41 +09:00
CMakeLists.txt samples and tests: Add REQUIRED to Zephyr find_package call 2023-03-02 09:58:27 +01:00
prj.conf sensors: Remove unnecessary Kconfig setting of sensors 2022-07-25 15:18:56 +02:00
README.rst samples: sensor: Add VCNL4040 sample 2020-09-04 13:03:12 -05:00
sample.yaml tests/samples: fix usage of integration_platforms 2022-05-14 14:49:59 -04:00

.. _vcnl4040_sample:

VCNL4040: proximity and ambient light sensor
############################################

Overview
********
 This sample periodically measures proximity and light for
 5 sec in the interval of 300msec in polling mode. Then threshold trigger mode
 is enabled with the high threshold value of 127 and data is fetched based
 on interrupt. The result is displayed on the console.

Requirements
************

 This sample uses the VCNL4040 sensor controlled using the I2C interface.
 Connect sensor INT for interrupt to Feather D5 pin on the Adafruit STM32F405 Feather.

References
**********

 - VCNL4040: https://www.vishay.com/docs/84274/vcnl4040.pdf

Building and Running
********************

 This project outputs sensor data to the console. It requires a VCNL4040
 sensor to be connected to the desired board.

 .. zephyr-app-commands::
    :app: samples/sensor/vcnl4040/
    :goals: build flash


Sample Output
=============

 .. code-block:: console

    get device vcnl4040
    Testing the polling mode.
    Proximity: 31
    Light (lux): 288

    <repeats for 5sec every 300ms>

    Polling mode test finished.
    Testing the trigger mode.
    Testing proximity trigger.
    ...
    Triggered.
    Proximity: 122

    <repeats whenever triggered for 5sec>

    Threshold trigger test finished.
    Trigger mode test finished.