stm32: flash: pull up clear_eop
All the "f" type flash parts have an EOP flag, even if it's in different bit positions. Add a header for this common functionality, and move it's implementation to the existing common file.
This commit is contained in:
parent
da7ebafcbe
commit
4840b6bc7e
|
@ -0,0 +1,32 @@
|
|||
/** @addtogroup flash_defines
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* This file is part of the libopencm3 project.
|
||||
*
|
||||
* This library is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libopencm3/cm3/common.h>
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* Clear the End of OPeration flag.
|
||||
*/
|
||||
void flash_clear_eop_flag(void);
|
||||
|
||||
END_DECLS
|
|
@ -100,7 +100,6 @@
|
|||
BEGIN_DECLS
|
||||
|
||||
void flash_clear_pgerr_flag(void);
|
||||
void flash_clear_eop_flag(void);
|
||||
void flash_clear_wrprterr_flag(void);
|
||||
void flash_clear_status_flags(void);
|
||||
uint32_t flash_get_status_flags(void);
|
||||
|
|
|
@ -75,7 +75,6 @@
|
|||
BEGIN_DECLS
|
||||
|
||||
void flash_clear_pgperr_flag(void);
|
||||
void flash_clear_eop_flag(void);
|
||||
void flash_clear_status_flags(void);
|
||||
void flash_wait_for_last_operation(void);
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f01.h>
|
||||
|
||||
/* --- FLASH_OPTION values ------------------------------------------------- */
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f01.h>
|
||||
|
||||
/* --- FLASH_OPTION bytes ------------------------------------------------- */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f24.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f234.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f24.h>
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
/*
|
||||
* For details see:
|
||||
* PM0081 Programming manual: STM32F40xxx and STM32F41xxx Flash programming
|
||||
|
@ -153,7 +154,6 @@
|
|||
BEGIN_DECLS
|
||||
|
||||
void flash_clear_pgperr_flag(void);
|
||||
void flash_clear_eop_flag(void);
|
||||
void flash_wait_for_last_operation(void);
|
||||
|
||||
void flash_unlock_option_bytes(void);
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#define LIBOPENCM3_FLASH_H
|
||||
|
||||
#include <libopencm3/stm32/common/flash_common_all.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
|
||||
/* --- FLASH registers ----------------------------------------------------- */
|
||||
|
||||
|
@ -225,7 +226,6 @@
|
|||
BEGIN_DECLS
|
||||
|
||||
void flash_clear_pgperr_flag(void);
|
||||
void flash_clear_eop_flag(void);
|
||||
void flash_wait_for_last_operation(void);
|
||||
void flash_dcache_enable(void);
|
||||
void flash_dcache_disable(void);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
/**@{*/
|
||||
|
||||
#include <libopencm3/stm32/flash.h>
|
||||
#include <libopencm3/stm32/common/flash_common_f.h>
|
||||
|
||||
|
||||
void flash_unlock(void)
|
||||
|
@ -39,3 +40,9 @@ void flash_lock(void)
|
|||
FLASH_CR |= FLASH_CR_LOCK;
|
||||
}
|
||||
|
||||
/* The bit number for EOP moves sometimes, but it's always a write 1 to clear */
|
||||
void flash_clear_eop_flag(void)
|
||||
{
|
||||
FLASH_SR |= FLASH_SR_EOP;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,16 +59,6 @@ void flash_clear_pgerr_flag(void)
|
|||
FLASH_SR |= FLASH_SR_PGERR;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Clear the End of Operation Status Flag
|
||||
|
||||
*/
|
||||
|
||||
void flash_clear_eop_flag(void)
|
||||
{
|
||||
FLASH_SR |= FLASH_SR_EOP;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Clear the Write Protect Error Status Flag
|
||||
|
||||
|
|
|
@ -55,17 +55,6 @@ void flash_clear_pgperr_flag(void)
|
|||
FLASH_SR |= FLASH_SR_PGPERR;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Clear the End of Operation Status Flag
|
||||
|
||||
*/
|
||||
|
||||
void flash_clear_eop_flag(void)
|
||||
{
|
||||
FLASH_SR |= FLASH_SR_EOP;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Wait until Last Operation has Ended
|
||||
|
||||
|
|
|
@ -94,16 +94,6 @@ void flash_clear_pgperr_flag(void)
|
|||
FLASH_SR |= FLASH_SR_PGPERR;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Clear the End of Operation Status Flag
|
||||
|
||||
*/
|
||||
|
||||
void flash_clear_eop_flag(void)
|
||||
{
|
||||
FLASH_SR |= FLASH_SR_EOP;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** @brief Wait until Last Operation has Ended
|
||||
|
|
|
@ -68,13 +68,6 @@ void flash_clear_pgperr_flag(void)
|
|||
FLASH_SR |= FLASH_SR_PROGERR;
|
||||
}
|
||||
|
||||
/** @brief Clear the End of Operation Status Flag
|
||||
*/
|
||||
void flash_clear_eop_flag(void)
|
||||
{
|
||||
FLASH_SR |= FLASH_SR_EOP;
|
||||
}
|
||||
|
||||
/** @brief Wait until Last Operation has Ended
|
||||
* This loops indefinitely until an operation (write or erase) has completed
|
||||
* by testing the busy flag.
|
||||
|
|
Loading…
Reference in New Issue