kinetis: Set LPUART clock source during uart_lpuart_init
This commit is contained in:
parent
2e701bd535
commit
82e960b642
@ -72,6 +72,11 @@ extern "C"
|
|||||||
#if !defined(OSC0) && defined(OSC)
|
#if !defined(OSC0) && defined(OSC)
|
||||||
#define OSC0 OSC
|
#define OSC0 OSC
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(SIM_SOPT2_LPUART0SRC_MASK) && defined(SIM_SOPT2_LPUARTSRC_MASK)
|
||||||
|
#define SIM_SOPT2_LPUART0SRC_MASK SIM_SOPT2_LPUARTSRC_MASK
|
||||||
|
#define SIM_SOPT2_LPUART0SRC_SHIFT SIM_SOPT2_LPUARTSRC_SHIFT
|
||||||
|
#define SIM_SOPT2_LPUART0SRC SIM_SOPT2_LPUARTSRC
|
||||||
|
#endif
|
||||||
#if !defined(SIM_SCGC5_LPTMR_SHIFT) && defined(SIM_SCGC5_LPTIMER_SHIFT)
|
#if !defined(SIM_SCGC5_LPTMR_SHIFT) && defined(SIM_SCGC5_LPTIMER_SHIFT)
|
||||||
#define SIM_SCGC5_LPTMR_SHIFT SIM_SCGC5_LPTIMER_SHIFT
|
#define SIM_SCGC5_LPTMR_SHIFT SIM_SCGC5_LPTIMER_SHIFT
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -63,6 +63,15 @@
|
|||||||
#define LPUART_OVERSAMPLING_RATE (16)
|
#define LPUART_OVERSAMPLING_RATE (16)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Default LPUART clock setting to avoid compilation failures, define this in
|
||||||
|
* periph_conf.h to set board specific configuration if using the LPUART. */
|
||||||
|
#ifndef LPUART_0_SRC
|
||||||
|
#define LPUART_0_SRC 0
|
||||||
|
#endif
|
||||||
|
#ifndef LPUART_1_SRC
|
||||||
|
#define LPUART_1_SRC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Runtime configuration space, holds pointers to callback functions for RX
|
* @brief Runtime configuration space, holds pointers to callback functions for RX
|
||||||
*/
|
*/
|
||||||
@ -296,7 +305,19 @@ static inline void uart_init_lpuart(uart_t uart, uint32_t baudrate)
|
|||||||
LPUART_Type *dev = uart_config[uart].dev;
|
LPUART_Type *dev = uart_config[uart].dev;
|
||||||
uint32_t clk = uart_config[uart].freq;
|
uint32_t clk = uart_config[uart].freq;
|
||||||
|
|
||||||
/* Remember to select a module clock in board_init! (SIM->SOPT2[LPUART0SRC]) */
|
/* Set LPUART clock source */
|
||||||
|
#ifdef SIM_SOPT2_LPUART0SRC
|
||||||
|
if (dev == LPUART0) {
|
||||||
|
SIM->SOPT2 = (SIM->SOPT2 & ~SIM_SOPT2_LPUART0SRC_MASK) |
|
||||||
|
SIM_SOPT2_LPUART0SRC(LPUART_0_SRC);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef SIM_SOPT2_LPUART1SRC
|
||||||
|
if (dev == LPUART1) {
|
||||||
|
SIM->SOPT2 = (SIM->SOPT2 & ~SIM_SOPT2_LPUART1SRC_MASK) |
|
||||||
|
SIM_SOPT2_LPUART1SRC(LPUART_1_SRC);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Select mode */
|
/* Select mode */
|
||||||
/* transmitter and receiver disabled */
|
/* transmitter and receiver disabled */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user