Start onewire interface. But probably won't finish it

This commit is contained in:
2020-02-25 19:34:23 +01:00
parent 71e2073a76
commit 0ddaef01c8
11 changed files with 195 additions and 108 deletions

View File

@@ -162,6 +162,16 @@ int uart_receive_data_with_dma(struct stm_uart *uart, const char **data, size_t
return dma_ring_buffer_periph_to_mem_get_data(&uart->rx_ring_buff, (const volatile void **)data, len);
}
char uart_get_char(struct stm_uart *uart)
{
if (!uart)
return 0;
/* Wait for data to be available */
while (!(uart->uart_dev->SR & USART_SR_RXNE));
return (char)uart->uart_dev->DR;
}
int uart_check_rx_avail(struct stm_uart *uart)
{
if (!uart)
@@ -181,3 +191,26 @@ void uart_tx_dma_complete_int_callback(struct stm_uart *uart)
dma_ring_buffer_mem_to_periph_int_callback(&uart->tx_ring_buff);
}
size_t uart_dma_tx_queue_avail(struct stm_uart *uart)
{
size_t fill_level = 0UL;
if (!uart)
return 0UL;
(void)dma_ring_buffer_mem_to_periph_fill_level(&uart->tx_ring_buff, &fill_level);
return fill_level;
}
size_t uart_dma_rx_queue_avail(struct stm_uart *uart)
{
size_t fill_level = 0UL;
if (!uart)
return 0UL;
(void)dma_ring_buffer_periph_to_mem_fill_level(&uart->rx_ring_buff, &fill_level);
return fill_level;
}