BigW Consortium Gitlab

Commit 890df657 by Mirac Chen

Port noise sensor tutorial to Red

parent eb78f134
sandboxed: true
version: 1.0.0
maxFileSystemBytes: 512K
start: manual
executables:
{
noiseData = ( noiseDataComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
( noiseData )
}
faultAction: restart
}
bindings:
{
noiseData.noiseDataComponent.le_adc -> modemService.le_adc
}
requires:
{
api:
{
${LEGATO_ROOT}/interfaces/modemServices/le_adc.api
}
}
sources:
{
noiseData.c
}
/**
* @file
*
* This app reads the current adc reading every 1 seconds
*
* <HR>
*
* Copyright (C) Sierra Wireless, Inc. Use of this work is subject to license.
*/
#include "legato.h"
#include "interfaces.h"
//--------------------------------------------------------------------------------------------------
/**
* The time between publishing ADC location readings
*
* @note Please change this timeout value as needed.
*/
//--------------------------------------------------------------------------------------------------
#define ADC_SAMPLE_INTERVAL_IN_MILLISECONDS (1000)
//--------------------------------------------------------------------------------------------------
/**
* Timer handler will publish the current ADC reading.
*/
//--------------------------------------------------------------------------------------------------
static void adcTimer
(
le_timer_Ref_t adcTimerRef
)
{
int32_t value;
const le_result_t result = le_adc_ReadValue("EXT_ADC0", &value);
if (result == LE_OK)
{
LE_INFO("EXT_ADC0 value is: %d", value);
}
else
{
LE_INFO("Couldn't get ADC value");
}
}
//--------------------------------------------------------------------------------------------------
/**
* Main program starts here
*/
//--------------------------------------------------------------------------------------------------
COMPONENT_INIT
{
LE_INFO("---------------------- ADC Reading started");
le_timer_Ref_t adcTimerRef = le_timer_Create("ADC Timer");
le_timer_SetMsInterval(adcTimerRef, ADC_SAMPLE_INTERVAL_IN_MILLISECONDS);
le_timer_SetRepeat(adcTimerRef, 0);
le_timer_SetHandler(adcTimerRef, adcTimer);
le_timer_Start(adcTimerRef);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment