I'm programming with an AVR and I'm trying to create a function to set a pin as an output. I made a struct to hold the Register and Pin number like this:
typedef struct Pin{
uint8_t pinNo;
volatile uint8_t* pinReg;
};
I then have this function to set a pin an output.
void pin_output(struct Pin pin){
//DDRA |= _BV(DDA6);
*(pin.pinReg) |= _BV(pin.pinNo);
}
Called like this:
struct Pin pin6;
pin6.pinNo = DDA6;
pin6.pinReg = DDRA;
pin_output(pin6);
This works fine but the led brightness very dim. If I set the output like this:
DDRA |= _BV(DDA6);
The pin is at its expect brightness about 3-5x more bright then with the function. What is getting lost in the function causing the problem with the brightness?