| 1 |
/* |
| 2 |
main.cpp - Main loop for Arduino sketches |
| 3 |
Copyright (c) 2005-2013 Arduino Team. All right reserved. |
| 4 |
|
| 5 |
This library is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU Lesser General Public |
| 7 |
License as published by the Free Software Foundation; either |
| 8 |
version 2.1 of the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This library is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
Lesser General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU Lesser General Public |
| 16 |
License along with this library; if not, write to the Free Software |
| 17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <Arduino.h> |
| 21 |
|
| 22 |
// Declared weak in Arduino.h to allow user redefinitions. |
| 23 |
int atexit(void (* /*func*/ )()) { return 0; } |
| 24 |
|
| 25 |
// Weak empty variant initialization function. |
| 26 |
// May be redefined by variant files. |
| 27 |
void initVariant() __attribute__((weak)); |
| 28 |
void initVariant() { } |
| 29 |
|
| 30 |
void setupUSB() __attribute__((weak)); |
| 31 |
void setupUSB() { } |
| 32 |
|
| 33 |
int main(void) |
| 34 |
{ |
| 35 |
init(); |
| 36 |
|
| 37 |
initVariant(); |
| 38 |
|
| 39 |
#if defined(USBCON) |
| 40 |
USBDevice.attach(); |
| 41 |
#endif |
| 42 |
|
| 43 |
setup(); |
| 44 |
|
| 45 |
for (;;) { |
| 46 |
loop(); |
| 47 |
if (serialEventRun) serialEventRun(); |
| 48 |
} |
| 49 |
|
| 50 |
return 0; |
| 51 |
} |
| 52 |
|