-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·82 lines (60 loc) · 1.7 KB
/
main.cpp
File metadata and controls
executable file
·82 lines (60 loc) · 1.7 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Sample main.cpp file. Blinks the built-in LED, sends a message out
// USART2, and turns on PWM on pin 2.
#include "wirish.h"
#include "rng.h"
#include "rcc.h"
void setup() {
uint32 test;
/* Set up the LED to blink */
pinMode(BOARD_GREEN_LED_PIN, OUTPUT);
pinMode(BOARD_ORANGE_LED_PIN, OUTPUT);
pinMode(BOARD_BLUE_LED_PIN, OUTPUT);
pinMode(BOARD_RED_LED_PIN, OUTPUT);
/* Turn on PWM on pin PWM_PIN */
// pinMode(PWM_PIN, PWM);
// pwmWrite(PWM_PIN, 0x8000);
/* Send a message out USART2 */
// Serial2.begin(9600);
// Serial2.println("Hello world!");
/* Send a message out the usb virtual serial port */
//SerialUSB.println("Hello!");
rng_init();
rng_enable();
// togglePin(BOARD_BLUE_LED_PIN);
while ( (test = rng_get_number()) < 3) {
// if ()
togglePin(BOARD_BLUE_LED_PIN);
/*
if (check_PLL() >2)
togglePin(BOARD_RED_LED_PIN);
if (check_PLL() < 15)
togglePin(BOARD_ORANGE_LED_PIN);*/
}
}
void loop() {
//4,294,967,295
togglePin(BOARD_GREEN_LED_PIN);
delay(100);
if (rng_get_number() < 2147483647UL) {
togglePin(BOARD_RED_LED_PIN);
delay(100);
}
if (rng_get_number() > 2147483647UL) {
togglePin(BOARD_BLUE_LED_PIN);
delay(100);
}
//togglePin(BOARD_ORANGE_LED_PIN);
//delay(100);
}
// Force init to be called *first*, i.e. before static object allocation.
// Otherwise, statically allocated objects that need libmaple may fail.
__attribute__((constructor)) void premain() {
init();
}
int main(void) {
setup();
while (true) {
loop();
}
return 0;
}