Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. // uart.h
  2. // version 1.0.1
  3.  
  4. // create new UART instance with BAUDRATE 9600
  5. // currently not implemented
  6. UART* uart1 = uart.new(2);
  7.  
  8. // construct UART frame
  9. UART_FRAME frm =
  10. {
  11. 0,
  12. 0,
  13. (uint8_t[14]){0},
  14. 0
  15. };
  16.  
  17. // construct and data array
  18. uint8_t tx_array[4] = {120, 0x22, 0, 'f'};
  19.  
  20. // send some data of type 'MSG'
  21. uart.send(uart1, UART_MSG, tx_array, 4);
  22.  
  23. // infinite loop of reading from UART
  24. for(;;)
  25. {
  26. uart.read(uart1, &frm, true);
  27. for (int i = 0; i < 1000; i++);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement