Lines Matching +full:mck +full:- +full:enabled
5 * SPDX-License-Identifier: Apache-2.0
47 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_poll_in()
49 Uart * const uart = cfg->regs; in uart_sam_poll_in()
51 if (!(uart->UART_SR & UART_SR_RXRDY)) { in uart_sam_poll_in()
52 return -EBUSY; in uart_sam_poll_in()
56 *c = (unsigned char)uart->UART_RHR; in uart_sam_poll_in()
63 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_poll_out()
65 Uart * const uart = cfg->regs; in uart_sam_poll_out()
68 while (!(uart->UART_SR & UART_SR_TXRDY)) { in uart_sam_poll_out()
72 uart->UART_THR = (uint32_t)c; in uart_sam_poll_out()
77 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_err_check()
79 volatile Uart * const uart = cfg->regs; in uart_sam_err_check()
82 if (uart->UART_SR & UART_SR_OVRE) { in uart_sam_err_check()
86 if (uart->UART_SR & UART_SR_PARE) { in uart_sam_err_check()
90 if (uart->UART_SR & UART_SR_FRAME) { in uart_sam_err_check()
94 uart->UART_CR = UART_CR_RSTSTA; in uart_sam_err_check()
101 struct uart_sam_dev_data *const dev_data = dev->data; in uart_sam_baudrate_set()
103 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_baudrate_set()
105 volatile Uart * const uart = cfg->regs; in uart_sam_baudrate_set()
112 "MCK frequency is too small to set required baud rate"); in uart_sam_baudrate_set()
117 return -EINVAL; in uart_sam_baudrate_set()
120 uart->UART_BRGR = UART_BRGR_CD(divisor); in uart_sam_baudrate_set()
121 dev_data->baud_rate = baudrate; in uart_sam_baudrate_set()
145 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_get_parity()
147 volatile Uart * const uart = cfg->regs; in uart_sam_get_parity()
149 switch (uart->UART_MR & UART_MR_PAR_Msk) { in uart_sam_get_parity()
169 const struct uart_sam_dev_cfg *const config = dev->config; in uart_sam_configure()
171 volatile Uart * const uart = config->regs; in uart_sam_configure()
174 if (cfg->stop_bits != UART_CFG_STOP_BITS_1 || in uart_sam_configure()
175 cfg->data_bits != UART_CFG_DATA_BITS_8 || in uart_sam_configure()
176 cfg->flow_ctrl != UART_CFG_FLOW_CTRL_NONE) { in uart_sam_configure()
177 return -ENOTSUP; in uart_sam_configure()
181 uart->UART_CR = UART_CR_RSTRX | UART_CR_RSTTX in uart_sam_configure()
188 uart->UART_MR = UART_MR_CHMODE_NORMAL in uart_sam_configure()
189 | uart_sam_cfg2sam_parity(cfg->parity); in uart_sam_configure()
192 retval = uart_sam_baudrate_set(dev, cfg->baudrate); in uart_sam_configure()
198 uart->UART_CR = UART_CR_RXEN | UART_CR_TXEN; in uart_sam_configure()
206 struct uart_sam_dev_data *const dev_data = dev->data; in uart_sam_config_get()
208 cfg->baudrate = dev_data->baud_rate; in uart_sam_config_get()
209 cfg->parity = uart_sam_get_parity(dev); in uart_sam_config_get()
211 cfg->stop_bits = UART_CFG_STOP_BITS_1; in uart_sam_config_get()
212 cfg->data_bits = UART_CFG_DATA_BITS_8; in uart_sam_config_get()
213 cfg->flow_ctrl = UART_CFG_FLOW_CTRL_NONE; in uart_sam_config_get()
224 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_fifo_fill()
226 volatile Uart * const uart = cfg->regs; in uart_sam_fifo_fill()
229 while ((uart->UART_SR & UART_SR_TXRDY) == 0) { in uart_sam_fifo_fill()
232 uart->UART_THR = *tx_data; in uart_sam_fifo_fill()
240 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_fifo_read()
242 volatile Uart * const uart = cfg->regs; in uart_sam_fifo_read()
248 if (uart->UART_SR & UART_SR_RXRDY) { in uart_sam_fifo_read()
249 rx_data[bytes_read] = uart->UART_RHR; in uart_sam_fifo_read()
261 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_tx_enable()
263 volatile Uart * const uart = cfg->regs; in uart_sam_irq_tx_enable()
265 uart->UART_IER = UART_IER_TXRDY; in uart_sam_irq_tx_enable()
270 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_tx_disable()
272 volatile Uart * const uart = cfg->regs; in uart_sam_irq_tx_disable()
274 uart->UART_IDR = UART_IDR_TXRDY; in uart_sam_irq_tx_disable()
279 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_tx_ready()
281 volatile Uart * const uart = cfg->regs; in uart_sam_irq_tx_ready()
284 * return true if the interrupt is also enabled in uart_sam_irq_tx_ready()
286 return (uart->UART_SR & UART_SR_TXRDY && in uart_sam_irq_tx_ready()
287 uart->UART_IMR & UART_IMR_TXRDY); in uart_sam_irq_tx_ready()
292 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_rx_enable()
294 volatile Uart * const uart = cfg->regs; in uart_sam_irq_rx_enable()
296 uart->UART_IER = UART_IER_RXRDY; in uart_sam_irq_rx_enable()
301 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_rx_disable()
303 volatile Uart * const uart = cfg->regs; in uart_sam_irq_rx_disable()
305 uart->UART_IDR = UART_IDR_RXRDY; in uart_sam_irq_rx_disable()
310 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_tx_complete()
312 volatile Uart * const uart = cfg->regs; in uart_sam_irq_tx_complete()
314 return (uart->UART_SR & UART_SR_TXRDY && in uart_sam_irq_tx_complete()
315 uart->UART_IMR & UART_IMR_TXEMPTY); in uart_sam_irq_tx_complete()
320 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_rx_ready()
322 volatile Uart * const uart = cfg->regs; in uart_sam_irq_rx_ready()
324 return (uart->UART_SR & UART_SR_RXRDY); in uart_sam_irq_rx_ready()
329 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_err_enable()
331 volatile Uart * const uart = cfg->regs; in uart_sam_irq_err_enable()
333 uart->UART_IER = UART_IER_OVRE | UART_IER_FRAME | UART_IER_PARE; in uart_sam_irq_err_enable()
338 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_err_disable()
340 volatile Uart * const uart = cfg->regs; in uart_sam_irq_err_disable()
342 uart->UART_IDR = UART_IDR_OVRE | UART_IDR_FRAME | UART_IDR_PARE; in uart_sam_irq_err_disable()
347 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_irq_is_pending()
349 volatile Uart * const uart = cfg->regs; in uart_sam_irq_is_pending()
351 return (uart->UART_IMR & (UART_IMR_TXRDY | UART_IMR_RXRDY)) & in uart_sam_irq_is_pending()
352 (uart->UART_SR & (UART_SR_TXRDY | UART_SR_RXRDY)); in uart_sam_irq_is_pending()
366 struct uart_sam_dev_data *const dev_data = dev->data; in uart_sam_irq_callback_set()
368 dev_data->irq_cb = cb; in uart_sam_irq_callback_set()
369 dev_data->irq_cb_data = cb_data; in uart_sam_irq_callback_set()
374 struct uart_sam_dev_data *const dev_data = dev->data; in uart_sam_isr()
376 if (dev_data->irq_cb) { in uart_sam_isr()
377 dev_data->irq_cb(dev, dev_data->irq_cb_data); in uart_sam_isr()
387 const struct uart_sam_dev_cfg *const cfg = dev->config; in uart_sam_init()
389 struct uart_sam_dev_data *const dev_data = dev->data; in uart_sam_init()
391 Uart * const uart = cfg->regs; in uart_sam_init()
395 (clock_control_subsys_t)&cfg->clock_cfg); in uart_sam_init()
398 retval = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); in uart_sam_init()
404 uart->UART_IDR = 0xFFFFFFFF; in uart_sam_init()
407 cfg->irq_config_func(dev); in uart_sam_init()
411 .baudrate = dev_data->baud_rate, in uart_sam_init()