blob: 247892dc00ab1823a45476803f16965c7c9dd4f4 (
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
|
// Tests the SysTick enable/disable functions
//
#include "wirish.h"
#include "systick.h"
#define LED_PIN 13
#define PWM_PIN 2
#define BUT 38
void setup()
{
/* Set up the LED to blink */
pinMode(LED_PIN, OUTPUT);
/* Turn on PWM on pin PWM_PIN */
pinMode(PWM_PIN, PWM);
pwmWrite(PWM_PIN, 0x8000);
pinMode(BUT, INPUT_PULLDOWN);
}
int toggle = 0;
long time = 0;
void loop() {
toggle ^= 1;
digitalWrite(LED_PIN, toggle);
// An artificial delay
int16 i = 1;
float j = 1;
for(i=0; i<6553; i++) {
j = sqrt(j) + 1;
}
if(digitalRead(BUT)) {
systick_disable();
} else {
systick_resume();
}
//SerialUSB.println(micros()); // there is a bug with this
SerialUSB.println(millis());
}
// Force init to be called *first*, i.e. before static object allocation.
// Otherwise, statically allocated object that need libmaple may fail.
__attribute__(( constructor )) void premain() {
init();
}
int main(void)
{
setup();
while (1) {
loop();
}
return 0;
}
|