Rolling back changes from a7a167c19b
that broke the build. Please test on actual hardware before pull-requesting "improvements"...
This commit is contained in:
parent
cd07dc7e67
commit
1f94513b58
11
device.h
11
device.h
|
@ -38,17 +38,8 @@
|
||||||
#define DAC_DDR DDRD
|
#define DAC_DDR DDRD
|
||||||
#define LED_PORT PORTB
|
#define LED_PORT PORTB
|
||||||
#define LED_DDR DDRB
|
#define LED_DDR DDRB
|
||||||
#define PTT_PORT PORTD
|
|
||||||
#define PTT_DDR DDRD
|
|
||||||
#define ADC_PORT PORTC
|
#define ADC_PORT PORTC
|
||||||
#define ADC_DDR DDRC
|
#define ADC_DDR DDRC
|
||||||
// Pins 3-7 on Port D = Arduino D3 - D7
|
|
||||||
#define DAC_HIGH _BV(7)
|
|
||||||
#define DAC_PINS _BV(7)&_BV(6)&_BV(5)&_BV(4)
|
|
||||||
#define LED_TX 1 // Arduino D9
|
|
||||||
#define LED_RX 2 // Arduino D10
|
|
||||||
#define PTT_TX 3 // Arduino D11
|
|
||||||
#define ADC_NO 0 // Arduino A0
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -38,9 +38,9 @@ void AFSK_hw_init(void) {
|
||||||
ADMUX = 0;
|
ADMUX = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ADC_DDR &= ~_BV(ADC_NO);
|
ADC_DDR &= ~_BV(0);
|
||||||
ADC_PORT &= ~_BV(ADC_NO);
|
ADC_PORT &= ~_BV(0);
|
||||||
DIDR0 |= _BV(ADC_NO);
|
DIDR0 |= _BV(0);
|
||||||
ADCSRB = _BV(ADTS2) |
|
ADCSRB = _BV(ADTS2) |
|
||||||
_BV(ADTS1) |
|
_BV(ADTS1) |
|
||||||
_BV(ADTS0);
|
_BV(ADTS0);
|
||||||
|
@ -51,7 +51,6 @@ void AFSK_hw_init(void) {
|
||||||
_BV(ADPS2);
|
_BV(ADPS2);
|
||||||
|
|
||||||
AFSK_DAC_INIT();
|
AFSK_DAC_INIT();
|
||||||
PTT_INIT();
|
|
||||||
LED_TX_INIT();
|
LED_TX_INIT();
|
||||||
LED_RX_INIT();
|
LED_RX_INIT();
|
||||||
}
|
}
|
||||||
|
@ -85,7 +84,6 @@ static void AFSK_txStart(Afsk *afsk) {
|
||||||
afsk->phaseAcc = 0;
|
afsk->phaseAcc = 0;
|
||||||
afsk->bitstuffCount = 0;
|
afsk->bitstuffCount = 0;
|
||||||
afsk->sending = true;
|
afsk->sending = true;
|
||||||
PTT_TX_ON();
|
|
||||||
LED_TX_ON();
|
LED_TX_ON();
|
||||||
afsk->preambleLength = DIV_ROUND(custom_preamble * BITRATE, 8000);
|
afsk->preambleLength = DIV_ROUND(custom_preamble * BITRATE, 8000);
|
||||||
AFSK_DAC_IRQ_START();
|
AFSK_DAC_IRQ_START();
|
||||||
|
@ -123,7 +121,6 @@ uint8_t AFSK_dac_isr(Afsk *afsk) {
|
||||||
if (fifo_isempty(&afsk->txFifo) && afsk->tailLength == 0) {
|
if (fifo_isempty(&afsk->txFifo) && afsk->tailLength == 0) {
|
||||||
AFSK_DAC_IRQ_STOP();
|
AFSK_DAC_IRQ_STOP();
|
||||||
afsk->sending = false;
|
afsk->sending = false;
|
||||||
PTT_TX_OFF();
|
|
||||||
LED_TX_OFF();
|
LED_TX_OFF();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +141,6 @@ uint8_t AFSK_dac_isr(Afsk *afsk) {
|
||||||
if (fifo_isempty(&afsk->txFifo)) {
|
if (fifo_isempty(&afsk->txFifo)) {
|
||||||
AFSK_DAC_IRQ_STOP();
|
AFSK_DAC_IRQ_STOP();
|
||||||
afsk->sending = false;
|
afsk->sending = false;
|
||||||
PTT_TX_OFF();
|
|
||||||
LED_TX_OFF();
|
LED_TX_OFF();
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -503,12 +499,9 @@ ISR(ADC_vect) {
|
||||||
TIFR1 = _BV(ICF1);
|
TIFR1 = _BV(ICF1);
|
||||||
AFSK_adc_isr(AFSK_modem, ((int16_t)((ADC) >> 2) - 128));
|
AFSK_adc_isr(AFSK_modem, ((int16_t)((ADC) >> 2) - 128));
|
||||||
if (hw_afsk_dac_isr) {
|
if (hw_afsk_dac_isr) {
|
||||||
// Set DAC pin(s) according to position in SIN wave.
|
DAC_PORT = (AFSK_dac_isr(AFSK_modem) & 0xF0) | _BV(3);
|
||||||
DAC_PORT |= (AFSK_dac_isr(AFSK_modem) & DAC_PINS);
|
|
||||||
} else {
|
} else {
|
||||||
// Set DAC pin(s) to the zero point in the SIN wave.
|
DAC_PORT = 128;
|
||||||
// This is represented by setting only the high-bit.
|
|
||||||
DAC_PORT = (DAC_PORT & (~DAC_PINS)) | DAC_HIGH;
|
|
||||||
}
|
}
|
||||||
++_clock;
|
++_clock;
|
||||||
}
|
}
|
|
@ -142,30 +142,23 @@ typedef struct Afsk
|
||||||
|
|
||||||
#define AFSK_DAC_IRQ_START() do { extern bool hw_afsk_dac_isr; hw_afsk_dac_isr = true; } while (0)
|
#define AFSK_DAC_IRQ_START() do { extern bool hw_afsk_dac_isr; hw_afsk_dac_isr = true; } while (0)
|
||||||
#define AFSK_DAC_IRQ_STOP() do { extern bool hw_afsk_dac_isr; hw_afsk_dac_isr = false; } while (0)
|
#define AFSK_DAC_IRQ_STOP() do { extern bool hw_afsk_dac_isr; hw_afsk_dac_isr = false; } while (0)
|
||||||
// DAC_PINS equals b11111000 which on port D on Arduino sets D3, D4, D5, D6, D7
|
#define AFSK_DAC_INIT() do { DAC_DDR |= 0xF8; } while (0)
|
||||||
// to be outputs.
|
|
||||||
#define AFSK_DAC_INIT() do { DAC_DDR |= DAC_PINS; } while (0)
|
|
||||||
|
|
||||||
// Here's some macros for controlling the RX/TX LEDs
|
// Here's some macros for controlling the RX/TX LEDs
|
||||||
// THE _INIT() functions writes to the DDRB register
|
// THE _INIT() functions writes to the DDRB register
|
||||||
// to configure the pins as output pins, and the _ON()
|
// to configure the pins as output pins, and the _ON()
|
||||||
// and _OFF() functions writes to the PORT registers
|
// and _OFF() functions writes to the PORT registers
|
||||||
// to turn the pins on or off.
|
// to turn the pins on or off.
|
||||||
#define LED_TX_INIT() do { LED_DDR |= _BV(LED_TX); } while (0)
|
#define LED_TX_INIT() do { LED_DDR |= _BV(1); } while (0)
|
||||||
#define LED_TX_ON() do { LED_PORT |= _BV(LED_TX); } while (0)
|
#define LED_TX_ON() do { LED_PORT |= _BV(1); } while (0)
|
||||||
#define LED_TX_OFF() do { LED_PORT &= ~_BV(LED_TX); } while (0)
|
#define LED_TX_OFF() do { LED_PORT &= ~_BV(1); } while (0)
|
||||||
|
|
||||||
#define LED_RX_INIT() do { LED_DDR |= _BV(LED_RX); } while (0)
|
#define LED_RX_INIT() do { LED_DDR |= _BV(2); } while (0)
|
||||||
#define LED_RX_ON() do { LED_PORT |= _BV(LED_RX); } while (0)
|
#define LED_RX_ON() do { LED_PORT |= _BV(2); } while (0)
|
||||||
#define LED_RX_OFF() do { LED_PORT &= ~_BV(LED_RX); } while (0)
|
#define LED_RX_OFF() do { LED_PORT &= ~_BV(2); } while (0)
|
||||||
|
|
||||||
// Along the same lines, these initialize and control the PTT signal
|
|
||||||
#define PTT_INIT() do { PTT_DDR |= _BV(PTT_TX); } while (0)
|
|
||||||
#define PTT_TX_ON() do { PTT_PORT |= _BV(PTT_TX); } while (0)
|
|
||||||
#define PTT_TX_OFF() do { PTT_PORT &= ~_BV(PTT_TX); } while (0)
|
|
||||||
|
|
||||||
void AFSK_init(Afsk *afsk);
|
void AFSK_init(Afsk *afsk);
|
||||||
void AFSK_transmit(char *buffer, size_t size);
|
void AFSK_transmit(char *buffer, size_t size);
|
||||||
void AFSK_poll(Afsk *afsk);
|
void AFSK_poll(Afsk *afsk);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue