3 Replies Latest reply on May 29, 2015 3:53 PM by rmull18

    ARRRRGH! Is there any way to switch GPIO faster ???!!!!



      I really, Really, REALLY need to be able to switch GPIO pins from out to in faster.  Surely there is a way to do this that doesn't require calling the Linux file I/O API (???!!!) like mraa_gpio_dir() does.  The latency involved in this one simple mraa function is costing us over $100 per unit.  If I can get this worked out I can read my sensors directly from GPIO and I don't need a PIC (and the associated cost and complexity) to do it for me.  I mean the idea of adding additional computing resources to a platform suffering from an over abundance of processing power is just silly.  Especially when all I need to do is read a few DTH11/22s.

      I know that the actual hardware part of this works pretty quickly.  I can generate the reset pulse then call mraa_gpio_dir() and see it switch almost immediately because I see the sensor able to drive the pin for the 80us presence pulse and all 40 subsequent bits of data.  But I don't get control back quickly enough to start reading the pulses.  I miss the presence pulse and 6-8 bits of the data.  Is the actually hardware switching done by this code from mraa_gpio_dir() maybe?

      if (advance_func->gpio_dir_replace != NULL) {
        return advance_func->gpio_dir_replace(dev,dir);
      if (advance_func->gpio_dir_pre != NULL) {
        mraa_result_t pre_ret = (advance_func->gpio_dir_pre(dev,dir));
        if (pre_ret != MRAA_SUCCESS) {
        return pre_ret;


      I've heard the "you shouldn't bit-bang under Linux" argument and I see the point, but there are very sound reasons (economics being a good one) to be able to interface to external components like the DHT22/11's via the GPIO.  I mean it's the IoT for cryin' out loud.  You wanna put Galileo/Edison in everything from waffle irons to tractors, you're gonna need to do a little more than blink LEDs.  Well maybe not for the waffle iron application ...


      Any pointers would really be appreciated.