Recording WAV files
Dependencies: mbed SDFileSystem
Diff: main.cpp
- Revision:
- 5:e222c59853e2
- Parent:
- 4:fc36c8ec2966
- Child:
- 6:b4538dd09336
--- a/main.cpp Sat Aug 17 03:28:33 2019 +0000 +++ b/main.cpp Tue Dec 24 11:23:19 2019 +0000 @@ -6,12 +6,16 @@ * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: April 4th, 2018 - * Revised: August 17th, 2019 + * Revised: December 24th, 2019 */ /* - Tested board on OS5 & OS2: + Tested board on OS2: Nucleo-F401RE, -F411RE, -F446RE, -L073RZ, -L152RE, -L476RG + Tested board on OS5.15.0 + Nucleo-F401RE, -F411RE, -F446RE, -L152RE, -L073RZ, -L476RG + nRF52840-DK, nRF52-DK + FRDM-F64K */ // Include -------------------------------------------------------------------- @@ -43,10 +47,18 @@ // Constructor ---------------------------------------------------------------- Serial pc(USBTX, USBRX, 115200); +#if defined(TARGET_NRF52840_DK) || defined(TARGET_NRF52_DK) ||\ + defined(TARGET_K64F) +DigitalIn user_sw(BUTTON1, PullUp); +#else DigitalIn user_sw(USER_BUTTON); +#endif #if (MBED_MAJOR_VERSION == 5) +#if defined(TARGET_NRF52840_DK) || defined(TARGET_NRF52_DK) +SDBlockDevice sd(D11, D12, D13, D10, 8000000); +#else SDBlockDevice sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, 12000000); -//SDBlockDevice sd(D11, D12, D13, D10, 8000000); +#endif FATFileSystem fs("fs"); #endif Timer tmr; @@ -104,8 +116,9 @@ DBG("line:%d\r\n", __LINE__); tmr.reset(); tmr.start(); - uint32_t size = get_disk_freespace(); - pc.printf("free %u ", size); + uint32_t size_disk = get_disk_freespace(); + uint32_t size_file = get_data_file_size("mydata.txt"); + pc.printf("free disk:%u, file:%u ", size_disk, size_file); fp = fopen("/fs/mydata.txt", "a"); if(fp != 0) { char tmp[64]; @@ -123,7 +136,7 @@ } fclose(fp); uint32_t time_sd = tmr.read_ms(); - pc.printf("time:%d ", time_sd); + pc.printf("time:%3d ", time_sd); #if (MBED_MAJOR_VERSION == 2) if (time_sd < LOOP_TIME -2){ wait_ms(LOOP_TIME - time_sd);