File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
samples/boards/st/backup_sram/src Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*/
6
6
7
+ #include <zephyr/cache.h>
7
8
#include <zephyr/device.h>
8
9
#include <zephyr/kernel.h>
9
10
#include <zephyr/sys/printk.h>
@@ -40,9 +41,15 @@ int main(void)
40
41
printk ("Current value in backup SRAM (%p): %d\n" , & backup .value , backup .value );
41
42
42
43
backup .value ++ ;
43
- #if __DCACHE_PRESENT
44
- SCB_CleanDCache_by_Addr (& backup , sizeof (backup ));
45
- #endif
44
+
45
+ #if defined(CONFIG_CACHE_MANAGEMENT ) && defined(CONFIG_DCACHE )
46
+ int err = sys_cache_data_flush_range (& backup , sizeof (backup ));
47
+
48
+ if (err != 0 ) {
49
+ printk ("Failed to flush the data cache (err: %d)\n" , err );
50
+ return 0 ;
51
+ }
52
+ #endif /* defined(CONFIG_CACHE_MANAGEMENT) && defined(CONFIG_DCACHE) */
46
53
47
54
printk ("Next reported value should be: %d\n" , backup .value );
48
55
printk ("Keep VBAT power source and reset the board now!\n" );
You can’t perform that action at this time.
0 commit comments