If you want to access to single bits you can use for example an array of structures to indicate the single port pins: struct led_pointer { unsigned char * address; unsigned char mask; }; const struct led_pointer My_Port[8]={ (unsigned char*) &PORT6, 0x02, (unsigned char*)&PORT6, 0x04, (unsigned char*) &PORT7, 0x10, (unsigned char*) &PORT7, 0x20, (unsigned char*) &PORT7, 0x40, (unsigned char*) &PORT7, 0x80, (unsigned char*) &PORT2, 0x02, (unsigned char*) &PORT2, 0x04 }; #define SET_BIT(X) *(My_Port[X].address)|=My_Port[X].mask #define CLEAR_BIT(X) *(My_Port[X].address)&=~My_Port[X].mask Then you have your pointers and structures. For single bit access this is OK. It is not usefull for complete port access.
↧