summaryrefslogtreecommitdiffstats
path: root/main.cpp
blob: 119e5cefb743c506f6d6d760e2ca986d575e053e (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
/* 
 * File:   main.cpp
 * Author: naopross
 *
 * Created on May 1, 2018, 6:18 PM
 */

#include <stdio.h>
#include <stdlib.h>

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

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

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);
    
    while (true) {
        while (uart::rx_buffer_empty<1>());
//        while (!uart::rx_buffer_empty<1>()) {
//            uart::write<1>(uart::read<1>());
//            uart::write<1>("\n\rk")
//        }
        
        uart::read<1>();        
        led1.toggle();
    }

    return 0;
}