jung6717 / arduino

Automatically exported from code.google.com/p/arduino
0 stars 0 forks source link

portRead() and portWrite() commands, if possible. #247

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What change would like to see?

portRead() and portWrite() functions.  Although given that the pins in the 
ports aren't necessarily all 
available or contiguous, we'll have to figure out some of the details.

Why?

So you can read and write the whole port at once - for speed, and eliminating 
some potential 
problems.

Original issue reported on code.google.com by dmel...@gmail.com on 6 May 2010 at 6:33

GoogleCodeExporter commented 8 years ago
You are thinking too simple.
There should be functions like:
digitalWrite8Pins(pin0, pin1, pin2, pin3, pin4, pin5, pin6, pin7, byteval);
digitalRead8Pins(pin0, pin1, pin2, pin3, pin4, pin5, pin6, pin7);
pinMode8Pins(pin0, pin1, pin2, pin3, pin4, pin5, pin6, pin7, dir);

Also, the 4 bit versions as well.
(which comes in handy for things like hd44780 LCDs)

If you use some fancy macros and logic, it is possible to detect if the
pins map to contiguous bits in a port and crush down the code to single 
instructions
if the pin values are all constants and all on the same port.
And if they aren't all on the same port, the logic can drop to nibble mode, or 
bit
i/o in the worst case.

By doing it this way, users don't have to worry about port issues and the code 
still
works with random pin assignments, but if they do know and understand about bits
within the ports, they can assign pins to a common port in the proper order to 
get
better/much faster code.

Original comment by bperry...@gmail.com on 11 May 2010 at 2:05

GoogleCodeExporter commented 8 years ago

Original comment by dmel...@gmail.com on 16 Dec 2011 at 10:06