Cleaned up port mapping mess

This commit is contained in:
Mark Qvist 2014-04-06 20:01:24 +02:00
parent ab4e337a18
commit b4de1f73ea
3 changed files with 14 additions and 25 deletions

View File

@ -346,9 +346,8 @@ static void afsk_txStart(Afsk *afsk) {
afsk->bitstuffCount = 0;
afsk->sending = true;
LED_TX_ON();
PTT_ON();
afsk->preambleLength = DIV_ROUND(CONFIG_AFSK_PREAMBLE_LEN * BITRATE, 8000);
AFSK_DAC_IRQ_START(afsk->dacPin);
AFSK_DAC_IRQ_START();
}
ATOMIC(afsk->tailLength = DIV_ROUND(CONFIG_AFSK_TRAILER_LEN * BITRATE, 8000));
}
@ -363,10 +362,9 @@ uint8_t afsk_dac_isr(Afsk *afsk) {
// If TX FIFO is empty and tail-length has decremented to 0
// we are done, stop the IRQ and reset
if (fifo_isempty(&afsk->txFifo) && afsk->tailLength == 0) {
AFSK_DAC_IRQ_STOP(afsk->dacPin);
AFSK_DAC_IRQ_STOP();
afsk->sending = false;
LED_TX_OFF();
PTT_OFF();
return 0;
} else {
// Reset the bitstuff counter if we have just sent
@ -394,10 +392,9 @@ uint8_t afsk_dac_isr(Afsk *afsk) {
// Handle escape sequences
if (afsk->currentOutputByte == AX25_ESC) {
if (fifo_isempty(&afsk->txFifo)) {
AFSK_DAC_IRQ_STOP(afsk->dacPin);
AFSK_DAC_IRQ_STOP();
afsk->sending = false;
LED_TX_OFF();
PTT_OFF();
return 0;
} else {
afsk->currentOutputByte = fifo_pop(&afsk->txFifo);
@ -543,10 +540,9 @@ void afsk_init(Afsk *afsk, int _adcPin, int _dacPin) {
// Init DAC & ADC
AFSK_ADC_INIT(_adcPin, afsk);
AFSK_DAC_INIT(_dacPin, afsk);
AFSK_DAC_INIT();
LED_TX_INIT();
LED_RX_INIT();
PTT_INIT();
DB(afsk->fd._type = KFT_AFSK);
afsk->fd.write = afsk_write;

View File

@ -20,11 +20,6 @@ struct Afsk;
void hw_afsk_adcInit(int ch, struct Afsk *_ctx);
void hw_afsk_dacInit(int ch, struct Afsk *_ctx);
// A shorthand macro for initializing the ADC.
// It just calls the actual ADC initialization code
// in "hardware.c"
#define AFSK_ADC_INIT(ch, ctx) hw_afsk_adcInit(ch, ctx)
// Here's some macros for controlling the RX/TX LEDs
// THE _INIT() functions writes to the DDRB register
// to configure the pins as output pins, and the _ON()
@ -38,26 +33,24 @@ void hw_afsk_dacInit(int ch, struct Afsk *_ctx);
#define LED_RX_ON() do { PORTB |= BV(2); } while (0)
#define LED_RX_OFF() do { PORTB &= ~BV(2); } while (0)
// FIXME: remove these, they're in the DAC writes now
#define PTT_INIT() do { DDRD |= BV(3); } while (0)
#define PTT_ON() do { PORTD |= BV(3); } while (0)
#define PTT_OFF() do { PORTD &= ~BV(3); } while (0)
// A shorthand macro for initializing the ADC.
// It just calls the actual ADC initialization code
// in "hardware.c"
#define AFSK_ADC_INIT(ch, ctx) hw_afsk_adcInit(ch, ctx)
// Initialization of the DAC pins. The DDRD register
// configures pins 0 through 7 for input or output.
// DDR stands for Data Direction Register. By setting
// it to 0xF8 we set 11111000, which means the pins
// 3, 4, 5, 6 and 7 will be set to output.
// FIXME: remove ch and ctx
#define AFSK_DAC_INIT(ch, ctx) do { (void)ch, (void)ctx; DDRD |= 0xF8; DDRB |= BV(3); } while (0)
#define AFSK_DAC_INIT() do { DDRD |= 0xF8; } while (0)
// These two macros start and stop the DAC being
// triggered in our timer interrupt. For starting
// These two macros start and stop the DAC routine
// being called in our timer interrupt. For starting
// it, we set a boolean flag to true, and false for
// stopping it. We also turn on and off pin 3 to trigger
// the PTT of the radio.
#define AFSK_DAC_IRQ_START(ch) do { (void)ch; extern bool hw_afsk_dac_isr; PORTB |= BV(3); hw_afsk_dac_isr = true; } while (0)
#define AFSK_DAC_IRQ_STOP(ch) do { (void)ch; extern bool hw_afsk_dac_isr; PORTB &= ~BV(3); hw_afsk_dac_isr = false; } while (0)
#define AFSK_DAC_IRQ_START() do { extern bool hw_afsk_dac_isr; PORTD |= BV(3); hw_afsk_dac_isr = true; } while (0)
#define AFSK_DAC_IRQ_STOP() do { extern bool hw_afsk_dac_isr; PORTD &= ~BV(3); hw_afsk_dac_isr = false; } while (0)
#endif

View File

@ -1,2 +1,2 @@
#define VERS_BUILD 361
#define VERS_BUILD 371
#define VERS_HOST "vixen"