aboutsummaryrefslogtreecommitdiff
path: root/cores
AgeCommit message (Collapse)Author
2014-06-25Support Atmega8 (and similar that define PE instead of UPE) againMatthijs Kooijman
These chips were previously supported, but since parity error checking was added, this support has broken. Most chips define UPE0 (etc.) for the parity error bit. Some chips don't have numbered UARTS so only define UPE and even fewer define PE instead of UPE. This adds support for those chips again. Closes: #2137
2014-06-19Merge branch 'master' into ide-1.5.xCristian Maglie
2014-06-19Fixed regression in USBAPI and CDC (xaljox)Cristian Maglie
See: https://github.com/arduino/Arduino/commit/9ac7e30252fce5b9dafde3288519b020b73c37bd#commitcomment-6718676
2014-06-13Merge branch 'master' into HEADCristian Maglie
2014-06-10Update USBAPI.hEmbedded Micro
Fixes bug where Serial.read() would always return 0 as the first byte.
2014-06-02Merge pull request #2104 from amulya349/masterCristian Maglie
Fix of a bug in Stream.cpp
2014-05-30Merge branch 'master' into HEADCristian Maglie
2014-05-30USB CDC available() method returns correct number of bytes in buffer.Cristian Maglie
See #1953
2014-05-30Fix of a bugAmulya Kumar Sahoo
Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen() : bool Stream::find(char *target) { return findUntil(target, NULL); } // as find but search ends if the terminator string is found bool Stream::findUntil(char *target, char *terminator) { return findUntil(target, strlen(target), terminator, strlen(terminator)); }
2014-05-30Fix of a bugAmulya Kumar Sahoo
Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen(): bool Stream::find(char *target) { return findUntil(target, NULL); } // as find but search ends if the terminator string is found bool Stream::findUntil(char *target, char *terminator) { return findUntil(target, strlen(target), terminator, strlen(terminator)); }
2014-05-26Merge branch 'usbcdc-improved' into ide-1.5.xCristian Maglie
2014-05-24Improve CDC read codePaul Brook
Read CDC data from USB FIFO on demand instead of in ISR. Remove superfluous ring buffer. Signed-off-by: Paul Brook <paul@nowt.org>
2014-05-24Fix race condition in USB CDC transmitPaul Brook
If the Start of Frame interrupt triggers just after the call to USB_SendSpace in USB_Send then we can get data loss. When the first bank is full and the second partially full, the SOF handler will release the second bank via USB_Flush. Data is then lost due to overflow as USB_Send continues writing data to the now-closed bank. Fix this by re-checking the FIFO status inside LockEP, immediately before doing the data write. Signed-off-by: Paul Brook <paul@nowt.org>
2014-05-24improved USB write speedsJustin Rajewski
2014-05-24Backported Print class from ide-1.5.x branchCristian Maglie
Close #1951
2014-05-23Merge branch 'ide-1.5.x-hwserial-cleanup' of ↵Cristian Maglie
github.com:matthijskooijman/Arduino into matthijskooijman-ide-1.5.x-hwserial-cleanup
2014-05-23Merge remote-tracking branch 'arduino/master' into ide-1.5.xCristian Maglie
Conflicts: build/shared/examples/01.Basics/Blink/Blink.ino build/shared/examples/09.USB/Keyboard/KeyboardReprogram/KeyboardReprogram.ino build/shared/examples/10.StarterKit/p02_SpaceshipInterface/p02_SpaceshipInterface.ino hardware/arduino/cores/arduino/HardwareSerial.cpp
2014-05-07Match return value to type in available()Zachary J. Fields
2014-05-06Remove unneeded register and ISR names in HardwareSerialx.cppMatthijs Kooijman
Before, HardwareSerial1+.cpp were a copy of HardwareSerial1.cpp with all 0's replaced by the corresponding number. This would mean that e.g. the Serial1 object would use the UBRRL register instead of UBRR1L when it was defined, or the USART_RX_vect instead of USART1_RX_vect. In practice, this would neve actually cause problems, since: - No avr chip currently has both the non-numbered registers as well as numbered registers. - HardwareSerial.h would only define HAVE_HWSERIALx when the corresponding numbered register is defined (except for HAVE_HWSERIAL0, which is also defined when the unnumbered registers are present). Furthermore, before both the UARTx_xx_vect and USART_x_xx_vect was used. Looking at the include files, only UART1_xx_vect is actually used (by iom161.h), the others use USARTx_xx_vect. For this reason, HardwareSerial1.cpp keeps the preprocessor conditional to select either UART or USART and the other files use USART unconditionally. While we're here, also fix the compiler error message when no valid ISR name was found (it previously said "for the first UART" in all cases).
2014-05-06Fix comment typoMatthijs Kooijman
2014-05-02Fix EXTERNAL_NUM_INTERRUPTS for atmega128rfa1 and atmega256rfr2Matthijs Kooijman
2014-04-20Fixed other trivial warnings in AVR USB core.Cristian Maglie
See #1877
2014-04-20Removed other unused variables in CDC.cpp and HID.cppCristian Maglie
See #1877
2014-04-20Removed 'USB_MANUFACTURER' constant redefinition for known VIDs.Cristian Maglie
See #1877
2014-04-20Merge branch 'ide-1.5.x-warnings' of github.com:matthijskooijman/Arduino ↵Cristian Maglie
into ide-1.5.x
2014-04-01Merge commit '1ad74' into ide-1.5.xCristian Maglie
2014-04-01Use correct type for index calculation in HardwareSerialCristian Maglie
2014-04-01I forgot a filejantje
2014-04-01Import WString from 1.5.6Matt Jenkins
2014-04-01Fixed string constructor overloading bugMatt Jenkins
2014-03-27Fix typo in SerialEvent3 handlingMatthijs Kooijman
In commit 0e97bcb (Put each HardwareSerial instance in its own .cpp file), the serial event handling was changed. This was probably a copy-paste typo. The effect of this bug was that SerialEvent3 would not run, unless SerialEvent2 was defined, but also that if SerialEvent2 is defined but SerialEvent3 is not, this could cause a reset (call to NULL pointer). This closes #1967, thanks to Peter Olson for finding the bug and fix.
2014-03-24Added support for different size of TX and RX buffer sizes.jantje
Added support for buffer sizes bigger than 256 bytes. Added possibility to overrule the default size. Added support for different size of TX and RX buffer sizes. The default values remain the same. You can however specify a different value for TX and RX buffer Added possibility to overrule the default size. If you want to have different values define SERIAL_TX_BUFFER_SIZE and SERIAL_RX_BUFFER_SIZE on the command line Added support for buffer sizes bigger than 256 bytes. Because of the possibility to change the size of the buffer sizes longer than 256 must be supported. The type of the indexes is decided upon the size of the buffers. So there is no increase in program/data size when the buffers are smaller than 257
2014-03-23This commit contains 2 changes:jantje
Added support for different size of TX and RX buffer sizes. Added support for buffer sizes bigger than 256 bytes. Added support for different size of TX and RX buffer sizes. The default values remain the same. If you want to have different values define SERIAL_TX_BUFFER_SIZE and SERIAL_RX_BUFFER_SIZE on the command line Added support for buffer sizes bigger than 256 bytes. The type of the indexes is decided upon the size of the buffers. So there is no increase in program/data size when the buffers are smaller than 257
2014-02-19Don't store peeked characters in a char variableMatthijs Kooijman
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-19Instead of #defining true and false, include stdbool.hMatthijs Kooijman
In C++, true and false are language keywords, so there is no need to define them as macros. Including stdbool.h in C++ effectively changes nothing. In C, true, false and also the bool type are not available, but including stdbool.h will make them available. Using stdbool.h means that we get true, false and the bool type in whatever way the compiler thinks is best, which seems like a good idea to me. This also fixes the following compiler warnings if a .c file includes both stdbool.h and Arduino.h: warning: "true" redefined [enabled by default] #define true 0x1 warning: "false" redefined [enabled by default] #define false 0x0 This fixes #1570 and helps toward fixing #1728. This only changed the AVR core, the SAM core already doesn't define true and false (but doesn't include stdbool.h either).
2014-02-19Use a union in IPAddress for uint8_t[] <-> uint32_t conversionMatthijs Kooijman
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-18In HardwareSerial::_rx_complete_irq, don't use int for buffer indexMatthijs Kooijman
This was already fixed for HardwareSerial.cpp in #1863, but there was one more case hidden in HardwareSerial_private.h. The index attributes have been uint8_t for a while, so there is no point in using int for local variables. This should allow the compiler to generate slightly more efficient code, but (at least on gcc 4.8.2) it also confuses the register allocator, causing this change to increase code size by 2 bytes instead due to extra push/pop instructions (but this will probably change in the future if the compiler improves).
2014-02-14In HardwareSerial, don't use int for buffer indicesMatthijs Kooijman
The index attributes have been uint8_t for a while, so there is no point in using int for local variables. This should allow the compiler to generate slightly more efficient code, but (at least on gcc 4.8.2) it also confuses the register allocator, causing this change to increase code size by 2 bytes instead due to extra push/pop instructions (but this will probably change in the future if the compiler improves).
2014-02-13Added license for Client, IPAddressm and Server (master branch)Cristian Maglie
See #1847 and #1117
2014-02-13Added license for Arduino.h, binary.h and main.cpp (master branch)Cristian Maglie
See #1847 and #1117
2014-02-10Added license for Arduino.h, binary.h and main.cppCristian Maglie
See #1847
2014-02-10Added license for Client, IPAddressm and ServerCristian Maglie
See #1847
2014-02-10Added license for avr/HardwareSerial.Cristian Maglie
See #1847
2014-01-29Reorder HardwareSerial init to fix compiler warnMatt Robinson
Switch the tx and rx buffer head/tail entries in the HardwareSerial initialisation list so that they match the order the fields are defined in. This fixes a compiler warning (repeated for each of the HardwareSerial source files the header is used in).
2014-01-28Clean up unused var from HardwareSerial_private.hMatt Robinson
2014-01-22In HardwareSerial::write, bypass the queue when it's emptyMatthijs Kooijman
This helps improve the effective datarate on high (>500kbit/s) bitrates, by skipping the interrupt and associated overhead. At 1 Mbit/s the implementation previously got up to about 600-700 kbit/s, but now it actually gets up to the 1Mbit/s (values are rough estimates, though).
2014-01-22Inlined HardwareSerial calls to RX ISR.Cristian Maglie
Moreover, declaring pointers-to-registers as const and using initializer list in class constructor allows the compiler to further improve inlining performance. This change recovers about 50 bytes of program space on single-UART devices. See #1711
2014-01-22Put each HardwareSerial instance in its own .cpp fileMatthijs Kooijman
By putting the ISRs and HardwareSerial instance for each instance in a separate compilation unit, the compile will only consider them for linking when the instance is actually used. The ISR is always referenced by the compiler runtime and the Serialx_available() function is always referenced by SerialEventRun(), but both references are weak and thus do not cause the compilation to be included in the link by themselves. The effect of this is that when multiple HardwareSerial ports are available, but not all are used, buffers are only allocated and ISRs are only included for the serial ports that are used. On the mega, this lowers memory usage from 653 bytes to just 182 when only using the first serial port. On boards with just a single port, there is no change, since the code and memory was already left out when no serial port was used at all. This fixes #1425 and fixes #1259.
2014-01-22Centrally decide which hardware UARTS are availableMatthijs Kooijman
Before, this decision was made in few different places, based on sometimes different register defines. Now, HardwareSerial.h decides wich UARTS are available, defines USE_HWSERIALn macros and HardwareSerial.cpp simply checks these macros (together with some #ifs to decide which registers to use for UART 0). For consistency, USBAPI.h also defines a HAVE_CDCSERIAL macro when applicable. For supported targets, this should change any behaviour. For unsupported targets, the error messages might subtly change because some checks are moved or changed. Additionally, this moves the USBAPI.h include form HardareSerial.h into Arduino.h and raises an error when both CDC serial and UART0 are available (previously this would silently use UART0 instead of CDC, but there is not currently any Atmel chip available for which this would occur).
2014-01-22Disable the UDRE interrupt sooner in HardwareSerialMatthijs Kooijman
Before, the interrupt was disabled when it was triggered and it turned out there was no data to send. However, the interrupt can be disabled already when the last byte is written to the UART, since write() will always re-enable the interrupt when it adds new data to the buffer. Closes: #1008