Add UART support for Kinetis boards (#18370)

* Add UART support for Kinetis boards

* Default PAL mode for GPIOV1
This commit is contained in:
Ryan 2022-09-17 11:24:03 +10:00 committed by GitHub
parent 786fabc144
commit 33c47fe010
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 17 deletions

View file

@ -18,7 +18,9 @@
#include "quantum.h" #include "quantum.h"
#if defined(WB32F3G71xx) || defined(WB32FQ95xx) #if defined(MCU_KINETIS)
static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE};
#elif defined(WB32F3G71xx) || defined(WB32FQ95xx)
static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_WRDLEN, SD1_STPBIT, SD1_PARITY, SD1_ATFLCT}; static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_WRDLEN, SD1_STPBIT, SD1_PARITY, SD1_ATFLCT};
#else #else
static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_CR1, SD1_CR2, SD1_CR3}; static SerialConfig serialConfig = {SERIAL_DEFAULT_BITRATE, SD1_CR1, SD1_CR2, SD1_CR3};
@ -30,11 +32,15 @@ void uart_init(uint32_t baud) {
if (!is_initialised) { if (!is_initialised) {
is_initialised = true; is_initialised = true;
#if defined(MCU_KINETIS)
serialConfig.sc_speed = baud;
#else
serialConfig.speed = baud; serialConfig.speed = baud;
#endif
#if defined(USE_GPIOV1) #if defined(USE_GPIOV1)
palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE_OPENDRAIN); palSetLineMode(SD1_TX_PIN, SD1_TX_PAL_MODE);
palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE_OPENDRAIN); palSetLineMode(SD1_RX_PIN, SD1_RX_PAL_MODE);
#else #else
palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE(SD1_TX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN); palSetLineMode(SD1_TX_PIN, PAL_MODE_ALTERNATE(SD1_TX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);
palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE(SD1_RX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN); palSetLineMode(SD1_RX_PIN, PAL_MODE_ALTERNATE(SD1_RX_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN);

View file

@ -28,32 +28,50 @@
# define SD1_TX_PIN A9 # define SD1_TX_PIN A9
#endif #endif
#ifndef SD1_TX_PAL_MODE
# define SD1_TX_PAL_MODE 7
#endif
#ifndef SD1_RX_PIN #ifndef SD1_RX_PIN
# define SD1_RX_PIN A10 # define SD1_RX_PIN A10
#endif #endif
#ifndef SD1_RX_PAL_MODE
# define SD1_RX_PAL_MODE 7
#endif
#ifndef SD1_CTS_PIN #ifndef SD1_CTS_PIN
# define SD1_CTS_PIN A11 # define SD1_CTS_PIN A11
#endif #endif
#ifndef SD1_CTS_PAL_MODE
# define SD1_CTS_PAL_MODE 7
#endif
#ifndef SD1_RTS_PIN #ifndef SD1_RTS_PIN
# define SD1_RTS_PIN A12 # define SD1_RTS_PIN A12
#endif #endif
#ifndef SD1_RTS_PAL_MODE #ifdef USE_GPIOV1
# define SD1_RTS_PAL_MODE 7 # ifndef SD1_TX_PAL_MODE
# define SD1_TX_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN
# endif
# ifndef SD1_RX_PAL_MODE
# define SD1_RX_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN
# endif
# ifndef SD1_CTS_PAL_MODE
# define SD1_CTS_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN
# endif
# ifndef SD1_RTS_PAL_MODE
# define SD1_RTS_PAL_MODE PAL_MODE_ALTERNATE_OPENDRAIN
# endif
#else
# ifndef SD1_TX_PAL_MODE
# define SD1_TX_PAL_MODE 7
# endif
# ifndef SD1_RX_PAL_MODE
# define SD1_RX_PAL_MODE 7
# endif
# ifndef SD1_CTS_PAL_MODE
# define SD1_CTS_PAL_MODE 7
# endif
# ifndef SD1_RTS_PAL_MODE
# define SD1_RTS_PAL_MODE 7
# endif
#endif #endif
#ifndef SD1_CR1 #ifndef SD1_CR1