aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp.example
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-02-08 22:38:21 -0500
committerMarti Bolivar <mbolivar@leaflabs.com>2011-02-10 17:50:26 -0500
commit05bb1e666f9542d5636645cf69df5d3741f2bc2e (patch)
tree2f3ab188df737fbbf9498dec869a3105ff7d50a8 /main.cpp.example
parentb84da9db8f61fcc79c9594cabb97ebc5142eb267 (diff)
downloadlibrambutan-05bb1e666f9542d5636645cf69df5d3741f2bc2e.tar.gz
librambutan-05bb1e666f9542d5636645cf69df5d3741f2bc2e.zip
Function examples/test-session.cpp on Native
Diffstat (limited to 'main.cpp.example')
-rw-r--r--main.cpp.example28
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) {