// Returns 64 bit mac timer count value
uint64_t get_timestamp()
{
uint16_t cnt;
cnt = read_counter();
printk ("counter value is 0x%x\n", cnt);
return cnt;
}
within caller:
uint64_t ts;
ts = get_timestamp();
printk ( "returned timestamp is 0x%x \n", ts );
I got the following on screen, What is wrong above?
counter value is 0x000045a5
returned timestamp is 0x00000000
counter value is 0x0000698f
returned timestamp is 0x00000000
You are seeing this issue becasuse you print out the values incorrectly. there are dedicated
printf
format macros for theuint*_t
types.from the manpage of
<inttypes.h>
:so for example, to print a
uint16_t
and auint64_t
you could write (untested):you should read
man stdint.h
andman inttypes.h
if you are interested in the details, and what the semantics of theLEAST
andFAST
types are. very cool stuff.