otError utilsFlashErasePage(uint32_t aAddress) { int32_t status; status = MSC_ErasePage((uint32_t *)mapAddress(aAddress)); return returnTypeConvert(status); }
void ANIM_prerenderFrames(void) { uint32_t i; uint32_t magicWord = 0xef32; /* Get the starting address of the prerendered frames */ uint32_t *addr = (uint32_t *)FRAMES_START; /* Get the end of the prerendered frames */ uint32_t *lastAddr = addr + FRAME_BUFFER_SIZE_WORDS * NUM_FRAMES; /* Get the address of the current frame buffer */ uint16_t *frameBuffer = FB_getActiveBuffer(); /* Check the last address for the magic word. * If this has been written the frames are already in flash * and we can skip the entire prerendering step */ if ( *lastAddr == magicWord ) { return; } MSC_Init(); /* Make emWin draw to the frame buffer */ FB_activateFrameBuffer(); /* Add meta data to frame buffer */ FB_writeControlSignals((uint8_t*)frameBuffer); /* Erase all the pages we are going to write to */ while ( addr < lastAddr ) { MSC_ErasePage(addr); addr += FRAME_BUFFER_SIZE_WORDS; } addr = (uint32_t *)FRAMES_START; for ( i=0; i<NUM_FRAMES; i++ ) { /* Render a frame */ GUI_DrawBitmap(frames[i], 0, 0); /* Copy entire frame buffer to flash */ MSC_WriteWord(addr, frameBuffer, FRAME_BUFFER_SIZE_BYTES); addr += FRAME_BUFFER_SIZE_WORDS; } /* Write magic word to indicate that the frames are ready in Flash */ MSC_WriteWord(lastAddr, &magicWord, 4); MSC_Deinit(); }
__ramfunc void FlushFlash( void ) #endif { /* We can't serve interrupts while erasing or writing to flash. */ INT_Disable(); MSC->LOCK = MSC_UNLOCK_CODE; /* Erase flash page */ MSC_ErasePage( (uint32_t*)flashStatus.pPageBase ); /* Program flash page */ MSC_WriteWord( (uint32_t*)flashStatus.pPageBase, flashPageBuf, flashPageSize ); MSC->LOCK = 0; INT_Enable(); }
/**************************************************************************//** * @brief GPIO Interrupt handler (PB10) * Increases number when PB0 is pressed. Wraps at 10000. *****************************************************************************/ void GPIO_EVEN_IRQHandler(void) { msc_Return_TypeDef ret; /* Acknowledge interrupt */ GPIO_IntClear(1 << 10); /* Initialize the MSC for writing */ MSC_Init(); /* Erase the page */ ret = MSC_ErasePage((uint32_t *) USERPAGE); /* Check for errors. If there are errors, set the global error variable and * deinitialize the MSC */ if (ret != mscReturnOk) { currentError = ret; MSC_Deinit(); return; } /* Increase the number of saves */ userData.numWrites++; /* Write data to the userpage */ ret = MSC_WriteWord((uint32_t *) USERPAGE, (void *) &userData, sizeof(UserData_TypeDef)); /* Check for errors. If there are errors, set the global error variable and * deinitialize the MSC */ if (ret != mscReturnOk) { currentError = ret; MSC_Deinit(); return; } /* Deinitialize the MSC. This disables writing and locks the MSC */ MSC_Deinit(); /* Signal completion of save. The number of saves will be displayed */ recentlySaved = true; }
rt_err_t fvs_erase_page(void *addr) { MSC_ErasePage(addr); return RT_EOK; }
void Userpage_erase(void){ uint32_t *addr = (uint32_t *)USER_PAGE_ADDR; MSC_ErasePage(addr); }