Commit 7da1e26a authored by Daniel Kampert's avatar Daniel Kampert 👷

Add new XMega clock driver to lib builder projects

parent 7fdf8c10
......@@ -14,6 +14,8 @@ Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "LibTester", "LibTester\LibT
EndProject
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "XMega384C3", "XMega384C3\XMega384C3.cproj", "{DCE6C7E3-EE26-4D79-826B-08594B9AD897}"
EndProject
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "XMega256A3BU", "XMega256A3BU\XMega256A3BU.cproj", "{0A10BDDF-7F33-40EA-AE7C-44B9D50BC75C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|AVR = Debug|AVR
......@@ -28,6 +30,10 @@ Global
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Debug|AVR.Build.0 = Debug|AVR
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.ActiveCfg = Release|AVR
{DCE6C7E3-EE26-4D79-826B-08594B9AD897}.Release|AVR.Build.0 = Release|AVR
{0A10BDDF-7F33-40EA-AE7C-44B9D50BC75C}.Debug|AVR.ActiveCfg = Debug|AVR
{0A10BDDF-7F33-40EA-AE7C-44B9D50BC75C}.Debug|AVR.Build.0 = Debug|AVR
{0A10BDDF-7F33-40EA-AE7C-44B9D50BC75C}.Release|AVR.ActiveCfg = Release|AVR
{0A10BDDF-7F33-40EA-AE7C-44B9D50BC75C}.Release|AVR.Build.0 = Release|AVR
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -84,48 +84,48 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGcc>
<avrgcc.common.Device>-mmcu=atxmega256a3bu -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\gcc\dev\atxmega256a3bu"</avrgcc.common.Device>
<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.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>BOARD=BOARD_NONE</Value>
<Value>MCU_NAME=MCU_NAME_ATXMEGA256A3BU</Value>
<Value>MCU_ARCH=MCU_ARCH_XMEGA</Value>
<Value>CONFIG="Config_LibXMega256A3BU.h"</Value>
<Value>MCU_LITTLE_ENDIAN</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
<Value>../../../../configs</Value>
<Value>../../../../include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<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>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
<avrgcc.common.Device>-mmcu=atxmega256a3bu -B "%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\gcc\dev\atxmega256a3bu"</avrgcc.common.Device>
<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.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>BOARD=BOARD_NONE</Value>
<Value>MCU_NAME=MCU_NAME_ATXMEGA256A3BU</Value>
<Value>MCU_ARCH=MCU_ARCH_XMEGA</Value>
<Value>CONFIG="Config_LibXMega256A3BU.h"</Value>
<Value>MCU_LITTLE_ENDIAN</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
<Value>../../../../configs</Value>
<Value>../../../../include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<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>libm</Value>
</ListValues>
</avrgcc.linker.libraries.Libraries>
<avrgcc.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\XMEGAA_DFP\1.1.68\include</Value>
</ListValues>
</avrgcc.assembler.general.IncludePaths>
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
</AvrGcc>
</ToolchainSettings>
<PostBuildEvent>copy "$(OutputDirectory)\$(OutputFileName)$(OutputFileExtension)" "..\..\..\$(OutputFileName)$(OutputFileExtension)"</PostBuildEvent>
</PropertyGroup>
......@@ -133,6 +133,7 @@
<Folder Include="source\" />
<Folder Include="source\Arch" />
<Folder Include="source\Arch\XMega" />
<Folder Include="source\Arch\XMega\ClockManagement\" />
<Folder Include="source\Arch\XMega\DMA" />
<Folder Include="source\Arch\XMega\GPIO" />
<Folder Include="source\Arch\XMega\I2C" />
......@@ -161,6 +162,9 @@
<Compile Include="source\Arch\XMega\BatteryBackup\BatteryBackup.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="source\Arch\XMega\ClockManagement\SysClock.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="source\Arch\XMega\CRC\CRC.c">
<SubType>compile</SubType>
</Compile>
......
/*
* SysClock.c
*
* Copyright (C) Daniel Kampert, 2018
* Website: www.kampis-elektroecke.de
* File info: Driver for Atmel AVR XMega system clock.
GNU GENERAL PUBLIC LICENSE:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Errors and commissions should be reported to [email protected]
*/
/** @file Arch/XMega/ClockManagement/SysClock.c
* @brief Driver for Atmel AVR XMega clock system.
*
* This file contains the implementation of the Atmel AVR XMega clock system.
*
* @author Daniel Kampert
* @bug No known bugs.
*/
#include "Arch/XMega/ClockManagement/SysClock.h"
uint32_t SysClock_GetClockPer4(void)
{
uint32_t Clock = SysClock_GetClock();
switch(CLK.PSCTRL >> 0x02)
{
case(CLK_PSADIV_1_gc):
{
return Clock;
}
case(CLK_PSADIV_2_gc):
{
return Clock >> 0x01;
}
case(CLK_PSADIV_4_gc):
{
return Clock >> 0x02;
}
case(CLK_PSADIV_8_gc):
{
return Clock >> 0x03;
}
case(CLK_PSADIV_16_gc):
{
return Clock >> 0x04;
}
case(CLK_PSADIV_32_gc):
{
return Clock >> 0x05;
}
case(CLK_PSADIV_64_gc):
{
return Clock >> 0x06;
}
case(CLK_PSADIV_128_gc):
{
return Clock >> 0x07;
}
case(CLK_PSADIV_256_gc):
{
return Clock >> 0x08;
}
case(CLK_PSADIV_512_gc):
{
return Clock >> 0x09;
}
default:
{
// Invalid case
return 0;
}
}
}
uint32_t SysClock_GetClockPer2(void)
{
uint32_t Clock = SysClock_GetClockPer4();
switch((CLK.PSCTRL & 0x03))
{
case(CLK_PSBCDIV_4_1_gc):
{
return Clock >> 0x02;
}
case(CLK_PSBCDIV_2_2_gc):
{
return Clock >> 0x01;
}
default:
{
return Clock;
}
}
}
uint32_t SysClock_GetClockPer(void)
{
uint32_t Clock = SysClock_GetClockPer2();
switch(CLK.PSCTRL & 0x01)
{
case(CLK_PSBCDIV_1_1_gc):
{
return Clock;
}
case(CLK_PSBCDIV_1_2_gc):
{
return Clock >> 0x01;
}
default:
{
return 0;
}
}
}
\ No newline at end of file
......@@ -139,6 +139,7 @@
<Folder Include="source\Arch\XMega\GPIO\" />
<Folder Include="source\Arch\XMega\I2C\" />
<Folder Include="source\Arch\XMega\AC" />
<Folder Include="source\Arch\XMega\ClockManagement" />
<Folder Include="source\Arch\XMega\RTC" />
<Folder Include="source\Arch\XMega\NVM\" />
<Folder Include="source\Arch\XMega\SPI\" />
......@@ -154,6 +155,9 @@
<Compile Include="source\Arch\XMega\AES\AES.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="source\Arch\XMega\ClockManagement\SysClock.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="source\Arch\XMega\CRC\CRC.c">
<SubType>compile</SubType>
</Compile>
......
/*
* SysClock.c
*
* Copyright (C) Daniel Kampert, 2018
* Website: www.kampis-elektroecke.de
* File info: Driver for Atmel AVR XMega system clock.
GNU GENERAL PUBLIC LICENSE:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Errors and commissions should be reported to [email protected]
*/
/** @file Arch/XMega/ClockManagement/SysClock.c
* @brief Driver for Atmel AVR XMega clock system.
*
* This file contains the implementation of the Atmel AVR XMega clock system.
*
* @author Daniel Kampert
* @bug No known bugs.
*/
#include "Arch/XMega/ClockManagement/SysClock.h"
uint32_t SysClock_GetClockPer4(void)
{
uint32_t Clock = SysClock_GetClock();
switch(CLK.PSCTRL >> 0x02)
{
case(CLK_PSADIV_1_gc):
{
return Clock;
}
case(CLK_PSADIV_2_gc):
{
return Clock >> 0x01;
}
case(CLK_PSADIV_4_gc):
{
return Clock >> 0x02;
}
case(CLK_PSADIV_8_gc):
{
return Clock >> 0x03;
}
case(CLK_PSADIV_16_gc):
{
return Clock >> 0x04;
}
case(CLK_PSADIV_32_gc):
{
return Clock >> 0x05;
}
case(CLK_PSADIV_64_gc):
{
return Clock >> 0x06;
}
case(CLK_PSADIV_128_gc):
{
return Clock >> 0x07;
}
case(CLK_PSADIV_256_gc):
{
return Clock >> 0x08;
}
case(CLK_PSADIV_512_gc):
{
return Clock >> 0x09;
}
default:
{
// Invalid case
return 0;
}
}
}
uint32_t SysClock_GetClockPer2(void)
{
uint32_t Clock = SysClock_GetClockPer4();
switch((CLK.PSCTRL & 0x03))
{
case(CLK_PSBCDIV_4_1_gc):
{
return Clock >> 0x02;
}
case(CLK_PSBCDIV_2_2_gc):
{
return Clock >> 0x01;
}
default:
{
return Clock;
}
}
}
uint32_t SysClock_GetClockPer(void)
{
uint32_t Clock = SysClock_GetClockPer2();
switch(CLK.PSCTRL & 0x01)
{
case(CLK_PSBCDIV_1_1_gc):
{
return Clock;
}
case(CLK_PSBCDIV_1_2_gc):
{
return Clock >> 0x01;
}
default:
{
return 0;
}
}
}
\ No newline at end of file
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