More commenting
This commit is contained in:
parent
fd6fbf7018
commit
e5513801f6
21
Modem/afsk.c
21
Modem/afsk.c
|
@ -396,16 +396,29 @@ void afsk_adc_isr(Afsk *afsk, int8_t currentSample) {
|
||||||
// synthesized by the DAC.
|
// synthesized by the DAC.
|
||||||
#define SWITCH_TONE(inc) (((inc) == MARK_INC) ? SPACE_INC : MARK_INC)
|
#define SWITCH_TONE(inc) (((inc) == MARK_INC) ? SPACE_INC : MARK_INC)
|
||||||
|
|
||||||
|
// This function starts the transmission
|
||||||
static void afsk_txStart(Afsk *afsk) {
|
static void afsk_txStart(Afsk *afsk) {
|
||||||
if (!afsk->sending) {
|
if (!afsk->sending) {
|
||||||
|
// Initialize the phase increment to
|
||||||
|
// that of the mark frequency
|
||||||
afsk->phaseInc = MARK_INC;
|
afsk->phaseInc = MARK_INC;
|
||||||
|
// Reset the phase accumulator to 0
|
||||||
afsk->phaseAcc = 0;
|
afsk->phaseAcc = 0;
|
||||||
|
// And also the bitstuff counter
|
||||||
afsk->bitstuffCount = 0;
|
afsk->bitstuffCount = 0;
|
||||||
|
// Indicate we are now sending
|
||||||
afsk->sending = true;
|
afsk->sending = true;
|
||||||
|
// And turn on the blingy LED
|
||||||
LED_TX_ON();
|
LED_TX_ON();
|
||||||
|
// We also need to calculate how many HDLC_FLAG
|
||||||
|
// bytes we need to send in preamble
|
||||||
afsk->preambleLength = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000);
|
afsk->preambleLength = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000);
|
||||||
AFSK_DAC_IRQ_START();
|
AFSK_DAC_IRQ_START();
|
||||||
}
|
}
|
||||||
|
// We make the same calculation for the tail length,
|
||||||
|
// but this needs to be atomic, since the txStart
|
||||||
|
// function could potentially be called while we
|
||||||
|
// are already transmitting.
|
||||||
ATOMIC(afsk->tailLength = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000));
|
ATOMIC(afsk->tailLength = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,10 +563,16 @@ uint8_t afsk_dac_isr(Afsk *afsk) {
|
||||||
afsk->sampleIndex = DAC_SAMPLESPERBIT;
|
afsk->sampleIndex = DAC_SAMPLESPERBIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve af new sample and DAC it
|
// We increment the phase accumulator
|
||||||
|
// by the amount needed for the tone
|
||||||
afsk->phaseAcc += afsk->phaseInc;
|
afsk->phaseAcc += afsk->phaseInc;
|
||||||
|
// We then make sure that we have not
|
||||||
|
// exceeded the length of our sine table
|
||||||
afsk->phaseAcc %= SIN_LEN;
|
afsk->phaseAcc %= SIN_LEN;
|
||||||
|
// Finally we decrement the sample counter
|
||||||
afsk->sampleIndex--;
|
afsk->sampleIndex--;
|
||||||
|
// ... and return the sample to for it to
|
||||||
|
// be written out
|
||||||
return sinSample(afsk->phaseAcc);
|
return sinSample(afsk->phaseAcc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ static void mp1Decode(MP1 *mp1) {
|
||||||
// if valid packets are found //
|
// if valid packets are found //
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void mp1Poll(MP1 *mp1) {
|
void mp1Poll(MP1 *mp1) {
|
||||||
int byte;
|
int byte; // A place to store our read byte
|
||||||
|
|
||||||
// Read bytes from the modem until we reach EOF
|
// Read bytes from the modem until we reach EOF
|
||||||
while ((byte = kfile_getc(mp1->modem)) != EOF) {
|
while ((byte = kfile_getc(mp1->modem)) != EOF) {
|
||||||
|
|
Loading…
Reference in New Issue