X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fdataflash_test.c;h=276f9f432079e2f5ce29b861bf6c05d759c05ae4;hb=515886be3106584a6d695d4b5453730121b91f74;hp=e81477583d5d0fae1466da07c733982e77db2967;hpb=a625fd2523a0c960351f124baa7cd5c3c69c3272;p=bertos.git diff --git a/bertos/drv/dataflash_test.c b/bertos/drv/dataflash_test.c index e8147758..276f9f43 100644 --- a/bertos/drv/dataflash_test.c +++ b/bertos/drv/dataflash_test.c @@ -37,7 +37,7 @@ * To test memory we fill one buffer with casual char, and write it in different * part of memory. After every write we read the data that we have been write * and compare this with test buffer, checking if write and read command work - * correclty. We also check if driver work properly when we make a write out the + * correclty. We also check if driver work properly when we make a write out the * limit of memory size. * * Note: dataflash driver use a kfile interface, so for write/read test @@ -45,25 +45,27 @@ * * * \version $Id$ - * * \author Daniele Basile */ #include "hw/hw_dataflash.h" #include "cfg/cfg_dataflash.h" +#include "cfg/cfg_kern.h" + +#include #include #include // Define logging setting (for cfg/log.h module). -#define LOG_LEVEL DATAFLASH_LOG_LEVEL -#define LOG_VERBOSITY DATAFLASH_LOG_VERBOSITY +#define LOG_LEVEL DATAFLASH_LOG_LEVEL +#define LOG_FORMAT DATAFLASH_LOG_FORMAT #include // for logging system #include #include #include - +#include #include #include @@ -86,14 +88,14 @@ #define DATAFLASH_TEST_STR_LEN 12307 // If you want use a rand function of standard library set to 1. -#define DATAFLASH_USE_RAND_FUNC 1 +#define DATAFLASH_USE_RAND_FUNC 0 /* \} */ /* * Kfile structure to test a dataflash. */ -static KFileSerial spi_fd; -static KFileDataflash dflash_fd; +static Serial spi_fd; +static DataFlash dflash_fd; /* * Define tmp buffer to stora data for @@ -106,8 +108,15 @@ static uint8_t save_buf[DATAFLASH_TEST_STR_LEN]; * Setup all needed to test dataflash memory * */ -int dataflash_testSetup(void) +int dataflash_testSetUp(void) { + kfile_testSetUp(); + LOG_INFO("KFILE setup..ok\n"); + + LOG_INFO("Check if kernel is enable (if enable you should see the assert message.)\n"); + SILENT_ASSERT("bertos/drv/dataflash_test.c:119: Assertion failed: !CONFIG_KERNEL"); + ASSERT(!CONFIG_KERNEL); + /* * This test use a kfile_test module, * so should include source in your makefile. @@ -121,10 +130,10 @@ int dataflash_testSetup(void) * Init SPI module and dataflash driver. */ // Open SPI comunication channel - spimaster_init(&spi_fd, SER_SPI0); + spimaster_init(&spi_fd, CONFIG_SPI_PORT); LOG_INFO("SPI0 init..ok\n"); - ser_setbaudrate(&spi_fd, 5000000UL); + ser_setbaudrate(&spi_fd, CONFIG_SPI_BAUDRATE); LOG_INFO("SPI0 set baudrate..ok\n"); //Init dataflash memory @@ -161,19 +170,10 @@ int dataflash_testSetup(void) */ int dataflash_testRun(void) { - if (!dataflash_testSetup()) - { - LOG_INFO("DATAFLASH setup..ok\n"); - } - else - { - LOG_ERR("DATAFLASH setup..fail!\n"); - return EOF; - } - LOG_INFO("Run KFILE test.\n"); - if (kfile_testRun(&dflash_fd.fd, test_buf, save_buf, sizeof(test_buf))) + SILENT_ASSERT("bertos/drv/dataflash.c:405: Assertion failed: fd->fd.seek_pos + size <= fd->fd.size"); + if (kfile_testRun(&dflash_fd.fd, test_buf, save_buf, sizeof(test_buf)) != EOF) { LOG_INFO("KFILE test..ok\n"); } @@ -208,7 +208,21 @@ int main(void) IRQ_ENABLE; kdbg_init(); - dataflash_testRun(); + #if CONFIG_KERNEL + proc_init(); + #endif + + if (!dataflash_testSetUp()) + { + LOG_INFO("DATAFLASH setup..ok\n"); + } + else + { + LOG_ERR("DATAFLASH setup..fail!\n"); + return EOF; + } + + dataflash_testRun(); for(;;) {