USART break signal should be sent explicitly as RX interrupt event.
USART TX and RX can run in parallel.
USART-RX line using intterupt mode (non-blocking)
USART-TX line using polling mode (blocking)
Optional stdout locking mechanism.
main.c
#include"nds-serial/serial.h"#include<string.h>#include<stdio.h>/* external entity */externvoiddelay(uint64_tms);
externNDS_DRIVER_USARTDriver_USART1;
/* private variables */staticcharstdin_buffer[512];
/* private function definition */staticvoidstdin_reader(void*p_buffer, uint16_tu16_cnt)
{
/* do something with received data *//* replace with flag or queue message *//* as this is still in interrupt context call */
}
/* public function definition */intmain(void)
{
uint8_tu8_cntr=0;
/* initialize terminal */serial_init(&Driver_USART1, 38400, NULL);
serial_start(stdin_reader, stdin_buffer, sizeof(stdin_buffer));
/* send directly to serial */char*p_text="hello world\n";
serial_write(p_text, strlen(p_text));
/* infinite loop */while(1) {
/* send in-direct using stdout */printf("counter = %d\r\n", u8_cntr++);
delay(1);
}
return0;
}