Can I pass an IO port as a parameter to a function?

I try to make function that take IO register parameter (AVR 32 PORTA) to manipulate it .but it doesn't work .

/*my function */
U8_t set_bits( U8_t port, U8_t mask)
{
port |= mask;
return port ;
}


/*call of function*/
PORTA=set_bits(PORTA , 0xF0);

Answers


Welll...it works, but you need to return the port. Currently it is a parameter (passed by value). Use:

void set_bits(volatile uint8_t *port, uint8_t mask)
{
    *port |= mask;
}

and call with:

    uint8_t port;
    set_bits( &port, mask);

Or you can return the port:

uint8_t set_bits(uint8_t port, uint8_t mask)
{
    port |= mask;
    return port;
}

and call with:

    uint8_t port;
    port= set_bits(port, mask);

Need Your Help

complex group by mysql query

sql mysql database facebook news-feed

I have a table with the following rows:

Correct handling of OnMouseWheel events in Ext-GWT

java mousewheel gxt

I'm trying to figure out which property of BoxComponentEvent will tell me if the generated OnMouseWheel event was a scroll-up or scroll-down event. I have output the values of all the properties