X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fafsk.c;h=229ca3ec359e0e44a5a2d8ffb5361ccfe9df35d3;hb=35be7aa348f671b0ed50ee43d903444edc4892af;hp=01b4347423030e146af30799870886d7eed1fda3;hpb=2a398044dd1d7b2af34a96c19ad378c25b546579;p=bertos.git diff --git a/bertos/net/afsk.c b/bertos/net/afsk.c index 01b43474..229ca3ec 100644 --- a/bertos/net/afsk.c +++ b/bertos/net/afsk.c @@ -32,7 +32,6 @@ * * \brief AFSK1200 modem. * - * \version $Id$ * \author Francesco Sacchi */ @@ -119,7 +118,16 @@ INLINE uint8_t sin_sample(uint16_t idx) #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; @@ -200,7 +208,7 @@ static bool hdlc_parse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) * 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) @@ -331,13 +339,14 @@ static void afsk_txStart(Afsk *af) * 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) { @@ -348,7 +357,8 @@ void afsk_dac_isr(Afsk *af) { AFSK_DAC_IRQ_STOP(af->dac_ch); af->sending = false; - return; + AFSK_STROBE_OFF(); + return 0; } else { @@ -387,7 +397,8 @@ void afsk_dac_isr(Afsk *af) { 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); @@ -444,8 +455,9 @@ void afsk_dac_isr(Afsk *af) 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); } @@ -522,7 +534,7 @@ static void afsk_clearerr(KFile *fd) /** * 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. */