diff --git a/configs/samd20-xplained/Kconfig b/configs/samd20-xplained/Kconfig index aea7a571559..a5273229eaf 100644 --- a/configs/samd20-xplained/Kconfig +++ b/configs/samd20-xplained/Kconfig @@ -51,5 +51,26 @@ config SAMD20_XPLAINED_OLED1MODULE_EXT2 endchoice endif +if USART4_SERIAL_CONSOLE +choice + prompt "USART 4 Connection" + default SAMD20_XPLAINED_USART4_EXT3 + +config SAMD20_XPLAINED_USART4_EXT1 + bool "EXT1" + depends on !SAMD20_XPLAINED_OLED1MODULE_EXT1 && !SAMD20_XPLAINED_IOMODULE_EXT1 + ---help--- + Select this option if the serial console is on SERCOM4 connected via + EXT1. The RX will be on PB9 and TX signal will be on PB8. + +config SAMD20_XPLAINED_USART4_EXT3 + bool "EXT3" + ---help--- + Select this option if the serial console is on SERCOM4 connect via + EXT3. The RX will be on PB13 and TX signal will be on PB12. + +endchoice +endif + endmenu endif diff --git a/configs/samd20-xplained/include/board.h b/configs/samd20-xplained/include/board.h index 94e82b9cb76..7893b5bbe79 100644 --- a/configs/samd20-xplained/include/board.h +++ b/configs/samd20-xplained/include/board.h @@ -198,7 +198,7 @@ /* DFLL closed loop mode configuration */ -#define BOARD_DFLL_GCLKGEN GCLK_CLKCTRL_GEN1 +#define BOARD_DFLL_SRCGCLKGEN GCLK_CLKCTRL_GEN1 #define BOARD_DFLL_MULTIPLIER 6 #define BOARD_DFLL_QUICKLOCK 1 #define BOARD_DFLL_TRACKAFTERFINELOCK 1 @@ -340,17 +340,54 @@ #define BOARD_FLASH_WAITSTATES 0 /* SERCOM definitions ***************************************************************/ +/* SERCOM4 is available on connectors EXT1 and EXT3 + * + * PIN EXT1 EXT3 GPIO Function + * ---- ---- ------ ----------- + * 13 PB09 PB13 SERCOM4 / USART RX + * 14 PB08 PB12 SERCOM4 / USART TX + * 19 19 GND + * 20 20 VCC + * + * If you have a TTL to RS-232 converter then this is the most convenient + * serial console to use. It is the default in all of these configurations. + */ -/* EDBG/CDC USART on SERCOM3 */ +#define BOARD_SERCOM4_GCLKGEN GCLK_CLKCTRL_GEN0 -#define BOARD_SERCOM3_GCLKGEN GCLK_CLKCTRL_GEN0 -#define BOARD_SERCOM3_MUXCONFIG (USART_CTRLA_RXPAD3 | USART_CTRLA_TXPAD2) -#define BOARD_SERCOM3_PINMAP_PAD0 0 -#define BOARD_SERCOM3_PINMAP_PAD1 0 -#define BOARD_SERCOM3_PINMAP_PAD2 PORT_SERCOM3_PAD2_1 -#define BOARD_SERCOM3_PINMAP_PAD3 PORT_SERCOM3_PAD3_1 +#if defined(CONFIG_SAMD20_XPLAINED_USART4_EXT1) +# define BOARD_SERCOM4_MUXCONFIG (USART_CTRLA_RXPAD1 | USART_CTRLA_TXPAD0) +# define BOARD_SERCOM4_PINMAP_PAD0 PORT_SERCOM4_PAD0_3 +# define BOARD_SERCOM4_PINMAP_PAD1 PORT_SERCOM4_PAD1_3 +# define BOARD_SERCOM4_PINMAP_PAD2 0 +# define BOARD_SERCOM4_PINMAP_PAD3 0 +#else /* if defined(CONFIG_SAMD20_XPLAINED_USART4_EXT3) */ +# define BOARD_SERCOM4_MUXCONFIG (USART_CTRLA_RXPAD1 | USART_CTRLA_TXPAD0) +# define BOARD_SERCOM4_PINMAP_PAD0 PORT_SERCOM4_PAD0_1 +# define BOARD_SERCOM4_PINMAP_PAD1 PORT_SERCOM4_PAD1_1 +# define BOARD_SERCOM4_PINMAP_PAD2 0 +# define BOARD_SERCOM4_PINMAP_PAD3 0 +#endif -#define BOARD_SERCOM3_FREQUENCY BOARD_GCLK0_FREQUENCY +#define BOARD_SERCOM4_FREQUENCY BOARD_GCLK0_FREQUENCY + +/* The SAMD20 Xplained Pro contains an Embedded Debugger (EDBG) that can be + * used to program and debug the ATSAMD20J18A using Serial Wire Debug (SWD). + * The Embedded debugger also include a Virtual Com port interface over + * SERCOM3. Virtual COM port connections: + * + * PA24 SERCOM3 / USART TXD + * PA25 SERCOM3 / USART RXD + */ + +#define BOARD_SERCOM3_GCLKGEN GCLK_CLKCTRL_GEN0 +#define BOARD_SERCOM3_MUXCONFIG (USART_CTRLA_RXPAD3 | USART_CTRLA_TXPAD2) +#define BOARD_SERCOM3_PINMAP_PAD0 0 +#define BOARD_SERCOM3_PINMAP_PAD1 0 +#define BOARD_SERCOM3_PINMAP_PAD2 PORT_SERCOM3_PAD2_1 +#define BOARD_SERCOM3_PINMAP_PAD3 PORT_SERCOM3_PAD3_1 + +#define BOARD_SERCOM3_FREQUENCY BOARD_GCLK0_FREQUENCY /* LED definitions ******************************************************************/ /* There are three LEDs on board the SAMD20 Xplained Pro board: The EDBG diff --git a/configs/samd20-xplained/nsh/defconfig b/configs/samd20-xplained/nsh/defconfig index 7e999af881e..f0a65c99fea 100644 --- a/configs/samd20-xplained/nsh/defconfig +++ b/configs/samd20-xplained/nsh/defconfig @@ -153,7 +153,7 @@ CONFIG_SAMD_HAVE_TC7=y # CONFIG_SAMD_SERCOM1 is not set # CONFIG_SAMD_SERCOM2 is not set CONFIG_SAMD_SERCOM3=y -# CONFIG_SAMD_SERCOM4 is not set +CONFIG_SAMD_SERCOM4=y # CONFIG_SAMD_SERCOM5 is not set # CONFIG_SAMD_TC0 is not set # CONFIG_SAMD_TC1 is not set @@ -170,6 +170,9 @@ CONFIG_SAMD_SERCOM3=y # CONFIG_SAMD_SERCOM3_ISI2C is not set # CONFIG_SAMD_SERCOM3_ISSPI is not set CONFIG_SAMD_SERCOM3_ISUSART=y +# CONFIG_SAMD_SERCOM4_ISI2C is not set +# CONFIG_SAMD_SERCOM4_ISSPI is not set +CONFIG_SAMD_SERCOM4_ISUSART=y # # Architecture Options @@ -245,6 +248,8 @@ CONFIG_NSH_MMCSDMINOR=0 # # CONFIG_SAMD20_XPLAINED_IOMODULE is not set # CONFIG_SAMD20_XPLAINED_OLED1MODULE is not set +# CONFIG_SAMD20_XPLAINED_USART4_EXT1 is not set +CONFIG_SAMD20_XPLAINED_USART4_EXT3=y # # RTOS Features @@ -344,14 +349,17 @@ CONFIG_SERIAL=y # CONFIG_DEV_LOWCONSOLE is not set # CONFIG_16550_UART is not set CONFIG_ARCH_HAVE_USART3=y +CONFIG_ARCH_HAVE_USART4=y # # USART Configuration # CONFIG_USART3_ISUART=y +CONFIG_USART4_ISUART=y CONFIG_MCU_SERIAL=y CONFIG_STANDARD_SERIAL=y -CONFIG_USART3_SERIAL_CONSOLE=y +# CONFIG_USART3_SERIAL_CONSOLE is not set +CONFIG_USART4_SERIAL_CONSOLE=y # CONFIG_NO_SERIAL_CONSOLE is not set # @@ -365,6 +373,18 @@ CONFIG_USART3_PARITY=0 CONFIG_USART3_2STOP=0 # CONFIG_USART3_IFLOWCONTROL is not set # CONFIG_USART3_OFLOWCONTROL is not set + +# +# USART4 Configuration +# +CONFIG_USART4_RXBUFSIZE=64 +CONFIG_USART4_TXBUFSIZE=64 +CONFIG_USART4_BAUD=9600 +CONFIG_USART4_BITS=8 +CONFIG_USART4_PARITY=0 +CONFIG_USART4_2STOP=0 +# CONFIG_USART4_IFLOWCONTROL is not set +# CONFIG_USART4_OFLOWCONTROL is not set # CONFIG_SERIAL_IFLOWCONTROL is not set # CONFIG_SERIAL_OFLOWCONTROL is not set # CONFIG_USBDEV is not set