Changeset - dc014539e59f
[Not reviewed]
default
0 6 0
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-11-07 20:32:23
ethanzonca@CL-SEC241-08.cedarville.edu
Slightly modified AX25 library and mods
6 files changed with 71 insertions and 53 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 USART_BAUDRATE 19200
 
#define MODULE_ID '1'
 
 
#endif /* CONFIG_H_ */
 
\ No newline at end of file
master/master/lib/ax25.c
Show inline comments
 
@@ -112,25 +112,26 @@ 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
 
}
 
*/
 
\ 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_
 
 
 
 
 
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
master/master/lib/serial.c
Show inline comments
 
/*
 
 * serial.c
 
 *
 
 * Created: 10/25/2012 3:19:49 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
#include "serial.h"
 
#include "../config.h"
 
#include <avr/io.h>
 
 
 
void serial_setup() {
 
	// Set registers!
 
	
 
	// from mnl
 
	// uart
 
	//UBRRH = (BAUD_PRESCALE >> 8); // 0
 
	//UBRRL = BAUD_PRESCALE; // 8
 
	//UCSRA = 0;
 
	//UCSRB = 0x18;
 
	//UCSRC = 0x06;
 
	//OCR0B = 0xff;
 
	//OCR0A = 0xff;
 
	//OCR1AL = 0xff;
 
	//OCR1BL = 0xff;
 
 
 
	/* Set baud rate */
 
	UBRR0H = (unsigned char)(BAUD_PRESCALE>>8);
 
	UBRR0L = (unsigned char)BAUD_PRESCALE;
 
	/* Enable receiver and transmitter */
 
	UCSR0B = (1<<RXEN0)|(1<<TXEN0);
 
	/* Set frame format: 8data, 2stop bit */
 
	UCSR0C = (3<<UCSZ00);
 
 
}
 
 
 
void serial_SendChar( char byte )
 
{
 
	while (!(UCSR0A & (1<<UDRE0)));
 
	UDR0 = byte;
 
}
 
 
void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data )
 
{
 
	char checkSum = 0x00; //initialize checksum
 
	
 
	serial_SendChar('['); //bracket indicates start of command
 
	serial_SendChar(moduleID);
 
	checkSum+=moduleID;
 
	
 
	serial_SendChar(sensorID);
 
	checkSum+=sensorID;
 
	
 
	//send each character of data individually
 
	for (int i=0; i<dataLength; i++)
 
	{
 
		serial_SendChar(data[i]);
 
		checkSum+=data[i];
 
	}
 
	
 
	serial_SendChar(checkSum);
 
	serial_SendChar(']'); //bracket indicates end of command
 
}
 
 
void serial_SendResponseData(){
 
	
 
}
 
 
void serial_setup() {
 
	// Set registers!	
 
	
 
	// from mnl
 
	// uart
 
	//UBRRH = (BAUD_PRESCALE >> 8); // 0
 
	//UBRRL = BAUD_PRESCALE; // 8
 
	//UCSRA = 0;
 
	//UCSRB = 0x18;
 
	//UCSRC = 0x06;
 
	//OCR0B = 0xff;
 
	//OCR0A = 0xff;
 
	//OCR1AL = 0xff;
 
	//OCR1BL = 0xff;
 
 
 
 
}
master/master/lib/serial.h
Show inline comments
 
/*
 
 * serial.h
 
 *
 
 * Created: 10/25/2012 3:19:42 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef SERIAL_H_
 
#define SERIAL_H_
 
 
#include <inttypes.h>
 
 
#define USART_BAUDRATE 19200
 
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1 )
 
 
void serial_SendChar( char byte );
 
void serial_SendCommand( char moduleID, char sensorID, uint8_t dataLength, char* data );
 
void serial_SendResponseData();
 
void serial_setup();
 
 
#endif /* SERIAL_H_ */
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
/*
 
 * Master Firmware
 
 *
 
 * Wireless Observational Modular Aerial Network
 
 * 
 
 * Ethan Zonca
 
 * Matthew Kanning
 
 * Kyle Ripperger
 
 * Matthew Kroening
 
 *
 
 */
 
 
 
#include "config.h"
 
 
#include <avr/io.h>
 
#include <util/delay.h>
 
 
#include "lib/serial.h"
 
#include "lib/afsk.h"
 
#include "lib/led.h"
 
 
void micro_setup() {
 
	// Generic microcontroller config options
 
	
 
}
 
 
int main(void)
 
{
 
	// Initialize
 
	micro_setup();
 
	led_setup();
 
	serial_setup(); // Config serial ports
 
	afsk_setup();
 
	
 
    while(1)
 
    {
 
		afsk_test();
 
        //serial_SendCommand('0','A',0,0);
 
    }
 
 */
 

	
 

	
 
#include "config.h"
 

	
 
#include <avr/io.h>
 
#include <util/delay.h>
 

	
 
#include "lib/serial.h"
 
#include "lib/afsk.h"
 
#include "lib/led.h"
 

	
 
void micro_setup() {
 
	// Generic microcontroller config options
 
	
 
}
 

	
 
int main(void)
 
{
 
	// Initialize
 
	micro_setup();
 
	led_setup();
 
	serial_setup(); // Config serial ports
 
	afsk_setup();
 
	
 
    while(1)
 
    {
 
		afsk_test();
 
        serial_SendCommand('0','A',0,0);
 
    }
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)