QNICE-FPGA
QNICE-FPGA copied to clipboard
Avoid repetitive code in our C demos
We might want to add
// convenient mechanism to access QNICE's Memory Mapped IO registers
#define MMIO( __x ) *((unsigned int volatile *) __x )
to c/qnice/monitor-lib/include/qmon.h
as this is something that we need "all the time". Of course - if we do that - we need to sift through demos and remove this definition there.
Also common things that we need in our demos like non-blocking waiting for a key, as Michael did it in world.c:
if (MMIO(IO_UART_SRA) & 1)
{
unsigned int tmp = MMIO(IO_UART_RHRA);
break;
}
if (MMIO(IO_KBD_STATE) & KBD_NEW_ANY)
{
unsigned int tmp = MMIO(IO_KBD_DATA);
break;
}
We might want to add this to the .h
file mentioned above and the implementation to c/qnice/monitor-lib/src/qmon.c
I bet there are a handful more things that we would find which would overall make our C demo code less redundant.
As this is just a "cleanup before a release" task, the priority is rather low, I guess :-)
I assigned it to myself and @MJoergen .
Obviously also some "how to program MMIO" and "how to program realtime" best practices need to be written around this.