diff --git a/APP_Framework/Applications/Make.defs b/APP_Framework/Applications/Make.defs index 581c8c124..03adcc80f 100644 --- a/APP_Framework/Applications/Make.defs +++ b/APP_Framework/Applications/Make.defs @@ -2,6 +2,7 @@ # APP_Framework/Applications/Make.defs ############################################################################ CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications +CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs) diff --git a/APP_Framework/Applications/app_test/Kconfig b/APP_Framework/Applications/app_test/Kconfig index 5c038893f..b2e94cf6e 100644 --- a/APP_Framework/Applications/app_test/Kconfig +++ b/APP_Framework/Applications/app_test/Kconfig @@ -29,5 +29,9 @@ menu "test app" default "/dev/dac_dev" endif endif + + config USER_TEST_SEMC + bool "Config test semc sdram" + default n endif endmenu diff --git a/APP_Framework/Applications/app_test/Make.defs b/APP_Framework/Applications/app_test/Make.defs new file mode 100755 index 000000000..792848910 --- /dev/null +++ b/APP_Framework/Applications/app_test/Make.defs @@ -0,0 +1,7 @@ +############################################################################ +# APP_Framework/Applications/app_test/Make.defs +############################################################################ +CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test + +include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/app_test/*/Make.defs) + diff --git a/APP_Framework/Applications/app_test/Makefile b/APP_Framework/Applications/app_test/Makefile index 8a74e5531..c6f0f3a9d 100644 --- a/APP_Framework/Applications/app_test/Makefile +++ b/APP_Framework/Applications/app_test/Makefile @@ -1,4 +1,4 @@ -SRC_FILES := +SRC_FILES := ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y) SRC_FILES += test_spi_flash.c @@ -12,4 +12,18 @@ ifeq ($(CONFIG_USER_TEST_DAC),y) SRC_FILES += test_dac.c endif +ifeq ($(CONFIG_USER_TEST_SEMC),y) + SRC_FILES += test_extsram.c +endif + +ifeq ($(CONFIG_ADD_XIZI_FETURES),y) include $(KERNEL_ROOT)/compiler.mk +endif + +include $(KERNEL_ROOT)/.config +ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) + include $(APPDIR)/Make.defs + CSRCS += test_extsram.c + include $(APPDIR)/Application.mk +endif + diff --git a/APP_Framework/Applications/app_test/test_extsram.c b/APP_Framework/Applications/app_test/test_extsram.c new file mode 100755 index 000000000..7ab4a173e --- /dev/null +++ b/APP_Framework/Applications/app_test/test_extsram.c @@ -0,0 +1,97 @@ + +#ifdef ADD_XIZI_FETURES +#include +#endif + +#include +#include +#include "transform.h" + +/* parameters for sram peripheral */ +// /* stm32f4 Bank3:0X68000000 */ +// #define SRAM_BANK_ADDR ((uint32_t)0X68000000) + +/* OK-1052 semc:0X80000000 */ +#define SRAM_BANK_ADDR ((uint32_t)0X80000000) + +/* data width: 8, 16, 32 */ +#define SRAM_DATA_WIDTH 16 + +/* sram size */ +#define SRAM_SIZE ((uint32_t)0x2000000) + +#define TICK_PER_SECOND 100 + +int extsram_test(void) +{ + int i = 0; + uint32_t start_time = 0, time_cast = 0; +#if SRAM_DATA_WIDTH == 8 + char data_width = 1; + uint8_t data = 0; +#elif SRAM_DATA_WIDTH == 16 + char data_width = 2; + uint16_t data = 0; +#else + char data_width = 4; + uint32_t data = 0; +#endif + + /* write data */ + printf("Writing the %ld bytes data, waiting....", SRAM_SIZE); + start_time = PrivGetTickTime(); + for (i = 0; i < SRAM_SIZE / data_width; i++) + { +#if SRAM_DATA_WIDTH == 8 + *(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width) = (uint8_t)0x55; +#elif SRAM_DATA_WIDTH == 16 + *(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width) = (uint16_t)0x5555; +#else + *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width) = (uint32_t)0x55555555; +#endif + } + time_cast = PrivGetTickTime() - start_time; + printf("Write data success, total time: %ld.%03ldS.\n", time_cast / TICK_PER_SECOND, + time_cast % TICK_PER_SECOND / ((TICK_PER_SECOND * 1 + 999) / 1000)); + + /* read data */ + printf("start Reading and verifying data, waiting....\n"); + for (i = 0; i < SRAM_SIZE / data_width; i++) + { +#if SRAM_DATA_WIDTH == 8 + data = *(volatile uint8_t *)(SRAM_BANK_ADDR + i * data_width); + if (data != 0x55) + { + printf("SRAM test failed!"); + break; + } +#elif SRAM_DATA_WIDTH == 16 + data = *(volatile uint16_t *)(SRAM_BANK_ADDR + i * data_width); + if (data != 0x5555) + { + printf("SRAM test failed! data = 0x%x\n",data); + break; + } +#else + data = *(volatile uint32_t *)(SRAM_BANK_ADDR + i * data_width); + if (data != 0x55555555) + { + printf("SRAM test failed!"); + break; + } +#endif + } + + if (i >= SRAM_SIZE / data_width) + { + printf("SRAM test success!\n"); + } + + return 0; +} + +#ifdef ADD_XIZI_FETURES +SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0), + sram_test, sram_test, sram_test); +#endif + diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig index 2c6697e66..e38a4d7e5 100755 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/aiit_board/xidatong-arm32/configs/mmnsh/defconfig @@ -66,3 +66,5 @@ CONFIG_TESTING_MM=y CONFIG_TESTING_MM_PROGNAME="mm" CONFIG_TESTING_MM_PRIORITY=100 CONFIG_TESTING_MM_STACKSIZE=2048 +CONFIG_USER_TEST=y +CONFIG_USER_TEST_SEMC=y diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h index df3e0f488..c899bfd6b 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh.h @@ -1458,6 +1458,10 @@ int nsh_foreach_var(FAR struct nsh_vtbl_s *vtbl, nsh_foreach_var_t cb, int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif +#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC) + int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif + #if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS) int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c index ef6d6b2be..de46c9f9e 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_Applicationscmd.c @@ -64,6 +64,19 @@ int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } #endif +/**************************************************************************** + * Name: cmd_Extsram + ****************************************************************************/ +#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC) +extern int extsram_test(void); +int cmd_Extsram(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) +{ + nsh_output(vtbl, "Hello, extra sdram!\n"); + extsram_test(); + return OK; +} +#endif + /**************************************************************************** * Name: cmd_Hcho1os ****************************************************************************/ diff --git a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c index 7f542859b..f513ecf23 100644 --- a/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c +++ b/Ubiquitous/Nuttx_Fusion_XiUOS/app_match_nuttx/apps/nshlib/nsh_command.c @@ -604,6 +604,10 @@ static const struct cmdmap_s g_cmdmap[] = { "lcd", cmd_Lcd, 1, 1, "[LCD demo cmd.]" }, #endif +#if defined(CONFIG_USER_TEST_SEMC) && !defined(CONFIG_NSH_DISABLE_USER_TEST_SEMC) + { "sram", cmd_Extsram, 1, 1, "[Extra sdram demo cmd.]" }, +#endif + #if defined(CONFIG_APPLICATION_SENSOR_HCHO_TB600B_WQ_HCHO1OS) && !defined(CONFIG_NSH_DISABLE_HCHO_TB600B_WQ_HCHO1OS) { "hcho1os", cmd_Hcho1os, 1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" }, #endif