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@6:0e1973fdfe28, 2017-05-03 (annotated)
- Committer:
- Thomas Cauwelier
- Date:
- Wed May 03 00:41:21 2017 +0200
- Revision:
- 6:0e1973fdfe28
- Parent:
- 4:a07612fbf279
- Child:
- 7:2b99a26e6a43
uart thread test
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" |
Thomas Cauwelier |
6:0e1973fdfe28 | 3 | #include "rtos.h" |
Thomas Cauwelier |
6:0e1973fdfe28 | 4 | |
Thomas Cauwelier |
6:0e1973fdfe28 | 5 | Serial out(p9, p10); //p9 |
Thomas Cauwelier |
6:0e1973fdfe28 | 6 | Serial in(p13, p14); //p14 |
Thomas Cauwelier |
6:0e1973fdfe28 | 7 | |
Thomas Cauwelier |
6:0e1973fdfe28 | 8 | |
Thomas Cauwelier |
6:0e1973fdfe28 | 9 | void receive_uart() { |
Thomas Cauwelier |
6:0e1973fdfe28 | 10 | while (true){ |
Thomas Cauwelier |
6:0e1973fdfe28 | 11 | if(in.readable()){ |
Thomas Cauwelier |
6:0e1973fdfe28 | 12 | char s[32]; |
Thomas Cauwelier |
6:0e1973fdfe28 | 13 | printf(in.gets(s, 32)); |
Thomas Cauwelier |
6:0e1973fdfe28 | 14 | }else{ |
Thomas Cauwelier |
6:0e1973fdfe28 | 15 | Thread::yield(); |
Thomas Cauwelier |
6:0e1973fdfe28 | 16 | } |
Thomas Cauwelier |
6:0e1973fdfe28 | 17 | } |
Thomas Cauwelier |
6:0e1973fdfe28 | 18 | } |
Desertification | 1:6b839581dc9f | 19 | |
Desertification | 1:6b839581dc9f | 20 | int main() { |
Thomas Cauwelier |
6:0e1973fdfe28 | 21 | printf("%s\n", "hello, term"); |
Thomas Cauwelier |
6:0e1973fdfe28 | 22 | |
Thomas Cauwelier |
6:0e1973fdfe28 | 23 | while (true){ |
Thomas Cauwelier |
6:0e1973fdfe28 | 24 | out.printf("hello, term\n"); |
Thomas Cauwelier |
6:0e1973fdfe28 | 25 | wait(1); |
Thomas Cauwelier |
6:0e1973fdfe28 | 26 | } |
Thomas Cauwelier |
6:0e1973fdfe28 | 27 | |
thoma@THOMAS-CAUWELIER.khbo.be | 4:a07612fbf279 | 28 | } |