Checkout the freedom-e-sdk and move demo_uart to freedom-e-sdk/software (or clone directly in place). Make as usual with the SDK to build and upload to target development board:
dave@Prospero:~/freedom-e-sdk$ make software PROGRAM=demo_uart BOARD=freedom-e300-hifive1 dave@Prospero:~/freedom-e-sdk$ make upload PROGRAM=demo\_uart BOARD=freedom-e300-hifive1
void UART_init(unsigned long baud, int stop_bits);
Write a string with option to block program until completed:
int UART_write(char * msg, int blocking);
Read input into a target buffer with options for controlling the number of characters to read, which character to stop reading on (typically \n or \r) and specify whether to block:
int UART_read_n(char * buffer, int max_chars, char terminator, int blocking);
- demo_uart.c: Quick and dirty demonstration. Sets up the UART for 9600 baud and a timer to print a message every second.
- UART_driver.c: Implementation.
- UART_driver.h: Include.
- Makefile: Adds functionality specific to this demo. Note that it's not standalone and relies on including other Makefiles from the SDK.