Go Down

Topic: portOutputRegister() (Read 3031 times) previous topic - next topic

jrraines

I have a color LCD breakout board from Adafruit and I am trying to get it working on a Teensy2++. It works fine on a Mega and I moved the 8 data pins to the interior pins on the Teensy2++ which should keep the port the same. It has power but nothing is appearing on the screen. I put the control lines that were on A0-A3 on the Mega onto the Teensy2++'s A0-A3 lines.

I started looking at how the driver code accesses the control lines. An example:
Code: [Select]
void TFTLCD::writeData(uint16_t data) {
  volatile uint8_t *wrportreg = portOutputRegister(wrport);

  *portOutputRegister(csport) &= ~cspin;
  //digitalWrite(_cs, LOW);
  *portOutputRegister(cdport) |= cdpin;
  //digitalWrite(_cd, HIGH);
  *portOutputRegister(rdport) |= rdpin;
  //digitalWrite(_rd, HIGH);
 
  *wrportreg |=  wrpin;
  //digitalWrite(_wr, HIGH);

  setWriteDir();
  write8(data >> 8);
 
  *wrportreg &= ~wrpin;
  //digitalWrite(_wr, LOW);
  *wrportreg |=  wrpin;
  //digitalWrite(_wr, HIGH);

  write8(data);

  *wrportreg &= ~wrpin;
  //digitalWrite(_wr, LOW);
  *wrportreg |=  wrpin;
  //digitalWrite(_wr, HIGH);

  *portOutputRegister(csport) |= cspin;
  //digitalWrite(_cs, HIGH);
}


The commented out code is a good way to figure out what the code means but I don't think I have seen portOutputRegister() before and haven't been able to find it when I poke around in various source files. I'm using Xcode 3.2.6 as my editor for the driver file so I get a nice popup list of defined symbols (maybe not as nice as if they were alphabetized).

So 2 questions: where is portOutputRegister defined and more importantly is there a better technique for finding a symbol that is defined in some included file rather than just opening and examining each included file? Seems like this general problem must have been solved with some neat tool that I don't know about. Maybe a 3rd question: what should I have read or googled to get the answer to the 2nd question?

PaulS

Quote
where is portOutputRegister defined

In pins_arduino.h:
Code: [Select]
#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )

Quote
is there a better technique for finding a symbol that is defined in some included file rather than just opening and examining each included file?

On Windows there is. Don't know about Macs, but I presume there must be.

jrraines

Thanks, Paul.

I would have thought there must be a unix tool of some sort on the Mac to do the job. It occurred to me (finally) that all those smart unix guys must have gotten fed up with hunting through dozens of haystacks looking for which one had the needle.



PaulS

Quote
I would have thought there must be a unix tool of some sort on the Mac to do the job.

Like grep?

Grumpy_Mike

I use Xcode and the "Find in project" function.

AWOL

Code: [Select]
find / -name "*.[ch]" | xargs grep portOutputRegister -l

Might take a while.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up