*
* \brief AFSK1200 modem.
*
- * \version $Id$
- * \author Francesco Sacchi <asterix@develer.com>
+ * \author Francesco Sacchi <batt@develer.com>
*/
#include "afsk.h"
uint16_t new_idx = idx % (SIN_LEN / 2);
new_idx = (new_idx >= (SIN_LEN / 4)) ? (SIN_LEN / 2 - new_idx - 1) : new_idx;
- #if CPU_HARVARD
- uint8_t data = pgm_read_char(&sin_table[new_idx]);
- #else
- uint8_t data = sin_table[new_idx];
- #endif
+ uint8_t data = pgm_read8(&sin_table[new_idx]);
return (idx >= (SIN_LEN / 2)) ? (255 - data) : data;
}
#define BIT_DIFFER(bitline1, bitline2) (((bitline1) ^ (bitline2)) & 0x01)
#define EDGE_FOUND(bitline) BIT_DIFFER((bitline), (bitline) >> 1)
-
+/**
+ * High-Level Data Link Control parsing function.
+ * Parse bitstream in order to find characters.
+ *
+ * \param hdlc HDLC context.
+ * \param bit current bit to be parsed.
+ * \param fifo FIFO buffer used to push characters.
+ *
+ * \return true if all is ok, false if the fifo is full.
+ */
static bool hdlc_parse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo)
{
bool ret = true;
* 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 af Afsk context to operate on.
* \param curr_sample current sample from the ADC.
*/
void afsk_adc_isr(Afsk *af, int8_t curr_sample)
* 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).
+ * \param af Afsk context to operate on.
*
- * \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)
{
+ AFSK_STROBE_ON();
+
/* Check if we are at a start of a sample cycle */
if (af->sample_count == 0)
{
{
AFSK_DAC_IRQ_STOP(af->dac_ch);
af->sending = false;
- return;
+ AFSK_STROBE_OFF();
+ return 0;
}
else
{
{
AFSK_DAC_IRQ_STOP(af->dac_ch);
af->sending = false;
- return;
+ AFSK_STROBE_OFF();
+ return 0;
}
else
af->curr_out = fifo_pop(&af->tx_fifo);
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--;
+ AFSK_STROBE_OFF();
+ return sin_sample(af->phase_acc);
}
ticks_t start = timer_clock();
#endif
- while (fifo_isempty_locked(&af->rx_fifo));
+ while (fifo_isempty_locked(&af->rx_fifo))
{
cpu_relax();
#if CONFIG_AFSK_RXTIMEOUT != -1
/**
* Initialize an AFSK1200 modem.
- * \param af Afsk context to operate one (\see Afsk).
+ * \param af Afsk context to operate on.
* \param adc_ch ADC channel used by the demodulator.
* \param dac_ch DAC channel used by the modulator.
*/