GR712RC unit tests 1.0
Bare-metal C++ hardware tests for the PLATO DPU (IAA-CSIC, 2019)
Loading...
Searching...
No Matches
memory_persistence.cpp
Go to the documentation of this file.
1
23
24#include <cstdint>
25#include <mcal/mcal.h>
26
27namespace
28{
29//Active delay, loops for x time.
30void delay()
31{
32 for (std::uint32_t iter= 0; iter < 4000; ++iter)
33 for (std::uint32_t iter2 = 0; iter2 < 100; iter2++)
34 {
36 }
37}
38}
39
40int main()
41{
42
43 constexpr std::uint32_t def_pattern = 0xABABABABUL;
44
45 // assert(sdram_memory_size > max_memory); Meter este assert..
46
47 mcal::init(nullptr);
48
49 std::uint32_t *memory_begin_position = reinterpret_cast<std::uint32_t *>(mcal::reg::mem_base_addr);
50 std::uint32_t *memory_end_position = reinterpret_cast<std::uint32_t *>(mcal::reg::mem_end_addr);
51
52 volatile std::uint32_t *memory_position = memory_begin_position;
53 while( memory_position < memory_end_position )
54 {
55 (* memory_position ) = def_pattern;
56
57 memory_position ++;
58 }
59
60 std::uint32_t per_checks_counter = 0;
61 while(1) {
62 volatile std::uint32_t *memory_check_position = memory_begin_position + 1;
63
64 // ::delay();
65 while( memory_check_position < memory_end_position )
66 {
67 if ((*memory_check_position) == def_pattern)
68 {
69 memory_check_position ++;
70 }
71 else
72 {
73 (* memory_begin_position ) = 0x12000000 | per_checks_counter;
74 return 1;
75 }
76
77 }
78 (* memory_begin_position ) = per_checks_counter;
79 per_checks_counter ++;
80
81 }
82
83 return 0;
84}
Microcontroller abstraction layer.
int main()
void nop()
Definition mcal_cpu.h:24
constexpr std::uint32_t mem_base_addr
Definition mcal_reg.h:16
constexpr std::uint32_t mem_end_addr
Definition mcal_reg.h:17
void init(config_type *)
Definition mcal.cpp:12