GR712RC unit tests 1.0
Bare-metal C++ hardware tests for the PLATO DPU (IAA-CSIC, 2019)
Loading...
Searching...
No Matches
memory_run_gpio.cpp
Go to the documentation of this file.
1
20
21#include <cstdint>
22#include <mcal/mcal.h>
23
24int main()
25{
26
27 constexpr std::uint32_t def_pattern = 0xABABABABUL;
28
29 mcal::init(nullptr);
30
31 //Instantiate the gpio pin32.
32 mcal::port::port_pin<std::uint32_t,
33 std::uint32_t,
35 UINT32_C(26) > gpio26_output_pin;
36
37 gpio26_output_pin.set_direction_output();
38
39
40 //Configure memory access
41 std::uint32_t *memory_begin_position = reinterpret_cast<std::uint32_t *>(mcal::reg::mem_base_addr);
42 std::uint32_t *memory_end_position = reinterpret_cast<std::uint32_t *>(mcal::reg::mem_end_addr);
43
44 volatile std::uint32_t *memory_position = memory_begin_position;
45 gpio26_output_pin.toggle_pin();
46 while( memory_position < memory_end_position )
47 {
48 (* memory_position ) = def_pattern;
49
50 memory_position ++;
51
52 }
53
54 gpio26_output_pin.toggle_pin();
55
56 volatile std::uint32_t *memory_check_position = memory_begin_position;
57 while( memory_check_position < memory_end_position )
58 {
59 gpio26_output_pin.toggle_pin();
60 if ((*memory_check_position) == def_pattern)
61 {
62 memory_check_position ++;
63 }
64 else
65 {
66 return 1;
67 }
68
69 }
70
71
72 return 0;
73}
static void set_direction_output()
Definition mcal_port.h:27
static void toggle_pin()
Definition mcal_port.h:101
Microcontroller abstraction layer.
int main()
constexpr std::uint32_t grgpio1_base_address
Definition mcal_reg.h:27
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