STM32 RTOS
0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Toggle main menu visibility
Loading...
Searching...
No Matches
flash.c
Go to the documentation of this file.
1
5
#include "
flash.h
"
6
11
12
DriverStatus_e
flashSetLatency
(
FlashRegisters_t
*flash, uint32_t latency)
13
{
14
DriverStatus_e
status =
DRIVER_STATUS_OK
;
15
16
if
(latency > (
FLASH_ACR_LATENCY_Msk
>>
FLASH_ACR_LATENCY_Pos
))
17
{
18
status =
DRIVER_STATUS_ERR_INVALID_PARAM
;
19
}
20
else
21
{
22
flash->
ACR
= (flash->
ACR
&
~FLASH_ACR_LATENCY_Msk
) | (latency <<
FLASH_ACR_LATENCY_Pos
);
23
24
/* RM0390 section 3.4.1 asks for this read-back before the clock rises.
25
* It is the project's only coverage exclusion: an in-memory struct
26
* always reads back what was written, so the failure branch needs
27
* silicon that rejects the write (see docs/DESIGN.md, "Host testing
28
* and its limits"). */
29
/* GCOVR_EXCL_START */
30
if
((flash->
ACR
&
FLASH_ACR_LATENCY_Msk
) != (latency <<
FLASH_ACR_LATENCY_Pos
))
31
{
32
status =
DRIVER_STATUS_ERR_HW_FAULT
;
33
}
34
/* GCOVR_EXCL_STOP */
35
}
36
37
return
status;
38
}
39
40
void
flashEnableCaches
(
FlashRegisters_t
*flash)
41
{
42
flash->
ACR
|=
FLASH_ACR_PRFTEN
|
FLASH_ACR_ICEN
|
FLASH_ACR_DCEN
;
43
}
44
flash.h
Flash driver: access latency (wait states), prefetch and caches.
DriverStatus_e
DriverStatus_e
Outcome of a driver call: a category for control flow, not a diagnosis.
Definition
driver_status.h:32
DRIVER_STATUS_OK
@ DRIVER_STATUS_OK
Succeeded.
Definition
driver_status.h:36
DRIVER_STATUS_ERR_HW_FAULT
@ DRIVER_STATUS_ERR_HW_FAULT
The hardware answered with a fault, such as a UART framing error or a rejected write.
Definition
driver_status.h:44
DRIVER_STATUS_ERR_INVALID_PARAM
@ DRIVER_STATUS_ERR_INVALID_PARAM
A parameter is outside its valid domain.
Definition
driver_status.h:38
flashSetLatency
DRIVER_MUST_CHECK DriverStatus_e flashSetLatency(FlashRegisters_t *flash, uint32_t latency)
Set the flash access latency and confirm it by reading it back.
Definition
flash.c:12
flashEnableCaches
void flashEnableCaches(FlashRegisters_t *flash)
Turn on prefetch and the instruction and data caches.
Definition
flash.c:40
FLASH_ACR_PRFTEN
#define FLASH_ACR_PRFTEN
<span class="regaccess">rw</span> Enable prefetch.
Definition
flash_reg.h:45
FLASH_ACR_ICEN
#define FLASH_ACR_ICEN
<span class="regaccess">rw</span> Enable the instruction cache.
Definition
flash_reg.h:48
FLASH_ACR_DCEN
#define FLASH_ACR_DCEN
<span class="regaccess">rw</span> Enable the data cache.
Definition
flash_reg.h:51
FLASH_ACR_LATENCY_Msk
#define FLASH_ACR_LATENCY_Msk
<span class="regaccess">rw</span> Wait states (0-15).
Definition
flash_reg.h:42
FLASH_ACR_LATENCY_Pos
#define FLASH_ACR_LATENCY_Pos
Bits 3:0.
Definition
flash_reg.h:40
FlashRegisters_t
Flash interface register block.
Definition
flash_reg.h:26
FlashRegisters_t::ACR
volatile uint32_t ACR
0x00: access control
Definition
flash_reg.h:27
drivers
src
flash.c
Generated by
1.18.0