summaryrefslogtreecommitdiffstats
path: root/main.cpp
blob: 860460c3992545337b9ae9dddefb2454bee814e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* 
 * File:   main.cpp
 * Author: naopross
 *
 * Created on May 1, 2018, 6:18 PM
 */

#define DEBUG

// basic devices
#include "hal/confbits.hpp"
#include "hal/hwconfig.hpp"

// specific devices
#include "hal/uart.tpp"
#include "hal/pin.tpp"

// standard library 
#include <string>

// microchip libraries
extern "C" {
    #include <xc.h>
    // #include <proc/p32mx470f512h.h>
}



int main(int argc, char** argv)
{
    osc::initialize();
    interrupts::initialize();
    uart::initialize<1>();

    pin<4> led1(&LATEbits, &TRISEbits, &PORTEbits);
    pin<6> led2(&LATEbits, &TRISEbits, &PORTEbits);
    pin<7> led3(&LATEbits, &TRISEbits, &PORTEbits);

    led1.set(1);
    led2.set(1);
    led3.set(1);

    uart::write<1>("started\n\r");
    
    while (true) {
        while (uart::rx_buffer<1>().empty());
        while (uart::rx_buffer<1>().size() > 0) {
            char c = uart::read<1>(); 
            
            uart::write<1>(c);
            uart::write<1>("\n\r");
        }
        
        led1.toggle();
    }

    return 0;
}