Skip to content

Commit f9bbd42

Browse files
Reuse HighCycleAreaOrOtpIrqHandler
1 parent 3135094 commit f9bbd42

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

hal_st/stm32fxxx/FlashInternalHighCycleAreaStm.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#include DEVICE_HEADER
21
#include "hal_st/stm32fxxx/FlashInternalHighCycleAreaStm.hpp"
32
#include "hal_st/stm32fxxx/FlashInternalStmDetail.hpp"
43
#include "infra/event/EventDispatcher.hpp"
54
#include "infra/util/ByteRange.hpp"
65
#include "infra/util/MemoryRange.hpp"
76
#include <cstdint>
7+
#include DEVICE_HEADER
88

99
namespace
1010
{
@@ -139,19 +139,6 @@ namespace hal
139139

140140
FlashInternalHighCycleAreaStm::WithIrqHandler::WithIrqHandler(uint32_t bank)
141141
: FlashInternalHighCycleAreaStm(bank)
142-
, nmi{
143-
IRQn_Type::NonMaskableInt_IRQn, []
144-
{
145-
// From RM0481, Section 7.3.4 FLASH read operations:
146-
// If the application reads an OTP data or flash high-cycle data not previously written, a
147-
// double ECC error is reported and only a word full of set bits is returned (see
148-
// Section 7.3.9 for details). The read data (in 16 bits) is stored in FLASH_ECCDR
149-
// register, so that the user can identify if the double ECC error is due to a virgin data or a
150-
// real ECC error.
151-
really_assert(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ECCD) && READ_REG(FLASH->ECCDR) == 0xFFFF);
152-
153-
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ECCD);
154-
}
155-
}
142+
, HighCycleAreaOrOtpIrqHandler()
156143
{}
157144
}

hal_st/stm32fxxx/FlashInternalHighCycleAreaStm.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
// Copyright (c) 2024 Koninklijke Philips N.V.
21
#ifndef HAL_FLASH_INTERNAL_HIGH_CYCLE_AREA_STM_HPP
32
#define HAL_FLASH_INTERNAL_HIGH_CYCLE_AREA_STM_HPP
43

5-
#include DEVICE_HEADER
64
#include "hal/interfaces/Flash.hpp"
7-
#include "hal_st/cortex/InterruptCortex.hpp"
5+
#include "hal_st/stm32fxxx/HighCycleAreaOrOtpIrqHandler.hpp"
86
#include "infra/util/MemoryRange.hpp"
97
#include <cstdint>
8+
#include DEVICE_HEADER
109

1110
namespace hal
1211
{
@@ -19,7 +18,7 @@ namespace hal
1918

2019
class WithIrqHandler;
2120

22-
FlashInternalHighCycleAreaStm(uint32_t bank = FLASH_BANK_2);
21+
explicit FlashInternalHighCycleAreaStm(uint32_t bank = FLASH_BANK_2);
2322

2423
void WriteBuffer(infra::ConstByteRange buffer, uint32_t address, infra::Function<void()> onDone) override;
2524
void ReadBuffer(infra::ByteRange buffer, uint32_t address, infra::Function<void()> onDone) override;
@@ -37,12 +36,10 @@ namespace hal
3736

3837
class FlashInternalHighCycleAreaStm::WithIrqHandler
3938
: public FlashInternalHighCycleAreaStm
39+
, private HighCycleAreaOrOtpIrqHandler
4040
{
4141
public:
42-
WithIrqHandler(uint32_t bank = FLASH_BANK_2);
43-
44-
private:
45-
hal::ImmediateInterruptHandler nmi;
42+
explicit WithIrqHandler(uint32_t bank = FLASH_BANK_2);
4643
};
4744
}
4845

0 commit comments

Comments
 (0)