flash_internal: minor, update doc/comment

This commit is contained in:
King Kévin 2020-01-01 23:35:32 +01:00
parent fe16ad18cd
commit a6fb25b6c6
2 changed files with 6 additions and 5 deletions

View File

@ -13,9 +13,9 @@
*
*/
/** library to read/write internal flash (code)
* @file flash_internal.c
* @file
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016-2018
* @date 2016-2020
* @note peripherals used: none
*/
/* standard libraries */
@ -27,6 +27,7 @@
#include <libopencm3/stm32/desig.h> // device signature definitions
#include <libopencm3/stm32/dbgmcu.h> // debug definitions
/* own libraries */
#include "flash_internal.h" // flash storage library API
#include "global.h" // global definitions
@ -111,7 +112,7 @@ int32_t flash_internal_write(uint32_t address, const uint8_t *buffer, size_t siz
// verify of we need to erase the flash before writing it
uint32_t page_start = address - (address % page_size); // get start of the current page
bool erase = false; // verify if the flash to write is erased of if we need to erase the page
for (uint32_t i = 0; i < size && (address + i) < (page_start + page_size); i += 2) { // verify if not bit need to be flipped to 1 again
for (uint32_t i = 0; i < size && (address + i) < (page_start + page_size); i += 2) { // verify if no bit need to be flipped to 1 again
if (*(uint16_t*)(buffer + i) != 0x0000 && (*(uint16_t*)(address + i)) != 0xffff ) { // to write the flashed, it needs to be erased, or the data needs to be 0
erase = true; // we need to erase the flash to flip the bit back to 1
}

View File

@ -13,9 +13,9 @@
*
*/
/** library to read/write internal flash (API)
* @file flash_internal.h
* @file
* @author King Kévin <kingkevin@cuvoodoo.info>
* @date 2016-2018
* @date 2016-2020
* @note peripherals used: none
*/
#pragma once