diff options
| author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-02-08 22:38:21 -0500 |
|---|---|---|
| committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-02-10 17:50:26 -0500 |
| commit | 0713c127112628b7eb2a75164560fa5cdac88827 (patch) | |
| tree | b65317122931e6e9e690678b9824ba05a3b9bb71 /main.cpp.example | |
| parent | a93626ced86d21d10c99848ccc6315ef917411a4 (diff) | |
Function examples/test-session.cpp on Native
Diffstat (limited to 'main.cpp.example')
| -rw-r--r-- | main.cpp.example | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/main.cpp.example b/main.cpp.example index 1032733..8fc522a 100644 --- a/main.cpp.example +++ b/main.cpp.example @@ -1,15 +1,17 @@ -// Sample main.cpp file. Blinks an LED, sends a message out USART2 -// and turns on PWM on pin 2 +// Sample main.cpp file. Blinks the built-in LED, sends a message out +// USART2, and turns on PWM on pin 2. #include "wirish.h" -#define LED_PIN 13 #define PWM_PIN 2 -void setup() -{ +void setup() { /* Set up the LED to blink */ - pinMode(LED_PIN, OUTPUT); + pinMode(BOARD_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); @@ -17,28 +19,20 @@ void setup() /* Send a message out the usb virtual serial port */ SerialUSB.println("Hello!"); - - /* Turn on PWM on pin PWM_PIN */ - pinMode(PWM_PIN, PWM); - pwmWrite(PWM_PIN, 0x8000); } -int toggle = 0; - void loop() { - toggle ^= 1; - digitalWrite(LED_PIN, toggle); + toggleLED(); delay(100); } // 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() { +__attribute__(( constructor )) void premain() { init(); } -int main(void) -{ +int main(void) { setup(); while (1) { |
