* Determine bit value by reading the last 3 sampled bits.
* If the number of ones is two or greater, the bit value is a 1,
* otherwise is a 0.
+ * This algorithm presumes that there are 8 samples per bit.
*/
+ STATIC_ASSERT(SAMPLEPERBIT == 8);
uint8_t bits = af->sampled_bits & 0x07;
if (bits == 0x07 // 111, 3 bits set to 1
|| bits == 0x06 // 110, 2 bits
#include <struct/fifobuf.h>
-// Demodulator constants
+
+/**
+ * ADC sample rate.
+ * The demodulator filters are designed to work at this frequency.
+ * If you need to change this remember to update afsk_adc_isr().
+ */
#define SAMPLERATE 9600
+
+/**
+ * Bitrate of the received/transmitted data.
+ * The demodulator filters and decoderes are designed to work at this frequency.
+ * If you need to change this remember to update afsk_adc_isr().
+ */
#define BITRATE 1200
#define SAMPLEPERBIT (SAMPLERATE / BITRATE)
return (Afsk *)fd;
}
-void afsk_adc_isr(Afsk *af, int8_t curr_sample);
+/**
+ * ADC ISR callback.
+ * This function has to be called by the ADC ISR when a sample of the configured
+ * channel is available.
+ * \param af Afsk context to operate one (\see Afsk).
+ * \param sample current sample from the ADC.
+ */
+void afsk_adc_isr(Afsk *af, int8_t sample);
+
+/**
+ * DAC ISR callback.
+ * This function has to be called by the DAC ISR when a sample of the configured
+ * channel has been converted out.
+ *
+ * \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.
+ */
void afsk_dac_isr(Afsk *af);
+
+/**
+ * Initialize an AFSK1200 modem.
+ * \param af Afsk context to operate one (\see Afsk).
+ * \param adc_ch ADC channel used by the demodulator.
+ * \param dac_ch DAC channel used by the modulator.
+ */
void afsk_init(Afsk *af, int adc_ch, int dac_ch);