Mangoh Red wp750x input config


#1

Hi everyone,
i have to connect one button to Mangoh Red, i used GPIO22 of CF3 GPIO. Following you can see the code:
.adef
executables:
{
gpioCf3Demo = ( gpioCf3PinComponent )
}

bindings:
{
  gpioCf3Demo.gpioCf3PinComponent.le_gpioPin22 -> gpioService.le_gpioPin22
}

processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}

  run:
   {
    ( gpioCf3Demo )
   }
}

.cdef
requires:
{
api:
{
le_gpioPin22 = le_gpio.api
}
}

cflags:
{
“-std=c99”
}

sources:
{
gpioCf3Pin.c
}

.c
#include “legato.h”
#include “interfaces.h”

static void Pin22ChangeCallback(bool state, void *ctx){
   LE_INFO("button pressed****************************");
 }

static void Pin22GpioSignal()
{
    le_gpioPin22_SetInput(LE_GPIOPIN22_ACTIVE_HIGH);
    le_gpioPin22_EnablePullDown();
    le_gpioPin22_AddChangeEventHandler(LE_GPIOPIN22_EDGE_BOTH, Pin22ChangeCallback, NULL, 0);

    le_gpioPin22_SetEdgeSense(LE_GPIOPIN22_EDGE_BOTH);
 }

 COMPONENT_INIT
 {
   LE_INFO("This is sample gpioctl Legato CF3 GPIO app by using le_gpio.api\n");

    Pin22GpioSignal();
    return;	
   }

I follow this example : https://github.com/legatoproject/legato-af/tree/master/apps/sample/gpioCf3Demo

The button is connected to pin 11 that correspond to GPIO22, and the other pin is connected to ground. Anyone can tell me what i’m wrong?

Thank you in advance!!!


#2

Hey @abalzano,

What seems to be the issue here? I’ve been working with the le_gpio API quite a bit and your code looks mostly correct to me. Are you having trouble compiling/building/deploying or are you just not seeing the change?

Cheers!


#3

Hi Nick
Thank you for your replay, anyway my problem is that i don’t see any change when i press the button. I checked also was enable by AT commands and everithing seems good. Regarding bulding/compilation i don’t have any error.


#4

Hey @abalzano,

Let’s confirm the app is installed and running. Start by ssh'ing into your target by invoking ssh root@192.168.2.2 (or another IP if you changed it). After logging into the ssh session, invoke app status or app status | grep gpioCf3Demo if you want to only see your new app. It’s also helpful to update versions in your .adef file as you go such that you can run app version <appname> to confirm the latest version is installed (its not uncommon for Legato to reject apps that fault frequently and roll them back).

If all is running as expected, let me know and we can go from there.

Cheers!


#5

Hi Nick, the app is runnig, as you can see in the attached picture. Just to be sure, at the moment i connected the push button to GPIO22, without external pull-up resistance, but i have just enable the internal pull-up. Maybe the is something wrong in the phisical connection.

Thank you, have a good day.


#6

here the pictureappversion


#7

Hey @abalzano,

Definitely double check the physical connections as its always a good thing to try and rule out. The only thing I see in your code that I’ve never tried before is the call to le_gpioPin22_SetEdgeSense(LE_GPIOPIN22_EDGE_BOTH);. I suspect this call is not needed since the edge sense is specified when attaching the change handler, but I would be surprised if this would cause issues.

Maybe try polling it every 30 seconds or so and print the value to the logs. See if these values match what you expect. If they are not what you expect, likely that GPIO pin is not working at all (physical or configuration).

I’ve also found it helpful to inspect things you depend on in situations like this. A few handy commands for this:

  • sdir list: Shows all services and bindings (and shows if any services are waiting).
  • dmesg and dmesg | grep i2c: Show the kernel logs. I’ve seen GPIO failure occur due to i2c problems so the grep can be useful.
  • logread | grep gpioService: Show the logs for gpioService. It should log if it’s having any issues.

Hopefully this is helpful,
Cheers!