diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-11-10 15:02:51 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-11-10 15:02:51 -0600 |
commit | ef5c4f674c80defe9e203e8fda7375472fabb79a (patch) | |
tree | 160f53574f3bb789ffaa94c3bb33e3d079a8c426 /nuttx | |
parent | 42fc9811e106b09913d3f8a269b88fa1abf657b5 (diff) | |
download | px4-nuttx-ef5c4f674c80defe9e203e8fda7375472fabb79a.tar.gz px4-nuttx-ef5c4f674c80defe9e203e8fda7375472fabb79a.tar.bz2 px4-nuttx-ef5c4f674c80defe9e203e8fda7375472fabb79a.zip |
SAMA5 I2S: Need to update the count of valid bytes at the conclusion of the read DMA
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_ssc.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/nuttx/arch/arm/src/sama5/sam_ssc.c b/nuttx/arch/arm/src/sama5/sam_ssc.c index 9490e7c15..6e42d5ea2 100644 --- a/nuttx/arch/arm/src/sama5/sam_ssc.c +++ b/nuttx/arch/arm/src/sama5/sam_ssc.c @@ -1053,6 +1053,10 @@ static int ssc_rxdma_setup(struct sam_ssc_s *priv) apb = bfcontainer->apb; DEBUGASSERT(((uintptr_t)apb->samp & 3) == 0); + /* No data received yet */ + + apb->nbytes = 0; + /* Physical address of the SSC RHR register and of the buffer location * in RAM. */ @@ -1203,13 +1207,25 @@ static void ssc_rx_worker(void *arg) bfcontainer = (struct sam_buffer_s *)sq_remfirst(&priv->rxdone); irqrestore(flags); - /* Perform the TX transfer done callback */ - DEBUGASSERT(bfcontainer && bfcontainer->callback); + + /* If the DMA was successful, then update the number of valid bytes in + * the audio buffer. + */ + + if (bfcontainer->result == OK) + { + bfcontainer->apb->nbytes = bfcontainer->apb->nmaxbytes; + } + + /* Perform the RX transfer done callback */ + bfcontainer->callback(&priv->dev, bfcontainer->apb, bfcontainer->arg, bfcontainer->result); - /* Release our reference on the audio buffer */ + /* Release our reference on the audio buffer. This may very likely + * cause the audio buffer to be freed. + */ apb_free(bfcontainer->apb); @@ -1585,7 +1601,9 @@ static void ssc_tx_worker(void *arg) bfcontainer->callback(&priv->dev, bfcontainer->apb, bfcontainer->arg, bfcontainer->result); - /* Release our reference on the audio buffer */ + /* Release our reference on the audio buffer. This may very likely + * cause the audio buffer to be freed. + */ apb_free(bfcontainer->apb); |