aboutsummaryrefslogtreecommitdiffstats
path: root/src/example_main.cpp
blob: 7202c662d9eb15404f44994733c48d254f8060d1 (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
60
61
62
63
64
65
#include "wiring.h"
#include "HardwareSerial.h"
#include "HardwareUsb.h"
#include "math.h"
#include "usb.h"

int ledPin = 13;
uint8_t bytes_in;

HardwareUsb Usb;

void setup()
{
    pinMode(ledPin, OUTPUT);
    Serial2.begin(9600);
    Serial2.println("setup start");

    pinMode(6, PWM);
    pwmWrite(6, 0x8000);
    pinMode(7, OUTPUT);

    Serial2.println("setup end");

    Usb.begin();
    Usb.flush();
}

int toggle = 0;

const char* testMsg = "hello world!\n";
const char x = 'a';
static inline void loop() {
    toggle ^= 1;
    digitalWrite(ledPin, toggle);
    delay(50);

    uint8_t numBytes=Usb.available();
    
    if (numBytes > 0) {
      while (numBytes-->0) {
	Usb.print(Usb.read());
      }
    }

    Usb.flush();
}


int main(void) {
    init();
    setup();

    while (1) {
        loop();
    }
    return 0;
}

/* Required for C++ hackery */
/* TODO: This really shouldn't go here... move it later
 * */
extern "C" void __cxa_pure_virtual(void) {
    while(1)
        ;
}