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

Function MSC_ErasePage

bsp/efm32/Libraries/emlib/src/em_msc.c:150–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148#pragma diag_suppress=Ta023
149#endif
150msc_Return_TypeDef MSC_ErasePage(uint32_t *startAddress)
151{
152 int timeOut = MSC_PROGRAM_TIMEOUT;
153
154 /* Address must be aligned to pages */
155 EFM_ASSERT((((uint32_t)startAddress) & 0x1FF) == 0);
156
157 /* Enable writing to the MSC */
158 MSC->WRITECTRL |= MSC_WRITECTRL_WREN;
159
160 /* Load address */
161 MSC->ADDRB = (uint32_t)startAddress;
162 MSC->WRITECMD = MSC_WRITECMD_LADDRIM;
163
164 /* Check for invalid address */
165 if (MSC->STATUS & MSC_STATUS_INVADDR)
166 {
167 /* Disable writing to the MSC */
168 MSC->WRITECTRL &= ~MSC_WRITECTRL_WREN;
169 return mscReturnInvalidAddr;
170 }
171
172 /* Check for write protected page */
173 if (MSC->STATUS & MSC_STATUS_LOCKED)
174 {
175 /* Disable writing to the MSC */
176 MSC->WRITECTRL &= ~MSC_WRITECTRL_WREN;
177 return mscReturnLocked;
178 }
179
180 /* Send erase page command */
181 MSC->WRITECMD = MSC_WRITECMD_ERASEPAGE;
182
183 /* Wait for the erase to complete */
184 while ((MSC->STATUS & MSC_STATUS_BUSY) && (timeOut != 0))
185 {
186 timeOut--;
187 }
188
189 if (timeOut == 0)
190 {
191 /* Disable writing to the MSC */
192 MSC->WRITECTRL &= ~MSC_WRITECTRL_WREN;
193 return mscReturnTimeOut;
194 }
195
196 /* Disable writing to the MSC */
197 MSC->WRITECTRL &= ~MSC_WRITECTRL_WREN;
198 return mscReturnOk;
199}
200#if defined( __ICCARM__ )
201#pragma diag_default=Ta022
202#pragma diag_default=Ta023

Callers 2

TRACE_ProfilerEnableFunction · 0.85
TRACE_ProfilerEnableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected