From 6bcec3bab157f4799f68d87b4d99038b18461c78 Mon Sep 17 00:00:00 2001 From: asterix Date: Mon, 26 Nov 2007 09:50:42 +0000 Subject: [PATCH] Add warning. Fix test function. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1007 38d2e660-2303-0410-9eaa-f027e97ec537 --- drv/dataflash.c | 42 +++++++++++++++++++++--------------------- drv/dataflash.h | 4 +++- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/drv/dataflash.c b/drv/dataflash.c index e2d2e291..2f4f897e 100644 --- a/drv/dataflash.c +++ b/drv/dataflash.c @@ -50,7 +50,7 @@ #include "hw_spi.h" - +#warning This driver must be test before use! /** * Global variable for store current and previous data * flash memory page address during operation of writing. @@ -543,7 +543,7 @@ void dataflash_test(void) dataflash_init(&fd); uint8_t test_buf[] = "0123456789 Develer s.r.l."; - uint8_t cmp_buf[]; + uint8_t cmp_buf[sizeof(test_buf)]; int tb_len = sizeof(test_buf); int tmp_len = 0; @@ -556,32 +556,32 @@ void dataflash_test(void) /* TEST 1 */ // Seek to addr 0 - if (!fd.seek(&fd, 0, SEEK_SET)) + if (!fd.seek(&fd, 0, KSM_SEEK_SET)) goto dataflash_test_end; // Test flash write to address 0 (page 0) - tmp_len = fd->write(&fd, test_buf, len_tb) - if (len_tb != tmp_len) + tmp_len = fd.write(&fd, test_buf, tb_len); + if (tb_len != tmp_len) { kprintf("Test 1: Wrong numer write bytes! expecteded [%d], write [%d]\n", tb_len, tmp_len); goto dataflash_test_end; } // Seek to addr 0 - if (fd.seek(&fd, 0, SEEK_SET) != 0) + if (fd.seek(&fd, 0, KSM_SEEK_SET) != 0) goto dataflash_test_end; tmp_len = 0; // Test flash read to address 0 (page 0) - tmp_len = fd->read(&fd, cmp_buf, len_tb); - if (len_tb != tmp_len) + tmp_len = fd.read(&fd, cmp_buf, tb_len); + if (tb_len != tmp_len) { kprintf("Test 1: Wrong numer read bytes! expecteded [%d], read [%d]\n", tb_len, tmp_len); goto dataflash_test_end; } // Compare if they are equal - if ((memcmp(cmp_buf,test_buf, len_tb) == 0) + if ((memcmp(cmp_buf,test_buf, tb_len) == 0)) { kprintf("Test 1: Readed test buf don't much!\n"); goto dataflash_test_end; @@ -595,8 +595,8 @@ void dataflash_test(void) tmp_len = 0; // Test flash write at the middle of memory - tmp_len = fd->write(&fd, test_buf, len_tb); - if (len_tb != tmp_len) + tmp_len = fd.write(&fd, test_buf, tb_len); + if (tb_len != tmp_len) { kprintf("Test 2: Wrong numer write bytes! expecteded [%d], write [%d]\n", tb_len, tmp_len); goto dataflash_test_end; @@ -608,15 +608,15 @@ void dataflash_test(void) tmp_len = 0; // Test flash read at the middle of memory - tmp_len = fd->read(&fd, cmp_buf, len_tb); - if (len_tb != tmp_len) + tmp_len = fd.read(&fd, cmp_buf, tb_len); + if (tb_len != tmp_len) { kprintf("Test 2: Wrong numer read bytes! expecteded [%d], read [%d]\n", tb_len, tmp_len); goto dataflash_test_end; } // Compare if they are equal - if ((memcmp(cmp_buf,test_buf, len_tb) == 0) + if ((memcmp(cmp_buf,test_buf, tb_len) == 0)) { kprintf("Test 2: Readed test buf don't much!\n"); goto dataflash_test_end; @@ -624,33 +624,33 @@ void dataflash_test(void) /* TEST 3 */ // Go to end of data flash. - if(!fd.seek(&fd, ((dataflashAddr_t)DFLASH_PAGE_SIZE * (dataflashAddr_t)DFLASH_NUM_PAGE) - len_tb, SEEK_END)); + if(!fd.seek(&fd, ((dataflashAddr_t)DFLASH_PAGE_SIZE * (dataflashAddr_t)DFLASH_NUM_PAGE) - len_tb, SEEK_END)) goto dataflash_test_end; tmp_len = 0; // Test flash write at the end of memory - tmp_len = fd->write(&fd, test_buf, len_tb); - if (len_tb != tmp_len) + tmp_len = fd.write(&fd, test_buf, tb_len); + if (tb_len != tmp_len) { kprintf("Test 3: Wrong numer write bytes! expecteded [%d], write [%d]\n", tb_len, tmp_len); goto dataflash_test_end; } // Go to end of data flash. - if(!fd.seek(&fd, ((dataflashAddr_t)DFLASH_PAGE_SIZE * (dataflashAddr_t)DFLASH_NUM_PAGE) - len_tb, SEEK_END)); + if(!fd.seek(&fd, ((dataflashAddr_t)DFLASH_PAGE_SIZE * (dataflashAddr_t)DFLASH_NUM_PAGE) - len_tb, SEEK_END)) goto dataflash_test_end; tmp_len = 0 // Test flash read at the end of memory - tmp_len = fd->read(&fd, cmp_buf, len_tb); - if (len_tb != tmp_len) + tmp_len = fd.read(&fd, cmp_buf, tb_len); + if (tb_len != tmp_len) { kprintf("Test 3: Wrong numer read bytes! expecteded [%d], read [%d]\n", tb_len, tmp_len); goto dataflash_test_end; } // Compare if they are equal - if ((memcmp(cmp_buf,test_buf, len_tb) == 0) + if ((memcmp(cmp_buf,test_buf, tb_len) == 0)) { kprintf("Test 3: Readed test buf don't much!\n"); goto dataflash_test_end; diff --git a/drv/dataflash.h b/drv/dataflash.h index b739883c..c49b9acd 100644 --- a/drv/dataflash.h +++ b/drv/dataflash.h @@ -48,6 +48,8 @@ #include +#warning This driver must be test before use! + /** * Type definition for dflash memory. */ @@ -202,7 +204,7 @@ typedef enum { } DataFlashOpcode; void dataflash_init(struct _KFile *fd); -void hal_dflash_test(void); +void dataflash_test(void); #endif /* DRV_DATAFLASH_H */ -- 2.25.1