Reformat ArduinoBlinkLED example

This commit is contained in:
Kristian Sloth Lauszus 2013-10-30 15:21:50 +01:00
parent 39e28822ba
commit 3c3b8ec986

View file

@ -3,40 +3,38 @@
#include <adk.h> #include <adk.h>
USB Usb; USB Usb;
ADK adk(&Usb,"TKJElectronics", // Manufacturer Name ADK adk(&Usb, "TKJElectronics", // Manufacturer Name
"ArduinoBlinkLED", // Model Name "ArduinoBlinkLED", // Model Name
"Example sketch for the USB Host Shield", // Description (user-visible string) "Example sketch for the USB Host Shield", // Description (user-visible string)
"1.0", // Version "1.0", // Version
"http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory) "http://www.tkjelectronics.dk/uploads/ArduinoBlinkLED.apk", // URL (web page to visit if no installed apps support the accessory)
"123456789"); // Serial Number (optional) "123456789"); // Serial Number (optional)
#define LED 13 // Pin 13 is occupied by the SCK pin on a normal Arduino (Uno, Duemilanove etc.), so use a different pin #define LED LED_BUILTIN // Pin 13 is occupied by the SCK pin on a normal Arduino (Uno, Duemilanove etc.), so use a different pin
void setup() void setup() {
{
Serial.begin(115200); Serial.begin(115200);
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
if (Usb.Init() == -1) { if (Usb.Init() == -1) {
Serial.print("\r\nOSCOKIRQ failed to assert"); Serial.print("\r\nOSCOKIRQ failed to assert");
while(1); //halt while (1); // halt
} }
pinMode(LED, OUTPUT); pinMode(LED, OUTPUT);
Serial.print("\r\nArduino Blink LED Started"); Serial.print("\r\nArduino Blink LED Started");
} }
void loop() void loop() {
{
Usb.Task(); Usb.Task();
if(adk.isReady()) { if (adk.isReady()) {
uint8_t msg[1]; uint8_t msg[1];
uint16_t len = sizeof(msg); uint16_t len = sizeof(msg);
uint8_t rcode = adk.RcvData(&len, msg); uint8_t rcode = adk.RcvData(&len, msg);
if(rcode && rcode != hrNAK) if (rcode && rcode != hrNAK)
USBTRACE2("Data rcv. :", rcode); USBTRACE2("Data rcv. :", rcode);
if(len > 0) { else if (len > 0) {
Serial.print(F("\r\nData Packet: ")); Serial.print(F("\r\nData Packet: "));
Serial.print(msg[0]); Serial.print(msg[0]);
digitalWrite(LED,msg[0] ? HIGH : LOW); digitalWrite(LED, msg[0] ? HIGH : LOW);
} }
} }
else else