Changeset - fd5edafa71ba
[Not reviewed]
default
0 2 4
ethanzonca@CL-SEC241-08.cedarville.edu - 12 years ago 2012-10-25 15:33:23
ethanzonca@CL-SEC241-08.cedarville.edu
Reorganized, moved functions to library
6 files changed with 167 insertions and 65 deletions:
0 comments (0 inline, 0 general)
master/master.atsln
Show inline comments
 
new file 100644
 

 
Microsoft Visual Studio Solution File, Format Version 11.00
 
# Atmel Studio Solution File, Format Version 11.00
 
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "master", "master\master.cproj", "{8579EC2D-5815-40DB-84E0-1D14239C7AEA}"
 
EndProject
 
Global
 
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 
		Debug|AVR = Debug|AVR
 
		Release|AVR = Release|AVR
 
	EndGlobalSection
 
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 
		{8579EC2D-5815-40DB-84E0-1D14239C7AEA}.Debug|AVR.ActiveCfg = Debug|AVR
 
		{8579EC2D-5815-40DB-84E0-1D14239C7AEA}.Debug|AVR.Build.0 = Debug|AVR
 
		{8579EC2D-5815-40DB-84E0-1D14239C7AEA}.Release|AVR.ActiveCfg = Release|AVR
 
		{8579EC2D-5815-40DB-84E0-1D14239C7AEA}.Release|AVR.Build.0 = Release|AVR
 
	EndGlobalSection
 
	GlobalSection(SolutionProperties) = preSolution
 
		HideSolutionNode = FALSE
 
	EndGlobalSection
 
EndGlobal
master/master/config.h
Show inline comments
 
new file 100644
 
/*
 
 * 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 BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE * 16UL))) -1 )
 
 
#endif /* CONFIG_H_ */
 
\ No newline at end of file
master/master/lib/serial.c
Show inline comments
 
new file 100644
 
/*
 
 * serial.c
 
 *
 
 * Created: 10/25/2012 3:19:49 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
#include <avr/io.h>
 
 
void serial_SendChar( char byte )
 
{
 
	while (!(UCSR0A & (1<<UDRE0)));
 
	UDR0 = byte;
 
}
 
 
void serial_SendCommand( char moduleID, char measureType, uint8_t dataLength, char* data )
 
{
 
	char checkSum = 0x00; //initialize checksum
 
	
 
	serial_SendChar('['); //bracket indicates start of command
 
	serial_SendChar(moduleID);
 
	checkSum+=moduleID;
 
	
 
	serial_SendChar(measureType);
 
	checkSum+=measureType;
 
	
 
	//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_Configure() {
 
	// Set registers!	
 
 
}
master/master/lib/serial.h
Show inline comments
 
new file 100644
 
/*
 
 * serial.h
 
 *
 
 * Created: 10/25/2012 3:19:42 PM
 
 *  Author: ethanzonca
 
 */ 
 
 
 
#ifndef SERIAL_H_
 
#define SERIAL_H_
 
 
void serial_SendChar( char byte );
 
void serial_SendCommand( char moduleID, char measureType, uint8_t dataLength, char* data );
 
void serial_SendResponseData();
 
void serial_Configure();
 
 
#endif /* SERIAL_H_ */
 
\ No newline at end of file
master/master/master.c
Show inline comments
 
@@ -6,45 +6,20 @@
 
 */ 
 
 
 
#include <avr/io.h>
 
 
void SendChar( char byte ) 
 
{
 
	while (!(UCSR0A & (1<<UDRE0)));
 
	UDR0 = byte;
 
}
 
#include "config.h"
 
 
void SendCommand( char moduleID, char measureType, uint8_t dataLength, char* data ) 
 
{
 
	char checkSum = 0x00; //initialize checksum
 
	
 
	SendChar("["); //bracket indicates start of command
 
	SendChar(moduleID);
 
	checkSum+=moduleID;
 
	
 
	SendChar(measureType);
 
	checkSum+=measureType;
 
	
 
	//send each character of data individually
 
	for (int i=0; i<dataLength; i++)
 
	{
 
		SendChar(data[i]);
 
		checkSum+=data[i];
 
	}
 
	
 
	SendChar(checkSum);
 
	SendChar("]"); //bracket indicates end of command
 
}
 
#include <avr/io.h>
 
#include <util/delay.h>
 
 
void SendResponseData(){
 
	
 
}
 
#include "lib/serial.h"
 
 
int main(void)
 
{
 
	// Initialize
 
	serial_Configure(); // Config serial ports
 
	
 
    while(1)
 
    {
 
        //TODO:: Please write your application code 
 
					
 
        serial_SendCommand('0','A',0,0);
 
    }
 
}
 
\ No newline at end of file
master/master/master.cproj
Show inline comments
 
@@ -21,53 +21,82 @@
 
    <OverrideVtorValue />
 
    <eraseonlaunchrule>0</eraseonlaunchrule>
 
    <AsfVersion>3.1.3</AsfVersion>
 
    <avrtool>com.atmel.avrdbg.tool.simulator</avrtool>
 
    <avrtoolinterface />
 
    <com_atmel_avrdbg_tool_simulator>
 
      <ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
 
      <ToolName xmlns="">AVR Simulator</ToolName>
 
      <ToolNumber xmlns="">
 
      </ToolNumber>
 
      <KeepTimersRunning xmlns="">true</KeepTimersRunning>
 
      <OverrideVtor xmlns="">false</OverrideVtor>
 
      <OverrideVtorValue xmlns="">
 
      </OverrideVtorValue>
 
      <Channel xmlns="">
 
        <host>127.0.0.1</host>
 
        <port>52692</port>
 
        <ssl>False</ssl>
 
      </Channel>
 
    </com_atmel_avrdbg_tool_simulator>
 
  </PropertyGroup>
 
  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
 
    <ToolchainSettings>
 
      <AvrGcc>
 
  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
 
  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
 
  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
 
  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
 
  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
 
  <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
 
  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
 
  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
 
  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
 
  <avrgcc.linker.libraries.Libraries>
 
    <ListValues>
 
      <Value>m</Value>
 
    </ListValues>
 
  </avrgcc.linker.libraries.Libraries>
 
</AvrGcc>
 
        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
 
        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
 
        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
 
        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
 
        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
 
        <avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
 
        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
 
        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
 
        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
 
        <avrgcc.linker.libraries.Libraries>
 
          <ListValues>
 
            <Value>m</Value>
 
          </ListValues>
 
        </avrgcc.linker.libraries.Libraries>
 
      </AvrGcc>
 
    </ToolchainSettings>
 
  </PropertyGroup>
 
  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
 
    <ToolchainSettings>
 
      <AvrGcc>
 
  <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
 
  <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
 
  <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
 
  <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
 
  <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
 
  <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
 
  <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
 
  <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
 
  <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
 
  <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
 
  <avrgcc.linker.libraries.Libraries>
 
    <ListValues>
 
      <Value>m</Value>
 
    </ListValues>
 
  </avrgcc.linker.libraries.Libraries>
 
  <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
 
</AvrGcc>
 
        <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
 
        <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
 
        <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
 
        <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
 
        <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
 
        <avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
 
        <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
 
        <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
 
        <avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
 
        <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
 
        <avrgcc.linker.libraries.Libraries>
 
          <ListValues>
 
            <Value>m</Value>
 
          </ListValues>
 
        </avrgcc.linker.libraries.Libraries>
 
        <avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
 
      </AvrGcc>
 
    </ToolchainSettings>
 
  </PropertyGroup>
 
  <ItemGroup>
 
    <Compile Include="config.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\serial.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="lib\serial.h">
 
      <SubType>compile</SubType>
 
    </Compile>
 
    <Compile Include="master.c">
 
      <SubType>compile</SubType>
 
    </Compile>
 
  </ItemGroup>
 
  <ItemGroup>
 
    <Folder Include="lib" />
 
  </ItemGroup>
 
  <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
 
</Project>
 
\ No newline at end of file
0 comments (0 inline, 0 general)