Mercurial > pub > halpp
changeset 3:3d9705e842f8
working on rcc and bus
author | cin |
---|---|
date | Wed, 18 Jan 2017 01:07:59 +0300 |
parents | 0c59e7a7782a |
children | ca4f5b55b391 |
files | f103c8/.settings/language.settings.xml f103c8/f103c8.elf.launch halpp/.settings/language.settings.xml halpp/include/gpio.h l476rg-hal-test/.cproject l476rg-hal-test/.settings/language.settings.xml l476rg-hal-test/.settings/org.eclipse.cdt.managedbuilder.core.prefs l476rg-hal-test/src/main.cpp l476rg/.settings/language.settings.xml |
diffstat | 9 files changed, 193 insertions(+), 139 deletions(-) [+] |
line wrap: on
line diff
--- a/f103c8/.settings/language.settings.xml Mon Jan 16 11:04:47 2017 +0300 +++ b/f103c8/.settings/language.settings.xml Wed Jan 18 01:07:59 2017 +0300 @@ -4,7 +4,7 @@ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> - <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="878633113351463331" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1787897757412856079" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> <language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.g++"/> </provider>
--- a/f103c8/f103c8.elf.launch Mon Jan 16 11:04:47 2017 +0300 +++ b/f103c8/f103c8.elf.launch Wed Jan 18 01:07:59 2017 +0300 @@ -1,46 +1,53 @@ -<?xml version="1.0" encoding="UTF-8"?> -<launchConfiguration type="com.atollic.hardwaredebug.launch.launchConfigurationType"> -<stringAttribute key="com.atollic.hardwaredebug.jlink_common.cpu_core" value="Cortex-M" /> -<stringAttribute key="com.atollic.hardwaredebug.jlink_common.device" value="STM32F103C8" /> -<stringAttribute key="com.atollic.hardwaredebug.jlink_common.endian" value="little" /> -<stringAttribute key="com.atollic.hardwaredebug.jlink_common.init_speed" value="4000" /> -<booleanAttribute key="com.atollic.hardwaredebug.jlink_common.scan_chain_auto" value="true" /> -<intAttribute key="com.atollic.hardwaredebug.jlink_common.scan_chain_irpre" value="0" /> -<intAttribute key="com.atollic.hardwaredebug.jlink_common.scan_chain_pos" value="0" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.analyzeCommands" value="# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers
# 2=32 bit, 1=16 bit and 0=8 bit parallelism mode
monitor flash set_parallelism_mode 2

# Load the program executable
load		

# Enable Debug connection in low power modes (DBGMCU->CR)
set *0xE0042004 = (*0xE0042004) | 0x7
# Start the executable
continue" /> -<booleanAttribute key="com.atollic.hardwaredebug.launch.enable_swv" value="false" /> -<intAttribute key="com.atollic.hardwaredebug.launch.formatVersion" value="2" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.ipAddress" value="localhost" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.jtagDevice" value="ST-LINK" /> -<intAttribute key="com.atollic.hardwaredebug.launch.portNumber" value="61234" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.remoteCommand" value="target extended-remote" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.runCommands" value="# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers
# 2=32 bit, 1=16 bit and 0=8 bit parallelism mode
monitor flash set_parallelism_mode 2

# Load the program executable
load		

# Enable Debug connection in low power modes (DBGMCU->CR)
set *0xE0042004 = (*0xE0042004) | 0x7
# Set a breakpoint at main().
tbreak main

# Run to the breakpoint.
continue" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.serverParam" value="-p 61234 -l 1 -d" /> -<booleanAttribute key="com.atollic.hardwaredebug.launch.startServer" value="true" /> -<booleanAttribute key="com.atollic.hardwaredebug.launch.swd_mode" value="true" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.swv_port" value="61235" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.swv_trace_div" value="120" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.swv_trace_hclk" value="120000000" /> -<booleanAttribute key="com.atollic.hardwaredebug.launch.swv_wait_for_sync" value="true" /> -<booleanAttribute key="com.atollic.hardwaredebug.launch.useRemoteTarget" value="true" /> -<stringAttribute key="com.atollic.hardwaredebug.launch.verifyCommands" value="# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers
# 2=32 bit, 1=16 bit and 0=8 bit parallelism mode
monitor flash set_parallelism_mode 2

# Load the program executable
load		

# Enable Debug connection in low power modes (DBGMCU->CR)
set *0xE0042004 = (*0xE0042004) | 0x7
# The executable starts automatically" /> -<booleanAttribute key="com.atollic.hardwaredebug.stlink.enable_logging" value="false" /> -<stringAttribute key="com.atollic.hardwaredebug.stlink.log_file" value="/home/sergey/Projects/ARM_workspace_7.0/f103c8/\Debug\st-link_gdbserver_log.txt" /> -<booleanAttribute key="com.atollic.hardwaredebug.stlink.verify_flash" value="false" /> -<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="${TOOLCHAIN_PATH}/arm-atollic-eabi-gdb" /> -<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard (Windows)" /> -<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi" /> -<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false" /> -<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${TOOLCHAIN_PATH}/arm-atollic-eabi-gdb" /> -<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2" /> -<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/f103c8.elf" /> -<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="f103c8" /> -<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="" /> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> -<listEntry value="/f103c8" /> -</listAttribute> -<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> -<listEntry value="4" /> -</listAttribute> -<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<memoryBlockExpressionList context="reserved-for-future-use"/>
" /> -</launchConfiguration> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<launchConfiguration type="com.atollic.hardwaredebug.launch.launchConfigurationType"> +<stringAttribute key="com.atollic.hardwaredebug.jlink_common.cpu_core" value="Cortex-M"/> +<stringAttribute key="com.atollic.hardwaredebug.jlink_common.device" value="STM32F103C8"/> +<stringAttribute key="com.atollic.hardwaredebug.jlink_common.endian" value="little"/> +<stringAttribute key="com.atollic.hardwaredebug.jlink_common.init_speed" value="4000"/> +<booleanAttribute key="com.atollic.hardwaredebug.jlink_common.jlink_check_serial_number" value="false"/> +<stringAttribute key="com.atollic.hardwaredebug.jlink_common.jlink_script_path" value=""/> +<booleanAttribute key="com.atollic.hardwaredebug.jlink_common.jlink_script_used" value="false"/> +<stringAttribute key="com.atollic.hardwaredebug.jlink_common.jlink_txt_serial_number" value=""/> +<booleanAttribute key="com.atollic.hardwaredebug.jlink_common.scan_chain_auto" value="true"/> +<intAttribute key="com.atollic.hardwaredebug.jlink_common.scan_chain_irpre" value="0"/> +<intAttribute key="com.atollic.hardwaredebug.jlink_common.scan_chain_pos" value="0"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.analyzeCommands" value="# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers # 2=32 bit, 1=16 bit and 0=8 bit parallelism mode monitor flash set_parallelism_mode 2 # Load the program executable load		 # Enable Debug connection in low power modes (DBGMCU->CR) set *0xE0042004 = (*0xE0042004) | 0x7 # Start the executable continue"/> +<booleanAttribute key="com.atollic.hardwaredebug.launch.enable_live_expr" value="true"/> +<intAttribute key="com.atollic.hardwaredebug.launch.formatVersion" value="2"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.hwinitCommands" value="# Initialize your hardware here "/> +<stringAttribute key="com.atollic.hardwaredebug.launch.ipAddress" value="localhost"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.jtagDevice" value="SEGGER J-LINK"/> +<intAttribute key="com.atollic.hardwaredebug.launch.portNumber" value="2331"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.remoteCommand" value="target extended-remote"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.runCommands" value="load break main monitor reset continue"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.serverParam" value="-port 2331 -s -CPU Cortex-M -device STM32F103C8 -endian little -speed 4000 -if swd -vd"/> +<booleanAttribute key="com.atollic.hardwaredebug.launch.startServer" value="true"/> +<booleanAttribute key="com.atollic.hardwaredebug.launch.swd_mode" value="true"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.swv_port" value="2332"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.swv_trace_div" value="8"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.swv_trace_hclk" value="8000000"/> +<intAttribute key="com.atollic.hardwaredebug.launch.trace_system" value="0"/> +<booleanAttribute key="com.atollic.hardwaredebug.launch.useRemoteTarget" value="true"/> +<stringAttribute key="com.atollic.hardwaredebug.launch.verifyCommands" value="# Set flash parallelism mode to 32, 16, or 8 bit when using STM32 F2/F4 microcontrollers # 2=32 bit, 1=16 bit and 0=8 bit parallelism mode monitor flash set_parallelism_mode 2 # Load the program executable load		 # Enable Debug connection in low power modes (DBGMCU->CR) set *0xE0042004 = (*0xE0042004) | 0x7 # The executable starts automatically"/> +<booleanAttribute key="com.atollic.hardwaredebug.launch.verify_flash_download" value="true"/> +<booleanAttribute key="com.atollic.hardwaredebug.stlink.enable_logging" value="false"/> +<stringAttribute key="com.atollic.hardwaredebug.stlink.log_file" value="/home/sergey/Projects/ARM_workspace_7.0/f103c8/\Debug\st-link_gdbserver_log.txt"/> +<booleanAttribute key="com.atollic.hardwaredebug.stlink.verify_flash" value="false"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="${TOOLCHAIN_PATH}/arm-atollic-eabi-gdb"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard (Windows)"/> +<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/> +<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/> +<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${TOOLCHAIN_PATH}/arm-atollic-eabi-gdb"/> +<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> +<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/f103c8.elf"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="f103c8"/> +<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/> +<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> +<listEntry value="/f103c8"/> +</listAttribute> +<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> +<listEntry value="4"/> +</listAttribute> +<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList context="reserved-for-future-use"/> "/> +</launchConfiguration>
--- a/halpp/.settings/language.settings.xml Mon Jan 16 11:04:47 2017 +0300 +++ b/halpp/.settings/language.settings.xml Wed Jan 18 01:07:59 2017 +0300 @@ -4,7 +4,7 @@ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> - <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="944816577120802337" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1863699703399830157" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> <language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.g++"/> </provider> @@ -14,7 +14,7 @@ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> - <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="944816577120802337" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1863699703399830157" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> <language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.g++"/> </provider>
--- a/halpp/include/gpio.h Mon Jan 16 11:04:47 2017 +0300 +++ b/halpp/include/gpio.h Wed Jan 18 01:07:59 2017 +0300 @@ -25,43 +25,34 @@ GpioOpenDrain = 1 } GpioOutputType; - template <typename TDev> class TGpio { - TDev& m_dev; - - explicit TGpio(const TGpio& ref); + template <typename TDev> class TGpioTraits { + explicit TGpioTraits(const TGpioTraits<TDev>&); + TGpioTraits(); public: - TGpio(TDev& dev) : m_dev(dev) { - + static void SetPinSpeed(unsigned short pin, GpioSpeed speed) { + TDev::instance().OSPEEDR = (TDev::instance().OSPEED & (~(3U << (pin * 2)))) | (speed << (pin * 2)); } - void SetPinSpeed(unsigned short pin, GpioSpeed speed) { - m_dev.OSPEEDR = (m_dev.OSPEED & (~(3U << (pin * 2)))) | (speed << (pin * 2)); + static void SetPinMode(unsigned short pin, GpioMode mode) { + TDev::instance().MODER = (TDev::instance().MODER & (~(3U << (pin * 2)))) | (mode << (pin * 2)); } - void SetPinMode(unsigned short pin, GpioMode mode) { - m_dev.MODER = (m_dev.MODER & (~(3U << (pin * 2)))) | (mode << (pin * 2)); - } - - void SetPinPullMode(unsigned short pin, GpioPullMode mode) { - m_dev.PUPDR = (m_dev.PUPDR & (~(3U << (pin * 2)))) | (mode << (pin * 2)); + static void SetPinPullMode(unsigned short pin, GpioPullMode mode) { + TDev::instance().PUPDR = (TDev::instance().PUPDR & (~(3U << (pin * 2)))) | (mode << (pin * 2)); } - void SetPinOutputType(unsigned short pin, GpioOutputType type) { - m_dev.OTYPER = (m_dev.OTYPER & (~(1U << pin))) | (type << pin); + static void SetPinOutputType(unsigned short pin, GpioOutputType type) { + TDev::instance().OTYPER = (TDev::instance().OTYPER & (~(1U << pin))) | (type << pin); } - void TooglePin(unsigned short pin) { - m_dev.ODR ^= 1U << pin; + static void TooglePin(unsigned short pin) { + TDev::instance().ODR ^= 1U << pin; } - void WritePin(unsigned short pin, unsigned short value) { - m_dev.ODR = (m_dev.ODR & (~(1U << pin))) | ((value & 1U) << pin); + static void WritePin(unsigned short pin, unsigned short value) { + TDev::instance().ODR = (TDev::instance().ODR & (~(1U << pin))) | ((value & 1U) << pin); } }; - template <typename TG, unsigned short Pin> class TGpioPin { - - }; - }
--- a/l476rg-hal-test/.cproject Mon Jan 16 11:04:47 2017 +0300 +++ b/l476rg-hal-test/.cproject Wed Jan 18 01:07:59 2017 +0300 @@ -131,20 +131,20 @@ <configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="com.atollic.truestudio.configuration.release.1226093006" name="Release" parent="com.atollic.truestudio.configuration.release"> <folderInfo id="com.atollic.truestudio.configuration.release.1226093006." name="/" resourcePath=""> <toolChain id="com.atollic.truestudio.exe.release.toolchain.1181167258" name="Atollic ARM Tools" superClass="com.atollic.truestudio.exe.release.toolchain"> - <option id="com.atollic.truestudio.toolchain_options.mcu.1309336340" name="Microcontroller" superClass="com.atollic.truestudio.toolchain_options.mcu" value="STM32L486RG" valueType="string"/> - <option id="com.atollic.truestudio.toolchain_options.vendor.540566628" name="Vendor name" superClass="com.atollic.truestudio.toolchain_options.vendor" value="STMicroelectronics" valueType="string"/> + <option id="com.atollic.truestudio.toolchain_options.mcu.1309336340" name="Microcontroller" superClass="com.atollic.truestudio.toolchain_options.mcu" useByScannerDiscovery="false" value="STM32L486RG" valueType="string"/> + <option id="com.atollic.truestudio.toolchain_options.vendor.540566628" name="Vendor name" superClass="com.atollic.truestudio.toolchain_options.vendor" useByScannerDiscovery="false" value="STMicroelectronics" valueType="string"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.atollic.truestudio.exe.release.toolchain.platform.1080844379" isAbstract="false" name="release platform" superClass="com.atollic.truestudio.exe.release.toolchain.platform"/> - <builder buildPath="${workspace_loc:/l476rg-hal-test}/Release" id="com.atollic.truestudio.mbs.builder1.2043040023" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="com.atollic.truestudio.mbs.builder1"/> + <builder buildPath="${workspace_loc:/l476rg-hal-test}/Release" customBuilderProperties="toolChainpathType=1|toolChainpathString=/home/sergey/applications/Atollic_TrueSTUDIO_for_ARM_7.0.1/ARMTools/bin|" id="com.atollic.truestudio.mbs.builder1.2043040023" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="com.atollic.truestudio.mbs.builder1"/> <tool id="com.atollic.truestudio.exe.release.toolchain.as.1318898242" name="Assembler" superClass="com.atollic.truestudio.exe.release.toolchain.as"> - <option id="com.atollic.truestudio.common_options.target.endianess.416216268" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess"/> - <option id="com.atollic.truestudio.common_options.target.mcpu.4347114" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" value="STM32L486RG" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.instr_set.1303002884" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpucore.1903320899" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" value="FPv4-SP-D16" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpu.1703800408" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> - <option id="com.atollic.truestudio.as.symbols.defined.2051703565" name="Defined symbols" superClass="com.atollic.truestudio.as.symbols.defined" valueType="definedSymbols"> + <option id="com.atollic.truestudio.common_options.target.endianess.416216268" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess" useByScannerDiscovery="false"/> + <option id="com.atollic.truestudio.common_options.target.mcpu.4347114" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" useByScannerDiscovery="false" value="STM32L486RG" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.instr_set.1303002884" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpucore.1903320899" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" useByScannerDiscovery="false" value="FPv4-SP-D16" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpu.1703800408" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> + <option id="com.atollic.truestudio.as.symbols.defined.2051703565" name="Defined symbols" superClass="com.atollic.truestudio.as.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols"> <listOptionValue builtIn="false" value="STM32L486xx"/> </option> - <option id="com.atollic.truestudio.as.general.incpath.1386261860" name="Include path" superClass="com.atollic.truestudio.as.general.incpath" valueType="includePath"> + <option id="com.atollic.truestudio.as.general.incpath.1386261860" name="Include path" superClass="com.atollic.truestudio.as.general.incpath" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value="../src"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/> @@ -153,22 +153,23 @@ <inputType id="com.atollic.truestudio.as.input.1107389315" name="Input" superClass="com.atollic.truestudio.as.input"/> </tool> <tool id="com.atollic.truestudio.exe.release.toolchain.gcc.1285066108" name="C Compiler" superClass="com.atollic.truestudio.exe.release.toolchain.gcc"> - <option id="com.atollic.truestudio.gcc.symbols.defined.550474352" name="Defined symbols" superClass="com.atollic.truestudio.gcc.symbols.defined" valueType="definedSymbols"> + <option id="com.atollic.truestudio.gcc.symbols.defined.550474352" name="Defined symbols" superClass="com.atollic.truestudio.gcc.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols"> <listOptionValue builtIn="false" value="STM32L486xx"/> </option> - <option id="com.atollic.truestudio.gcc.directories.select.1090459034" name="Include path" superClass="com.atollic.truestudio.gcc.directories.select" valueType="includePath"> + <option id="com.atollic.truestudio.gcc.directories.select.1090459034" name="Include path" superClass="com.atollic.truestudio.gcc.directories.select" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value="../src"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/halpp/include}""/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/> <listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/> </option> - <option id="com.atollic.truestudio.common_options.target.endianess.843883489" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess"/> - <option id="com.atollic.truestudio.common_options.target.mcpu.1479828622" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" value="STM32L486RG" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.instr_set.448938746" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpucore.1614902400" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" value="FPv4-SP-D16" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpu.2057432724" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> - <option id="com.atollic.truestudio.gcc.optimization.prep_garbage.1183071415" name="Prepare dead code removal " superClass="com.atollic.truestudio.gcc.optimization.prep_garbage" value="true" valueType="boolean"/> - <option id="com.atollic.truestudio.gcc.optimization.prep_data.686366138" name="Prepare dead data removal" superClass="com.atollic.truestudio.gcc.optimization.prep_data" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.common_options.target.endianess.843883489" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess" useByScannerDiscovery="false"/> + <option id="com.atollic.truestudio.common_options.target.mcpu.1479828622" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" useByScannerDiscovery="false" value="STM32L486RG" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.instr_set.448938746" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpucore.1614902400" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" useByScannerDiscovery="false" value="FPv4-SP-D16" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpu.2057432724" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> + <option id="com.atollic.truestudio.gcc.optimization.prep_garbage.1183071415" name="Prepare dead code removal " superClass="com.atollic.truestudio.gcc.optimization.prep_garbage" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.gcc.optimization.prep_data.686366138" name="Prepare dead data removal" superClass="com.atollic.truestudio.gcc.optimization.prep_data" useByScannerDiscovery="false" value="true" valueType="boolean"/> <inputType id="com.atollic.truestudio.gcc.input.241557803" superClass="com.atollic.truestudio.gcc.input"/> </tool> <tool id="com.atollic.truestudio.exe.release.toolchain.ld.1678773308" name="C Linker" superClass="com.atollic.truestudio.exe.release.toolchain.ld"> @@ -182,35 +183,37 @@ <option id="com.atollic.truestudio.ld.optimization.do_garbage.1493511857" name="Dead code removal " superClass="com.atollic.truestudio.ld.optimization.do_garbage" value="true" valueType="boolean"/> </tool> <tool id="com.atollic.truestudio.exe.release.toolchain.gpp.930238019" name="C++ Compiler" superClass="com.atollic.truestudio.exe.release.toolchain.gpp"> - <option id="com.atollic.truestudio.gpp.symbols.defined.441450292" name="Defined symbols" superClass="com.atollic.truestudio.gpp.symbols.defined" valueType="definedSymbols"> + <option id="com.atollic.truestudio.gpp.symbols.defined.441450292" name="Defined symbols" superClass="com.atollic.truestudio.gpp.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols"> <listOptionValue builtIn="false" value="STM32L486xx"/> </option> - <option id="com.atollic.truestudio.gpp.directories.select.1426153494" name="Include path" superClass="com.atollic.truestudio.gpp.directories.select" valueType="includePath"> + <option id="com.atollic.truestudio.gpp.directories.select.1426153494" name="Include path" superClass="com.atollic.truestudio.gpp.directories.select" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value="../src"/> + <listOptionValue builtIn="false" value=""${workspace_loc:/halpp/include}""/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Include"/> <listOptionValue builtIn="false" value="../Drivers/CMSIS/Device/ST/STM32L4xx/Include"/> <listOptionValue builtIn="false" value="../Drivers/STM32L4xx_HAL_Driver/Inc"/> </option> - <option id="com.atollic.truestudio.common_options.target.endianess.1362774688" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess"/> - <option id="com.atollic.truestudio.common_options.target.mcpu.156788988" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" value="STM32L486RG" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.instr_set.766386504" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpucore.873771862" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" value="FPv4-SP-D16" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpu.1039126836" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> - <option id="com.atollic.truestudio.gpp.optimization.prep_garbage.1461712760" name="Prepare dead code removal" superClass="com.atollic.truestudio.gpp.optimization.prep_garbage" value="true" valueType="boolean"/> - <option id="com.atollic.truestudio.gpp.optimization.prep_data.407648088" name="Prepare dead data removal" superClass="com.atollic.truestudio.gpp.optimization.prep_data" value="true" valueType="boolean"/> - <option id="com.atollic.truestudio.gpp.optimization.fno_rtti.335319288" name="Disable RTTI" superClass="com.atollic.truestudio.gpp.optimization.fno_rtti" value="true" valueType="boolean"/> - <option id="com.atollic.truestudio.gpp.optimization.fno_exceptions.51506950" name="Disable exception handling" superClass="com.atollic.truestudio.gpp.optimization.fno_exceptions" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.common_options.target.endianess.1362774688" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess" useByScannerDiscovery="false"/> + <option id="com.atollic.truestudio.common_options.target.mcpu.156788988" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" useByScannerDiscovery="false" value="STM32L486RG" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.instr_set.766386504" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpucore.873771862" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" useByScannerDiscovery="false" value="FPv4-SP-D16" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpu.1039126836" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> + <option id="com.atollic.truestudio.gpp.optimization.prep_garbage.1461712760" name="Prepare dead code removal" superClass="com.atollic.truestudio.gpp.optimization.prep_garbage" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.gpp.optimization.prep_data.407648088" name="Prepare dead data removal" superClass="com.atollic.truestudio.gpp.optimization.prep_data" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.gpp.optimization.fno_rtti.335319288" name="Disable RTTI" superClass="com.atollic.truestudio.gpp.optimization.fno_rtti" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.gpp.optimization.fno_exceptions.51506950" name="Disable exception handling" superClass="com.atollic.truestudio.gpp.optimization.fno_exceptions" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.gpp.cppstandard.1588710503" superClass="com.atollic.truestudio.gpp.cppstandard" useByScannerDiscovery="false" value="com.atollic.truestudio.gpp.cppstandard.cpp0x" valueType="enumerated"/> <inputType id="com.atollic.truestudio.gpp.input.1410705987" superClass="com.atollic.truestudio.gpp.input"/> </tool> <tool id="com.atollic.truestudio.exe.release.toolchain.ldcc.1598610548" name="C++ Linker" superClass="com.atollic.truestudio.exe.release.toolchain.ldcc"> - <option id="com.atollic.truestudio.common_options.target.endianess.617198953" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess"/> - <option id="com.atollic.truestudio.common_options.target.mcpu.976712891" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" value="STM32L486RG" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.instr_set.686627514" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpucore.360686412" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" value="FPv4-SP-D16" valueType="enumerated"/> - <option id="com.atollic.truestudio.common_options.target.fpu.332993398" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> - <option id="com.atollic.truestudio.ld.general.cclib.1591242648" name="Runtime Library" superClass="com.atollic.truestudio.ld.general.cclib" value="com.atollic.truestudio.ld.general.cclib.CCSmallCSmall" valueType="enumerated"/> - <option id="com.atollic.truestudio.ldcc.optimization.do_garbage.1728094444" name="Dead code removal" superClass="com.atollic.truestudio.ldcc.optimization.do_garbage" value="true" valueType="boolean"/> - <option id="com.atollic.truestudio.ldcc.general.scriptfile.477789384" name="Linker script" superClass="com.atollic.truestudio.ldcc.general.scriptfile" value="../stm32l4_flash.ld" valueType="string"/> + <option id="com.atollic.truestudio.common_options.target.endianess.617198953" name="Endianess" superClass="com.atollic.truestudio.common_options.target.endianess" useByScannerDiscovery="false"/> + <option id="com.atollic.truestudio.common_options.target.mcpu.976712891" name="Microcontroller" superClass="com.atollic.truestudio.common_options.target.mcpu" useByScannerDiscovery="false" value="STM32L486RG" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.instr_set.686627514" name="Instruction set" superClass="com.atollic.truestudio.common_options.target.instr_set" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.instr_set.thumb2" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpucore.360686412" name="FPU" superClass="com.atollic.truestudio.common_options.target.fpucore" useByScannerDiscovery="false" value="FPv4-SP-D16" valueType="enumerated"/> + <option id="com.atollic.truestudio.common_options.target.fpu.332993398" name="Floating point" superClass="com.atollic.truestudio.common_options.target.fpu" useByScannerDiscovery="false" value="com.atollic.truestudio.common_options.target.fpu.hard" valueType="enumerated"/> + <option id="com.atollic.truestudio.ld.general.cclib.1591242648" name="Runtime Library" superClass="com.atollic.truestudio.ld.general.cclib" useByScannerDiscovery="false" value="com.atollic.truestudio.ld.general.cclib.CCSmallCSmall" valueType="enumerated"/> + <option id="com.atollic.truestudio.ldcc.optimization.do_garbage.1728094444" name="Dead code removal" superClass="com.atollic.truestudio.ldcc.optimization.do_garbage" useByScannerDiscovery="false" value="true" valueType="boolean"/> + <option id="com.atollic.truestudio.ldcc.general.scriptfile.477789384" name="Linker script" superClass="com.atollic.truestudio.ldcc.general.scriptfile" useByScannerDiscovery="false" value="../stm32l4_flash.ld" valueType="string"/> <inputType id="com.atollic.truestudio.ldcc.input.700595841" name="Input" superClass="com.atollic.truestudio.ldcc.input"> <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/> <additionalInput kind="additionalinput" paths="$(LIBS)"/>
--- a/l476rg-hal-test/.settings/language.settings.xml Mon Jan 16 11:04:47 2017 +0300 +++ b/l476rg-hal-test/.settings/language.settings.xml Wed Jan 18 01:07:59 2017 +0300 @@ -4,7 +4,7 @@ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> - <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="940512069781223905" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1885092277368706637" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> <language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.g++"/> </provider> @@ -14,7 +14,7 @@ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> - <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="944816577120802337" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1885092277368706637" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> <language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.g++"/> </provider>
--- a/l476rg-hal-test/.settings/org.eclipse.cdt.managedbuilder.core.prefs Mon Jan 16 11:04:47 2017 +0300 +++ b/l476rg-hal-test/.settings/org.eclipse.cdt.managedbuilder.core.prefs Wed Jan 18 01:07:59 2017 +0300 @@ -1,10 +1,20 @@ eclipse.preferences.version=1 +environment/buildEnvironmentInclude/com.atollic.truestudio.configuration.release.1226093006/CPATH/delimiter=\: +environment/buildEnvironmentInclude/com.atollic.truestudio.configuration.release.1226093006/CPATH/operation=remove +environment/buildEnvironmentInclude/com.atollic.truestudio.configuration.release.1226093006/C_INCLUDE_PATH/delimiter=\: +environment/buildEnvironmentInclude/com.atollic.truestudio.configuration.release.1226093006/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/com.atollic.truestudio.configuration.release.1226093006/append=true +environment/buildEnvironmentInclude/com.atollic.truestudio.configuration.release.1226093006/appendContributed=true environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.575721757/CPATH/delimiter=\: environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.575721757/CPATH/operation=remove environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.575721757/C_INCLUDE_PATH/delimiter=\: environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.575721757/C_INCLUDE_PATH/operation=remove environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.575721757/append=true environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.575721757/appendContributed=true +environment/buildEnvironmentLibrary/com.atollic.truestudio.configuration.release.1226093006/LIBRARY_PATH/delimiter=\: +environment/buildEnvironmentLibrary/com.atollic.truestudio.configuration.release.1226093006/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/com.atollic.truestudio.configuration.release.1226093006/append=true +environment/buildEnvironmentLibrary/com.atollic.truestudio.configuration.release.1226093006/appendContributed=true environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.575721757/LIBRARY_PATH/delimiter=\: environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.575721757/LIBRARY_PATH/operation=remove environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.575721757/append=true
--- a/l476rg-hal-test/src/main.cpp Mon Jan 16 11:04:47 2017 +0300 +++ b/l476rg-hal-test/src/main.cpp Wed Jan 18 01:07:59 2017 +0300 @@ -45,30 +45,52 @@ using namespace halpp; -template<typename TDev, unsigned short PIN> class TLed { - TDev& m_dev; +template<typename TDev, unsigned short PIN, typename TTraits = TGpioTraits<TDev> > class TLed { + TLed(); + explicit TLed(const TLed&); public: - TLed(TDev& dev) : - m_dev(dev) { + static void Init() { + TTraits::SetPinMode(PIN, GpioModeOutput); + TTraits::SetPinOutputType(PIN, GpioPushPull); + TTraits::SetPinPullMode(PIN, GpioNoPull); + } + static void Set() { + TTraits::WritePin(PIN, 1); } + static void Reset() { + TTraits::WritePin(PIN, 0); + } + + static void Toogle() { + TTraits::TooglePin(PIN); + } +}; + +template<typename TDev, typename TTraits = TGpioTraits<TDev> > class TLedInst { + const unsigned short m_ledNo; + + explicit TLedInst(const TLedInst&); +public: + TLedInst(unsigned short led) : m_ledNo(led) { + } void Init() const { - m_dev.SetPinMode(5, halpp::GpioModeOutput); - m_dev.SetPinOutputType(5, halpp::GpioOutputType::GpioPushPull); - m_dev.SetPinPullMode(5, halpp::GpioPullMode::GpioNoPull); + TTraits::SetPinMode(m_ledNo, GpioModeOutput); + TTraits::SetPinOutputType(m_ledNo, GpioPushPull); + TTraits::SetPinPullMode(m_ledNo, GpioNoPull); } void Set() const { - m_dev.WritePin(PIN, 1); + TTraits::WritePin(m_ledNo, 1); } void Reset() const { - m_dev.WritePin(PIN, 0); + TTraits::WritePin(m_ledNo, 0); } void Toogle() const { - m_dev.TooglePin(PIN); + TTraits::TooglePin(m_ledNo); } }; @@ -79,6 +101,19 @@ } }; +class APB1Bus { +public: + static void Enable(unsigned int flag) { + RCC->APB1ENR1 |= flag; + } +}; + +class APB1Bus2 { + static void Enable(uint32_t flag) { + RCC->APB1ENR2 |= flag; + } +}; + template<typename TBus, unsigned short ENF> class TDevice { public: static void Enable() { @@ -86,21 +121,29 @@ } }; -class GpioA : public TGpio<GPIO_TypeDef>, public TDevice<AHB2Bus, RCC_AHB2ENR_GPIOAEN> { - static GpioA m_instance; - typedef TGpio<GPIO_TypeDef> GpioBase; +class Hardware { public: + class GpioA: public TDevice<AHB2Bus, RCC_AHB2ENR_GPIOAEN> { + public: + static GPIO_TypeDef& instance() { + return *GPIOA; + } + }; - GpioA(GPIO_TypeDef& dev) : GpioBase(dev) { - - } + class Tim3: public TDevice<AHB1Bus, RCC_APB1ENR1_TIM3EN> { + public: + static TIM_TypeDef& instance() { + return *TIM3; + } + }; - static GpioA& instance() { - return m_instance; - } + static const TLedInst<GpioA> greenLed; + static const TLedInst<GpioA> led2; + }; -GpioA GpioA::m_instance(*GPIOA); +const TLedInst<Hardware::GpioA> Hardware::greenLed(5); +const TLedInst<Hardware::GpioA> Hardware::led2(5); int main(void) { @@ -116,14 +159,14 @@ /* TODO - Add your application code here */ - GpioA::Enable(); - - TLed<halpp::TGpio<GPIO_TypeDef>, 5> led1(GpioA::instance()); - led1.Init(); + Hardware::GpioA::Enable(); + Hardware::greenLed.Init(); + Hardware::led2.Init(); /* Infinite loop */ while (1) { - led1.Toogle(); + Hardware::greenLed.Toogle(); + Hardware::led2.Toogle(); for (int i = 0; i < 1000000; i++) { }
--- a/l476rg/.settings/language.settings.xml Mon Jan 16 11:04:47 2017 +0300 +++ b/l476rg/.settings/language.settings.xml Wed Jan 18 01:07:59 2017 +0300 @@ -4,7 +4,7 @@ <extension point="org.eclipse.cdt.core.LanguageSettingsProvider"> <provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/> <provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/> - <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="922121010244122911" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> + <provider class="com.atollic.truestudio.mbs.GCCSpecsDetectorAtollicArm" console="false" env-hash="1793193066533405323" id="com.atollic.truestudio.mbs.provider" keep-relative-paths="false" name="Atollic ARM Tools Language Settings" parameter="${COMMAND} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true"> <language-scope id="org.eclipse.cdt.core.gcc"/> <language-scope id="org.eclipse.cdt.core.g++"/> </provider>