I have a program in which I have to manipulate 4 LEDs. I have a function that is designed to find out exactlywhat I need to do to each LED ie flash, fade, dim, etc but in order to save on code space I would like to send the program the LED by reference. For instance on of my functions looks like the following:
void switchon(&sbit LED, bit turnon) { if(turnon) { LED=ON; } if(!turnon) { LED=OFF; } }
"It's quite simple, really: "pass by reference" doesn't exist in C. You have to pass a pointer instead:" Except that bits are not "addressable" and therefore cannot be directly passed by reference. Also, presuming LED is a port (meaning SFR) bit, the SFR cannot be passed by reference assuming you want to directly dereference it.