You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
1.6 KiB
33 lines
1.6 KiB
/* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
/* Copyright (c) 2016 King Kévin <kingkevin@cuvoodoo.info> */
|
|
/* this library is used to store (read and write) data in flash */
|
|
/* peripherals used: none */
|
|
#include <libopencm3/stm32/desig.h> // device signature utilities
|
|
|
|
// how much data (in bytes) should we be able to store (be sure it's available and does not overlap the firmware)
|
|
#define STORAGE_SIZE 2048
|
|
// the end of the flash area where to store data
|
|
#define STORAGE_END FLASH_BASE+DESIG_FLASH_SIZE
|
|
// the start of the flash area where to store data (be sure it's after the firmware data)
|
|
// we will only use the last kilobytes
|
|
#define STORAGE_START STORAGE_END-STORAGE_SIZE
|
|
|
|
/* read <size> data from address <address> into <buffer>
|
|
* returns if read succeeded */
|
|
bool storage_read(uint32_t address, uint8_t *buffer, size_t size);
|
|
/* write <size> data from <buffer> to address <address>
|
|
* returns if write succeeded */
|
|
bool storage_write(uint32_t address, uint8_t *buffer, size_t size);
|
|
|