コード例 #1
0
ファイル: flash_erase_all.c プロジェクト: hulei123/git123
// See flash.h for documentation of this function.
status_t flash_erase_all(flash_driver_t * driver, uint32_t key)
{
    if (driver == NULL)
    {
        return kStatus_InvalidArgument;
    }

    // preparing passing parameter to erase all flash blocks
    // 1st element for the FCCOB register
    FTFx_WR_FCCOBx(FTFx, 0, FTFx_ERASE_ALL_BLOCK);

    // Validate the user key
    status_t returnCode = flash_check_user_key(key);
    if (returnCode)
    {
        return returnCode;
    }

    // calling flash command sequence function to execute the command
    returnCode = flash_command_sequence(driver);

    flash_cache_clear(driver);

    return returnCode;
}
コード例 #2
0
// See bl_shutdown_cleanup.h for documentation of this function.
void shutdown_cleanup(shutdown_type_t shutdown)
{
#if !defined(BOOTLOADER_HOST)
    if (shutdown != kShutdownType_Reset)
    {
        // Clear (flush) the flash cache.
        flash_cache_clear(NULL);
    }

    if (shutdown != kShutdownType_Cleanup)
    {
        // Shutdown all peripherals because they could be active
        uint32_t i;
        for (i = 0; g_peripherals[i].typeMask != 0; i++)
        {
            if (g_peripherals[i].controlInterface->shutdown)
            {
                g_peripherals[i].controlInterface->shutdown(&g_peripherals[i]);
            }
        }
    }

    // If we are permanently exiting the bootloader, there are a few extra things to do.
    if (shutdown == kShutdownType_Shutdown)
    {
        // Turn off global interrupt
        lock_acquire();

        // Shutdown microseconds driver.
        microseconds_shutdown();

#if defined(RCM_FM)
        // Disable force ROM.
        RCM_BWR_FM_FORCEROM(RCM, 0);

        // Clear status register (bits are w1c).
        RCM_BWR_MR_BOOTROM(RCM, 3);
#endif // defined(RCM_FM)

        init_interrupts();

        // Set the VTOR to default.
        SCB->VTOR = kDefaultVectorTableAddress;

        // Restore clock to default before leaving bootloader.
        configure_clocks(kClockOption_ExitBootloader);

        // De-initialize hardware such as disabling port clock gate
        deinit_hardware();

        // Restore global interrupt.
        __enable_irq();

#if BL_FEATURE_BYPASS_WATCHDOG
        // De-initialize watchdog
        bootloader_watchdog_deinit();
#endif // BL_FEATURE_BYPASS_WATCHDOG
    }

    // Memory barriers for good measure.
    __ISB();
    __DSB();
#endif
}