Commit df8898da authored by Martin Vítek's avatar Martin Vítek

Add initial NetworkTypes

parent 893f965a
......@@ -60,7 +60,7 @@ void ARP_class::assembly_request(const uint8_t (&IP)[4], ethernet_payload& paylo
arp->protocol_size = 4;
arp->operation_code = __htons(ARP_REQUEST);
uint8_t myIP[4] = {192, 168, 1, 2};
uint8_t myIP[4] = {10, 20, 70, 145};
//My MAC
memcpy(arp->MAC_sender, my_mac, 6);
......
#pragma once
#include <cstdint>
class MAC
{
public:
MAC()
{
}
};
class IP
{
public:
union
{
uint32_t value;
uint8_t array[4];
}ip;
public:
IP()
{
}
uint32_t operator=(const uint32_t ip)
{
this->ip.value = ip;
return this->ip.value;
}
uint32_t operator=(const uint8_t (&ip)[4])
{
for (uint8_t i=0; i<sizeof(ip); i++)
{
this->ip.array[i] = ip[i];
}
return this->ip.value;
}
uint8_t operator[](const uint8_t index)
{
if (index >= sizeof(ip)) return 0;
return ip.array[index];
}
bool operator==(const IP& ip)
{
return this->ip.value == ip.ip.value;
}
bool operator!=(const IP& ip)
{
return this->ip.value != ip.ip.value;
}
void set(const uint32_t ip)
{
this->ip.value = ip;
}
void set(const uint8_t (&ip)[4])
{
for (uint8_t i=0; i<sizeof(ip); i++)
{
this->ip.array[i] = ip[i];
}
}
uint32_t get()
{
return ip.value;
}
void get(uint8_t (&ip)[4])
{
for (uint8_t i=0; i<sizeof(ip); i++)
{
ip[i] = this->ip.array[i];
}
}
};
#include "NixieStack.h"
NixieStack::NixieStack()
{
}
#pragma once
#include <cstdint>
#include <machine/endian.h>
class NixieStack
{
public:
NixieStack();
};
......@@ -29,6 +29,7 @@
#include "Debug.h"
#include "ARP.h"
#include "ethernet_frame.h"
#include "NetworkTypes.h"
using namespace ENC28J60_namespace;
......@@ -88,7 +89,21 @@ int main(void)
ethernet_frame arp_frame;
ARP_class arp(my_mac);
arp.assembly_request({192, 168, 1, 1}, arp_frame.payload);
IP ip;
ip = {192, 168, 1, 1};
uint32_t adfasdf;
adfasdf = ip;
for (uint8_t i=0; i<4; i++)
{
uart.send_dec(ip.ip.array[i]);
uart.send('.');
}
uart.send_new_line();
arp.assembly_request({10, 20, 70, 113}, arp_frame.payload);
memcpy(arp_frame.dest_address, broadcast_mac, 6);
memcpy(arp_frame.src_address, my_mac, 6);
......@@ -97,6 +112,8 @@ int main(void)
//debug.frame(arp_frame);
sys.delay_ms(1000);
sys.delay_ms(1000);
sys.delay_ms(1000);
......
......@@ -5,6 +5,11 @@ VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{E66E83B9-2572-4076-B26E-6BE79FF3018A}") = "nixie-clock", "nixie-clock.cppproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CDA0D3AC-0AAF-460C-A9EA-45C2E82B5241}"
ProjectSection(SolutionItems) = preProject
NetworkTypes.h = NetworkTypes.h
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM
......
......@@ -121,75 +121,75 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<ArmGccCpp>
<armgcc.common.outputfiles.hex>True</armgcc.common.outputfiles.hex>
<armgcc.common.outputfiles.lss>True</armgcc.common.outputfiles.lss>
<armgcc.common.outputfiles.eep>True</armgcc.common.outputfiles.eep>
<armgcc.common.outputfiles.bin>True</armgcc.common.outputfiles.bin>
<armgcc.common.outputfiles.srec>True</armgcc.common.outputfiles.srec>
<armgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</armgcc.compiler.symbols.DefSymbols>
<armgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcc.compiler.directories.IncludePaths>
<armgcc.compiler.optimization.level>Optimize (-O1)</armgcc.compiler.optimization.level>
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.optimization.PrepareDataForGarbageCollection>True</armgcc.compiler.optimization.PrepareDataForGarbageCollection>
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
<armgcc.compiler.warnings.ExtraWarnings>True</armgcc.compiler.warnings.ExtraWarnings>
<armgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</armgcccpp.compiler.symbols.DefSymbols>
<armgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcccpp.compiler.directories.IncludePaths>
<armgcccpp.compiler.optimization.level>Optimize (-O1)</armgcccpp.compiler.optimization.level>
<armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcccpp.compiler.optimization.PrepareDataForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareDataForGarbageCollection>
<armgcccpp.compiler.optimization.DebugLevel>Maximum (-g3)</armgcccpp.compiler.optimization.DebugLevel>
<armgcccpp.compiler.warnings.AllWarnings>True</armgcccpp.compiler.warnings.AllWarnings>
<armgcccpp.compiler.warnings.ExtraWarnings>True</armgcccpp.compiler.warnings.ExtraWarnings>
<armgcccpp.compiler.miscellaneous.OtherFlags>-std=c++14</armgcccpp.compiler.miscellaneous.OtherFlags>
<armgcccpp.linker.general.AdditionalSpecs>Use syscall stubs (--specs=nosys.specs)</armgcccpp.linker.general.AdditionalSpecs>
<armgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</armgcccpp.linker.libraries.Libraries>
<armgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>%24(ProjectDir)\Device_Startup</Value>
</ListValues>
</armgcccpp.linker.libraries.LibrarySearchPaths>
<armgcccpp.linker.optimization.GarbageCollectUnusedSections>True</armgcccpp.linker.optimization.GarbageCollectUnusedSections>
<armgcccpp.linker.memorysettings.ExternalRAM />
<armgcccpp.linker.miscellaneous.LinkerFlags>-Tsamd20g18_flash.ld</armgcccpp.linker.miscellaneous.LinkerFlags>
<armgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcccpp.assembler.general.IncludePaths>
<armgcccpp.assembler.debugging.DebugLevel>Default (-g)</armgcccpp.assembler.debugging.DebugLevel>
<armgcccpp.preprocessingassembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcccpp.preprocessingassembler.general.IncludePaths>
<armgcccpp.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcccpp.preprocessingassembler.debugging.DebugLevel>
</ArmGccCpp>
<armgcc.common.outputfiles.hex>True</armgcc.common.outputfiles.hex>
<armgcc.common.outputfiles.lss>True</armgcc.common.outputfiles.lss>
<armgcc.common.outputfiles.eep>True</armgcc.common.outputfiles.eep>
<armgcc.common.outputfiles.bin>True</armgcc.common.outputfiles.bin>
<armgcc.common.outputfiles.srec>True</armgcc.common.outputfiles.srec>
<armgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</armgcc.compiler.symbols.DefSymbols>
<armgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcc.compiler.directories.IncludePaths>
<armgcc.compiler.optimization.level>Optimize (-O1)</armgcc.compiler.optimization.level>
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.optimization.PrepareDataForGarbageCollection>True</armgcc.compiler.optimization.PrepareDataForGarbageCollection>
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>
<armgcc.compiler.warnings.ExtraWarnings>True</armgcc.compiler.warnings.ExtraWarnings>
<armgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</armgcccpp.compiler.symbols.DefSymbols>
<armgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcccpp.compiler.directories.IncludePaths>
<armgcccpp.compiler.optimization.level>Optimize (-O1)</armgcccpp.compiler.optimization.level>
<armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcccpp.compiler.optimization.PrepareDataForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareDataForGarbageCollection>
<armgcccpp.compiler.optimization.DebugLevel>Maximum (-g3)</armgcccpp.compiler.optimization.DebugLevel>
<armgcccpp.compiler.warnings.AllWarnings>True</armgcccpp.compiler.warnings.AllWarnings>
<armgcccpp.compiler.warnings.ExtraWarnings>True</armgcccpp.compiler.warnings.ExtraWarnings>
<armgcccpp.compiler.miscellaneous.OtherFlags>-std=c++14</armgcccpp.compiler.miscellaneous.OtherFlags>
<armgcccpp.linker.general.AdditionalSpecs>Use syscall stubs (--specs=nosys.specs)</armgcccpp.linker.general.AdditionalSpecs>
<armgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</armgcccpp.linker.libraries.Libraries>
<armgcccpp.linker.libraries.LibrarySearchPaths>
<ListValues>
<Value>%24(ProjectDir)\Device_Startup</Value>
</ListValues>
</armgcccpp.linker.libraries.LibrarySearchPaths>
<armgcccpp.linker.optimization.GarbageCollectUnusedSections>True</armgcccpp.linker.optimization.GarbageCollectUnusedSections>
<armgcccpp.linker.memorysettings.ExternalRAM />
<armgcccpp.linker.miscellaneous.LinkerFlags>-Tsamd20g18_flash.ld</armgcccpp.linker.miscellaneous.LinkerFlags>
<armgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcccpp.assembler.general.IncludePaths>
<armgcccpp.assembler.debugging.DebugLevel>Default (-g)</armgcccpp.assembler.debugging.DebugLevel>
<armgcccpp.preprocessingassembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\SAMD20_DFP\1.1.84\samd20\include</Value>
<Value>%24(PackRepoDir)\arm\CMSIS\4.2.0\CMSIS\Include\</Value>
</ListValues>
</armgcccpp.preprocessingassembler.general.IncludePaths>
<armgcccpp.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcccpp.preprocessingassembler.debugging.DebugLevel>
</ArmGccCpp>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
......@@ -274,6 +274,12 @@
<Compile Include="NixieDisplay.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="NixieStack.cpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="NixieStack.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="PWM_test.h">
<SubType>compile</SubType>
</Compile>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment