Skip to content

Commit 948a5c8

Browse files
committed
Added support for Arduino Esplora
1 parent 2e5851c commit 948a5c8

File tree

18 files changed

+1132
-0
lines changed

18 files changed

+1132
-0
lines changed

build/shared/revisions.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2+
[hardware]
3+
4+
* Added support for the Arduino Esplora
5+
16
ARDUINO 1.0.2 - 2012.11.05
27

38
[hardware]
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
;************************************************************
2+
; Windows USB CDC ACM Setup File
3+
; Copyright (c) 2000 Microsoft Corporation
4+
5+
6+
[Version]
7+
Signature="$Windows NT$"
8+
Class=Ports
9+
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
10+
Provider=%MFGNAME%
11+
LayoutFile=layout.inf
12+
CatalogFile=%MFGFILENAME%.cat
13+
DriverVer=11/15/2007,5.1.2600.0
14+
15+
[Manufacturer]
16+
%MFGNAME%=DeviceList, NTamd64
17+
18+
[DestinationDirs]
19+
DefaultDestDir=12
20+
21+
22+
;------------------------------------------------------------------------------
23+
; Windows 2000/XP/Vista-32bit Sections
24+
;------------------------------------------------------------------------------
25+
26+
[DriverInstall.nt]
27+
include=mdmcpq.inf
28+
CopyFiles=DriverCopyFiles.nt
29+
AddReg=DriverInstall.nt.AddReg
30+
31+
[DriverCopyFiles.nt]
32+
usbser.sys,,,0x20
33+
34+
[DriverInstall.nt.AddReg]
35+
HKR,,DevLoader,,*ntkern
36+
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
37+
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
38+
39+
[DriverInstall.nt.Services]
40+
AddService=usbser, 0x00000002, DriverService.nt
41+
42+
[DriverService.nt]
43+
DisplayName=%SERVICE%
44+
ServiceType=1
45+
StartType=3
46+
ErrorControl=1
47+
ServiceBinary=%12%\%DRIVERFILENAME%.sys
48+
49+
;------------------------------------------------------------------------------
50+
; Vista-64bit Sections
51+
;------------------------------------------------------------------------------
52+
53+
[DriverInstall.NTamd64]
54+
include=mdmcpq.inf
55+
CopyFiles=DriverCopyFiles.NTamd64
56+
AddReg=DriverInstall.NTamd64.AddReg
57+
58+
[DriverCopyFiles.NTamd64]
59+
%DRIVERFILENAME%.sys,,,0x20
60+
61+
[DriverInstall.NTamd64.AddReg]
62+
HKR,,DevLoader,,*ntkern
63+
HKR,,NTMPDriver,,%DRIVERFILENAME%.sys
64+
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
65+
66+
[DriverInstall.NTamd64.Services]
67+
AddService=usbser, 0x00000002, DriverService.NTamd64
68+
69+
[DriverService.NTamd64]
70+
DisplayName=%SERVICE%
71+
ServiceType=1
72+
StartType=3
73+
ErrorControl=1
74+
ServiceBinary=%12%\%DRIVERFILENAME%.sys
75+
76+
77+
;------------------------------------------------------------------------------
78+
; Vendor and Product ID Definitions
79+
;------------------------------------------------------------------------------
80+
; When developing your USB device, the VID and PID used in the PC side
81+
; application program and the firmware on the microcontroller must match.
82+
; Modify the below line to use your VID and PID. Use the format as shown below.
83+
; Note: One INF file can be used for multiple devices with different VID and PIDs.
84+
; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
85+
;------------------------------------------------------------------------------
86+
[SourceDisksFiles]
87+
[SourceDisksNames]
88+
[DeviceList]
89+
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_003C
90+
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_803C&MI_00
91+
92+
[DeviceList.NTamd64]
93+
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_003C
94+
%DESCRIPTION%=DriverInstall, USB\VID_2341&PID_803C&MI_00
95+
96+
;------------------------------------------------------------------------------
97+
; String Definitions
98+
;------------------------------------------------------------------------------
99+
;Modify these strings to customize your device
100+
;------------------------------------------------------------------------------
101+
[Strings]
102+
MFGFILENAME="CDC_vista"
103+
DRIVERFILENAME ="usbser"
104+
MFGNAME="Arduino LLC (www.arduino.cc)"
105+
INSTDISK="Arduino Esplora Driver Installer"
106+
DESCRIPTION="Arduino Esplora"
107+
SERVICE="USB RS-232 Emulation Driver"

hardware/arduino/boards.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,27 @@ leonardo.build.variant=leonardo
167167

168168
##############################################################
169169

170+
esplora.name=Arduino Esplora
171+
esplora.upload.protocol=avr109
172+
esplora.upload.maximum_size=28672
173+
esplora.upload.speed=57600
174+
esplora.upload.disable_flushing=true
175+
esplora.bootloader.low_fuses=0xff
176+
esplora.bootloader.high_fuses=0xd8
177+
esplora.bootloader.extended_fuses=0xcb
178+
esplora.bootloader.path=caterina
179+
esplora.bootloader.file=Caterina-Esplora.hex
180+
esplora.bootloader.unlock_bits=0x3F
181+
esplora.bootloader.lock_bits=0x2F
182+
esplora.build.mcu=atmega32u4
183+
esplora.build.f_cpu=16000000L
184+
esplora.build.vid=0x2341
185+
esplora.build.pid=0x803C
186+
esplora.build.core=arduino
187+
esplora.build.variant=leonardo
188+
189+
##############################################################
190+
170191
micro.name=Arduino Micro
171192
micro.upload.protocol=avr109
172193
micro.upload.maximum_size=28672

hardware/arduino/bootloaders/caterina/Caterina.c

100755100644
File mode changed.

hardware/arduino/bootloaders/caterina/Caterina.h

100755100644
File mode changed.

hardware/arduino/bootloaders/caterina/Descriptors.c

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ const USB_Descriptor_String_t ProductString =
197197
.UnicodeString = L"Arduino Leonardo"
198198
#elif DEVICE_PID == 0x0037
199199
.UnicodeString = L"Arduino Micro "
200+
#elif DEVICE_PID == 0x003C
201+
.UnicodeString = L"Arduino Esplora "
200202
#else
201203
.UnicodeString = L"USB IO board "
202204
#endif

hardware/arduino/bootloaders/caterina/Descriptors.h

100755100644
File mode changed.

hardware/arduino/bootloaders/caterina/Makefile

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
# PID = 0x0036
5858
# official Micro PID
5959
# PID = 0x0037
60+
# official Esplora PID
61+
# PID = 0x003C
6062

6163
# MCU name
6264
MCU = atmega32u4

hardware/arduino/cores/arduino/USBCore.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ const u16 STRING_IPRODUCT[17] = {
5555
'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
5656
#elif USB_PID == 0x8037
5757
'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' '
58+
#elif USB_PID == 0x803C
59+
'A','r','d','u','i','n','o',' ','E','s','p','l','o','r','a',' '
5860
#elif USB_PID == 0x9208
5961
'L','i','l','y','P','a','d','U','S','B',' ',' ',' ',' ',' ',' '
6062
#else

libraries/Esplora/Esplora.cpp

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/*
2+
Esplora.cpp - Arduino Esplora board library
3+
Written by Enrico Gueli
4+
Copyright (c) 2012 Arduino(TM) All right reserved.
5+
6+
This library is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU Lesser General Public
8+
License as published by the Free Software Foundation; either
9+
version 2.1 of the License, or (at your option) any later version.
10+
11+
This library is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
Lesser General Public License for more details.
15+
16+
You should have received a copy of the GNU Lesser General Public
17+
License along with this library; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*/
20+
21+
22+
#include "Esplora.h"
23+
24+
_Esplora Esplora;
25+
26+
/*
27+
* The following constants tell, for each accelerometer
28+
* axis, which values are returned when the axis measures
29+
* zero acceleration.
30+
*/
31+
const int ACCEL_ZERO_X = 320;
32+
const int ACCEL_ZERO_Y = 330;
33+
const int ACCEL_ZERO_Z = 310;
34+
35+
const byte MUX_ADDR_PINS[] = { A0, A1, A2, A3 };
36+
const byte MUX_COM_PIN = A4;
37+
38+
const int JOYSTICK_DEAD_ZONE = 100;
39+
40+
const byte RED_PIN = 5;
41+
const byte BLUE_PIN = 9;
42+
const byte GREEN_PIN = 10;
43+
44+
const byte BUZZER_PIN = 6;
45+
46+
// non-multiplexer Esplora pins:
47+
// Accelerometer: x-A5, y-A7, z-A6
48+
// External outputs: D3, D11
49+
// Buzzer: A8
50+
// RGB Led: red-D5, green-D10/A11, blue-D9/A10
51+
// Led 13: D13
52+
53+
const byte ACCEL_X_PIN = A5;
54+
const byte ACCEL_Y_PIN = A11;
55+
const byte ACCEL_Z_PIN = A6;
56+
57+
const byte LED_PIN = 13;
58+
59+
_Esplora::_Esplora() {
60+
for (byte p=0; p<4; p++) {
61+
pinMode(MUX_ADDR_PINS[p], OUTPUT);
62+
}
63+
pinMode(RED_PIN, OUTPUT);
64+
pinMode(GREEN_PIN, OUTPUT);
65+
pinMode(BLUE_PIN, OUTPUT);
66+
}
67+
68+
unsigned int _Esplora::readChannel(byte channel) {
69+
digitalWrite(MUX_ADDR_PINS[0], (channel & 1) ? HIGH : LOW);
70+
digitalWrite(MUX_ADDR_PINS[1], (channel & 2) ? HIGH : LOW);
71+
digitalWrite(MUX_ADDR_PINS[2], (channel & 4) ? HIGH : LOW);
72+
digitalWrite(MUX_ADDR_PINS[3], (channel & 8) ? HIGH : LOW);
73+
// workaround to cope with lack of pullup resistor on joystick switch
74+
if (channel == CH_JOYSTICK_SW) {
75+
pinMode(MUX_COM_PIN, INPUT_PULLUP);
76+
unsigned int joystickSwitchState = (digitalRead(MUX_COM_PIN) == HIGH) ? 1023 : 0;
77+
digitalWrite(MUX_COM_PIN, LOW);
78+
return joystickSwitchState;
79+
}
80+
else
81+
return analogRead(MUX_COM_PIN);
82+
}
83+
84+
boolean _Esplora::joyLowHalf(byte joyCh) {
85+
return (readChannel(joyCh) < 512 - JOYSTICK_DEAD_ZONE)
86+
? LOW : HIGH;
87+
}
88+
89+
boolean _Esplora::joyHighHalf(byte joyCh) {
90+
return (readChannel(joyCh) > 512 + JOYSTICK_DEAD_ZONE)
91+
? LOW : HIGH;
92+
}
93+
94+
boolean _Esplora::readButton(byte ch) {
95+
if (ch >= SWITCH_1 && ch <= SWITCH_4) {
96+
ch--;
97+
}
98+
99+
switch(ch) {
100+
case JOYSTICK_RIGHT:
101+
return joyLowHalf(CH_JOYSTICK_X);
102+
case JOYSTICK_LEFT:
103+
return joyHighHalf(CH_JOYSTICK_X);
104+
case JOYSTICK_UP:
105+
return joyLowHalf(CH_JOYSTICK_Y);
106+
case JOYSTICK_DOWN:
107+
return joyHighHalf(CH_JOYSTICK_Y);
108+
}
109+
110+
unsigned int val = readChannel(ch);
111+
return (val > 512) ? HIGH : LOW;
112+
}
113+
114+
void _Esplora::writeRGB(byte r, byte g, byte b) {
115+
writeRed(r);
116+
writeGreen(g);
117+
writeBlue(b);
118+
}
119+
120+
#define RGB_FUNC(name, pin, lastVar) \
121+
void _Esplora::write##name(byte val) { \
122+
if (val == lastVar) \
123+
return; \
124+
analogWrite(pin, val); \
125+
lastVar = val; \
126+
delay(5); \
127+
} \
128+
\
129+
byte _Esplora::read##name() { \
130+
return lastVar; \
131+
}
132+
133+
RGB_FUNC(Red, RED_PIN, lastRed)
134+
RGB_FUNC(Green, GREEN_PIN, lastGreen)
135+
RGB_FUNC(Blue, BLUE_PIN, lastBlue)
136+
137+
void _Esplora::tone(unsigned int freq) {
138+
if (freq > 0)
139+
::tone(BUZZER_PIN, freq);
140+
else
141+
::noTone(BUZZER_PIN);
142+
}
143+
144+
void _Esplora::tone(unsigned int freq, unsigned long duration) {
145+
if (freq > 0)
146+
::tone(BUZZER_PIN, freq, duration);
147+
else
148+
::noTone(BUZZER_PIN);
149+
}
150+
151+
void _Esplora::noTone() {
152+
::noTone(BUZZER_PIN);
153+
}
154+
155+
int _Esplora::readTemperature(const byte scale) {
156+
long rawT = readChannel(CH_TEMPERATURE);
157+
if (scale == DEGREES_C) {
158+
return (int)((rawT * 500 / 1024) - 50);
159+
}
160+
else if (scale == DEGREES_F) {
161+
return (int)((rawT * 450 / 512 ) - 58);
162+
}
163+
else {
164+
return readTemperature(DEGREES_C);
165+
}
166+
}
167+
168+
int _Esplora::readAccelerometer(const byte axis) {
169+
switch (axis) {
170+
case X_AXIS: return analogRead(ACCEL_X_PIN) - ACCEL_ZERO_X;
171+
case Y_AXIS: return analogRead(ACCEL_Y_PIN) - ACCEL_ZERO_Y;
172+
case Z_AXIS: return analogRead(ACCEL_Z_PIN) - ACCEL_ZERO_Z;
173+
default: return 0;
174+
}
175+
}

0 commit comments

Comments
 (0)