Changeset - 02b6a488f4ee
[Not reviewed]
default
0 5 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-01 14:53:54
ethanzonca@CL-SEC241-08.cedarville.edu
Work on AFSK, minor mods to slave
5 files changed with 113 insertions and 97 deletions:
0 comments (0 inline, 0 general)
master/master/lib/afsk.c
Show inline comments
 
@@ -5,18 +5,6 @@
 
 *  Author: ethanzonca
 
 */ 
 
 
/*
 
 * Master Firmware
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 

	
 
#define F_CPU 11059200
 

	
 
#include <stdint.h>
 
@@ -55,7 +43,7 @@ PROGMEM extern const uint8_t afsk_sine_t
 
  115, 116, 118, 119, 121, 122, 124, 125
 
};
 

	
 
inline uint8_t afsk_read_sample(int phase)
 
static inline uint8_t afsk_read_sample(int phase)
 
{
 
  return pgm_read_byte_near(afsk_sine_table + phase);
 
}
 
@@ -64,51 +52,6 @@ volatile uint16_t phase = 10;
 
volatile uint16_t phasedelta = 3300;
 
extern const uint16_t TABLE_SIZE = sizeof(afsk_sine_table);
 

	
 
void afsk_setup() {
 
	
 
  // Source timer2 from clkIO (datasheet p.164)
 
  ASSR &= ~(_BV(EXCLK) | _BV(AS2));
 

	
 
  // Set fast PWM mode with TOP = 0xff: WGM22:0 = 3  (p.150)
 
  TCCR2A |= _BV(WGM21) | _BV(WGM20);
 
  TCCR2B &= ~_BV(WGM22);
 

	
 
  // Do non-inverting PWM on pin OC2B (arduino pin 3) (p.159).
 
  // OC2A (arduino pin 11) stays in normal port operation:
 
  // COM2B1=1, COM2B0=0, COM2A1=0, COM2A0=0
 
  TCCR2A = (TCCR2A | _BV(COM2B1)) & ~(_BV(COM2B0) | _BV(COM2A1) | _BV(COM2A0));
 

	
 
  // No prescaler (p.162)
 
  TCCR2B = (TCCR2B & ~(_BV(CS22) | _BV(CS21))) | _BV(CS20);
 
    
 
  // Enable interrupt when TCNT2 reaches TOP (0xFF) (p.151, 163)
 
	//TIMSK2 |= _BV(TOIE2);
 
	TIMSK2 |= 0b00000001;
 

	
 
	// Initialize PORTA
 
	DDRA = 0xff;
 
	PORTA = 0x00;
 
	
 
	DDRD = 0xff;
 
	PORTD = 0xff;
 
	
 
	// todo: init radio, maybe in main
 
	
 
	sei();
 
}
 

	
 

	
 
void afsk_test() {	
 
	uint8_t flap[26] = {"abcdefghijklmnopqrstuvwxyz"};
 
	afsk_send(flap, sizeof(flap)*8);
 
	afsk_start();
 
	while(afsk_busy());
 
	_delay_ms(500);
 
}
 

	
 

	
 

	
 

	
 
// constants
 
#define MODEM_CLOCK_RATE F_CPU
 
#define PLAYBACK_RATE MODEM_CLOCK_RATE / 256  // Fast PWM
 
@@ -136,41 +79,22 @@ volatile unsigned int afsk_packet_size =
 
volatile const uint8_t *afsk_packet;
 

	
 

	
 
void afsk_send(const uint8_t *buffer, int len)
 
{
 
	afsk_packet_size = len;
 
	afsk_packet = buffer;
 
}
 

	
 

	
 

	
 
int afsk_busy()
 
{
 
	return go;
 

	
 
void afsk_ptt_off() {
 
	// turn ptt off
 
}
 

	
 
void afsk_start()
 
{
 
	phasedelta = PHASE_DELTA_1200;
 
	phase = 0;
 
	packet_pos = 0;
 
	current_sample_in_baud = 0;
 
	go = true;
 

	
 
	// Key the radio
 
	afsk_ptt_on();
 

	
 
	// Start transmission
 
	afsk_timer_start();
 
void afsk_ptt_on() {
 
	// turn the ptt on... possibly delay based on spec
 
}
 

	
 

	
 

	
 
afsk_ptt_off() {
 
	
 
}
 

	
 
afsk_ptt_on() {
 
	
 
}
 

	
 

	
 
ISR(TIMER2_OVF_vect) 
 
@@ -235,3 +159,78 @@ void afsk_timer_stop()
 
	// Disable playback interrupt
 
	TIMSK2 &= ~_BV(TOIE2);
 
}
 

	
 

	
 

	
 

	
 

	
 
// External
 

	
 
void afsk_start()
 
{
 
	phasedelta = PHASE_DELTA_1200;
 
	phase = 0;
 
	packet_pos = 0;
 
	current_sample_in_baud = 0;
 
	go = true;
 

	
 
	// Key the radio
 
	afsk_ptt_on();
 

	
 
	// Start transmission
 
	afsk_timer_start();
 
}
 

	
 
int afsk_busy()
 
{
 
	return go;
 
}
 

	
 
void afsk_send(const uint8_t *buffer, int len)
 
{
 
	afsk_packet_size = len;
 
	afsk_packet = buffer;
 
}
 

	
 

	
 
void afsk_setup() {
 
	
 
	// Source timer2 from clkIO (datasheet p.164)
 
	ASSR &= ~(_BV(EXCLK) | _BV(AS2));
 

	
 
	// Set fast PWM mode with TOP = 0xff: WGM22:0 = 3  (p.150)
 
	TCCR2A |= _BV(WGM21) | _BV(WGM20);
 
	TCCR2B &= ~_BV(WGM22);
 

	
 
	// Do non-inverting PWM on pin OC2B (arduino pin 3) (p.159).
 
	// OC2A (arduino pin 11) stays in normal port operation:
 
	// COM2B1=1, COM2B0=0, COM2A1=0, COM2A0=0
 
	TCCR2A = (TCCR2A | _BV(COM2B1)) & ~(_BV(COM2B0) | _BV(COM2A1) | _BV(COM2A0));
 

	
 
	// No prescaler (p.162)
 
	TCCR2B = (TCCR2B & ~(_BV(CS22) | _BV(CS21))) | _BV(CS20);
 
	
 
	// Enable interrupt when TCNT2 reaches TOP (0xFF) (p.151, 163)
 
	//TIMSK2 |= _BV(TOIE2);
 
	TIMSK2 |= 0b00000001;
 

	
 
	// Initialize PORTA
 
	DDRA = 0xff;
 
	PORTA = 0x00;
 
	
 
	DDRD = 0xff;
 
	PORTD = 0xff;
 
	
 
	// todo: init radio, maybe in main
 
	
 
	sei();
 
}
 

	
 

	
 
void afsk_test() {
 
	uint8_t flap[26] = {"abcdefghijklmnopqrstuvwxyz"};
 
	afsk_send(flap, sizeof(flap)*8);
 
	afsk_start();
 
	while(afsk_busy());
 
	_delay_ms(500);
 
}
master/master/lib/afsk.h
Show inline comments
 
@@ -11,7 +11,8 @@
 
 
void afsk_setup();
 
void afsk_test();
 
void afsk_send(const uint8_t *buffer, int len);
 
int afsk_busy();
 
void afsk_start();
 
void afsk_stop();
 
 
#endif /* AFSK_H_ */
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
/*
 
 * master.c
 
 * Master Firmware
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 *
 
 * Created: 10/25/2012 2:48:04 PM
 
 *  Author: mkanning
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */ 
 
 
master/master/master.cproj
Show inline comments
 
@@ -120,6 +120,12 @@
 
    <Compile Include="lib\afsk.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\ax25.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\ax25.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\led.c">
 
      <SubType>compile</SubType>
 
    </Compile>
slave2/slave/slave/slave.c
Show inline comments
 
/*
 
 * slave.c
 
 * Slave Firmware
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 *
 
 * Created: 10/25/2012 9:59:40 PM
 
 *  Author: mkanning
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
@@ -12,21 +17,21 @@
 
 #include <util/delay.h>
 
 
 #include "lib/serial.h"
 
 
#include "lib/led.h"
 
 
 void micro_Configure() {
 
void micro_setup() {
 
	 // Generic microcontroller config options
 
 }
 
 
 int main(void)
 
 {
 
	 // Initialize
 
	 micro_Configure();
 
	 led_Configure();
 
	 serial_Configure(); // Config serial ports
 
	micro_setup();
 
	led_setup();
 
	serial_setup(); // Config serial ports
 
	 
 
	 while(1)
 
	 {
 
		 serial_SendCommand('0','A',0,0);
 
        //serial_SendCommand('0','A',0,0);
 
	 }
 
 }
 
\ No newline at end of file
0 comments (0 inline, 0 general)