aleksa said:
Some memory-mapped devices require a write to a specific
memory address in order to do something.
The data written is of no importance.
They typically are;-)
How can I instruct the compiler to write
whatever value it finds handy in that moment?
What means "handy at that moment"? That's a bit unspecific.
If you want to write just a single byte then, as Ben Pfaff
pointed out, using an unsigned char pointer (with the ad-
dress cast to that) would do. If you want to write more than
a single byte (but that would, of course, also work for a
single byte) you could use memcpy() to the target address,
cast to a void pointer. But there could be problems with
that: many devices want e.g. a single 16-bit or 32-bit wide
write or they won't do what you expect from such an access.
memcpy() is under no obligation to do it that way (even though
there's some chance that it copies in larger than 1-byte wide
chunks if possible). In device drivers you will often find
several functions for different wide accesses. If you need
e.g. to read or write 16-bit or 32-bit wide data instead of
an unsigned char (or uint8_t) pointer you'd use uint16_t or
uint32_t pointers. You have to carefully read the specifi-
cations for the hardware and decide which function to use
in each case - there's no fit-it-all function you could use
without further thought.
Regards, Jens