<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 13-08-2015 14:51, Ketul Shah wrote:<br>
    </div>
    <blockquote
cite="mid:CAM3zFrRKiBowc06mznNNs2h9Gt5VGA+BW=b01s3xr-QHacszhw@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Andre,
        <div><br>
        </div>
        <div>Thanks for the reply. </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">On 13 August 2015 at 19:13, André
            Marques <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:andre.lousa.marques@gmail.com"
                target="_blank">andre.lousa.marques@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello
              Ketul,<span class=""><br>
                <br>
                On 13-08-2015 13:04, Ketul Shah wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  Hi Andre,<br>
                  <br>
                  Great API and happy to know that it is merged with
                  main line.<br>
                  <br>
                  Eventually I implemented GPIO driver for BBB using
                  this API. After debugging for rtems_gpio_get_value()
                  on BBB I found the following bug.<br>
                  <br>
                  For BBB, GPIO pin nos. varies from 0 to 32. So
                  function return type would be uint32_t instead of
                  uint8_t.<br>
                  <br>
                  For BBB I wrote :-<br>
                  <br>
                  uint32_t rtems_gpio_bsp_get_value(uint32_t bank,
                  uint32_t pin)<br>
                  {<br>
                    return (mmio_read(bbb_reg(bank, AM335X_GPIO_DATAIN))
                  & BIT(pin));<br>
                </blockquote>
              </span></blockquote>
            <div>So it would be:-  return ((mmio_read(bbb_reg(bank,
              AM335X_GPIO_DATAIN)) & BIT(pin)) > 0); </div>
            <div>Am I correct ?</div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex"><span
                class="">
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  }<br>
                  <br>
                </blockquote>
              </span></blockquote>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Yes, but since this function is not used by applications maybe it
    would be best to return the bitmask here and avoid another
    operation, as rtems_gpio_get_value does the mapping to 1 anyway for
    any value above 0.<br>
    <br>
    So yes the bsp function shall return uint32_t instead of the
    uint8_t. Doxygen also has to be updated.<br>
    <br>
    <blockquote
cite="mid:CAM3zFrRKiBowc06mznNNs2h9Gt5VGA+BW=b01s3xr-QHacszhw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex"><span
                class="">
                <blockquote class="gmail_quote" style="margin:0 0 0
                  .8ex;border-left:1px #ccc solid;padding-left:1ex">
                </blockquote>
                <br>
              </span>
              the rtems_gpio_bsp_get_value returns the value of a GPIO
              pin, which can only be either 0 or 1. This is not platform
              dependent. Any value greater than zero should map to 1.<br>
              <br>
              I do notice that I forgot this detail in the Pi
              implementation too, so it is also returning a 32 bit
              value.<br>
              <br>
              The reasoning for the 8-bit return is that the return will
              always be binary. 0 or non-zero, but by mapping a non-zero
              value to 1 may make more sense than outputing a 32-bit
              bitmask, which was the initial approach.<br>
              <br>
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex">
                Thanks.<br>
                <br>
                Best Regards,<br>
                Ketul<br>
                <br>
              </blockquote>
              <br>
              --André Marques.<br>
              <br>
              [snip]<br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>