forked from backupbrain/ArduinoBoardManager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduinoBoardManager.cpp
132 lines (112 loc) · 4.53 KB
/
ArduinoBoardManager.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*-------------------------------------------------------------------------
Arduino library to determine the Arduino models and features,
as well as the SDK version.
Most features can be accessed via static variables.
You must instantiate if you want to know if the name of the board
or if specific features such exist, for example multiple serial
connections on the Arduino Mega.
This list may be neither comprehensive nor up to date
A full list of boards and processor names are available on Wikipedia:
https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems
@author Tony Gaitatzis [email protected]
@date 2015-12-10
-------------------------------------------------------------------------
This file is part of the Arduino Board Manager library
NeoPixel is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
NeoPixel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with NeoPixel. If not, see
<http://www.gnu.org/licenses/>.
-------------------------------------------------------------------------*/
#include "ArduinoBoardManager.h"
ArduinoBoardManager::ArduinoBoardManager() {
// clear the features
memset(FEATURES, false, NUM_FEATURES);
static const unsigned long BOARD_UNKNOWN = 0x0;
static const unsigned long BOARD_UNO = 0x01;
static const unsigned long BOARD_ZERO = 0x02;
static const unsigned long BOARD_DUE = 0x03;
static const unsigned long BOARD_MICRO= 0x04;
static const unsigned long BOARD_YUN_400 = 0x05;
static const unsigned long BOARD_LEONARDO = 0x06;
static const unsigned long BOARD_MEGA = 0x07;
static const unsigned long BOARD_NANO = 0x08;
static const unsigned long BOARD_NANO_3 = 0x09;
static const unsigned long BOARD_LILYPAD = 0x08;
static const unsigned long BOARD_TRINKET = 0x09;
switch (ArduinoBoardManager::BOARD) {
case ArduinoBoardManager::BOARD_UNO:
strcpy(BOARD_NAME, "UNO");
strcpy(CPU_NAME, "ATmega328P");
break;
case ArduinoBoardManager::BOARD_ZERO:
strcpy(BOARD_NAME, "Zero");
strcpy(CPU_NAME, "ATSAMD21G18A");
FEATURES[ArduinoBoardManager::FEATURE_ANALOG_OUT] = true;
break;
case ArduinoBoardManager::BOARD_DUE:
strcpy(BOARD_NAME, "Due");
strcpy(CPU_NAME, "ATSAM3X8E");
FEATURES[ArduinoBoardManager::FEATURE_ANALOG_OUT] = true;
break;
case ArduinoBoardManager::BOARD_MICRO:
strcpy(BOARD_NAME, "Micro");
strcpy(CPU_NAME, "Atmega32U4");
break;
case ArduinoBoardManager::BOARD_YUN_400:
strcpy(BOARD_NAME, "Yun");
strcpy(CPU_NAME, "AR9331");
break;
case ArduinoBoardManager::BOARD_LEONARDO:
strcpy(BOARD_NAME, "Leonardo");
strcpy(CPU_NAME, "ATmega16U4");
break;
case ArduinoBoardManager::BOARD_MEGA:
strcpy(BOARD_NAME, "Mega");
strcpy(CPU_NAME, "ATmega1280");
FEATURES[ArduinoBoardManager::FEATURE_MULTIPLE_SERIAL] = true;
break;
case ArduinoBoardManager::BOARD_NANO:
strcpy(BOARD_NAME, "Nano");
strcpy(CPU_NAME, "ATmega168");
break;
case ArduinoBoardManager::BOARD_NANO_3:
strcpy(BOARD_NAME, "Nano");
strcpy(CPU_NAME, "ATmega328");
break;
case ArduinoBoardManager::BOARD_LILYPAD:
strcpy(BOARD_NAME, "Lilypad");
strcpy(CPU_NAME, "ATmega168V");
break;
case ArduinoBoardManager::BOARD_LILYPAD_2:
strcpy(BOARD_NAME, "Lilypad");
strcpy(CPU_NAME, "ATmega328V");
break;
case ArduinoBoardManager::BOARD_TRINKET:
strcpy(BOARD_NAME, "Trinket");
strcpy(CPU_NAME, "ATTiny85");
break;
case ArduinoBoardManager::BOARD_101:
strcpy(BOARD_NAME, "101");
strcpy(CPU_NAME, "ARCv2EM");
FEATURES[ArduinoBoardManager::FEATURE_BLUETOOTH_4] = true;
FEATURES[ArduinoBoardManager::FEATURE_ACCELEROMETER] = true;
FEATURES[ArduinoBoardManager::FEATURE_GYROSCOPE] = true;
break;
default:
strcpy(BOARD_NAME, "Unknown");
strcpy(CPU_NAME, "Unknown");
}
}
bool ArduinoBoardManager::featureExists(uint8_t feature) {
if ((feature < ArduinoBoardManager::NUM_FEATURES) &&
(ArduinoBoardManager::FEATURES[feature]))
return true;
return false;
}