Simplify DAC ISR interface: now afsk_dac_isr() return the next sample.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Sat, 10 Oct 2009 12:53:46 +0000 (12:53 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Sat, 10 Oct 2009 12:53:46 +0000 (12:53 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3069 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/net/afsk.c
bertos/net/afsk.h
bertos/net/afsk_test.c

index 4a195891d9befe3e1a96c7d5b5dafc86fa854678..5efce302ab08a7be4677a8331c79e25da4eebbc5 100644 (file)
@@ -342,10 +342,9 @@ static void afsk_txStart(Afsk *af)
  *
  * \param af Afsk context to operate one (\see Afsk).
  *
- * \note The next DAC output sample is supplied by the Afsk driver through calling
- *        the AFSK_DAC_SET() callback.
+ * \return The next DAC output sample.
  */
-void afsk_dac_isr(Afsk *af)
+uint8_t afsk_dac_isr(Afsk *af)
 {
        /* Check if we are at a start of a sample cycle */
        if (af->sample_count == 0)
@@ -357,7 +356,7 @@ void afsk_dac_isr(Afsk *af)
                        {
                                AFSK_DAC_IRQ_STOP(af->dac_ch);
                                af->sending = false;
-                               return;
+                               return 0;
                        }
                        else
                        {
@@ -396,7 +395,7 @@ void afsk_dac_isr(Afsk *af)
                                        {
                                                AFSK_DAC_IRQ_STOP(af->dac_ch);
                                                af->sending = false;
-                                               return;
+                                               return 0;
                                        }
                                        else
                                                af->curr_out = fifo_pop(&af->tx_fifo);
@@ -453,8 +452,8 @@ void afsk_dac_isr(Afsk *af)
        af->phase_acc += af->phase_inc;
        af->phase_acc %= SIN_LEN;
 
-       AFSK_DAC_SET(af->dac_ch, sin_sample(af->phase_acc));
        af->sample_count--;
+       return sin_sample(af->phase_acc);
 }
 
 
index 5f75b3e38d2b8d046c9a76324722bc2aa53df712..bd82e66012d72eb9d5d5163f00dfcb3bfdc0d195 100644 (file)
@@ -205,7 +205,7 @@ INLINE Afsk *AFSK_CAST(KFile *fd)
 
 
 void afsk_adc_isr(Afsk *af, int8_t sample);
-void afsk_dac_isr(Afsk *af);
+uint8_t afsk_dac_isr(Afsk *af);
 void afsk_init(Afsk *af, int adc_ch, int dac_ch);
 
 
index 7ce7b4c60d6c62c9ba61ff08a4af206779bde3bd..09c1ffdb1d6b9eccb65459e12ed0af73e2375054 100644 (file)
@@ -184,8 +184,11 @@ int afsk_testRun(void)
        ax25_send(&ax25, AX25_CALL("abcdef", 0), AX25_CALL("123456", 1), buf, sizeof(buf));
 
        while (afsk_tx_test)
-               afsk_dac_isr(&afsk_fd);
-
+       {
+               int8_t val = afsk_dac_isr(&afsk_fd) - 128;
+               ASSERT(fwrite(&val, 1, sizeof(val), fp_dac) == sizeof(val));
+               data_written++;
+       }
 
        #define SND_DATASIZE_OFF 8
        #if CPU_AVR