Lines Matching full:hal
1 #include "hal/spi_slave_hal.h"
2 #include "hal/spi_ll.h"
8 #include "hal/gdma_ll.h"
22 bool spi_slave_hal_usr_is_done(spi_slave_hal_context_t* hal) in spi_slave_hal_usr_is_done() argument
24 return spi_ll_usr_is_done(hal->hw); in spi_slave_hal_usr_is_done()
27 void spi_slave_hal_user_start(const spi_slave_hal_context_t *hal) in spi_slave_hal_user_start() argument
29 spi_ll_clear_int_stat(hal->hw); //clear int bit in spi_slave_hal_user_start()
30 spi_ll_user_start(hal->hw); in spi_slave_hal_user_start()
33 void spi_slave_hal_prepare_data(const spi_slave_hal_context_t *hal) in spi_slave_hal_prepare_data() argument
35 if (hal->use_dma) { in spi_slave_hal_prepare_data()
38 if (hal->rx_buffer) { in spi_slave_hal_prepare_data()
39 lldesc_setup_link(hal->dmadesc_rx, hal->rx_buffer, ((hal->bitlen + 7) / 8), true); in spi_slave_hal_prepare_data()
42 spi_dma_ll_rx_reset(hal->dma_in, hal->rx_dma_chan); in spi_slave_hal_prepare_data()
43 spi_ll_dma_rx_fifo_reset(hal->dma_in); in spi_slave_hal_prepare_data()
44 spi_ll_slave_reset(hal->hw); in spi_slave_hal_prepare_data()
45 spi_ll_infifo_full_clr(hal->hw); in spi_slave_hal_prepare_data()
47 spi_ll_dma_rx_enable(hal->hw, 1); in spi_slave_hal_prepare_data()
48 spi_dma_ll_rx_start(hal->dma_in, hal->rx_dma_chan, &hal->dmadesc_rx[0]); in spi_slave_hal_prepare_data()
50 if (hal->tx_buffer) { in spi_slave_hal_prepare_data()
51 lldesc_setup_link(hal->dmadesc_tx, hal->tx_buffer, (hal->bitlen + 7) / 8, false); in spi_slave_hal_prepare_data()
53 spi_dma_ll_tx_reset(hal->dma_out, hal->tx_dma_chan); in spi_slave_hal_prepare_data()
54 spi_ll_dma_tx_fifo_reset(hal->dma_out); in spi_slave_hal_prepare_data()
55 spi_ll_slave_reset(hal->hw); in spi_slave_hal_prepare_data()
56 spi_ll_outfifo_empty_clr(hal->hw); in spi_slave_hal_prepare_data()
58 spi_ll_dma_tx_enable(hal->hw, 1); in spi_slave_hal_prepare_data()
59 spi_dma_ll_tx_start(hal->dma_out, hal->tx_dma_chan, (&hal->dmadesc_tx[0])); in spi_slave_hal_prepare_data()
63 if (hal->tx_buffer) { in spi_slave_hal_prepare_data()
64 spi_ll_slave_reset(hal->hw); in spi_slave_hal_prepare_data()
65 spi_ll_write_buffer(hal->hw, hal->tx_buffer, hal->bitlen); in spi_slave_hal_prepare_data()
68 spi_ll_cpu_tx_fifo_reset(hal->hw); in spi_slave_hal_prepare_data()
71 spi_ll_slave_set_rx_bitlen(hal->hw, hal->bitlen); in spi_slave_hal_prepare_data()
72 spi_ll_slave_set_tx_bitlen(hal->hw, hal->bitlen); in spi_slave_hal_prepare_data()
76 spi_ll_enable_mosi(hal->hw, (hal->rx_buffer == NULL) ? 0 : 1); in spi_slave_hal_prepare_data()
77 spi_ll_enable_miso(hal->hw, (hal->tx_buffer == NULL) ? 0 : 1); in spi_slave_hal_prepare_data()
81 void spi_slave_hal_store_result(spi_slave_hal_context_t *hal) in spi_slave_hal_store_result() argument
86 hal->rcv_bitlen = spi_ll_slave_get_rcv_bitlen(hal->hw); in spi_slave_hal_store_result()
87 if (hal->rcv_bitlen == hal->bitlen - 1) { in spi_slave_hal_store_result()
88 hal->rcv_bitlen++; in spi_slave_hal_store_result()
90 if (!hal->use_dma && hal->rx_buffer) { in spi_slave_hal_store_result()
92 …spi_ll_read_buffer(hal->hw, hal->rx_buffer, (hal->rcv_bitlen > hal->bitlen) ? hal->bitlen : hal->r… in spi_slave_hal_store_result()
96 uint32_t spi_slave_hal_get_rcv_bitlen(spi_slave_hal_context_t *hal) in spi_slave_hal_get_rcv_bitlen() argument
98 return hal->rcv_bitlen; in spi_slave_hal_get_rcv_bitlen()
103 bool spi_slave_hal_dma_need_reset(const spi_slave_hal_context_t *hal) in spi_slave_hal_dma_need_reset() argument
107 if (hal->use_dma && hal->rx_buffer) { in spi_slave_hal_dma_need_reset()
112 for (i = 0; hal->dmadesc_rx[i].eof == 0 && hal->dmadesc_rx[i].owner == 0; i++) {} in spi_slave_hal_dma_need_reset()
113 if (hal->dmadesc_rx[i].owner) { in spi_slave_hal_dma_need_reset()