An experiement to see how much work again it would take to add the T4 methods to allow user sketches to increase the size of Serial ports RX and TX buffers, without having to edit the Source code which does it then for all sketches.
T3.x SerialN Add extra memory capabilities for Serial1-6
Also
Fixed serialEventX yield handling when you call begin multiple times
There is an issue that if you are not using the serialEvent type code and you call SerialX.begin multiple times, it will add that item to the process list multiple times, which can overrun the memory and cause crash or the like.
Fix was to check the list first and see if we are already in the list.
Migrating the half duplex support I did in the Stagnant and out of date PR to enhance Uarts: https://github.com/PaulStoffregen/cores/pull/419
To try to support Half duplex mode in a similar way like we do for RS485 like support.
With T3.x made use of bitband address for the TX Direction setting, so
Except for the begin which calls format, no code changed, we simply stored the bitband address of the TXDIR flag into the TXDIR variable that was already used for the set direction flag.
For T4.x - it is a little more work as there is no bitband support on M7 processors. For GPIO there is a Set and Clear register which we use, but for the appropriate UART register there is no such setup of registers. So I have to special case we are in that mode and do it... Also since not atomic I cli/sei...
Serial Half Duplex - Fix T4Serial1 and T-LC Serial1-3
Updates: T4
T4 Serial 1 did not have proper settings for IOMUXC_LPUART6_TX_SELECT_INPUT
Tested T4.1 Serial1-8
Tested T3.5 Serial1-6
T3.6 - Added support for LPUART which is Serial6 which now works.
T-LC
Make half duplex work on T-LC on Serials1-3
Tested on on T3.5 1-6
Code is setup that if there are no eventResponders that have registered to do interrupt calls, don't have the systic code in place to look for it.
Also yield code. Now figures out if the user has any code that installs their own serialEventX methods, to call them, but if they have left the default weak pointer versions, to not call them in yield. Likewise will only look for eventRespnder events if the sketch has actually attached any events. If none of these conditions are true, yield will just check one flag and return.
T3.x Serial events cleanup
The code for the second port was accidentally expanded into
usb_serial3.c, while the code for the third port was expanded in
usb_serial2.c.
Fixes: cd4c30fde5 ("Expand all USB serial 2 & 3 stuff (needed for Arduino IDE use)")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Add support for a triple serial port configuration (USB_TRIPLE_SERIAL),
providing a composite USB device, comprised of three serial ports.
The third serial port is called usb_serial3 (C) or SerialB (C++).
Note that no dummy C++ class is created if USB_DISABLED is defined,
unlike for the first port.
This increases binary size by ca. 0.5 KiB (despite needing 720 more
bytes for USB buffers, as gcc-5.4.1 no longer decides to unroll a loop
over all endpoints in usb_isr()).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Add support for a dual serial port configuration (USB_DUAL_SERIAL),
providing a composite USB device, comprised of two serial ports.
The second serial port is called usb_serial2 (C) or SerialA (C++).
Note that no dummy C++ class is created if USB_DISABLED is defined,
unlike for the first port.
This increases binary size by ca. 1.2 KiB (720 bytes for USB buffers).
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Add preprocessor macros to control the naming of functions, structures
and classes, to ease the creation of multiple USB serial instances.
Name generation for each instance is controlled using the
USB_SERIAL_SUFFIX and SERIAL_CLASS_SUFFIX defines.
Move the preprocessor macro wrappers around the usb_serial_port data
members to usb_serial.h, as preprocessor macro names cannot be
parameterized.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Extract core USB serial functionality in a new usb_serial_port C class,
to allow creating multiple USB serial instances without duplicating all
code.
The original API is retained by creating static inline functions and
preprocessor macros using the old names, which are wrappers around the
new usb_serial_port functions and data members.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Create a macro to emit all values for a CDC Interface Association
Descriptor, and use it.
This will avoid duplication when adding support for multiple USB serial
interfaces.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Create a macro to emit all values for the various CDC descriptors, and
use it. Note that this does not include the CDC Interface Association
Descriptor, as the latter is needed only for composite USB devices.
This will avoid duplication when adding support for multiple USB serial
interfaces.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
When including "core_pins.h":
teensy3/usb_dev.c: In function '_reboot_Teensyduino_':
teensy3/usb_dev.c:899:1: warning: 'noreturn' function does return
Fix this by adding a call to __builtin_unreachable().
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
- usb_serial_class::readBytes() calls millis(), hence it should
include "core_pins.h",
- usb_serial_flush_callback() is a public function, but is not
declared in the header file.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
When processing CDC_SET_CONTROL_LINE_STATE and CDC_SET_LINE_CODING
requests, wIndex is ignored. Hence if the CDC Status Interface is
enabled, these requests are always processed, even when not destined for
the actual serial status interface.
Fix this by adding a check to ensure that wIndex matches the CDC status
interface.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>