main.c 563 B

123456789101112131415161718192021222324
  1. #include "uart.h"
  2. #include <string.h>
  3. #include <stdio.h>
  4. int main()
  5. {
  6. uart_handle_st uart;
  7. memset(&uart, 0, sizeof(uart));
  8. uart_handle_set_device(&uart, "/dev/ttyS1");
  9. uart_handle_set_baudrate(&uart, 115200);
  10. uart_handle_set_databits(&uart, 8);
  11. uart_handle_set_stopbits(&uart, 1);
  12. uart_handle_set_parity(&uart, PARITY_NONE);
  13. uart_handle_set_flow_control(&uart, FLOW_CONTROL_NONE);
  14. uart_handle_set_block(&uart, 1);
  15. if(uart_handle_open(&uart) < 0)
  16. {
  17. printf("Failed to open UART\n");
  18. return -1;
  19. }
  20. }