Skip to content

Commit ec5c61b

Browse files
committed
Housekeeping
1 parent 1b7e3cc commit ec5c61b

File tree

24 files changed

+592
-230
lines changed

24 files changed

+592
-230
lines changed

digistump-avr/cores/pro/Stream.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi
7575
// find returns true if the target string is found
7676
bool Stream::find(char *target)
7777
{
78-
return findUntil(target, "");
78+
return findUntil(target, strlen(target), NULL, 0);
7979
}
8080

8181
// reads data from the stream until the target string of given length is found

digistump-avr/cores/pro/TinySoftwareSPI.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void SoftSPIClass::begin(byte SCK_, byte MOSI_, byte MISO_, byte SS_){
7777
}
7878
}
7979

80-
byte SoftSPIClass::noTransfer(byte _data){
80+
byte SoftSPIClass::noTransfer(byte _data __attribute__((unused))){
8181
//This does nothing. If you call SPI.transfer() before calling begin() or after calling end(), the call will be redirected here to avoid crash.
8282
return 0xFF;
8383
}
@@ -208,7 +208,7 @@ void SoftSPIClass::setDataMode(uint8_t mode)
208208
}
209209
}
210210

211-
void SoftSPIClass::setClockDivider(uint8_t rate)
211+
void SoftSPIClass::setClockDivider(uint8_t rate __attribute__((unused)))
212212
{
213213

214214
//does nothing as the speed cannot be changed - fixed at Fcpu/16

digistump-avr/cores/tiny/WInterrupts.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include "WConstants.h"
3737
#include "wiring_private.h"
3838

39-
volatile static voidFuncPtr intFunc[NUMBER_EXTERNAL_INTERRUPTS];
39+
static volatile voidFuncPtr intFunc[NUMBER_EXTERNAL_INTERRUPTS];
4040

4141
#if defined( MCUCR ) && ! defined( EICRA )
4242
#define EICRA MCUCR

digistump-avr/libraries/DigisparkCDC/osccal.c

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <avr/io.h>
11+
#include "usbdrv.h" // for usbMeasureFrameLength()
1112

1213
#ifndef uchar
1314
#define uchar unsigned char

digistump-avr/libraries/DigisparkJoystick/Readme.txt

+23-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CPU CORE CLOCK FREQUENCY
4949
========================
5050
We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz,
5151
16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The
52-
actual clock rate must be configured in usbdrv.h.
52+
actual clock rate must be configured in usbconfig.h.
5353

5454
12 MHz Clock
5555
This is the traditional clock rate of V-USB because it's the lowest clock
@@ -113,13 +113,28 @@ IDs. See http://www.obdev.at/vusb/ for details.
113113
DEVELOPMENT SYSTEM
114114
==================
115115
This driver has been developed and optimized for the GNU compiler version 3
116-
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
117-
that you use the GNU compiler suite because it is freely available. V-USB
118-
has also been ported to the IAR compiler and assembler. It has been tested
119-
with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the "small" and "tiny"
120-
memory model. Not every release is tested with IAR CC and the driver may
121-
therefore fail to compile with IAR. Please note that gcc is more efficient for
122-
usbdrv.c because this module has been deliberately optimized for gcc.
116+
and 4. We recommend that you use the GNU compiler suite because it is freely
117+
available. V-USB has also been ported to the IAR compiler and assembler. It
118+
has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the
119+
"small" and "tiny" memory model. Not every release is tested with IAR CC and
120+
the driver may therefore fail to compile with IAR. Please note that gcc is
121+
more efficient for usbdrv.c because this module has been deliberately
122+
optimized for gcc.
123+
124+
Gcc version 3 produces smaller code than version 4 due to new optimizing
125+
capabilities which don't always improve things on 8 bit CPUs. The code size
126+
generated by gcc 4 can be reduced with the compiler options
127+
-fno-move-loop-invariants, -fno-tree-scev-cprop and
128+
-fno-inline-small-functions in addition to -Os. On devices with more than
129+
8k of flash memory, we also recommend the linker option --relax (written as
130+
-Wl,--relax for gcc) to convert absolute calls into relative where possible.
131+
132+
For more information about optimizing options see:
133+
134+
http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html
135+
136+
These optimizations are good for gcc 4.x. Version 3.x of gcc does not support
137+
most of these options and produces good code anyway.
123138

124139

125140
USING V-USB FOR FREE

digistump-avr/libraries/DigisparkJoystick/usbdrv.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ uchar usbCurrentDataToken;/* when we check data toggling to ignore duplica
4545
#endif
4646

4747
/* USB status registers / not shared with asm code */
48-
const uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
48+
uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
4949
static usbMsgLen_t usbMsgLen = USB_NO_MSG; /* remaining number of bytes */
50-
static uchar usbMsgFlags; /* flag values see below */
50+
uchar usbMsgFlags; /* flag values see USB_FLG_* */
5151

52-
#define USB_FLG_MSGPTR_IS_ROM (1<<6)
5352
#define USB_FLG_USE_USER_RW (1<<7)
5453

5554
/*
@@ -335,6 +334,9 @@ uchar flags = USB_FLG_MSGPTR_IS_ROM;
335334
GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER, usbDescriptorStringSerialNumber)
336335
SWITCH_DEFAULT
337336
if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
337+
if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_RAM){
338+
flags = 0;
339+
}
338340
len = usbFunctionDescriptor(rq);
339341
}
340342
SWITCH_END
@@ -347,6 +349,9 @@ uchar flags = USB_FLG_MSGPTR_IS_ROM;
347349
#endif
348350
SWITCH_DEFAULT
349351
if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
352+
if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_RAM){
353+
flags = 0;
354+
}
350355
len = usbFunctionDescriptor(rq);
351356
}
352357
SWITCH_END
@@ -498,7 +503,8 @@ static uchar usbDeviceRead(uchar *data, uchar len)
498503
}else
499504
#endif
500505
{
501-
uchar i = len, *r = usbMsgPtr;
506+
uchar i = len;
507+
usbMsgPtr_t r = usbMsgPtr;
502508
if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
503509
do{
504510
uchar c = USB_READ_FLASH(r); /* assign to char size variable to enforce byte ops */

digistump-avr/libraries/DigisparkJoystick/usbdrv.h

+22-2
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,17 @@ USB messages, even if they address another (low-speed) device on the same bus.
164164
*/
165165
#define USB_NO_MSG ((usbMsgLen_t)-1) /* constant meaning "no message" */
166166

167+
#ifndef usbMsgPtr_t
168+
#define usbMsgPtr_t uchar *
169+
#endif
170+
/* Making usbMsgPtr_t a define allows the user of this library to define it to
171+
* an 8 bit type on tiny devices. This reduces code size, especially if the
172+
* compiler supports a tiny memory model.
173+
* The type can be a pointer or scalar type, casts are made where necessary.
174+
* Although it's paradoxical, Gcc 4 generates slightly better code for scalar
175+
* types than for pointers.
176+
*/
177+
167178
struct usbRequest; /* forward declaration */
168179

169180
#ifdef __cplusplus
@@ -182,11 +193,20 @@ USB_PUBLIC void usbPoll(void);
182193
* Please note that debug outputs through the UART take ~ 0.5ms per byte
183194
* at 19200 bps.
184195
*/
185-
extern const uchar *usbMsgPtr;
196+
extern uchar *usbMsgPtr;
186197
/* This variable may be used to pass transmit data to the driver from the
187198
* implementation of usbFunctionWrite(). It is also used internally by the
188199
* driver for standard control requests.
189200
*/
201+
202+
extern uchar usbMsgFlags; /* flag values see USB_FLG_* */
203+
/* Can be set to `USB_FLG_MSGPTR_IS_ROM` in `usbFunctionSetup()` or
204+
* `usbFunctionDescriptor()` if `usbMsgPtr` has been set to a flash memory
205+
* address.
206+
*/
207+
208+
#define USB_FLG_MSGPTR_IS_ROM (1<<6)
209+
190210
USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]);
191211
/* This function is called when the driver receives a SETUP transaction from
192212
* the host which is not answered by the driver itself (in practice: class and
@@ -335,7 +355,7 @@ extern unsigned usbCrc16Append(unsigned data, uchar len);
335355
* bytes.
336356
*/
337357
#if USB_CFG_HAVE_MEASURE_FRAME_LENGTH
338-
extern unsigned usbMeasureFrameLength(void);
358+
extern unsigned usbMeasureFrameLength(void); // defined in usbdrvasm.S
339359
/* This function MUST be called IMMEDIATELY AFTER USB reset and measures 1/7 of
340360
* the number of CPU cycles during one USB frame minus one low speed bit
341361
* length. In other words: return value = 1499 * (F_CPU / 10.5 MHz)

digistump-avr/libraries/DigisparkKeyboard/DigiKeyboard.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ class DigiKeyboardDevice : public Print {
162162
size_t write(uint8_t chr) {
163163
uint8_t data = 0;
164164
if (chr == 0x09) {
165-
data = KEY_TAB;
165+
data = (uint8_t)KEY_TAB;
166166
}else if (chr == 0x0a) {
167-
data = KEY_ENTER;
167+
data = (uint8_t)KEY_ENTER;
168168
}else if (chr >= 0x20) {
169169
data = pgm_read_byte_near(keycodes_ascii + (chr - 0x20));
170170
}

digistump-avr/libraries/DigisparkKeyboard/Readme.txt

+23-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ CPU CORE CLOCK FREQUENCY
4949
========================
5050
We supply assembler modules for clock frequencies of 12 MHz, 12.8 MHz, 15 MHz,
5151
16 MHz, 16.5 MHz 18 MHz and 20 MHz. Other clock rates are not supported. The
52-
actual clock rate must be configured in usbdrv.h.
52+
actual clock rate must be configured in usbconfig.h.
5353

5454
12 MHz Clock
5555
This is the traditional clock rate of V-USB because it's the lowest clock
@@ -113,13 +113,28 @@ IDs. See http://www.obdev.at/vusb/ for details.
113113
DEVELOPMENT SYSTEM
114114
==================
115115
This driver has been developed and optimized for the GNU compiler version 3
116-
(gcc 3). It does work well with gcc 4, but with bigger code size. We recommend
117-
that you use the GNU compiler suite because it is freely available. V-USB
118-
has also been ported to the IAR compiler and assembler. It has been tested
119-
with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the "small" and "tiny"
120-
memory model. Not every release is tested with IAR CC and the driver may
121-
therefore fail to compile with IAR. Please note that gcc is more efficient for
122-
usbdrv.c because this module has been deliberately optimized for gcc.
116+
and 4. We recommend that you use the GNU compiler suite because it is freely
117+
available. V-USB has also been ported to the IAR compiler and assembler. It
118+
has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8 with the
119+
"small" and "tiny" memory model. Not every release is tested with IAR CC and
120+
the driver may therefore fail to compile with IAR. Please note that gcc is
121+
more efficient for usbdrv.c because this module has been deliberately
122+
optimized for gcc.
123+
124+
Gcc version 3 produces smaller code than version 4 due to new optimizing
125+
capabilities which don't always improve things on 8 bit CPUs. The code size
126+
generated by gcc 4 can be reduced with the compiler options
127+
-fno-move-loop-invariants, -fno-tree-scev-cprop and
128+
-fno-inline-small-functions in addition to -Os. On devices with more than
129+
8k of flash memory, we also recommend the linker option --relax (written as
130+
-Wl,--relax for gcc) to convert absolute calls into relative where possible.
131+
132+
For more information about optimizing options see:
133+
134+
http://www.tty1.net/blog/2008-04-29-avr-gcc-optimisations_en.html
135+
136+
These optimizations are good for gcc 4.x. Version 3.x of gcc does not support
137+
most of these options and produces good code anyway.
123138

124139

125140
USING V-USB FOR FREE

digistump-avr/libraries/DigisparkKeyboard/USB-ID-FAQ.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version 2009-08-22
1+
Version 2012-07-09
22

33
==========================
44
WHY DO WE NEED THESE IDs?
@@ -107,8 +107,8 @@ WHO IS THE OWNER OF THE VENDOR-ID?
107107
Objective Development has obtained ranges of USB Product-IDs under two
108108
Vendor-IDs: Under Vendor-ID 5824 from Wouter van Ooijen (Van Ooijen
109109
Technische Informatica, www.voti.nl) and under Vendor-ID 8352 from Jason
110-
Kotzin (Clay Logic, www.claylogic.com). Both VID owners have received their
111-
Vendor-ID directly from usb.org.
110+
Kotzin (now flirc.tv, Inc.). Both VID owners have received their Vendor-ID
111+
directly from usb.org.
112112

113113

114114
=========================================================================

digistump-avr/libraries/DigisparkKeyboard/USB-IDs-for-free.txt

+25-5
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ If you use one of the IDs listed below, your device and host-side software
8686
must conform to these rules:
8787

8888
(1) The USB device MUST provide a textual representation of the serial
89-
number. The serial number string MUST be available at least in USB language
90-
0x0409 (English/US).
89+
number, unless ONLY the operating system's default class driver is used.
90+
The serial number string MUST be available at least in USB language 0x0409
91+
(English/US).
9192

9293
(2) The serial number MUST start with either an Internet domain name (e.g.
9394
"mycompany.com") registered and owned by you, or an e-mail address under your
@@ -108,6 +109,11 @@ driver for Vendor Class devices is needed, this driver must be libusb or
108109
libusb-win32 (see http://libusb.org/ and
109110
http://libusb-win32.sourceforge.net/).
110111

112+
(7) If ONLY the operating system's default class driver is used, e.g. for
113+
mice, keyboards, joysticks, CDC or MIDI devices and no discrimination by an
114+
application is needed, the serial number may be omitted.
115+
116+
111117
Table if IDs for discrimination by serial number string:
112118

113119
PID dec (hex) | VID dec (hex) | Description of use
@@ -121,12 +127,26 @@ PID dec (hex) | VID dec (hex) | Description of use
121127
---------------+---------------+-------------------------------------------
122128
10203 (0x27db) | 5824 (0x16c0) | For USB Keyboards
123129
---------------+---------------+-------------------------------------------
124-
10204 (0x27db) | 5824 (0x16c0) | For USB Joysticks
130+
10204 (0x27dc) | 5824 (0x16c0) | For USB Joysticks
131+
---------------+---------------+-------------------------------------------
132+
10205 (0x27dd) | 5824 (0x16c0) | For CDC-ACM class devices (modems)
133+
---------------+---------------+-------------------------------------------
134+
10206 (0x27de) | 5824 (0x16c0) | For MIDI class devices
125135
---------------+---------------+-------------------------------------------
126-
10205 (0x27dc) | 5824 (0x16c0) | For CDC-ACM class devices (modems)
136+
10207 (0x27df) | 5824 (0x16c0) | For Mass Storage class devices
127137
---------------+---------------+-------------------------------------------
128-
10206 (0x27dd) | 5824 (0x16c0) | For MIDI class devices
138+
10208 (0x27e0) | 5824 (0x16c0) | For Audio class devices
129139
---------------+---------------+-------------------------------------------
140+
10209 (0x27e1) | 5824 (0x16c0) | For CDC-ECM class devices
141+
---------------+---------------+-------------------------------------------
142+
10210 (0x27e2) | 5824 (0x16c0) | For MTP class devices
143+
---------------+---------------+-------------------------------------------
144+
145+
Note that the last six cannot be implemented using V-USB in a standards
146+
compliant way because they require bulk endpoints which are forbidden for
147+
low speed devices. We provide them nevertheless, either if you want to
148+
implement a non-compliant device or implement it using other technology
149+
than V-USB.
130150

131151

132152
=================

0 commit comments

Comments
 (0)