Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SoftSerial SDFileSystem mbed wave_player
main.cpp@3:f128424d2e80, 2017-05-02 (annotated)
- Committer:
- thoma@THOMAS-CAUWELIER.khbo.be
- Date:
- Tue May 02 19:20:21 2017 +0200
- Revision:
- 3:f128424d2e80
- Parent:
- 1:6b839581dc9f
- Child:
- 4:a07612fbf279
add manchester
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Desertification | 1:6b839581dc9f | 1 | |
Desertification | 1:6b839581dc9f | 2 | #include "mbed.h" |
Desertification | 1:6b839581dc9f | 3 | |
Desertification | 1:6b839581dc9f | 4 | int main() { |
thoma@THOMAS-CAUWELIER.khbo.be | 3:f128424d2e80 | 5 | printf("%s", "hello, term"); |
Desertification | 1:6b839581dc9f | 6 | } |
Desertification | 1:6b839581dc9f | 7 | |
Desertification | 1:6b839581dc9f | 8 | |
Desertification | 1:6b839581dc9f | 9 | |
Desertification | 1:6b839581dc9f | 10 | |
Desertification | 1:6b839581dc9f | 11 | /** A serial port (UART) for communication with other serial devices |
Desertification | 1:6b839581dc9f | 12 | * |
Desertification | 1:6b839581dc9f | 13 | * Can be used for Full Duplex communication, or Simplex by specifying |
Desertification | 1:6b839581dc9f | 14 | * one pin as NC (Not Connected) |
Desertification | 1:6b839581dc9f | 15 | * |
Desertification | 1:6b839581dc9f | 16 | * This uses software serial emulation, regular serial pins are alot better, |
Desertification | 1:6b839581dc9f | 17 | * however if you don't have spare ones, you can use this. It is advicable |
Desertification | 1:6b839581dc9f | 18 | * to put the serial connection with highest speed to hardware serial. |
Desertification | 1:6b839581dc9f | 19 | * |
Desertification | 1:6b839581dc9f | 20 | * If you lack RAM memory you can also use SoftSerial without this buffer around it. |
Desertification | 1:6b839581dc9f | 21 | * In that case it is fully blocking. |
Desertification | 1:6b839581dc9f | 22 | * |
Desertification | 1:6b839581dc9f | 23 | * Example: |
Desertification | 1:6b839581dc9f | 24 | * @code |
Desertification | 1:6b839581dc9f | 25 | * #include "mbed.h" |
Desertification | 1:6b839581dc9f | 26 | * #include "BufferedSoftSerial.h" |
Desertification | 1:6b839581dc9f | 27 | * |
Desertification | 1:6b839581dc9f | 28 | * SoftSerial block(USBTX, USBRX); |
Desertification | 1:6b839581dc9f | 29 | * BufferedSoftSerial buf(USBTX, USBRX); |
Desertification | 1:6b839581dc9f | 30 | * |
Desertification | 1:6b839581dc9f | 31 | * int main() |
Desertification | 1:6b839581dc9f | 32 | * { |
Desertification | 1:6b839581dc9f | 33 | * while(1) { |
Desertification | 1:6b839581dc9f | 34 | * Timer s; |
Desertification | 1:6b839581dc9f | 35 | * |
Desertification | 1:6b839581dc9f | 36 | * s.start(); |
Desertification | 1:6b839581dc9f | 37 | * buf.printf("Hello World - buffered\r\n"); |
Desertification | 1:6b839581dc9f | 38 | * int buffered_time = s.read_us(); |
Desertification | 1:6b839581dc9f | 39 | * wait(0.1f); // give time for the buffer to empty |
Desertification | 1:6b839581dc9f | 40 | * |
Desertification | 1:6b839581dc9f | 41 | * s.reset(); |
Desertification | 1:6b839581dc9f | 42 | * block.printf("Hello World - blocking\r\n"); |
Desertification | 1:6b839581dc9f | 43 | * int polled_time = s.read_us(); |
Desertification | 1:6b839581dc9f | 44 | * s.stop(); |
Desertification | 1:6b839581dc9f | 45 | * wait(0.1f); // give time for the buffer to empty |
Desertification | 1:6b839581dc9f | 46 | * |
Desertification | 1:6b839581dc9f | 47 | * buf.printf("printf buffered took %d us\r\n", buffered_time); |
Desertification | 1:6b839581dc9f | 48 | * buf.printf("printf blocking took %d us\r\n", polled_time); |
Desertification | 1:6b839581dc9f | 49 | * wait(5); |
Desertification | 1:6b839581dc9f | 50 | * } |
Desertification | 1:6b839581dc9f | 51 | * } |
Desertification | 1:6b839581dc9f | 52 | **/ |