MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / fal_sample

Function fal_sample

bsp/hc32/tests/test_fal.c:40–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38
39
40static int fal_sample(int argc, char **argv)
41{
42 const struct fal_partition *param;
43 int ret;
44 uint32_t Address;
45 uint8_t errFlag = 0;
46
47 fal_init(); //抽象层初始化
48 /* Set write buffer, clear read buffer */
49 for (uint32_t index = 0; index < TEST_BUF_SIZE; index++)
50 {
51 write_buffer[index] = index;
52 }
53 param = fal_partition_find(FAL_PART_NAME);
54 if (param == RT_NULL)
55 {
56 rt_kprintf("not find partition app!\r\n");
57 return -1;
58 }
59 for (int j = 0; j < TEST_RW_CNT; j++)
60 {
61 errFlag = 0;
62 Address = TEST_RW_START_ADDR + j * TEST_BUF_SIZE;
63 rt_kprintf("........test %d address 0x%08x........\r\n", j + 1, Address);
64 /* erase process */
65
66 if (j == 31)
67 {
68 rt_kprintf(".......");
69 }
70
71 ret = fal_partition_erase(param, Address, TEST_BUF_SIZE);
72 if (ret >= 0)
73 {
74 rt_kprintf("Erase succeeded!\r\n");
75 }
76 else
77 {
78 rt_kprintf("Erase failed!\r\n");
79 return ret;
80 }
81 /* write process */
82 ret = fal_partition_write(param, Address, write_buffer, TEST_BUF_SIZE);
83 if (ret >= 0)
84 {
85 rt_kprintf("Write succeeded!\r\n");
86 }
87 else
88 {
89 rt_kprintf("Write failed!\r\n");
90 return ret;
91 }
92 /* read process */
93 for (uint32_t index = 0; index < TEST_BUF_SIZE; index++)
94 {
95 read_buffer[index] = 0;
96 }
97 ret = fal_partition_read(param, Address, read_buffer, TEST_BUF_SIZE);

Callers

nothing calls this directly

Calls 6

fal_initFunction · 0.85
fal_partition_findFunction · 0.85
rt_kprintfFunction · 0.85
fal_partition_eraseFunction · 0.85
fal_partition_writeFunction · 0.85
fal_partition_readFunction · 0.85

Tested by

no test coverage detected