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

Function sd_mount

bsp/ft2004/drivers/drv_sdcard.c:76–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76static void sd_mount(void *parameter)
77{
78 rt_uint8_t state = 0; /* 1. is valid card ,0 is removal */
79#ifdef BSP_SDC_IRQ_CARD_REMOVE
80 rt_uint32_t status;
81#endif
82 while (1)
83 {
84 switch (state)
85 {
86 case 0:
87 if (ft2004_card_status() == 1)
88 {
89#ifdef BSP_SDC_IRQ_CARD_REMOVE
90 ft2004_card_remove_check(0, RT_NULL); /* Clear removal flag bit */
91#endif
92 if (_sdcard_mount() == RT_EOK)
93 {
94 state = 1;
95 }
96 else
97 {
98 /* For the critical case of frequent plug */
99 rt_kprintf("dfs_unmount \r\n");
100 _sdcard_unmount();
101 ft2004_sdctrl_reset();
102 }
103 }
104 else
105 {
106 rt_thread_mdelay(100);
107 }
108 break;
109 case 1:
110
111#ifdef BSP_SDC_IRQ_CARD_REMOVE
112 if (ft2004_card_remove_check(RT_WAITING_FOREVER, &status) == RT_EOK)
113 {
114 if (status & SDCTR_CARD_REMOVE_FLG)
115 {
116 state = 0;
117 _sdcard_unmount();
118 }
119 }
120#else
121 if (ft2004_card_status() == 0)
122 {
123 state = 0;
124 _sdcard_unmount();
125 }
126#endif
127 else
128 {
129 rt_thread_mdelay(100);
130 }
131 break;
132 default:
133 state = 0;

Callers

nothing calls this directly

Calls 7

ft2004_card_statusFunction · 0.85
ft2004_card_remove_checkFunction · 0.85
rt_kprintfFunction · 0.85
ft2004_sdctrl_resetFunction · 0.85
rt_thread_mdelayFunction · 0.85
_sdcard_mountFunction · 0.70
_sdcard_unmountFunction · 0.70

Tested by

no test coverage detected