disable on mimxrt10xx (Teensy40 41) Serial port Hooks

As mentioned in issue #6241  the commit to setup port hooks is now
    causing all input/output that are to go to the Mu window to also
    go to the LpUart that is defined the port serial.c

    and in this case it goes to lpuart4, which on Teensy 4, 4.1 is
    used on Arduino Serial2.  With this new code this port no longer
    works properly.

    This is one way to solve it, in that there is a #if defined() that
    if not set, all of the code in this file is ignored and the higher
    level supervisor stub versions of these functions will be used, which
    don't interfere with Serial2 and my test sketch works again.

    Note: the PR for Switch to Port Serial Hooks, also changed code in
    other ports.  I have not tried to see how.

    There are other more global fixes for this, in which maybe a higer
    level  #if that disables the code within the top level supervisor.  Or
    could be software controlled

    Again this may not be the final solution, but at least it gets
    Serial2 up and running agin.
This commit is contained in:
KurtE 2022-04-06 15:58:27 -07:00
parent b0bb5ff5d3
commit 219ef5e407

View File

@ -26,15 +26,15 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "supervisor/serial.h"
#include "py/mphal.h" #include "py/mphal.h"
#include <string.h> #include <string.h>
#include "supervisor/serial.h"
#include "fsl_clock.h" #include "fsl_clock.h"
#include "fsl_lpuart.h" #include "fsl_lpuart.h"
// TODO: Switch this to using DEBUG_UART. // TODO: Switch this to using DEBUG_UART.
#if defined(USE_DEBUG_PORT_CODE)
// static LPUART_Type *uart_instance = LPUART1; // evk // static LPUART_Type *uart_instance = LPUART1; // evk
static LPUART_Type *uart_instance = LPUART4; // feather 1011 static LPUART_Type *uart_instance = LPUART4; // feather 1011
// static LPUART_Type *uart_instance = LPUART2; // feather 1062 // static LPUART_Type *uart_instance = LPUART2; // feather 1062
@ -42,11 +42,12 @@ static LPUART_Type *uart_instance = LPUART4; // feather 1011
static uint32_t UartSrcFreq(void) { static uint32_t UartSrcFreq(void) {
uint32_t freq; uint32_t freq;
/* To make it simple, we assume default PLL and divider settings, and the only variable /* To make it simple, we assume default PLL and divider settings, and the only
from application is use PLL3 source or OSC source */ variable from application is use PLL3 source or OSC source */
/* PLL3 div6 80M */ /* PLL3 div6 80M */
if (CLOCK_GetMux(kCLOCK_UartMux) == 0) { if (CLOCK_GetMux(kCLOCK_UartMux) == 0) {
freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) /
(CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
} else { } else {
freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
} }
@ -65,9 +66,7 @@ void port_serial_init(void) {
LPUART_Init(uart_instance, &config, UartSrcFreq()); LPUART_Init(uart_instance, &config, UartSrcFreq());
} }
bool port_serial_connected(void) { bool port_serial_connected(void) { return true; }
return true;
}
char port_serial_read(void) { char port_serial_read(void) {
uint8_t data; uint8_t data;
@ -88,3 +87,4 @@ void port_serial_write_substring(const char *text, uint32_t len) {
LPUART_WriteBlocking(uart_instance, (uint8_t *)text, len); LPUART_WriteBlocking(uart_instance, (uint8_t *)text, len);
} }
#endif // USE_DEBUG_PORT_CODE