X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Farm%2Fdrv%2Fflash_at91.c;fp=bertos%2Fcpu%2Farm%2Fdrv%2Fflash_at91.c;h=f46c48812e8cedcde9f322515a228fed63b6980b;hb=0cd323b49018066aee36ccd684f7f38785a010a6;hp=09f64eff87d624d014f8445f0afc3462f4f61d6f;hpb=cd7f7400bd7798f2b1082ee1f9fe91fef8e5ca27;p=bertos.git diff --git a/bertos/cpu/arm/drv/flash_at91.c b/bertos/cpu/arm/drv/flash_at91.c index 09f64eff..f46c4881 100644 --- a/bertos/cpu/arm/drv/flash_at91.c +++ b/bertos/cpu/arm/drv/flash_at91.c @@ -67,30 +67,39 @@ #define FLASH_START_ADDR (FLASH_START_PAGE * FLASH_PAGE_SIZE_BYTES) /** - * Send write command. - * - * After WR command cpu write bufferd page into flash memory. + * Really send the flash write command. * * \note This function has to be placed in RAM because - * executing code from Flash while a writing process + * executing code from flash while a writing process * is in progress is forbidden. - */ -RAM_FUNC NOINLINE static void flash_at91_sendWRcmd(uint32_t page) + */ +RAM_FUNC NOINLINE static void write_page(uint32_t page) { - cpu_flags_t flags; - - LOG_INFO("Writing page %ld...\n", page); - - IRQ_SAVE_DISABLE(flags); - // Send the 'write page' command MC_FCR = MC_KEY | MC_FCMD_WP | (MC_PAGEN_MASK & (page << 8)); - // Wait for end of command + // Wait for the end of command while(!(MC_FSR & BV(MC_FRDY))) { //NOP; } +} + + +/** + * Send write command. + * + * After WR command cpu write bufferd page into flash memory. + * + */ +INLINE void flash_at91_sendWRcmd(uint32_t page) +{ + cpu_flags_t flags; + + LOG_INFO("Writing page %ld...\n", page); + + IRQ_SAVE_DISABLE(flags); + write_page(page); IRQ_RESTORE(flags); LOG_INFO("Done\n");