Enable UART programmatically

I have a Raspberry Pi 3B+ that communicates via uart with another custom board (9600 8N1 and a bunch of characters, nothing special).
On the RPi I’ve written a program in C with Geany that’s launched at boot and runs in background, while on the second board there’s an Atmel microcontroller programmed with AVR Studio.
On the RPi I’ve enabled the serial console, using dietpi-config, to be able to use the serial0, but in this way all the text printed on the screen during the RPi boot is sent over the uart0…
The boards share the same power supply, so at boot could be enough to ignore the first 30~60s (on the Atmel side) but in my opinion should be better to enable the serial0 programmatically on the RPi when needed.
I’ve searched on the web but I didn’t find a solution in C (and moreover I’m quite new to RPi and its OS).
How can I enable the uart0 in my C program?
Or, how can I prevent all the boot messages to be sent over uart0?

Thanks, J.