Mercurial > pub > halpp
changeset 1:a0b14b11ad9f
working on dependencies between MCU devices such as GPIO, Pins and Timers
author | cin |
---|---|
date | Fri, 13 Jan 2017 02:11:02 +0300 |
parents | 32a3b1785697 |
children | 0c59e7a7782a |
files | halpp/include/gpio.h halpp/include/pwm.h l476rg-hal-test/.cproject l476rg-hal-test/include/msp.h l476rg-hal-test/src/main.cpp l476rg-hal-test/src/msp.cpp |
diffstat | 6 files changed, 60 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/halpp/include/gpio.h Fri Jan 13 02:11:02 2017 +0300 @@ -0,0 +1,15 @@ +#pragma once + +namespace halpp { + + template <typename TTraits> class TGpio { + public: + + + }; + + template <typename TGpio, unsigned short Pin> class TGpioPin { + + }; + +}
--- a/halpp/include/pwm.h Thu Jan 12 02:45:43 2017 +0300 +++ b/halpp/include/pwm.h Fri Jan 13 02:11:02 2017 +0300 @@ -2,28 +2,46 @@ namespace halpp { - template <typename TTim> class TPwmChannel1Traits { + template <typename TTim> class TTimerTraits { public: - typedef uint32_t pulse_t; + typedef unsigned int pulse_t; + }; - static void SetPeriod(TTim& tim, pulse_t value) { - tim.CCR1 = value; + typedef enum { + Normal, + Inverse + } PwmPolarity; + + template <typename TTim, int Ch> class TPwmChannelTraits { + typedef typename TTimerTraits<TTim>::pulse_t pulse_t; + public: + static void SetPulse(TTim& tim, pulse_t value) { } }; + template <typename TTim> + template <typename TTim, typename TTraits> class TPwmChannel { + typedef typename TTraits::pulse_t pulse_t; private: TTim& m_tim; - explicit TPwmChannel(const TPwmChannel<TTim,TTRaits>& self); + // deny copy constructor + explicit TPwmChannel(const TPwmChannel<TTim,TTraits>& self); public: TPwmChannel(TTim& tim): m_tim(tim) { } - void SetPulse(TTraits::pulse_t value) { + void SetPulse(pulse_t value) { TTraits::SetPeriod(m_tim, value); } + + void Enable() { + } + + void Disable() { + } }; }
--- a/l476rg-hal-test/.cproject Thu Jan 12 02:45:43 2017 +0300 +++ b/l476rg-hal-test/.cproject Fri Jan 13 02:11:02 2017 +0300 @@ -38,7 +38,7 @@ </tool> <tool id="com.atollic.truestudio.exe.debug.toolchain.gcc.2143128573" name="C Compiler" superClass="com.atollic.truestudio.exe.debug.toolchain.gcc"> <option id="com.atollic.truestudio.gcc.symbols.defined.378788506" name="Defined symbols" superClass="com.atollic.truestudio.gcc.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols"> - <listOptionValue builtIn="false" value="STM32L486xx"/> + <listOptionValue builtIn="false" value="STM32L476xx"/> </option> <option id="com.atollic.truestudio.gcc.directories.select.1111651463" name="Include path" superClass="com.atollic.truestudio.gcc.directories.select" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value="../include"/> @@ -69,7 +69,7 @@ </tool> <tool id="com.atollic.truestudio.exe.debug.toolchain.gpp.1625442919" name="C++ Compiler" superClass="com.atollic.truestudio.exe.debug.toolchain.gpp"> <option id="com.atollic.truestudio.gpp.symbols.defined.1663945888" name="Defined symbols" superClass="com.atollic.truestudio.gpp.symbols.defined" useByScannerDiscovery="false" valueType="definedSymbols"> - <listOptionValue builtIn="false" value="STM32L486xx"/> + <listOptionValue builtIn="false" value="STM32L476xx"/> </option> <option id="com.atollic.truestudio.gpp.directories.select.172494999" name="Include path" superClass="com.atollic.truestudio.gpp.directories.select" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value="../include"/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/l476rg-hal-test/include/msp.h Fri Jan 13 02:11:02 2017 +0300 @@ -0,0 +1,14 @@ +#pragma once +#include "pwm.h" +#include "stm32l476xx.h" + +using namespace halpp; + + +class Hardware { + + typedef TPwmChannel<TIM_TypeDef, TPwmChannel1Traits<TIM_TypeDef> > PwmChannel1; +public: + + static PwmChannel1 pwm1; +};
--- a/l476rg-hal-test/src/main.cpp Thu Jan 12 02:45:43 2017 +0300 +++ b/l476rg-hal-test/src/main.cpp Fri Jan 13 02:11:02 2017 +0300 @@ -28,6 +28,7 @@ /* Includes */ #include "stm32l4xx.h" +#include "msp.h" /* Private macro */ /* Private variables */ @@ -60,6 +61,7 @@ /* Infinite loop */ while (1) { + Hardware::pwm1.SetPulse(150); i++; } }