forked from xuos/xiuos
				
			support extra sdram test
This commit is contained in:
		
							parent
							
								
									c4eaff938b
								
							
						
					
					
						commit
						bcff330830
					
				|  | @ -2,6 +2,7 @@ | ||||||
| # APP_Framework/Applications/Make.defs | # APP_Framework/Applications/Make.defs | ||||||
| ############################################################################ | ############################################################################ | ||||||
| CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications | CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications | ||||||
|  | CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test | ||||||
| CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list | CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list | ||||||
| 
 | 
 | ||||||
| include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs) | include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs) | ||||||
|  |  | ||||||
|  | @ -29,5 +29,9 @@ menu "test app" | ||||||
|                             default "/dev/dac_dev" |                             default "/dev/dac_dev" | ||||||
|                     endif |                     endif | ||||||
|                 endif |                 endif | ||||||
|  | 
 | ||||||
|  |             config USER_TEST_SEMC | ||||||
|  |                 bool "Config test semc sdram" | ||||||
|  |                 default n | ||||||
|         endif |         endif | ||||||
| endmenu | endmenu | ||||||
|  |  | ||||||
|  | @ -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) | ||||||
|  | 
 | ||||||
|  | @ -1,4 +1,4 @@ | ||||||
| SRC_FILES :=  | SRC_FILES := | ||||||
| 
 | 
 | ||||||
| ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y) | ifeq ($(CONFIG_USER_TEST_SPI_FLASH),y) | ||||||
| 	SRC_FILES += test_spi_flash.c | 	SRC_FILES += test_spi_flash.c | ||||||
|  | @ -12,4 +12,18 @@ ifeq ($(CONFIG_USER_TEST_DAC),y) | ||||||
| 	SRC_FILES += test_dac.c | 	SRC_FILES += test_dac.c | ||||||
| endif | endif | ||||||
| 
 | 
 | ||||||
|  | ifeq ($(CONFIG_USER_TEST_SEMC),y) | ||||||
|  | 	SRC_FILES += test_extsram.c | ||||||
|  | endif | ||||||
|  | 
 | ||||||
|  | ifeq ($(CONFIG_ADD_XIZI_FETURES),y) | ||||||
| include $(KERNEL_ROOT)/compiler.mk | 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 | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,97 @@ | ||||||
|  | 
 | ||||||
|  | #ifdef ADD_XIZI_FETURES | ||||||
|  | #include <xizi.h> | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | #include <stdio.h> | ||||||
|  | #include <stdint.h> | ||||||
|  | #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 | ||||||
|  | 
 | ||||||
|  | @ -66,3 +66,5 @@ CONFIG_TESTING_MM=y | ||||||
| CONFIG_TESTING_MM_PROGNAME="mm" | CONFIG_TESTING_MM_PROGNAME="mm" | ||||||
| CONFIG_TESTING_MM_PRIORITY=100 | CONFIG_TESTING_MM_PRIORITY=100 | ||||||
| CONFIG_TESTING_MM_STACKSIZE=2048 | CONFIG_TESTING_MM_STACKSIZE=2048 | ||||||
|  | CONFIG_USER_TEST=y | ||||||
|  | CONFIG_USER_TEST_SEMC=y | ||||||
|  |  | ||||||
|  | @ -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); |   int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); | ||||||
| #endif | #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) | #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); |   int cmd_Hcho1os(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | @ -64,6 +64,19 @@ int cmd_Lcd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) | ||||||
| } | } | ||||||
| #endif | #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 |  * Name: cmd_Hcho1os | ||||||
|  ****************************************************************************/ |  ****************************************************************************/ | ||||||
|  |  | ||||||
|  | @ -604,6 +604,10 @@ static const struct cmdmap_s g_cmdmap[] = | ||||||
|   { "lcd",      cmd_Lcd,     1, 1, "[LCD demo cmd.]" }, |   { "lcd",      cmd_Lcd,     1, 1, "[LCD demo cmd.]" }, | ||||||
| #endif | #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) | #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.]" }, |   { "hcho1os",       cmd_Hcho1os,       1, 1, "[get the concentration of formaldehyde with sensor tb600b_wq_hcho1os.]" }, | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue