Announcement

Collapse
No announcement yet.

Cannot use more than one GPIO to set up HOOK_GPIN event

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot use more than one GPIO to set up HOOK_GPIN event

    Hello,
    I am using the RF100 and the protoboard.

    When ONLY setting up the GPIO_5 (mapped to the S1 switch) to generate a HOOK_GPIN event, pressing/depressing the S1 swicth generates the events as expected always.

    When adding a secondary gpio to generate an additional HOOK_GPIN event, pressing/depressing the S1 swicth generates ONLY the very first event ALWAYS, and then they are not generated. The secondary GPIO generates the events most of the time.

    Can't two or more GPIO's be used simultaneously to generate HOOK_GPIN events?

    The code used to set it up is:
    ...
    RTC_ALARM_PIN = BUTTON_PIN
    XL345_AXIS_INT1 = GPIO_6

    setPinDir(XL345_AXIS_INT1, False)
    setPinPullup(XL345_AXIS_INT1, False)

    monitorPin(RTC_ALARM_PIN, True)
    wakeupOn(RTC_ALARM_PIN, True, False)

    monitorPin(XL345_AXIS_INT1, True)
    wakeupOn(XL345_AXIS_INT1, True, False)
    ...
    And the code used for event handler is:
    @setHook(HOOK_GPIN)
    def wakeUpEvent(pinNum, isSet):
    global RTC_ALARM_PIN
    global XL345_AXIS_INT1

    rpc(portalAddr, 'logEvent', "+wakeUpEvent" + ", pinNum:" + str(pinNum) + ", isSet:" + str(isSet))

    Thanks,
    Eugen

  • #2
    clarification

    Hi Eugene,

    There's several areas that could be your issue.

    First, you mention in your post about setting up GPIO_5. NONE of your code in the response, however, uses GPIO_5.

    In your code snippet, you are using "BUTTON_PIN" and "GPIO_6". (I am assuming that you are including evalBase.py that maps BUTTON_PIN to DEMO_BUTTON_PIN which is mapped to GPIO_1.) Therefore, I am confirming that you are trying to detect an event from GPIO_1 or GPIO_6, correct?

    OK, then you correctly set up the monitoring of those two pins with the monitorPin functions.

    Finally, you try running it and wonder why you never (or hardly ever, it isn't clear from your post) get the other pin event.

    It appears you have forgotten that you actually need to process which pin actually generated the hook:
    if pin == GPIO_6:
    pass /* logic for what to do if GPIO_6 triggered it */

    or
    if pin == GPIO_1:
    pass

    Here's an example of monitoring for GPIO_11 hook that is self-contained:
    ----------------------------------------------------------------

    @setHook(HOOK_STARTUP)
    def startupEvent():
    """Event called at system startup"""

    setPinDir(GPIO_1, True)
    writePin(LED_PIN, True)

    setPinDir(GPIO_11, False) #set pin as input
    monitorPin(GPIO_11, True) #lets monitor this pin
    mcastRpc(1, 1, 'initRelayBoard')



    @setHook(HOOK_GPIN)
    def myfunction(pin, isPulledLow):
    # mcastRpc(1, 1, 'initRelayBoard')
    if pin == GPIO_11: #is pin change the brown wire
    if not isPulledLow: #is the wire input high
    mcastRpc(1, 1, 'setRelay', 1, True)

    else:
    mcastRpc(1, 1, 'setRelay', 1, False)

    Comment


    • #3
      note: it might be that he is trying to produce a second interrupt while the first is still asserted (i.e. have not cleared the first trigger). This is a known thing with the Freescale hardware – the interrupt engine multiplexes the signals will continue to believe it is in the first interrupt regardless of any new interrupts that come in.

      I also took your code, made a few changes and it seems to work .....

      Code:
       
      from synapse.evalBase import *
      from synapse.pinWakeup import *
      portalAddr = "\x00\x00\x01"
       
      @setHook(HOOK_STARTUP) 
      def startupEvent():
       
          detectEvalBoards()
       
          RTC_ALARM_PIN = BUTTON_PIN  #should be GPIO_5
          XL345_AXIS_INT1 = GPIO_6
       
       
          setPinDir(XL345_AXIS_INT1, False)
          setPinPullup(XL345_AXIS_INT1, False)
          monitorPin(XL345_AXIS_INT1, True)
          monitorPin(RTC_ALARM_PIN, True)
       
          wakeupOn(RTC_ALARM_PIN, True, False)
          wakeupOn(XL345_AXIS_INT1, True, False)
       
       
      @setHook(HOOK_GPIN)
      def wakeUpEvent(pinNum, isSet):
          global RTC_ALARM_PIN,XL345_AXIS_INT1, portalAddr
          print "pin detected"
          rpc(portalAddr, 'logEvent', "+wakeUpEvent" + ", pinNum:" + str(pinNum) + ", isSet:" + str(isSet))

      Comment

      X