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: mbed SDFileSystem
Revision 5:e222c59853e2, committed 2019-12-24
- Comitter:
- kenjiArai
- Date:
- Tue Dec 24 11:23:19 2019 +0000
- Parent:
- 4:fc36c8ec2966
- Child:
- 6:b4538dd09336
- Commit message:
- Updated main.cpp & Mon
Changed in this revision
--- a/FatFs_Mon/mon.cpp Sat Aug 17 03:28:33 2019 +0000
+++ b/FatFs_Mon/mon.cpp Tue Dec 24 11:23:19 2019 +0000
@@ -8,7 +8,7 @@
* Created: May 5th, 2015
* Revised: June 14th, 2015
* Revised: April 7th, 2018
- * Revised: August 17th, 2019
+ * Revised: December 24th, 2019
*/
/*
@@ -119,7 +119,7 @@
"x extend commands mode\r\n"
"q Return to main\r\n"
"t Show current time or Adjust time\r\n"
- " e.g. t 18 3 28 14 48 20 -> 2018-03-28 14:48:20\r\n"
+ " e.g. t 19 12 24 10 11 12 -> 2019-12-24 10:11:12\r\n"
"? Help/You know the command\r\n"
"\r\n";
@@ -292,6 +292,30 @@
}
}
+uint32_t get_data_file_size(const char *const file_name)
+{
+ BYTE res;
+ //const char *file_name ="acc_data.txt";
+
+ if (Dirx == NULL){
+ Dirx = new FATFS_DIR;
+ }
+ char p = NULL;
+ res = f_opendir(Dirx, &p);
+ if (res) {
+ put_rc((FRESULT)res);
+ return 0;
+ }
+ for(;;) {
+ res = f_readdir(Dirx, &Finfo);
+ if ((res != FR_OK) || !Finfo.fname[0]) break;
+ if (strcmp(Finfo.fname, file_name) == 0){
+ return Finfo.fsize;
+ }
+ }
+ return 0;
+}
+
static void extended_mon( char *ptr )
{
PUTS(HelpMsg1);
--- a/FatFs_Mon/mon.h Sat Aug 17 03:28:33 2019 +0000 +++ b/FatFs_Mon/mon.h Tue Dec 24 11:23:19 2019 +0000 @@ -2,14 +2,15 @@ * mbed Application program for the mbed * FatFs Check program /monitor part * - * Copyright (c) 2015,'18 Kenji Arai / JH1PJL + * Copyright (c) 2015,'18,'19 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * https://os.mbed.com/users/kenjiArai/ * Created: May 5th, 2015 * Revised: June 14th, 2015 - * Revised: April 7th, 2018 + * Revised: December 24th, 2019 */ // Function prototypes -------------------------------------------------------- void mon(void); uint32_t get_disk_freespace(void); +uint32_t get_data_file_size(const char *const file_name);
--- 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);