| 148 | #pragma diag_suppress=Ta023 |
| 149 | #endif |
| 150 | msc_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 |
no outgoing calls
no test coverage detected