Go Down

Topic: Using PIN's of MAX3421e USB HOST SHIELD (Read 1 time) previous topic - next topic

NI$HANT

Hi i wanted to utilise the GPIN GPOUT pins on the SparkFun's USB HOST SHIELD , is there any code snippet to access the same given im using the USB HOST 2.0 library?

"Real Men can Accomplish  Anything"
- <a href="http://www.winacro.com">  <b><font color="red">Website</font></b> </a> 
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੁਂ!

Nick Gammon

You want to use those 16 pins for some purpose, is that it?

This snippet from board_qc.pde might illustrate the general idea:

Code: [Select]
  /* GPIO test */
  /* in order to simplify board layout, GPIN pins on text fixture are connected to GPOUT */
  /* in reverse order, i.e, GPIN0 is connected to GPOUT7, GPIN1 to GPOUT6, etc. */
  {
    uint8_t tmpbyte;
    Notify(PSTR("\r\nGPIO test. Connect GPIN0 to GPOUT7, GPIN1 to GPOUT6, and so on"));
    for( uint8_t sample_gpio = 0; sample_gpio < 255; sample_gpio++ ) {
      Usb.gpioWr( sample_gpio );
      tmpbyte = Usb.gpioRd();
      /* bit reversing code copied vetbatim from http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */
      tmpbyte  = ((tmpbyte * 0x0802LU & 0x22110LU) | (tmpbyte * 0x8020LU & 0x88440LU)) * 0x10101LU >> 16;
      if( sample_gpio != tmpbyte ) {
        Notify(PSTR("\r\nTest failed. Value written: "));
        print_hex( sample_gpio, 8 );
        Notify(PSTR(" Value read: "));
        print_hex( tmpbyte , 8 );
        Notify(PSTR(" "));
        press_any_key();
        break;
      }//if( sample_gpio != tmpbyte...
    }//for( uint8_t sample_gpio...
    Notify(PSTR("\r\nGPIO test passed."));           
  }//GPIO test



Judging by that you want Usb.gpioWr(x)  to write and x = Usb.gpioRd() to read.
http://www.gammon.com.au/electronics

NI$HANT

Quote
You want to use those 16 pins for some purpose, is that it?


Yes sir and i got it, Thanks!
"Real Men can Accomplish  Anything"
- <a href="http://www.winacro.com">  <b><font color="red">Website</font></b> </a> 
- skype : nishants5  

ਫ਼ਤੇਹ ਕਰੁਂ!

Hazem

Dear Sirs
what is the use of Notify() syntax, and where does it output the data?

also i want to ask how does the program Board_qc output the test result?

than you for help

Go Up