Using GPIO, ADC and i2c interface on mangOH/legato

All,

Samples that you can follow to learn how to use GPIOs on the mangOH platform are available at https://github.com/mangOH/mangOH/tree/524d0f9feae2ab6bb92bab03c346b08c4439f38f/samples/tutorials/hardwareInterfaces
These sample apps will allow you to:
a. blink an LED on a timer: TimerLed
b. turn LED on and off using push button: TouchSensor
c. turn LED on and off using GPIO : Cf3GpioControl

Tutorials are coming soon and will be posted online. If you want to use them in the meantime, make sure mangOH system is installed on your target.

cheers,
Ashish

Apps to use ADC and i2c are uploaded

Thanks Ashish. These samples/tutorials are a great idea. I’m sure many (including myself) will find value in them.

One question that applies these sample apps:

In the function 'touch_ledGpio_ChangeHandler'

What’s the purpose of setting up edge detection on the LED gpio output pin?

// set call back for change in state of GPIO
mangoh_ledGpio_SetEdgeSense(MANGOH_LEDGPIO_EDGE_BOTH);

The change event handler is added to the push button or gpio input pin when the component is initialised.

Cheers,
Raf

Hi Raf,
Correct, that line should be removed.
cheers,
Ashish

The correction was made in commit 5685a272df630bb5f058343441eca10fa2c778a1. Raf, if you (or anyone else) notice errors in the tutorial code or see room for improvement, feel free to make a pull request or open an issue.

Problems reading ADC2/3

ADC0/1 work fine is this a known issue ???

ec 12 12:06:29 | kernel | [ 341.513505] qup_i2c qup_i2c.0: QUP: I2C status flags :0x1363c8, irq:187
Dec 12 12:06:29 | kernel | [ 341.519304] qup_i2c qup_i2c.0: I2C slave addr:0x3a not connected
Dec 12 12:06:29 | kernel | [ 341.540424] gpio_check_and_wake: wake-n_gpio77 STATE=WAKEUP
Dec 12 12:06:29 | kernel | [ 341.546009] Frame payload len 0xff0d overruns buffer size (0x26)
Dec 12 12:06:29 | kernel | [ 341.558858] Failed to recv response
Dec 12 12:06:29 | kernel | [ 341.561544] swimcu_read_adc restart failed on chan 8, try init
Dec 12 12:06:29 | kernel | [ 341.579642] Unhandled frame type 191
Dec 12 12:06:29 | kernel | [ 341.582023] Failed to receive a frame 1
Dec 12 12:06:29 | kernel | [ 341.590813] swimcu_event_query: fail 1
Dec 12 12:06:29 | kernel | [ 341.614954] Unhandled frame type 191
Dec 12 12:06:29 | kernel | [ 341.618556] Failed to recv response
Dec 12 12:06:29 | kernel | [ 341.621181] swimcu adc_init: fail chan 1
Dec 12 12:06:29 | kernel | [ 341.625087] swimcu_read_adc: fail to init chan 1
Dec 12 12:06:29 | Legato | modemDaemon[495]/swiQmi T=main | swiQmi.c swiQmi_CheckResponse() 768 | Sending QMI_SWI_M2M_ADC_READ_RESP_V01 failed: rc=0 (), resp.result=1.[0x01], resp.error=48.[0x30]
Dec 12 12:06:29 | Legato | modemDaemon[495]/le_pa T=main | pa_adc_qmi.c pa_adc_ReadValue() 154 | Failed to read ADC.3 (channel.11)
Dec 12 12:06:29 | Legato | combapp[1702]/combwp85 T=main | main.c _combwp85_COMPONENT_INIT() 24 | ADC 0 19944 1 9067 2 -1225338512 3 0

Hi Gregory,

Yes, this is a known issue with ADV2 and ADC3 which is caused by excessive loading of i2c bus when all ports of i2c hub are simultaneously enabled. Please update the gpio expander application from github with the fix

Regards,
Ashish

1 Like

Thank you this is running on a prototype board not mango board ill adjust the software accordingly and turn off all I2C expander bus lines we have incorporated the I2C bus expander in the design …

Thank you for your feedback.

…

I can confirm that this resolves the issue thank you

Hello Ashish,
I am using the latest version of gpioExpanderGreen from github and there is still problem to read ADC2 in “wiredSensor” application. Please suggest! Thank You!