How to use the ADC in an app?


#1

I don’t see an example of using the ADC in the samples provided in developer studio.

If I just add a call to le_adc_ReadValue() into a ‘Hello World’ example, I get:

implicit declaration of function ‘le_adc_ReadValue’

If I #include “le_adc_interface.h”, I get:

fatal error: le_adc_interface.h: No such file or directory

So what is the correct process to add ADC access to a developer studio project?

cross-post on Sierra Wireless forum: https://forum.sierrawireless.com/viewtopic.php?f=177&t=9763


#2

I tried adding

requires:
{
    api:
    {
        le_adc.api
    }
}

in the Component.cdef

and

bindings:
{
		timerhello.timerHelloComponent.le_adc -> modemService.le_adc
}

in timerHello.adef

The compiler could then find the header OK, but complained about “incompatible types” for the 1st argument of le_adc_ReadValue().

The documentation say:

le_result_t 	le_adc_ReadValue (const char *adcName, int32_t *adcValuePtr)

But the actual definition is:

le_result_t le_adc_ReadValue( le_adc_AdcChannelInput_t adcChannel, int32_t* adcValuePtr)

So, instead of “EXT_ADC1” (as a string) as the documentation suggests, I tried LE_ADC_EXT_ADC1 instead.

This builds OK, but le_adc_ReadValue() returns -6:

LE_FAULT = -6,              ///< Unspecified internal error.

I see the following in th Legato Console:

Legato | modemDaemon[652]/le_pa T=main | swiQmi.c swiQmi_OEMCheckResponseCode() 729 | Sending QMI_SWI_M2M_ADC_READ_RESP_V01 failed: rc=0, resp.result=1.[0x01], resp.error=48.[0x30]
Legato | modemDaemon[652]/le_pa T=main | pa_adc_qmi.c pa_adc_ReadValue() 86 | Failed to read adc channel 1

#3

It seems that the ADC access was known not to work in this Firmware version.
(16.04.0 is required)

It would have been helpful if the documentation had stated that!

:angry:

and also required a developer studio update to 4.1 - and then installation of the 16.04.0 Package.

Having done the updates, le_adc_ReadValue() does, indeed, take a string as its first parameter.


#4