#if !(ARCH & ARCH_UNITTEST)
#warning TODO:This is an example implementation, you must implement it!
- #define AFSK_ADC_INIT() do { /* Implement me */ } while (0)
+
+ #define AFSK_ADC_INIT(ch, ctx) do { (void)ch, (void)ctx; } while (0)
#define AFSK_STROBE_INIT() do { /* Implement me */ } while (0)
#define AFSK_STROBE_ON() do { /* Implement me */ } while (0)
#define AFSK_STROBE_OFF() do { /* Implement me */ } while (0)
- void afsk_adc_isr(void);
- #define DEFINE_AFSK_ADC_ISR() void afsk_adc_isr(void)
- #define AFSK_ADC_IRQ_END() do { /* Implement me */ } while (0)
-
- #define AFSK_READ_ADC() (0)
-
- void afsk_dac_isr(void);
- #define DEFINE_AFSK_DAC_ISR() void afsk_dac_isr(void)
- #define AFSK_DAC_IRQ_END() do { /* Implement me */ } while (0)
- #define AFSK_DAC_IRQ_START() do { /* Implement me */ } while (0)
- #define AFSK_DAC_IRQ_STOP() do { /* Implement me */ } while (0)
- #define AFSK_SET_DAC(val) do { (void)val; } while (0)
+ #define AFSK_DAC_INIT(ch, ctx) do { (void)ch, (void)ctx; } while (0)
+ #define AFSK_DAC_IRQ_START(ch) do { (void)ch; /* Implement me */ } while (0)
+ #define AFSK_DAC_IRQ_STOP(ch) do { (void)ch; /* Implement me */ } while (0)
+ #define AFSK_DAC_SET(ch, val) do { (void)ch; (void)val; } while (0)
#else /* (ARCH & ARCH_UNITTEST) */
#include <stdio.h>
extern FILE *fp_dac;
extern bool afsk_tx_test;
- #define AFSK_ADC_INIT() do { } while (0)
+ #define AFSK_ADC_INIT(ch, ctx) do { (void)ch, (void)ctx; } while (0)
#define AFSK_STROBE_INIT() /* Implement me */
#define AFSK_STROBE_ON() /* Implement me */
#define AFSK_STROBE_OFF() /* Implement me */
- #define AFSK_ADC_IRQ_END() do { /* Implement me */ } while (0)
-
- #define AFSK_DAC_IRQ_END() do { /* Implement me */ } while (0)
- #define AFSK_DAC_IRQ_START() do { afsk_tx_test = true; } while (0)
- #define AFSK_DAC_IRQ_STOP() do { afsk_tx_test = false; } while (0)
- #define AFSK_SET_DAC(_val) \
+ #define AFSK_DAC_INIT(ch, ctx) do { (void)ch, (void)ctx; } while (0)
+ #define AFSK_DAC_IRQ_START(ch) do { (void)ch; afsk_tx_test = true; } while (0)
+ #define AFSK_DAC_IRQ_STOP(ch) do { (void)ch; afsk_tx_test = false; } while (0)
+ #define AFSK_DAC_SET(ch, _val) \
do { \
+ (void)ch; \
int8_t val = (_val) - 128; \
ASSERT(fwrite(&val, 1, sizeof(val), fp_dac) == sizeof(val)); \
data_written++; \
AFSK_STROBE_OFF();
- AFSK_ADC_IRQ_END();
}
static void afsk_txStart(Afsk *af)
af->stuff_cnt = 0;
af->sending = true;
af->preamble_len = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000);
- AFSK_DAC_IRQ_START();
+ AFSK_DAC_IRQ_START(af->dac_ch);
}
ATOMIC(af->trailer_len = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000));
}
/* We have just finished transimitting a char, get a new one. */
if (fifo_isempty(&af->tx_fifo) && af->trailer_len == 0)
{
- AFSK_DAC_IRQ_STOP();
+ AFSK_DAC_IRQ_STOP(af->dac_ch);
af->sending = false;
- AFSK_DAC_IRQ_END();
return;
}
else
{
if (fifo_isempty(&af->tx_fifo))
{
- AFSK_DAC_IRQ_STOP();
+ AFSK_DAC_IRQ_STOP(af->dac_ch);
af->sending = false;
- AFSK_DAC_IRQ_END();
return;
}
else
af->phase_acc += af->phase_inc;
af->phase_acc %= SIN_LEN;
- AFSK_SET_DAC(sin_sample(af->phase_acc));
+ AFSK_DAC_SET(af->dac_ch, sin_sample(af->phase_acc));
af->sample_count--;
- AFSK_DAC_IRQ_END();
}
}
-void afsk_init(Afsk *af)
+void afsk_init(Afsk *af, int adc_ch, int dac_ch)
{
#if CONFIG_AFSK_RXTIMEOUT != -1
MOD_CHECK(timer);
#endif
memset(af, 0, sizeof(*af));
+ af->adc_ch = adc_ch;
+ af->dac_ch = dac_ch;
fifo_init(&af->delay_fifo, (uint8_t *)af->delay_buf, sizeof(af->delay_buf));
fifo_init(&af->rx_fifo, af->rx_buf, sizeof(af->rx_buf));
fifo_init(&af->tx_fifo, af->tx_buf, sizeof(af->tx_buf));
- AFSK_ADC_INIT();
+ AFSK_ADC_INIT(adc_ch, af);
+ AFSK_DAC_INIT(dac_ch, af);
AFSK_STROBE_INIT();
kprintf("MARK_INC %d, SPACE_INC %d\n", MARK_INC, SPACE_INC);