Changeset - 9716361162e0
[Not reviewed]
default
0 5 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-08 15:40:33
ethanzonca@CL-SEC241-08.cedarville.edu
ax25 implementation complete (compiles)
5 files changed with 27 insertions and 6 deletions:
0 comments (0 inline, 0 general)
master/master/config.h
Show inline comments
 
/*
 
 * config.h
 
 *
 
 * Created: 10/25/2012 3:28:22 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef CONFIG_H_
 
#define CONFIG_H_
 
 
#define F_CPU 11059200
 
#define MODULE_ID '1'
 
 
// --------------------------------------------------------------------------
 
// AX.25 config (ax25.c)
 
// --------------------------------------------------------------------------
 

	
 
// TX delay in milliseconds
 
#define TX_DELAY      300
 

	
 
// Maximum packet delay
 
#define MAX_PACKET_LEN 512  // bytes
 
 
 
 
#endif /* CONFIG_H_ */
 
\ No newline at end of file
master/master/lib/afsk.c
Show inline comments
 
/*
 
 * fsk.c
 
 *
 
 * Created: 10/29/2012 7:40:34 PM
 
 *  Author: ethanzonca
 
 */
 

	
 
#define F_CPU 11059200
 

	
 
#include "../config.h"
 

	
 
#include <stdint.h>
 
#include <stdbool.h>
 
#include <avr/io.h>
 
#include <avr/interrupt.h> 
 
#include <util/delay.h>
 
#include <avr/pgmspace.h>
 

	
 

	
 
PROGMEM extern const uint8_t afsk_sine_table[512] = {
 
  127, 129, 130, 132, 133, 135, 136, 138, 139, 141, 143, 144, 146, 147, 149, 150, 152, 153, 155, 156, 158, 
 
  159, 161, 163, 164, 166, 167, 168, 170, 171, 173, 174, 176, 177, 179, 180, 182, 183, 184, 186, 187, 188, 
 
  190, 191, 193, 194, 195, 197, 198, 199, 200, 202, 203, 204, 205, 207, 208, 209, 210, 211, 213, 214, 215, 
 
  216, 217, 218, 219, 220, 221, 223, 224, 225, 226, 227, 228, 228, 229, 230, 231, 232, 233, 234, 235, 236, 
 
  236, 237, 238, 239, 239, 240, 241, 242, 242, 243, 244, 244, 245, 245, 246, 247, 247, 248, 248, 249, 249, 
 
  249, 250, 250, 251, 251, 251, 252, 252, 252, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 
 
  254, 254, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, 253, 253, 253, 252, 252, 252, 251, 
 
  251, 251, 250, 250, 249, 249, 249, 248, 248, 247, 247, 246, 245, 245, 244, 244, 243, 242, 242, 241, 240, 
 
  239, 239, 238, 237, 236, 236, 235, 234, 233, 232, 231, 230, 229, 228, 228, 227, 226, 225, 224, 223, 221, 
 
  220, 219, 218, 217, 216, 215, 214, 213, 211, 210, 209, 208, 207, 205, 204, 203, 202, 200, 199, 198, 197, 
 
  195, 194, 193, 191, 190, 188, 187, 186, 184, 183, 182, 180, 179, 177, 176, 174, 173, 171, 170, 168, 167, 
 
  166, 164, 163, 161, 159, 158, 156, 155, 153, 152, 150, 149, 147, 146, 144, 143, 141, 139, 138, 136, 135, 
 
  133, 132, 130, 129, 127, 125, 124, 122, 121, 119, 118, 116, 115, 113, 111, 110, 108, 107, 105, 104, 102, 
 
  101,  99,  98,  96,  95,  93,  91,  90,  88,  87,  86,  84,  83,  81,  80,  78,  77,  75,  74,  72,  71, 
master/master/lib/afsk.h
Show inline comments
 
/*
 
 * afsk.h
 
 *
 
 * Created: 10/29/2012 7:43:03 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef AFSK_H_
 
#define AFSK_H_
 
 
// Private
 
void afsk_output_sample(uint8_t s);
 
void afsk_timer_stop();
 
 
// Public
 
void afsk_setup();
 
void afsk_test();
 
void afsk_send(const uint8_t *buffer, int len);
 
int afsk_busy();
 
void afsk_start();
 
 
#endif /* AFSK_H_ */
 
\ No newline at end of file
master/master/lib/ax25.c
Show inline comments
 
/*
 
 * ax25.c
 
 *
 
 * Created: 10/30/2012 12:16:41 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
/*
 

	
 
#include <inttypes.h>
 
#include "../config.h"
 
#include "ax25.h"
 
#include "afsk.h"
 

	
 
// Module constants
 
#define MAX_PACKET_LEN 512  // bytes
 

	
 
// Module globals
 
static uint16_t crc;
 
static uint8_t ones_in_a_row;
 
static uint8_t packet[MAX_PACKET_LEN];
 
static unsigned int packet_size;
 

	
 
// Module functions
 
void update_crc(uint8_t a_bit)
 
{
 
	crc ^= a_bit;
 
	if (crc & 1)
 
	crc = (crc >> 1) ^ 0x8408;  // X-modem CRC poly
 
	else
 
	crc = crc >> 1;
 
}
 

	
 
void send_byte(uint8_t a_byte)
 
{
 
	uint8_t i = 0;
 
	while (i++ < 8) {
 
		uint8_t a_bit = a_byte & 1;
 
		a_byte >>= 1;
 
		update_crc(a_bit);
 
		if (a_bit) {
 
@@ -113,25 +112,24 @@ void ax25_send_header(const struct s_add
 
	// Protocol ID: 0xf0 = no layer 3 data
 
	send_byte(0xf0);
 
}
 

	
 
void ax25_send_footer()
 
{
 
	// Save the crc so that it can be treated it atomically
 
	uint16_t final_crc = crc;
 
	
 
	// Send the CRC
 
	send_byte(~(final_crc & 0xff));
 
	final_crc >>= 8;
 
	send_byte(~(final_crc & 0xff));
 
	
 
	// Signal the end of frame
 
	ax25_send_flag();
 
}
 

	
 
void ax25_flush_frame()
 
{
 
	// Key the transmitter and send the frame
 
	afsk_send(packet, packet_size);
 
	afsk_start();
 
}
 
*/
 
\ No newline at end of file
master/master/lib/ax25.h
Show inline comments
 
/*
 
 * ax25.h
 
 *
 
 * Created: 10/30/2012 12:14:05 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef AX25_H_
 
#define AX25_H_
 
 
struct s_address {
 
	char callsign[7];
 
	unsigned char ssid;
 
};
 
 
void ax25_send_byte(uint8_t a_byte);
 
void ax25_send_flag();
 
void ax25_send_string(const char *string);
 
void ax25_send_header(const struct s_address *addresses, int num_addresses);
 
void ax25_send_footer();
 
void ax25_flush_frame();
 
 
#endif /* AX25_H_ */
 
\ No newline at end of file
0 comments (0 inline, 0 general)