Reading Light Sensor - Bosch XDK110 Quick Start Manual

Cross-domain development kit
Hide thumbs Also See for XDK110:
Table of Contents

Advertisement

!
The first expression is used to generate a return code. Afterwards the light sensor is initialised by
LightSensor_init()
initiated.

3.2 Reading light sensor

After the correct initialization the sensor is ready to read. The following code snippet describes how a
function reading the incoming sensor data has to be implemented.
Code 10: Implementation to read the light sensor data
/* Include this code in XdkApplicationTemplate.c */
static void
readLightSensor(xTimerHandle xTimer)
{
(void) xTimer;
/* Read and print light sensor data */
uint32_t
milliLuxData = UINT32_C(0);
Retcode_T
returnValue = LightSensor_readLuxData(
if
(RETCODE_OK
{
printf("Light sensor data obtained in milli lux :%d
int) milliLuxData);
}
!
In code 7 the sensor value of the light sensor is read. The first expression is related to the freeRTOS
operating system and so not necessarily needed. It is only there to prevent a warning of the compiler. The
following declaration of the variable
light sensor data is stored. It follows the declaration of the condition state
read. The next line of code describes the actual reading of the light sensor data via
LightSensor_readLuxData()
executed if the return value of
the light sensor data was successful.
The initialization of the light sensor and a function that reads its data are implemented. Now a timer or
operating task has to be implemented that periodically reads the data und prints it to the XDK Workbench
console. Additionally to the code lines above the implementation of the timer task takes place in
: The following code lines shows how to implement the required timer task.
appInitSystem()
XDK110
© Bosch Connected Devices and Solutions GmbH reserves all rights even in the event of industrial property rights. We reserve all rights of disposal such as
copying and passing on to third parties. BOSCH and the symbol are registered trademarks of Robert Bosch GmbH, Germany.
Note: Specifications within this document are subject to change without notice.
Workbench First Steps Guide XDK110
, which returns the return code that can be checked if the sensor was correctly
returnValue = RETCODE_FAILURE;
xdkLightSensor_MAX44009_Handle,&milliLuxData);
== returnValue)
milliLuxData
. The display of the data takes place in the if bracket, the
LightSensor_readLuxData()
describes the generation of a 32-bit variable where the
returnValue
is
RETCODE_OK
Page ! 1 9
\n\r",(unsigned
if the data could be
printf()
. This means that the reading of
is only
BCDS

Advertisement

Table of Contents
loading

Table of Contents