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@7:2b99a26e6a43, 2017-05-03 (annotated)
- Committer:
- Thomas Cauwelier
- Date:
- Wed May 03 00:46:24 2017 +0200
- Revision:
- 7:2b99a26e6a43
- Parent:
- 6:0e1973fdfe28
- Child:
- 8:4fcc746968b3
uart thread test (start thread)
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 |
7:2b99a26e6a43 | 21 | printf("%s\r\n", "hello, term!"); |
Thomas Cauwelier |
7:2b99a26e6a43 | 22 | |
Thomas Cauwelier |
7:2b99a26e6a43 | 23 | Thread thread; |
Thomas Cauwelier |
7:2b99a26e6a43 | 24 | thread.start(receive_uart); |
Thomas Cauwelier |
6:0e1973fdfe28 | 25 | |
Thomas Cauwelier |
6:0e1973fdfe28 | 26 | while (true){ |
Thomas Cauwelier |
7:2b99a26e6a43 | 27 | out.printf("hello, term\r\n"); |
Thomas Cauwelier |
6:0e1973fdfe28 | 28 | wait(1); |
Thomas Cauwelier |
6:0e1973fdfe28 | 29 | } |
Thomas Cauwelier |
6:0e1973fdfe28 | 30 | |
thoma@THOMAS-CAUWELIER.khbo.be | 4:a07612fbf279 | 31 | } |