用途: SBUS
output/build/uboot-custom/arch/arm/mach-stm32mp/include/mach/stm32.h
#ifdef CONFIG_STM32MP15X
#define STM32_USART1_BASE 0x5C000000
#define STM32_USART2_BASE 0x4000E000
#endif
#ifdef CONFIG_STM32MP13X
#define STM32_USART1_BASE 0x4c000000
#define STM32_USART2_BASE 0x4c001000
#endif
#define STM32_USART3_BASE 0x4000F000
#define STM32_UART4_BASE 0x40010000
#define STM32_UART5_BASE 0x40011000
#define STM32_USART6_BASE 0x44003000
#define STM32_UART7_BASE 0x40018000
#define STM32_UART8_BASE 0x40019000
output/build/linux-custom/drivers/tty/serial/stm32-usart.h
#define USART_CR2_SWAP BIT(15) /* F7 */
#define USART_CR2_RXINV BIT(16) /* F7 */
#define USART_CR2_TXINV BIT(17) /* F7 */
output/build/linux-custom/drivers/tty/serial/stm32-usart.c
static int stm32_usart_startup(struct uart_port *port)
{
struct stm32_port *stm32_port = to_stm32_port(port);
...
...
if (stm32_port->swap) {
val = readl_relaxed(port->membase + ofs->cr2);
val |= USART_CR2_SWAP;
writel_relaxed(val, port->membase + ofs->cr2);
}
//if (!strcmp("4000e000.serial", name))
if (port->mapbase == 0x4000e000)
{
val = readl_relaxed(port->membase + ofs->cr2);
printk(KERN_ERR "%s, read CR2=0x%x\n", __FUNCTION__, val);
val |= (USART_CR2_TXINV | USART_CR2_RXINV);
writel_relaxed(val, port->membase + ofs->cr2);
printk(KERN_ERR "%s, write CR2=0x%x\n", __FUNCTION__, val);
}
...
...
}
static void stm32_usart_set_termios(struct uart_port *port,
struct ktermios *termios,
const struct ktermios *old)
{
struct stm32_port *stm32_port = to_stm32_port(port);
...
...
cr1 = USART_CR1_TE | USART_CR1_RE;
if (stm32_port->fifoen)
cr1 |= USART_CR1_FIFOEN;
cr2 = stm32_port->swap ? USART_CR2_SWAP : 0;
if (port->mapbase == 0x4000e000)
{
cr2 |= (USART_CR2_RXINV | USART_CR2_TXINV);
pr_info("%s, write CR2=%x\n", __FUNCITON__, cr2);
}
...
...
}
ref:
1. 错误之STM32F072CBT6芯片的串口高级功能之反相配置问题(HAL库)
2. 基於stm32和富斯遙控器的SBUS波形分析和通訊實現
3. RF from the TX Line
沒有留言:
張貼留言