1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/cpu/efm32_common/periph/flashpage.c
2017-11-13 20:27:16 +01:00

41 lines
874 B
C

/*
* Copyright (C) 2017 Bas Stottelaar <basstottelaar@gmail.com>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup cpu_efm32_common
* @ingroup drivers_periph_flashpage
* @{
*
* @file
* @brief Low-level flash page driver implementation
*
* @author Bas Stottelaar <basstottelaar@gmail.com>
*
* @}
*/
#include "cpu.h"
#include "assert.h"
#include "periph/flashpage.h"
#include "em_msc.h"
void flashpage_write(int page, void *data)
{
assert(page < FLASHPAGE_NUMOF);
uint32_t *page_addr = (uint32_t *)flashpage_addr(page);
uint32_t *data_addr = (uint32_t *)data;
MSC_Init();
MSC_ErasePage(page_addr);
MSC_WriteWord(page_addr, data_addr, FLASHPAGE_SIZE);
MSC_Deinit();
}