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@27:6dbcad451cbc, 2017-05-17 (annotated)
- Committer:
- Desertification
- Date:
- Wed May 17 00:22:55 2017 +0000
- Revision:
- 27:6dbcad451cbc
- Parent:
- 26:1c8a7d0bb4b7
fix file receive not starting
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 |
9:d95984ce5de9 | 3 | #include "Manchester.h" |
Desertification | 23:121e3235ccfa | 4 | //#include "SoftSerial.h" |
Thomas Cauwelier |
15:75f9bd5d7659 | 5 | #include "MySoftSerial.h" |
Desertification | 21:2a91babf5a6d | 6 | #include "SDFileSystem.h" |
Desertification | 21:2a91babf5a6d | 7 | #include "wave_player.h" |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 8 | #include "Relay.h" |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 9 | #include "Client.h" |
Desertification | 21:2a91babf5a6d | 10 | |
Desertification | 21:2a91babf5a6d | 11 | |
Desertification | 21:2a91babf5a6d | 12 | void test_player(){ |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 13 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 14 | Serial usb(USBTX,USBRX); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 15 | usb.baud(115200); |
Desertification | 21:2a91babf5a6d | 16 | AnalogOut DACout(p18); |
Desertification | 21:2a91babf5a6d | 17 | wave_player waver(&DACout); |
Desertification | 21:2a91babf5a6d | 18 | waver.set_verbosity(0); |
Desertification | 21:2a91babf5a6d | 19 | sd.disk_initialize(); |
Desertification | 21:2a91babf5a6d | 20 | FILE *wave_file; |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 21 | printf("Hello, wave world!\n"); |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 22 | wave_file=fopen("/sd/test.wav","r"); |
Desertification | 21:2a91babf5a6d | 23 | if(wave_file == NULL) { |
Desertification | 21:2a91babf5a6d | 24 | error("Could not open file for write\n"); |
Desertification | 21:2a91babf5a6d | 25 | } |
Desertification | 21:2a91babf5a6d | 26 | waver.play(wave_file); |
Desertification | 21:2a91babf5a6d | 27 | fclose(wave_file); |
Desertification | 21:2a91babf5a6d | 28 | } |
Desertification | 1:6b839581dc9f | 29 | |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 30 | void test_client(){ |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 31 | Serial usb(USBTX,USBRX); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 32 | usb.baud(115200); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 33 | |
Thomas Cauwelier |
15:75f9bd5d7659 | 34 | MySoftSerial s(p18,p17); |
Desertification | 21:2a91babf5a6d | 35 | |
Desertification | 23:121e3235ccfa | 36 | s.baud(20000); |
Thomas Cauwelier |
13:c111ea1c5990 | 37 | while (true) { |
Thomas Cauwelier |
13:c111ea1c5990 | 38 | while (!s.readable()); |
Desertification | 14:e29cca7e64b2 | 39 | printf("got %i\r\n",s.getc()); |
Thomas Cauwelier |
13:c111ea1c5990 | 40 | } |
Thomas Cauwelier |
13:c111ea1c5990 | 41 | } |
Thomas Cauwelier |
13:c111ea1c5990 | 42 | |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 43 | void test_relay(){ |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 44 | Serial usb(USBTX,USBRX); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 45 | usb.baud(115200); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 46 | |
Desertification | 16:1a0589d846bf | 47 | MySoftSerial s(p17,p18); |
Desertification | 21:2a91babf5a6d | 48 | //MySoftSerial s(LED1,p18); |
Desertification | 23:121e3235ccfa | 49 | s.baud(20000); |
Desertification | 14:e29cca7e64b2 | 50 | int i = 0; |
Desertification | 21:2a91babf5a6d | 51 | while (true) { |
Desertification | 23:121e3235ccfa | 52 | //wait(0.1); |
Desertification | 18:3aeaa22b265d | 53 | for (int j = 0; j < 1; ++j) { |
Desertification | 16:1a0589d846bf | 54 | while(!s.writeable()); |
Desertification | 16:1a0589d846bf | 55 | printf("put %i\r\n", i); |
Desertification | 23:121e3235ccfa | 56 | s.putc(i); |
Desertification | 16:1a0589d846bf | 57 | i++; |
Desertification | 16:1a0589d846bf | 58 | } |
Thomas Cauwelier |
13:c111ea1c5990 | 59 | } |
Thomas Cauwelier |
13:c111ea1c5990 | 60 | } |
Thomas Cauwelier |
13:c111ea1c5990 | 61 | |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 62 | #define RELAY 0 |
Thomas Cauwelier |
13:c111ea1c5990 | 63 | |
Desertification | 21:2a91babf5a6d | 64 | int main(){ |
Desertification | 21:2a91babf5a6d | 65 | |
Desertification | 21:2a91babf5a6d | 66 | //test_player(); |
Desertification | 21:2a91babf5a6d | 67 | |
Desertification | 21:2a91babf5a6d | 68 | if (RELAY) { |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 69 | Relay relay(p17,20000,USBTX,USBRX,115200); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 70 | relay.run(); |
Thomas Cauwelier |
24:d91e9b3b5bd5 | 71 | //test_relay(); |
Thomas Cauwelier |
12:a070de571ea1 | 72 | } else { |
Desertification | 27:6dbcad451cbc | 73 | Serial usb(USBTX,USBRX); |
Desertification | 27:6dbcad451cbc | 74 | usb.baud(115200); |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 75 | Client client(p17,20000); |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 76 | client.run(); |
Thomas Cauwelier |
26:1c8a7d0bb4b7 | 77 | //test_client(); |
Thomas Cauwelier |
6:0e1973fdfe28 | 78 | } |
thoma@THOMAS-CAUWELIER.khbo.be | 4:a07612fbf279 | 79 | } |