![](/media/cache/profiles/5487e79fa0ccd0b79e5d4a4c8ced005d.50x50_q85.jpg)
Testing to see if fread blocks Ticker(). It does.
main.cpp@0:8d0e8caaf3e4, 2010-10-05 (annotated)
- Committer:
- opiette
- Date:
- Tue Oct 05 03:47:18 2010 +0000
- Revision:
- 0:8d0e8caaf3e4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
opiette | 0:8d0e8caaf3e4 | 1 | #include "mbed.h" |
opiette | 0:8d0e8caaf3e4 | 2 | |
opiette | 0:8d0e8caaf3e4 | 3 | DigitalOut led1(LED1); |
opiette | 0:8d0e8caaf3e4 | 4 | DigitalOut led2(LED2); |
opiette | 0:8d0e8caaf3e4 | 5 | DigitalOut led3(LED3); |
opiette | 0:8d0e8caaf3e4 | 6 | DigitalOut led4(LED4); |
opiette | 0:8d0e8caaf3e4 | 7 | Ticker tick; |
opiette | 0:8d0e8caaf3e4 | 8 | LocalFileSystem sd("sd"); |
opiette | 0:8d0e8caaf3e4 | 9 | |
opiette | 0:8d0e8caaf3e4 | 10 | void flash(void){ |
opiette | 0:8d0e8caaf3e4 | 11 | if (led1 == 1) |
opiette | 0:8d0e8caaf3e4 | 12 | led1 = 0; |
opiette | 0:8d0e8caaf3e4 | 13 | else |
opiette | 0:8d0e8caaf3e4 | 14 | led1=1; |
opiette | 0:8d0e8caaf3e4 | 15 | } |
opiette | 0:8d0e8caaf3e4 | 16 | |
opiette | 0:8d0e8caaf3e4 | 17 | |
opiette | 0:8d0e8caaf3e4 | 18 | int main() { |
opiette | 0:8d0e8caaf3e4 | 19 | |
opiette | 0:8d0e8caaf3e4 | 20 | FILE* fp = fopen("/sd/test.wav","rb"); |
opiette | 0:8d0e8caaf3e4 | 21 | tick.attach_us(&flash, 1000); |
opiette | 0:8d0e8caaf3e4 | 22 | |
opiette | 0:8d0e8caaf3e4 | 23 | while(1) { |
opiette | 0:8d0e8caaf3e4 | 24 | led2 = 1; |
opiette | 0:8d0e8caaf3e4 | 25 | wait_ms(1000); |
opiette | 0:8d0e8caaf3e4 | 26 | led2 = 0; |
opiette | 0:8d0e8caaf3e4 | 27 | |
opiette | 0:8d0e8caaf3e4 | 28 | char* buffer; |
opiette | 0:8d0e8caaf3e4 | 29 | buffer = (char*)malloc(8000); |
opiette | 0:8d0e8caaf3e4 | 30 | |
opiette | 0:8d0e8caaf3e4 | 31 | led3 = 1; |
opiette | 0:8d0e8caaf3e4 | 32 | wait_ms(1000); |
opiette | 0:8d0e8caaf3e4 | 33 | led3 = 0; |
opiette | 0:8d0e8caaf3e4 | 34 | |
opiette | 0:8d0e8caaf3e4 | 35 | fread(buffer, 1, 8000, fp); |
opiette | 0:8d0e8caaf3e4 | 36 | |
opiette | 0:8d0e8caaf3e4 | 37 | led4 = 1; |
opiette | 0:8d0e8caaf3e4 | 38 | wait_ms(1000); |
opiette | 0:8d0e8caaf3e4 | 39 | led4 = 0; |
opiette | 0:8d0e8caaf3e4 | 40 | } |
opiette | 0:8d0e8caaf3e4 | 41 | } |