2014-04-06 11:46:24 -06:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// First things first, all the includes we need //
|
|
|
|
//////////////////////////////////////////////////////
|
2014-04-03 14:21:37 -06:00
|
|
|
|
2014-04-03 14:29:26 -06:00
|
|
|
#ifndef FSK_MODEM_HW
|
|
|
|
#define FSK_MODEM_HW
|
2014-04-03 14:21:37 -06:00
|
|
|
|
2014-05-20 03:20:19 -06:00
|
|
|
#include "cfg/cfg_arch.h" // Architecture configuration
|
2014-04-03 14:21:37 -06:00
|
|
|
|
2014-05-20 03:20:19 -06:00
|
|
|
#include <avr/io.h> // AVR IO functions from BertOS
|
2014-04-03 14:21:37 -06:00
|
|
|
|
2014-04-06 11:46:24 -06:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Definitions and some useful macros //
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Forward declaration of our modem "object"
|
2014-04-03 14:21:37 -06:00
|
|
|
struct Afsk;
|
2014-04-06 11:46:24 -06:00
|
|
|
|
|
|
|
// Function declarations
|
2014-04-03 14:21:37 -06:00
|
|
|
void hw_afsk_adcInit(int ch, struct Afsk *_ctx);
|
|
|
|
void hw_afsk_dacInit(int ch, struct Afsk *_ctx);
|
|
|
|
|
2014-04-06 11:03:45 -06:00
|
|
|
// Here's some macros for controlling the RX/TX LEDs
|
2014-04-06 11:46:24 -06:00
|
|
|
// THE _INIT() functions writes to the DDRB register
|
|
|
|
// to configure the pins as output pins, and the _ON()
|
|
|
|
// and _OFF() functions writes to the PORT registers
|
|
|
|
// to turn the pins on or off.
|
2014-04-06 09:17:13 -06:00
|
|
|
#define LED_TX_INIT() do { DDRB |= BV(1); } while (0)
|
|
|
|
#define LED_TX_ON() do { PORTB |= BV(1); } while (0)
|
|
|
|
#define LED_TX_OFF() do { PORTB &= ~BV(1); } while (0)
|
|
|
|
|
|
|
|
#define LED_RX_INIT() do { DDRB |= BV(2); } while (0)
|
|
|
|
#define LED_RX_ON() do { PORTB |= BV(2); } while (0)
|
|
|
|
#define LED_RX_OFF() do { PORTB &= ~BV(2); } while (0)
|
|
|
|
|
2014-04-06 12:01:24 -06:00
|
|
|
// 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)
|
2014-04-03 14:21:37 -06:00
|
|
|
|
2014-04-06 11:46:24 -06:00
|
|
|
// 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.
|
2014-04-06 12:01:24 -06:00
|
|
|
#define AFSK_DAC_INIT() do { DDRD |= 0xF8; } while (0)
|
2014-04-06 11:46:24 -06:00
|
|
|
|
2014-04-06 12:01:24 -06:00
|
|
|
// These two macros start and stop the DAC routine
|
|
|
|
// being called in our timer interrupt. For starting
|
2014-04-06 11:46:24 -06:00
|
|
|
// 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.
|
2014-04-06 12:01:24 -06:00
|
|
|
#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)
|
2014-04-03 14:21:37 -06:00
|
|
|
|
2014-04-27 10:54:01 -06:00
|
|
|
#define AFSK_HW_PTT_ON() do { extern bool hw_ptt_on; hw_ptt_on = true; } while (0)
|
|
|
|
#define AFSK_HW_PTT_OFF() do { extern bool hw_ptt_on; hw_ptt_on = false; } while (0)
|
|
|
|
|
2014-04-03 14:29:26 -06:00
|
|
|
#endif
|