mmu2_serial.cpp 601 B

12345678910111213141516171819202122232425262728293031
  1. #include "mmu2_serial.h"
  2. #include "uart2.h"
  3. namespace MMU2 {
  4. void MMU2Serial::begin(uint32_t baud){
  5. uart2_init(baud); // @@TODO we may skip the baud rate setting in case of 8bit FW ... could save some bytes...
  6. }
  7. void MMU2Serial::close() {
  8. // @@TODO - probably turn off the UART
  9. }
  10. int MMU2Serial::read() {
  11. return fgetc(uart2io);
  12. }
  13. void MMU2Serial::flush() {
  14. // @@TODO - clear the output buffer
  15. }
  16. void MMU2Serial::write(const uint8_t *buffer, size_t size) {
  17. while(size--){
  18. fputc(*buffer, uart2io);
  19. ++buffer;
  20. }
  21. }
  22. MMU2Serial mmu2Serial;
  23. } // namespace MMU2