Fix streaming implementation, now it could be halt only calling the stop function.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 15 Sep 2011 14:36:10 +0000 (14:36 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 15 Sep 2011 14:36:10 +0000 (14:36 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5051 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/cortex-m3/drv/dac_sam3.c

index f4090468a1be751eceeab4c231b3fe84629bec06..0516fdec1d24c372b3d6296fa7b942e067b271bd 100644 (file)
@@ -276,14 +276,16 @@ static void sam3x_dac_start(struct Dac *dac, void *_buf, size_t len, size_t slic
        while (1)
        {
                event_wait(&buff_emtpy);
+               if (dac->hw->end)
+                       break;
+
+               remaing_size -= chunk_size;
+               next_idx += chunk_size;
+
                if (remaing_size <= 0)
                {
-                       DAC_TC_CCR = BV(TC_CCR_CLKDIS);
-                       dac->hw->end = true;
+                       remaing_size = len;
                        next_idx = 0;
-                       chunk_size = 0;
-                       remaing_size = 0;
-                       break;
                }
 
                dac->ctx.callback(dac, &sample_buff[next_idx], chunk_size);
@@ -293,10 +295,16 @@ static void sam3x_dac_start(struct Dac *dac, void *_buf, size_t len, size_t slic
 static void sam3x_dac_stop(struct Dac *dac)
 {
        dac->hw->end = false;
+       next_idx = 0;
+       remaing_size = 0;
+       chunk_size = 0;
+
        /* Disable the irq, timer and channel */
        DACC_IDR = BV(DACC_ENDTX);
        DACC_PTCR |= BV(DACC_PTCR_TXTDIS);
        DAC_TC_CCR = BV(TC_CCR_CLKDIS);
+
+       event_do(&buff_emtpy);
 }