GR712RC unit tests 1.0
Bare-metal C++ hardware tests for the PLATO DPU (IAA-CSIC, 2019)
Loading...
Searching...
No Matches
gpio_inout.cpp
Go to the documentation of this file.
1
24
25#include <cstdint>
26#include <mcal/mcal.h>
27
28//#include <bcc/bcc.h>
29//#include <bcc/bcc_param.h>
30
31namespace
32{
33//Active delay, loops for x time.
34void delay()
35{
36 for (std::uint32_t iter= 0; iter < 4000; ++iter)
37 for (std::uint32_t iter2 = 0; iter2 < 100; iter2++)
38 {
40 }
41}
42}
43
44
45int main()
46{
47
48 //mcal::init(nullptr);
49 mcal::init(nullptr);
50
51 //Instantiate the gpio pin32.
52 mcal::port::port_pin<std::uint32_t,
53 std::uint32_t,
55 UINT32_C(25) > gpio25_input_pin;
56
57 gpio25_input_pin.set_direction_input();
58
59 //Instantiate the gpio pin32.
60 mcal::port::port_pin<std::uint32_t,
61 std::uint32_t,
63 UINT32_C(26) > gpio26_output_pin;
64
65 gpio26_output_pin.set_direction_output();
66
67 // gpio26_output_pin.set_pin_low();
68
69 while(1)
70 {
71
72 if (!gpio25_input_pin.read_input_value())
73 {
74 gpio26_output_pin.toggle_pin();
75 }
76 }
77
78 return 0;
79}
static void set_direction_output()
Definition mcal_port.h:27
static bool read_input_value()
Definition mcal_port.h:92
static void set_direction_input()
Definition mcal_port.h:50
static void toggle_pin()
Definition mcal_port.h:101
int main()
Microcontroller abstraction layer.
void nop()
Definition mcal_cpu.h:24
constexpr std::uint32_t grgpio1_base_address
Definition mcal_reg.h:27
void init(config_type *)
Definition mcal.cpp:12