I'm using Atmel Studio to build hex files for AVR microcontrollers. Every time I try to build a certain project while using the following function is generating a warning of casting to pointer from integer or different size.
The function is:
static inline uint8 init_reg(uint8 reg, uint8 val)
{
if (val > 255)
return E_FAIL;
*(volatile uint8 *) (reg) = val;
return S_PASS;
}
I want to know the cause of such warning. Thank you...
uint8? If it's a typedef for an 8-bit integer type then this code is pretty weird.val > 255would be redundant, and it's a bit strange to pass your memory address (in the range 0-255) as an integer instead of a pointer.