File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -661,17 +661,17 @@ static inline size_t spi_context_total_rx_len(struct spi_context *ctx)
661
661
/* Similar to spi_context_total_tx_len, except does not count words that have been finished
662
662
* in the current buffer, ie only including what is remaining in the current buffer in the sum.
663
663
*/
664
- static inline size_t spi_context_tx_len_left (struct spi_context * ctx )
664
+ static inline size_t spi_context_tx_len_left (struct spi_context * ctx , uint8_t dfs )
665
665
{
666
- return ctx -> tx_len + spi_context_count_tx_buf_lens (ctx , 1 );
666
+ return ( ctx -> tx_len * dfs ) + spi_context_count_tx_buf_lens (ctx , 1 );
667
667
}
668
668
669
669
/* Similar to spi_context_total_rx_len, except does not count words that have been finished
670
670
* in the current buffer, ie only including what is remaining in the current buffer in the sum.
671
671
*/
672
- static inline size_t spi_context_rx_len_left (struct spi_context * ctx )
672
+ static inline size_t spi_context_rx_len_left (struct spi_context * ctx , uint8_t dfs )
673
673
{
674
- return ctx -> rx_len + spi_context_count_rx_buf_lens (ctx , 1 );
674
+ return ( ctx -> rx_len * dfs ) + spi_context_count_rx_buf_lens (ctx , 1 );
675
675
}
676
676
677
677
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -241,6 +241,7 @@ static void lpspi_isr(const struct device *dev)
241
241
const struct lpspi_config * config = dev -> config ;
242
242
struct lpspi_data * data = dev -> data ;
243
243
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
244
+ uint8_t word_size_bytes = lpspi_data -> word_size_bytes ;
244
245
struct spi_context * ctx = & data -> ctx ;
245
246
uint32_t status_flags = base -> SR ;
246
247
@@ -252,7 +253,7 @@ static void lpspi_isr(const struct device *dev)
252
253
lpspi_handle_tx_irq (dev );
253
254
}
254
255
255
- if (spi_context_rx_len_left (ctx ) == 0 ) {
256
+ if (spi_context_rx_len_left (ctx , word_size_bytes ) == 0 ) {
256
257
base -> IER &= ~LPSPI_IER_RDIE_MASK ;
257
258
base -> CR |= LPSPI_CR_RRF_MASK ; /* flush rx fifo */
258
259
}
@@ -274,7 +275,8 @@ static void lpspi_isr(const struct device *dev)
274
275
lpspi_data -> fill_len = fill_len ;
275
276
}
276
277
277
- if (spi_context_rx_len_left (ctx ) == 1 && (LPSPI_VERID_MAJOR (base -> VERID ) < 2 )) {
278
+ if ((DIV_ROUND_UP (spi_context_rx_len_left (ctx , word_size_bytes ), word_size_bytes ) == 1 ) &&
279
+ (LPSPI_VERID_MAJOR (base -> VERID ) < 2 )) {
278
280
/* Due to stalling behavior on older LPSPI,
279
281
* need to end xfer in order to get last bit clocked out on bus.
280
282
*/
You can’t perform that action at this time.
0 commit comments