| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 import 'dart:typed_data'; | |
| 6 | |
| 7 import 'package:stm32f746g_disco/uart.dart'; | |
| 8 import 'package:stm32f746g_disco/stm32f746g_disco.dart'; | |
| 9 | |
| 10 main() { | |
| 11 const int CR = 13; | |
| 12 const int LF = 10; | |
| 13 | |
| 14 STM32F746GDiscovery disco = new STM32F746GDiscovery(); | |
| 15 Uart uart = disco.uart; | |
| 16 | |
| 17 uart.writeString("\rWelcome to Dart UART echo!\r\n"); | |
| 18 uart.writeString("--------------------------\r\n"); | |
| 19 while (true) { | |
| 20 var data = new Uint8List.view(uart.readNext()); | |
| 21 // Map CR to CR+LF for nicer console output. | |
| 22 if (data.indexOf(CR) != -1) { | |
| 23 for (int i = 0; i < data.length; i++) { | |
| 24 var byte = data[i]; | |
| 25 uart.writeByte(byte); | |
| 26 if (byte == CR) { | |
| 27 uart.writeByte(LF); | |
| 28 } | |
| 29 } | |
| 30 } else { | |
| 31 uart.write(data.buffer); | |
| 32 } | |
| 33 } | |
| 34 } | |
| OLD | NEW |