softspi driver and its app test

This commit is contained in:
wuzheng
2022-11-09 19:23:12 +08:00
parent 094986ac76
commit d3836f1a6f
20 changed files with 590 additions and 26 deletions

View File

@@ -26,6 +26,17 @@ menu "test app"
endif
endif
menuconfig USER_TEST_SD
bool "Config test sd"
default n
if USER_TEST_SD
if ADD_XIZI_FETURES
config SD_FPATH
string "Set sd file path"
default "/sdcard_testfile"
endif
endif
config USER_TEST_SEMC
bool "Config test semc sdram"
default n
@@ -33,5 +44,7 @@ menu "test app"
config USER_TEST_LCD
bool "Config test lcd device"
default n
endif
endmenu

View File

@@ -25,6 +25,10 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES += test_dac.c
endif
ifeq ($(CONFIG_USER_TEST_SD),y)
SRC_FILES += test_softspi_sd.c
endif
ifeq ($(CONFIG_USER_TEST_SEMC),y)
SRC_FILES += test_extsram.c
endif

View File

@@ -56,4 +56,4 @@ void TestAdc(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@@ -0,0 +1,31 @@
#include <stdio.h>
#include <string.h>
#include <transform.h>
#define MAX_READ_LENGTH 1000
// sd card here is loaded as "/"
void TestSD(void)
{
//open the file in sdcard
int fd = open(SD_FPATH,O_RDWR|O_CREAT);
char filewords[MAX_READ_LENGTH];
memset(filewords,0,MAX_READ_LENGTH);
//read and write then close file
read(fd,filewords,MAX_READ_LENGTH);
printf("read data is \n%s\n",filewords);
const char *input_words = "these words are going to write in sdcard\n";
write(fd,input_words,strlen(input_words));
close(fd);
//re-open the file and re-read the file
fd = open(SD_FPATH,O_RDWR);
read(fd,filewords,MAX_READ_LENGTH);
printf("read data is \n%s\n",filewords);
close(fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestSD, a sdcard test sample, PRIV_SHELL_CMD_MAIN_ATTR);