From 6c66c4384ca07a728254e3d88f1f3f9ad087332a Mon Sep 17 00:00:00 2001 From: asterix Date: Mon, 26 Sep 2011 17:09:09 +0000 Subject: [PATCH] Fix caching buffer for tx and rx when slice len==2. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5095 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/drv/i2s_sam3.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/bertos/cpu/cortex-m3/drv/i2s_sam3.c b/bertos/cpu/cortex-m3/drv/i2s_sam3.c index 5a5ba13e..bfd57934 100644 --- a/bertos/cpu/cortex-m3/drv/i2s_sam3.c +++ b/bertos/cpu/cortex-m3/drv/i2s_sam3.c @@ -58,7 +58,7 @@ #include -#define I2S_DMAC_CH 3 +#define I2S_DMAC_CH 0 #define I2S_CACHED_CHUNK_SIZE 2 @@ -142,7 +142,6 @@ static void sam3_i2s_txStop(I2s *i2s) i2s_status |= I2S_STATUS_END_TX; i2s_status &= ~I2S_STATUS_TX; - event_do(&data_ready); } @@ -234,9 +233,11 @@ static void sam3_i2s_txStart(I2s *i2s, void *buf, size_t len, size_t slice_len) remaing_size -= chunk_size; next_idx += chunk_size; - if (chunk_size >= remaing_size) - break; - + if (remaing_size <= 0) + { + remaing_size = transfer_size; + next_idx = 0; + } } dmac_setLLITransfer(I2S_DMAC_CH, prev, I2S_TX_DMAC_CFG); @@ -339,8 +340,11 @@ static void sam3_i2s_rxStart(I2s *i2s, void *buf, size_t len, size_t slice_len) remaing_size -= chunk_size; next_idx += chunk_size; - if (chunk_size >= remaing_size) - break; + if (remaing_size <= 0) + { + remaing_size = transfer_size; + next_idx = 0; + } } dmac_setLLITransfer(I2S_DMAC_CH, prev, I2S_RX_DMAC_CFG); -- 2.25.1