|
26 | 26 | * THE SOFTWARE.
|
27 | 27 | */
|
28 | 28 |
|
| 29 | +#include "supervisor/serial.h" |
29 | 30 | #include "py/mphal.h"
|
30 | 31 | #include <string.h>
|
31 |
| -#include "supervisor/serial.h" |
32 | 32 |
|
33 | 33 | #include "fsl_clock.h"
|
34 | 34 | #include "fsl_lpuart.h"
|
35 | 35 |
|
36 | 36 | // TODO: Switch this to using DEBUG_UART.
|
37 |
| - |
| 37 | +// If the board defined a debug uart tx or rx pin then we enable this code |
| 38 | +#if defined(CIRCUITPY_DEBUG_UART_TX) || defined(CIRCUITPY_DEBUG_UART_RX) |
38 | 39 | // static LPUART_Type *uart_instance = LPUART1; // evk
|
39 | 40 | static LPUART_Type *uart_instance = LPUART4; // feather 1011
|
40 | 41 | // static LPUART_Type *uart_instance = LPUART2; // feather 1062
|
41 |
| - |
42 | 42 | static uint32_t UartSrcFreq(void) {
|
43 | 43 | uint32_t freq;
|
44 | 44 |
|
45 |
| - /* To make it simple, we assume default PLL and divider settings, and the only variable |
46 |
| - from application is use PLL3 source or OSC source */ |
| 45 | + /* To make it simple, we assume default PLL and divider settings, and the only |
| 46 | + variable from application is use PLL3 source or OSC source */ |
47 | 47 | /* PLL3 div6 80M */
|
48 | 48 | if (CLOCK_GetMux(kCLOCK_UartMux) == 0) {
|
49 |
| - freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); |
| 49 | + freq = (CLOCK_GetPllFreq(kCLOCK_PllUsb1) / 6U) / |
| 50 | + (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U); |
50 | 51 | } else {
|
51 | 52 | freq = CLOCK_GetOscFreq() / (CLOCK_GetDiv(kCLOCK_UartDiv) + 1U);
|
52 | 53 | }
|
@@ -88,3 +89,4 @@ void port_serial_write_substring(const char *text, uint32_t len) {
|
88 | 89 |
|
89 | 90 | LPUART_WriteBlocking(uart_instance, (uint8_t *)text, len);
|
90 | 91 | }
|
| 92 | +#endif // USE_DEBUG_PORT_CODE |
0 commit comments