GR712RC unit tests 1.0
Bare-metal C++ hardware tests for the PLATO DPU (IAA-CSIC, 2019)
Loading...
Searching...
No Matches
uart_periph.cpp
Go to the documentation of this file.
1
22
23#include <cstdint>
24#include <mcal/mcal.h>
25#include <array>
26
27namespace
28{
29
31 std::uint8_t,
33
34//Active delay, loops for x time.
35void delay()
36{
37 for (std::uint32_t iter= 0; iter < 4000; ++iter)
38 for (std::uint32_t iter2 = 0; iter2 < 100; iter2++)
39 {
41 }
42}
43}
44
45typedef std::array<std::uint32_t,64> buffer_type;
46
47int main()
48{
49
50 constexpr std::array<std::uint8_t,13> welcome_msg = {'\n', '\r', 'U', 'A', 'R', 'T',' ', 'T','e', 's', 't', '\n', '\r'};
51 constexpr std::array<std::uint8_t,12> underline_msg = {'=', '=', '=', '=', '=','=', '=','=', '=', '=', '\n', '\r'};
52
53 mcal::init(nullptr);
54
55 //Instantiate the gpio pin32.
56 mcal::port::port_pin<std::uint32_t,
57 std::uint32_t,
59 UINT32_C(26) > gpio26_output_pin;
60
61 gpio26_output_pin.set_direction_output();
62
63 //Print the Welcome Message
64 the_uart0.send_n( welcome_msg.begin(), welcome_msg.end() );
65 delay();
66 the_uart0.send_n( underline_msg.begin(), underline_msg.end() );
67 delay();
68
69 std::uint8_t byte_to_recv;
70 while(1)
71 {
72
73 gpio26_output_pin.toggle_pin();
74
75 the_uart0.send('T');
76
77 if (the_uart0.receive_ready() )
78 {
79 the_uart0.recv(byte_to_recv);
80 delay();
81 the_uart0.send(byte_to_recv);
82 }
83 delay();
84
85 }
86
87 return 0;
88}
static void set_direction_output()
Definition mcal_port.h:27
static void toggle_pin()
Definition mcal_port.h:101
Microcontroller abstraction layer.
void nop()
Definition mcal_cpu.h:24
constexpr std::uint32_t grgpio1_base_address
Definition mcal_reg.h:27
constexpr std::uint32_t uart0_base_address
Definition mcal_reg.h:46
void init(config_type *)
Definition mcal.cpp:12
std::array< std::uint32_t, 64 > buffer_type
int main()