From 4ebb8b433309c67d161345c43c99450c661b8403 Mon Sep 17 00:00:00 2001 From: batt Date: Sat, 10 Oct 2009 13:01:56 +0000 Subject: [PATCH] Simplify afsk testing harness. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3072 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/hw/hw_afsk.h | 92 +++++++++++++++++------------------------- bertos/net/afsk_test.c | 6 +-- 2 files changed, 38 insertions(+), 60 deletions(-) diff --git a/bertos/hw/hw_afsk.h b/bertos/hw/hw_afsk.h index 6737edb4..ec9b8be2 100644 --- a/bertos/hw/hw_afsk.h +++ b/bertos/hw/hw_afsk.h @@ -42,66 +42,46 @@ #include "cfg/cfg_arch.h" -#if !(ARCH & ARCH_UNITTEST) - #warning TODO:This is an example implementation, you must implement it! +#warning TODO:This is an example implementation, you must implement it! - /** - * Initialize the specified channel of the ADC for AFSK needs. - * The adc should be configured to have a continuos stream of convertions. - * For every convertion there must be an ISR that read the sample - * and call afsk_adc_isr(), passing the context and the sample. - * - * \param ch channel to be used for AFSK demodulation. - * \param ctx AFSK context (\see Afsk). This parameter must be saved and - * passed back to afsk_adc_isr() for every convertion. - */ - #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) - - /** - * Initialize the specified channel of the DAC for AFSK needs. - * The DAC has to be configured in order to call an ISR for every sample sent. - * The DAC doesn't have to start the IRQ immediatly but have to wait - * the AFSK driver to call AFSK_DAC_IRQ_START(). - * The ISR must then call afsk_dac_isr() passing the AFSK context. - * \param ch DAC channel to be used for AFSK modulation. - * \param ctx AFSK context (\see Afsk). This parameter must be saved and - * passed back to afsk_dac_isr() for every convertion. - */ - #define AFSK_DAC_INIT(ch, ctx) do { (void)ch, (void)ctx; } while (0) - - /** - * Start DAC convertions on channel \a ch. - * \param ch DAC channel. - */ - #define AFSK_DAC_IRQ_START(ch) do { (void)ch; /* Implement me */ } while (0) - - /** - * Stop DAC convertions on channel \a ch. - * \param ch DAC channel. - */ - #define AFSK_DAC_IRQ_STOP(ch) do { (void)ch; /* Implement me */ } while (0) - -#else /* (ARCH & ARCH_UNITTEST) */ - - #include - - /* For test */ - extern bool afsk_tx_test; +/** + * Initialize the specified channel of the ADC for AFSK needs. + * The adc should be configured to have a continuos stream of convertions. + * For every convertion there must be an ISR that read the sample + * and call afsk_adc_isr(), passing the context and the sample. + * + * \param ch channel to be used for AFSK demodulation. + * \param ctx AFSK context (\see Afsk). This parameter must be saved and + * passed back to afsk_adc_isr() for every convertion. + */ +#define AFSK_ADC_INIT(ch, ctx) do { (void)ch, (void)ctx; } 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) - #define AFSK_STROBE_INIT() /* Implement me */ - #define AFSK_STROBE_ON() /* Implement me */ - #define AFSK_STROBE_OFF() /* Implement me */ +/** + * Initialize the specified channel of the DAC for AFSK needs. + * The DAC has to be configured in order to call an ISR for every sample sent. + * The DAC doesn't have to start the IRQ immediatly but have to wait + * the AFSK driver to call AFSK_DAC_IRQ_START(). + * The ISR must then call afsk_dac_isr() passing the AFSK context. + * \param ch DAC channel to be used for AFSK modulation. + * \param ctx AFSK context (\see Afsk). This parameter must be saved and + * passed back to afsk_dac_isr() for every convertion. + */ +#define AFSK_DAC_INIT(ch, ctx) do { (void)ch, (void)ctx; } while (0) - #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) +/** + * Start DAC convertions on channel \a ch. + * \param ch DAC channel. + */ +#define AFSK_DAC_IRQ_START(ch) do { (void)ch; /* Implement me */ } while (0) -#endif /* !(ARCH & ARCH_UNITTEST) */ +/** + * Stop DAC convertions on channel \a ch. + * \param ch DAC channel. + */ +#define AFSK_DAC_IRQ_STOP(ch) do { (void)ch; /* Implement me */ } while (0) #endif /* HW_AFSK_H */ diff --git a/bertos/net/afsk_test.c b/bertos/net/afsk_test.c index 09c1ffdb..9aa50830 100644 --- a/bertos/net/afsk_test.c +++ b/bertos/net/afsk_test.c @@ -61,12 +61,9 @@ FILE *fp_adc; FILE *fp_dac; uint32_t data_size; uint32_t data_written; -bool afsk_tx_test; Afsk afsk_fd; AX25Ctx ax25; -int8_t afsk_adc_val; - int msg_cnt; static void message_hook(UNUSED_ARG(struct AX25Msg *, msg)) { @@ -183,12 +180,13 @@ int afsk_testRun(void) ax25_send(&ax25, AX25_CALL("abcdef", 0), AX25_CALL("123456", 1), buf, sizeof(buf)); - while (afsk_tx_test) + do { int8_t val = afsk_dac_isr(&afsk_fd) - 128; ASSERT(fwrite(&val, 1, sizeof(val), fp_dac) == sizeof(val)); data_written++; } + while (afsk_fd.sending); #define SND_DATASIZE_OFF 8 #if CPU_AVR -- 2.25.1