I’m trying to access the AVR registers in Arduino Mega. By including the necessary header files( avr/io and also for interrupts avr/interrputs.h).
The fuctionality which I’m trying has been achieved (I tried to access Timer 5 and generate an interrupt).
However, I want to try a different approach. Instead of just setting the values to registers, such as OCR5A = 154, I want to make use of bit access. For example, take a look at the snippet below:
#define TIMER5_INTERRUPT_MASK_REGISTER 0x73 //TIMSK5
#define TIMER5_INTERRUPT_FLAG_REGISTER 0x3A //TIFR5
typedef union _timer5_interrupt_masking_register
uint8_t TOIE5 : 1; /*!<  Overflow Interrupt Enable /
uint8_t OCIE5A : 1; /!<  Output Compare A Match Interrupt Enable /
uint8_t OCIE5B : 1; /!<  Output Compare B Match Interrupt Enable /
uint8_t OCIE5C : 1; /!<  Output Compare C Match Interrupt Enable /
uint8_t RESERVED0 : 1; /!<  Reserved Bit /
uint8_t ICIE5 : 1; /!<  Input Capture Interrupt Enable /
uint8_t RESERVED1 : 1; /!<  Reserved Bit /
uint8_t RESERVED2 : 1; /!<  Reserved Bit */
typedef struct _timer5_registers
timer5_interrupt_masking_register TIMER5_INTR_MASK_REG; /*!< Interrupt mask register /
timer5_interrupt_masking_register TIMER5_INTR_FLAG_REG; /!< Interrupt flag register */
By this approach, it makes my work easier by just accessing that bit and setting it low or high. For example, I want to enable a compare match interrupt, I can access corresponding bit on Interrupt Mask register and Mask it.
But the problem is, since Arduino already uses AVR library, defining this structure with the exact register name (which is already being used by AVR library) creates an ambiguity and throws an error.
““exit status 1
expected unqualified-id before numeric constant””
So my question, Is there any other way by which I can access the registers through the User defined structures?
Where can I find a published header file for Atmega2560 containing all necessary macros and register mapping?