The problem I am trying to solve is the desire to avoid having to know/remember anything about port and bit numbering as it relates to physical pins on the OM device. Especially since it is liable to change from device to device as time goes on.
While the user will still have to handle the PORT, DDR, and PIN functions, I want them not to have to deal with _which_ port, etc it is, and only know that it has DDR, etc that needs to be manipulated.
I hope I explained the rationale well enough.

The bottom line is that I would like to be able to get down to something very ZX-like in manipulating the pins. Eventually having something as clear as PutPin(PinNum,Function);
where function is INPUT_TRISTATE,INPUT_HIGH, OUTPUT_HIGH, OUTPUT_LOW.
And the matching code of GetPin(PinNum); These may be able to expand to macros and a lookup table, or to a subroutine call plus macros and a lookup table.
What I see is something initially like this (written off the top of my head, so it is not going to work as is):
In a header there will be this:
| Code: |
#IFDEF (__atmega128__)//maybe this would be better checking for an OM128
#DEFINE OM_PORTE = 0x38; //an example of a memory mapped port location
#DEFINE OM_DDRE = 0x39;
#DEFINE OM_PINE = 0x40;
//other similar defines for all other port combinations
#ENDIF
|
Then somewhere (a header?) will be this:
| Code: |
//entries are PORT,DDR,PIN,BIT
#DEFINE PORT = 0
#DEFINE DDR = 1
#DEFINE PIN = 2
#DEFINE BIT = 3
unsigned char pin_table[] = {
0,0,0,0,//pin1 zeros signify an illegal I/O pin
0,0,0,0,//pin2
0,0,0,0,//pin3
0,0,0,0,//pin4
OM_PORTE,OM_DDRE,OM_PINE,(1
|