Here is what I am trying to do:
sbit PORT_1_0 = P1^0;
void main () { PORT_1_0 = 1; while(1) { PORT_1_0 =~ PORT_1_0; } }
Now this is as simple as it gets. The question is, is it possible to do the same thing using an element of a struct?
Something like:
struct abc { unsigned char bit : 1; };
struct bit bit_array[24];
bit_array[0].bit = P1^0; //Assign the port pin to be toggled
//and then the toggling here.
Basically, how to assign a port pin to the bit in a struct? I am doing this because based on the address of a frame, I need to decide which pin is to be set. I hope you get the question.
"I agree with you on the extra memory wastage, but is it possible to do such an operation?"
Sure, if you don't need to pack 8 bits in a byte and using some of your example's names:
unsigned char bit_array[24]; void foo(void) { bit_array[0] = PORT_1_0; PORT_1_0 = !!bit_array[0]; }
!! gaurantees "boolification" (my word) in case the byte value is other than 0 or 1.