Commit Graph

347 Commits

Author SHA1 Message Date
Matthijs Kooijman 1c6a57e15d Include stdio.h in dtostrf.c
This makes the declaration of sprintf available, so the function is not
implicitely declared, which triggers two compiler warnings.

This helps towards #1792
2014-02-19 16:09:30 +01:00
Matthijs Kooijman 8e35973ff9 Remove check that is always false
len is an unsigned variable, so it will never be less than 0.

This helps towards #1792.
2014-02-19 16:09:30 +01:00
Matthijs Kooijman b196a4a9c5 Suppress "unused parameter" warnings
A bunch of functions have parameters they do not use, but which cannot
be removed for API compatibility.

In syscalls_sam3.c, there are a lot of these, so this adds an "UNUSED"
macro which adds the "unused" variable attribute if supported (GCC
specific), or is just a noop on other compilers.

In CDC.cpp, there's only three of these variables, so this commit just
forces a dummy evaluation of them to suppress the warnings.

This helps towards #1792.
2014-02-19 16:09:30 +01:00
Matthijs Kooijman 4cf21dcdd1 Don't store peeked characters in a char variable
peekNextDigit() returns an int, so it can return -1 in addition to all
256 possible bytes. By putting the result in a signe char, all bytes
over 128 will be interpreted as "no bytes available". Furthermore, it
seems that on SAM "char" is unsigned by default, causing the
"if (c < 0)" line a bit further down to always be false.

Using an int is more appropriate.

A different fix for this issue was suggested in #1399. This fix helps
towards #1728.
2014-02-19 16:09:30 +01:00
Matthijs Kooijman 3035239a4e Use a union in IPAddress for uint8_t[] <-> uint32_t conversion
Previously, pointer casting was used, but this resulted in strict-aliasing warnings:

IPAddress.h: In member function ‘IPAddress::operator uint32_t() const’:
IPAddress.h:46:61: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     operator uint32_t() const { return *((uint32_t*)_address); };
                                                             ^
IPAddress.h: In member function ‘bool IPAddress::operator==(const IPAddress&) const’:
IPAddress.h:47:81: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
                                                                                 ^
IPAddress.h:47:114: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
     bool operator==(const IPAddress& addr) const { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };

Converting between unrelated types like this is commonly done using a union,
which do not break the strict-aliasing rules. Using that union, inside
IPAddress there is now an attribute _address.bytes for the raw byte
arra, or _address.dword for the uint32_t version.

Since we now have easy access to the uint32_t version, this also removes
two memcpy invocations that can just become assignments.

This patch does not change the generated code in any way, the compiler
already optimized away the memcpy calls and the previous casts mean
exactly the same.

This is a different implementation of a part of #1399 and it helps
toward fixing #1728.
2014-02-19 16:09:29 +01:00
Matthijs Kooijman 5b83043290 Include stdint.h from IPAddress.h on SAM
This happened for AVR in 34885b01, this commit makes the SAM version
identical again.
2014-02-18 21:10:35 +01:00
Cristian Maglie 8504bca280 Merge branch 'ide-1.5.x' of github.com:dpslwk/Arduino into dpslwk-ide-1.5.x 2014-02-14 15:35:47 +01:00
Cristian Maglie 79f5a34954 Revert "Changed pins definition in variants from constants to #defines."
This reverts commit e2b15c852b.
2014-02-13 17:37:00 +01:00
Cristian Maglie 397046a844 Added license for Arduino.h, binary.h and main.cpp
See #1847
2014-02-10 12:55:16 +01:00
Cristian Maglie 9eb0c1495c Added license for Client, IPAddressm and Server
See #1847
2014-02-10 12:55:16 +01:00
Jimmy Hedman fb324358ee Compile with -x assembler-with-cpp instead of -assembler-with-cpp.
- Newer avr-gcc doesn't use -assembler-with-cpp, but
  uses -x assembler-with-cpp. This works with older compilers as well.
2014-01-21 21:57:35 +01:00
dpslwk 8364134ada Wire library, move hard references IRQn to defines in variant.h 2014-01-17 20:44:19 +00:00
Matthijs Kooijman dde1a7541f Make some operators in IPAddress const
These functions do not modify the IPAddress object, but were not marked
as const. This meant that you could not do:

void set_ip(const IPAddress& ip) {
	uint32_t copy = ip;
}

Since calling operator uint32_t() on ip would discard the constness of
the reference.
2014-01-15 16:20:48 +01:00
Federico Fissore dfe77f388d Removed = char from #define. See https://github.com/arduino/Arduino/issues/1792#issuecomment-31650586 2014-01-06 18:20:37 +01:00
Federico Fissore 9fce7f1839 Added new EULER constant. Fixes #1792 2014-01-06 09:48:34 +01:00
Cristian Maglie 673847c8b6 Improved portability of String class (maniacbug) 2014-01-01 17:22:40 +01:00
Cristian Maglie e2d373ed61 sam: Added digitalPinHasPWM(..) method
Fixes #1342
2013-12-31 20:58:10 +01:00
Cristian Maglie 90ab663146 sam: moved "variant" methods into proper place 2013-12-31 20:57:14 +01:00
Cristian Maglie c50821ba10 Fixed value of NUM_DIGITAL_PINS for Arduino Due 2013-12-31 20:55:43 +01:00
Matthijs Kooijman 98777e816f Use PGM_P instead of prog_char
On later versions of avr-libc, prog_char is deprecated. In 0acebeeff4
the one occurence of prog_char was replaced by "char PROGMEM", which is
not entirely correct (PROGMEM is supposed to be an attribute on a
variable, not on a type, even though this is how things work in older
libc versions). However, in 1130fede3a a few new occurences of
prog_char are introduced, which break compilation on newer libc versions
again.

This commit changes all these pointer types to use the PGM_P macro from
<avr/pgmspace.h>. This macro is just "const char *" in newer libc
versions and "const prog_char *" in older versions, so it should always
work.

References #795
2013-12-31 20:01:40 +01:00
Cristian Maglie 0b72c88b42 Merge pull request #1762 from matthijskooijman/ide-1.5.x-write-char
Support both char* and uint8* in Stream and Print
2013-12-30 10:58:03 -08:00
Cristian Maglie 825d8c8455 sam: Optimized delayMicroseconds() (Rob Tillaart)
See #1121
2013-12-30 12:17:50 +01:00
Matthijs Kooijman 2ea12d0220 Remove unneeded casts in Print::write(const String&)
Now that Print::write(const char*) is also available, these casts are no
longer needed.
2013-12-24 13:22:43 +01:00
Matthijs Kooijman f304abe35f Add uint8_t* versions of methods in Stream
The new functions just call their char* equivalents, but this allows
reading bytes into a buffer of uint8_t as well as chars.
2013-12-24 13:22:42 +01:00
Matthijs Kooijman 250386802f Add Print::write(const char *, size_t)
The new function just calls Print::write(const uint8_t *, size_t), but
this allows writing out a buffer of chars (without having to learn about
casts).
2013-12-24 13:22:42 +01:00
Cristian Maglie 660c7d86fd Optimized Print::print(String&) (part 2) 2013-12-23 12:04:15 +01:00
Cristian Maglie b530742603 [sam] Fixed regression in analogRead() (fails to read multiple channels) (Mark Tillotson)
See #1740 #1634

http://forum.arduino.cc/index.php?topic=203322.msg1509907#msg1509907
2013-12-18 15:46:42 +01:00
Cristian Maglie a1c4809105 [sam] Fixed regression in analogRead() (fails to read multiple channels)
Fixes #1740
2013-12-16 11:07:45 +01:00
Cristian Maglie 2e7b645571 [sam] Fixed wrap-around bug in delay() (Mark Tillotson)
Fixes #1736
2013-12-14 00:33:57 +01:00
Cristian Maglie e2b15c852b Changed pins definition in variants from constants to #defines. 2013-12-13 15:13:18 +01:00
Cristian Maglie 43f9f15358 Upped version to 1.5.5 2013-11-28 10:53:50 +01:00
Cristian Maglie d5c828736b Revert "SPI library to new format" 2013-11-21 15:05:36 +01:00
Cristian Maglie 71bb7f7ae3 Fixed vid/pid definition for arduino_due_x_dbg in boards.txt. (Luca Baldini)
http://forum.arduino.cc/index.php?topic=197003
2013-11-15 14:01:36 +01:00
Cristian Maglie 9a9652d506 Revert "Wire library to the 1.5 format"
This reverts commit a31857688b.
2013-11-15 12:54:59 +01:00
Cristian Maglie 3ba9480972 Merge pull request #1634 from cmaglie/adc-fix
Improved ADC speed on Arduino Due
2013-11-12 00:57:28 -08:00
Cristian Maglie 56572fa0de Added SERIAL metadata into variant files. 2013-11-11 13:41:04 +01:00
Cristian Maglie 8e3da56624 Added LED_BUILTIN definition to Arduino Due 2013-11-03 18:29:34 +01:00
Cristian Maglie 8f1e3fd703 Using NOT_AN_INTERRUPT defined constant 2013-10-31 12:44:24 +01:00
Cristian Maglie 35d477297d Added pinToInterrupt() variant macro (Paul Stoffregen) 2013-10-31 12:43:41 +01:00
Cristian Maglie 1fc54f5003 [sam] Improved analogRead speed.
See #1418
2013-10-21 12:38:37 +02:00
Fede85 02550de1e9 Merge remote-tracking branch 'origin/ide-1.5.x' into ide-1.5.x 2013-10-10 20:59:01 +02:00
Cristian Maglie 40dce96f11 Fixed adc_init() function.
See #1418
2013-10-09 15:54:47 +02:00
Cristian Maglie a21d92e5c8 [sam] Added empty Serial::begin() with options for CDC-ACM
See #1563
2013-09-30 16:27:07 +02:00
Cristian Maglie f03093332b [sam] Fixed initialization of ADC timings (improves analogRead speed by a factor x10)
Discussion:
http://www.djerickson.com/arduino/
http://forum.arduino.cc/index.php?topic=156849
http://forum.arduino.cc/index.php?topic=187693

Fixes #1418
2013-09-26 01:22:01 +02:00
Fede85 a31857688b Wire library to the 1.5 format 2013-09-10 18:50:42 +02:00
Cristian Maglie 421fa18c3c Updated revision log, and upped version to 1.5.4 2013-09-09 19:47:25 +02:00
Federico Fissore effb59da4b Merge remote-tracking branch 'arduino/ide-1.5.x' into dev-ide-1.5.x-discovery 2013-09-06 12:59:24 +02:00
Cristian Maglie c86eed942d Fixed String class regression after f80c6c5f35
This should make explicit String-from-integer constructor working again:

   int a = 10;
   String(a, 4);
2013-09-03 18:40:30 +02:00
Cristian Maglie 690eac4047 Moved arm-gcc upgrade to specific development branch 2013-08-30 10:58:16 +02:00
Cristian Maglie ea8c14421a Merge branch 'ide-1.5.x' into dev-ide-1.5.x-discovery
Conflicts:
	app/src/processing/app/Preferences.java
	app/src/processing/app/debug/Uploader.java
2013-08-23 15:59:24 +02:00