From: batt Date: Fri, 9 Oct 2009 21:48:32 +0000 (+0000) Subject: Add support for preamble/trailer before starting real data transmission: this give... X-Git-Tag: 2.3.0~30 X-Git-Url: https://codewiz.org/gitweb?p=bertos.git;a=commitdiff_plain;h=441c294a809638c22c77ae37c8e7bb57cf57f126 Add support for preamble/trailer before starting real data transmission: this give the TX rig some time to switch to/from transmit mode. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3053 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cfg/cfg_afsk.h b/bertos/cfg/cfg_afsk.h index 791916d2..f5a27e42 100644 --- a/bertos/cfg/cfg_afsk.h +++ b/bertos/cfg/cfg_afsk.h @@ -62,7 +62,7 @@ * $WIZ$ type = "int" * $WIZ$ min = 2 */ -#define CONFIG_AFSK_TX_BUFLEN 256 +#define CONFIG_AFSK_TX_BUFLEN 32 /** * AFSK DAC sample rate for modem outout. @@ -78,4 +78,21 @@ */ #define CONFIG_AFSK_RXTIMEOUT 0 + +/** + * AFSK Preamble length in [ms], before starting transmissions. + * $WIZ$ type = "int" + * $WIZ$ min = 1 + */ +#define CONFIG_AFSK_PREAMBLE_LEN 300UL + + + +/** + * AFSK Trailer length in [ms], before stopping transmissions. + * $WIZ$ type = "int" + * $WIZ$ min = 1 + */ +#define CONFIG_AFSK_TRAILER_LEN 50UL + #endif /* CFG_AFSK_H */ diff --git a/bertos/net/afsk.c b/bertos/net/afsk.c index d2291262..e516a3f3 100644 --- a/bertos/net/afsk.c +++ b/bertos/net/afsk.c @@ -164,6 +164,9 @@ static uint8_t hdlc_bit_idx; #define BIT_DIFFER(bitline1, bitline2) (((bitline1) ^ (bitline2)) & 0x01) #define EDGE_FOUND(bitline) BIT_DIFFER((bitline), (bitline) >> 1) +static uint16_t preamble_len; +static uint16_t trailer_len; + static void hdlc_parse(bool bit) { demod_bits <<= 1; @@ -342,8 +345,10 @@ static void afsk_txStart(void) phase_acc = 0; stuff_cnt = 0; sending = true; + preamble_len = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000); AFSK_DAC_IRQ_START(); } + ATOMIC(trailer_len = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000)); } #define BIT_STUFF_LEN 5 @@ -358,7 +363,7 @@ DEFINE_AFSK_DAC_ISR() if (tx_bit == 0) { /* We have just finished transimitting a char, get a new one. */ - if (fifo_isempty(&tx_fifo)) + if (fifo_isempty(&tx_fifo) && trailer_len == 0) { AFSK_DAC_IRQ_STOP(); sending = false; @@ -375,7 +380,25 @@ DEFINE_AFSK_DAC_ISR() stuff_cnt = 0; bit_stuff = true; - curr_out = fifo_pop(&tx_fifo); + + /* + * Handle preamble and trailer + */ + if (preamble_len == 0) + { + if (fifo_isempty(&tx_fifo)) + { + trailer_len--; + curr_out = HDLC_FLAG; + } + else + curr_out = fifo_pop(&tx_fifo); + } + else + { + preamble_len--; + curr_out = HDLC_FLAG; + } /* Handle char escape */ if (curr_out == AX25_ESC)