libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
flash_common_f.c
Go to the documentation of this file.
1
/** @addtogroup flash_file
2
*
3
*/
4
5
/*
6
* This file is part of the libopencm3 project.
7
*
8
* This library is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* This library is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Lesser General Public License for more details.
17
*
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with this library. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
/**@{*/
23
24
#include <
libopencm3/stm32/flash.h
>
25
#include <
libopencm3/stm32/common/flash_common_f.h
>
26
27
28
void
flash_unlock
(
void
)
29
{
30
/* Authorize the FPEC access. */
31
FLASH_KEYR
=
FLASH_KEYR_KEY1
;
32
FLASH_KEYR
=
FLASH_KEYR_KEY2
;
33
}
34
35
void
flash_lock
(
void
)
36
{
37
FLASH_CR
|=
FLASH_CR_LOCK
;
38
}
39
40
/* The bit number for EOP moves sometimes, but it's always a write 1 to clear */
41
void
flash_clear_eop_flag
(
void
)
42
{
43
FLASH_SR
|=
FLASH_SR_EOP
;
44
}
45
46
/**@}*/
flash.h
flash_common_f.h
FLASH_SR
#define FLASH_SR
Definition:
flash_common_f01.h:43
FLASH_KEYR
#define FLASH_KEYR
Definition:
flash_common_f01.h:41
FLASH_CR
#define FLASH_CR
Definition:
flash_common_f01.h:44
FLASH_CR_LOCK
#define FLASH_CR_LOCK
Definition:
flash_common_f01.h:80
FLASH_KEYR_KEY2
#define FLASH_KEYR_KEY2
Definition:
flash_common_f01.h:96
FLASH_SR_EOP
#define FLASH_SR_EOP
Definition:
f1/flash.h:82
FLASH_KEYR_KEY1
#define FLASH_KEYR_KEY1
Definition:
flash_common_f01.h:95
flash_unlock
void flash_unlock(void)
Unlock the Flash Program and Erase Controller This enables write access to the Flash memory.
Definition:
flash_common_f.c:28
flash_clear_eop_flag
void flash_clear_eop_flag(void)
Clear the End of OPeration flag.
Definition:
flash_common_f.c:41
flash_lock
void flash_lock(void)
Lock the Flash Program and Erase Controller Used to prevent spurious writes to FLASH.
Definition:
flash_common_f.c:35
lib
stm32
common
flash_common_f.c
Generated on Tue Mar 7 2023 16:11:24 for libopencm3 by
1.9.4