Passing port to a function using pointer
Posted: 23 Dec 2014 08:19
With C for 8051, can I code as the following:
My code doesn't work. Can somebody help me?
Code: Select all
unsigned char Button(unsigned char *PORT, unsigned char pin, unsigned char active_state)
{
switch(active_state)
{
case LOW_STATE: if((((*PORT) >> pin) & 1) == LOW_STATE)
{
//My code
}
}
}
void main(void)
{
unsigned char button_state;
while(1)
{
button_state = Button(&P2, 0, LOW_STATE);
}
}