xiuos\Ubiquitous\RT-Thread_Fusion_XiUOS\aiit_board\xidatong-arm32\applications\main.c:

1.添加usb测试函数
This commit is contained in:
zhujiarui666 2022-06-27 16:27:12 +08:00
parent c2d7562f46
commit 9f0a316c6d
1 changed files with 65 additions and 0 deletions

View File

@ -48,3 +48,68 @@ static void sdram_test2(void)
}
MSH_CMD_EXPORT(sdram_test2, sdram test2);
#endif
#ifdef BSP_USB1_HOST
#include <dfs_posix.h>
static char test_data[120], buffer[120];
#define TEST_FN "/testusb.c"
void readwrite(const char* filename)
{
int fd;
int index, length;
fd = open(TEST_FN, O_WRONLY | O_CREAT | O_TRUNC, 0);
if (fd < 0)
{
rt_kprintf("open file for write failed\n");
return;
}
for (index = 0; index < sizeof(test_data); index ++)
{
test_data[index] = index + 27;
}
length = write(fd, test_data, sizeof(test_data));
if (length != sizeof(test_data))
{
rt_kprintf("write data failed\n");
close(fd);
return;
}
close(fd);
fd = open(TEST_FN, O_RDONLY, 0);
if (fd < 0)
{
rt_kprintf("check: open file for read failed\n");
return;
}
length = read(fd, buffer, sizeof(buffer));
if (length != sizeof(buffer))
{
rt_kprintf("check: read file failed\n");
close(fd);
return;
}
for (index = 0; index < sizeof(test_data); index ++)
{
if (test_data[index] != buffer[index])
{
rt_kprintf("check: check data failed at %d\n", index);
close(fd);
return;
}
}
rt_kprintf("usb host read/write udisk successful\r\n");
close(fd);
}
MSH_CMD_EXPORT(readwrite, usb host read write test);
#endif