Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ports refactoring complete

  • Loading branch information...
commit 7b0ca2323b427879d5a08ed2f7d3f6454a65e7f2 1 parent dff3fb0
Konstantin Chizhov authored
View
8 LcdTest/LcdTest.aps
@@ -2,7 +2,7 @@
<MANAGEMENT>
<ProjectName>LcdTest</ProjectName>
<Created>22-Mar-2010 14:35:37</Created>
- <LastEdit>26-Dec-2010 22:23:06</LastEdit>
+ <LastEdit>27-Dec-2010 16:35:44</LastEdit>
<ICON>241</ICON>
<ProjectType>0</ProjectType>
<Created>22-Mar-2010 14:35:37</Created>
@@ -13,7 +13,7 @@
<CODE_CREATION>
<ObjectFile>default\LcdTest.elf</ObjectFile>
<EntryFile></EntryFile>
- <SaveFolder>E:\Projects\McuProjects\LcdTest\</SaveFolder></CODE_CREATION>
+ <SaveFolder>D:\Projects\McuProjects\LcdTest\</SaveFolder></CODE_CREATION>
<DEBUG_TARGET>
<CURRENT_TARGET>AVR Simulator</CURRENT_TARGET>
<CURRENT_PART>ATmega16.xml</CURRENT_PART>
@@ -29,7 +29,7 @@
<FILES>
<SOURCEFILE>LcdTest.cpp</SOURCEFILE><OTHERFILE>default\LcdTest.lss</OTHERFILE><OTHERFILE>default\LcdTest.map</OTHERFILE></FILES>
<CONFIGS>
- <CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>atmega16</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>LcdTest.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS><OPTION><FILE>LcdTest.cpp</FILE><OPTIONLIST></OPTIONLIST></OPTION></OPTIONS><INCDIRS><INCLUDE>..\mcucpp\</INCLUDE></INCDIRS><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS>
+ <CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>atmega16</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>LcdTest.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>0</ISDIRTY><OPTIONS/><INCDIRS><INCLUDE>..\mcucpp\</INCLUDE></INCDIRS><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS>
<LASTCONFIG>default</LASTCONFIG>
<USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN>
- <IOView><usergroups/><sort sorted="0" column="0" ordername="1" orderaddress="1" ordergroup="1"/></IOView><Files><File00000><FileId>00000</FileId><FileName>LcdTest.cpp</FileName><Status>1</Status></File00000><File00001><FileId>00001</FileId><FileName>e:\Projects\mcuprojects\mcucpp\HD44780.h</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>E:\Projects\McuProjects\mcucpp\latch.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>E:\Projects\McuProjects\mcucpp\pinlist.h</FileName><Status>1</Status></File00003><File00004><FileId>00004</FileId><FileName>default\LcdTest.lss</FileName><Status>1</Status></File00004><File00005><FileId>00005</FileId><FileName>E:\Projects\McuProjects\mcucpp\gpiobase.h</FileName><Status>1</Status></File00005><File00006><FileId>00006</FileId><FileName>E:\Projects\McuProjects\mcucpp\ioports.h</FileName><Status>1</Status></File00006></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
+ <ProjectFiles><Files><Name>D:\Projects\McuProjects\LcdTest\LcdTest.cpp</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>LcdTest.cpp</FileName><Status>1</Status></File00000><File00001><FileId>00001</FileId><FileName>default\LcdTest.lss</FileName><Status>1</Status></File00001><File00002><FileId>00002</FileId><FileName>D:\Projects\McuProjects\mcucpp\iopins.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>D:\Projects\McuProjects\mcucpp\AVR\AvrPorts.h</FileName><Status>1</Status></File00003><File00004><FileId>00004</FileId><FileName>D:\Projects\McuProjects\mcucpp\ioports.h</FileName><Status>1</Status></File00004><File00005><FileId>00005</FileId><FileName>D:\Projects\McuProjects\mcucpp\pinlist.h</FileName><Status>1</Status></File00005><File00006><FileId>00006</FileId><FileName>D:\Projects\McuProjects\mcucpp\latch.h</FileName><Status>1</Status></File00006><File00007><FileId>00007</FileId><FileName>d:\Projects\mcuprojects\mcucpp\HD44780.h</FileName><Status>1</Status></File00007><File00008><FileId>00008</FileId><FileName>D:\Projects\McuProjects\mcucpp\loki\TypeManip.h</FileName><Status>1</Status></File00008><File00009><FileId>00009</FileId><FileName>D:\Projects\McuProjects\mcucpp\loki\Typelist.h</FileName><Status>1</Status></File00009></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
View
4 LcdTest/LcdTest.cpp
@@ -18,18 +18,20 @@ typedef ThreePinLatch<Pb0, Pb1, Pb2, 'L'> Latch1;
typedef TPin<Latch1, 6> L6;
typedef TPin<Latch1, 7> L7;
-typedef Lcd<PinList<Pa0, Pa1, Pa2, Pa3, Pa4, Pa5, Pa6> > Lcd1;
+typedef Lcd<PinList<Pc0, Pc1, Pc2, Pa4, Pa5, Pa6, Pa7> > Lcd1;
typedef Lcd<PinList<L0, L1, L2, L3, L4, L5, L6> > Lcd2;
int main()
{
+
Lcd1::Init();
Lcd1::Puts("Hello world!", 12);
Lcd2::Init();
Lcd2::Puts("Hello world!", 12);
+
while(1)
{
View
26 MspLcd/MspLcd.ewp
@@ -654,7 +654,7 @@
</option>
<option>
<name>XclFile</name>
- <state>$TOOLKIT_DIR$\CONFIG\lnk430F149.xcl</state>
+ <state>$TOOLKIT_DIR$\CONFIG\lnk430G2231.xcl</state>
</option>
<option>
<name>XclFileSlave</name>
@@ -956,7 +956,7 @@
</option>
<option>
<name>Input description</name>
- <state>Full formatting.</state>
+ <state>No specifier n, no float or long long.</state>
</option>
<option>
<name>Output variant</name>
@@ -965,7 +965,7 @@
</option>
<option>
<name>Output description</name>
- <state>Full formatting.</state>
+ <state>No specifier a or A.</state>
</option>
<option>
<name>GRuntimeLibSelectSlave</name>
@@ -982,7 +982,7 @@
</option>
<option>
<name>OGChipSelectMenu</name>
- <state>MSP430F149 MSP430F149</state>
+ <state>MSP430G2231 MSP430G2231</state>
</option>
<option>
<name>GStackHeapOverride</name>
@@ -990,11 +990,11 @@
</option>
<option>
<name>GStackSize2</name>
- <state>80</state>
+ <state>50</state>
</option>
<option>
<name>GHeapSize2</name>
- <state>80</state>
+ <state>0</state>
</option>
<option>
<name>RadioDataModelType</name>
@@ -1002,7 +1002,7 @@
</option>
<option>
<name>GHeap20Size</name>
- <state>###Uninitialized###</state>
+ <state>80</state>
</option>
<option>
<name>GeneralMisraRules98</name>
@@ -1057,15 +1057,15 @@
</option>
<option>
<name>CCListCFile</name>
- <state>0</state>
+ <state>1</state>
</option>
<option>
<name>CCListCMnemonics</name>
- <state>0</state>
+ <state>1</state>
</option>
<option>
<name>CCListCMessages</name>
- <state>0</state>
+ <state>1</state>
</option>
<option>
<name>CCListAssFile</name>
@@ -1231,7 +1231,7 @@
<option>
<name>CCOptStrategy</name>
<version>0</version>
- <state>1</state>
+ <state>0</state>
</option>
<option>
<name>CCOptLevelSlave</name>
@@ -1535,7 +1535,7 @@
</option>
<option>
<name>XclFile</name>
- <state>$TOOLKIT_DIR$\CONFIG\lnk430F149.xcl</state>
+ <state>$TOOLKIT_DIR$\CONFIG\lnk430G2231.xcl</state>
</option>
<option>
<name>XclFileSlave</name>
@@ -1663,7 +1663,7 @@
</option>
<option>
<name>ExtraOutputFile</name>
- <state>templproj.a43</state>
+ <state>MspLcd.a43</state>
</option>
<option>
<name>ExtraOutputFormat</name>
View
3  MspLcd/main.cpp
@@ -31,11 +31,12 @@ int main( void )
{
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW | WDTHOLD;
-
+
MyLcd::Init();
MyLcd::Puts("Hello msp430", 8);
MyLcd::Goto(0x40);
MyLcd::Puts("Hello msp430"+8, 4);
+
while(1)
{
View
1  mcucpp/AVR/AvrPorts.h
@@ -99,6 +99,7 @@ namespace IO
{
public:
typedef uint8_t DataT;
+ typedef NativePortBase Base;
enum{Width=sizeof(DataT)*8};
public:
enum Configuration
View
1  mcucpp/AVR/XMegaPorts.h
@@ -100,6 +100,7 @@ namespace IO
{
public:
typedef uint8_t DataT;
+ typedef NativePortBase Base;
enum{Width=sizeof(DataT)*8};
public:
/*TODO: Implement other configurations*/
View
1  mcucpp/Arm/Stm32Ports.h
@@ -16,6 +16,7 @@ namespace IO
{
public:
enum{Width=16};
+ typedef NativePortBase Base;
typedef uint16_t DataT;
enum Configuration
{
View
2  mcucpp/HD44780.h
@@ -5,7 +5,7 @@
// Title : C++ LCD HD44780 compatible display
// Author : Konstantin Chizhov
// Date : 2010
-// Target MCU : Atmel mega AVR, TINY avr AND Xmega Series
+// Target MCU : platform independent
//
// This code is distributed under the GNU Public License
// which can be found at http://www.gnu.org/licenses/gpl.txt
View
1  mcucpp/MSP430/Msp430Ports.h
@@ -80,6 +80,7 @@ namespace IO
public:
typedef uint8_t DataT;
enum{DirBit = 1, AltSelBit = 2, ResEnBit = 4};
+ typedef NativePortBase Base;
enum{Width=sizeof(DataT)*8};
public:
enum Configuration
View
2  mcucpp/ioports.h
@@ -49,7 +49,7 @@ namespace IO
{
public:
typedef DontCareConfiguration Configuration;
-
+ typedef GpioBase Base;
typedef uint8_t DataT;
static void Write(DataT value)
{ }
View
3  mcucpp/latch.h
@@ -8,7 +8,8 @@
class LatchBase : public IO::GpioBase
{
public:
- enum{Out = 1};
+ //typedef IO::GpioBase Base;
+ typedef LatchBase Base;
//SetConfiguration is do nothing function
// and accepts any configuration type
typedef DontCareConfiguration Configuration;
View
94 mcucpp/pinlist.h
@@ -63,42 +63,72 @@ namespace IO
// Checks if all ports has the same configuration enum
// PlaceHolderType matchs any type in TList
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class PlaceHolderType, bool skipNext> struct CheckSameConfig;
- template <class PlaceHolderType, bool skipNext> struct CheckSameConfig<NullType, PlaceHolderType, skipNext>
+ template <class TList, class CurrentConfig = typename TList::Head::Configuration>
+ struct CheckSameConfig;
+
+ template<class TList, class CurrentConfig, class NextConfig>
+ struct CheckSameConfigHelper
+ {
+ enum{value = 0};
+ };
+
+ template<class Head, class Tail, class CurrentConfig>
+ struct CheckSameConfigHelper<Typelist<Head, Tail>, CurrentConfig, CurrentConfig>
+ {
+ enum{value = CheckSameConfig<Tail, CurrentConfig>::value};
+ };
+
+ template <class CurrentConfig> struct CheckSameConfig<NullType, CurrentConfig>
{
enum{value = 1};
- enum{EndOfList = 1};
- typedef NullType PinConfigType;
};
- template <class Head, class Tail, class PlaceHolderType, bool skipNext>
- struct CheckSameConfig< Typelist<Head, Tail>, PlaceHolderType, skipNext>
+ template <class Head, class Tail, class CurrentConfig>
+ struct CheckSameConfig<Typelist<Head, Tail>, CurrentConfig>
{
- //private:
- typedef typename Head::Configuration PinConfigType;
- typedef CheckSameConfig<Tail, PlaceHolderType, false> Next;
- typedef typename Next::PinConfigType NextConfig;
- enum{SameAsNext = IsSameType<PinConfigType, NextConfig>::value};
+ enum{value = CheckSameConfigHelper<Typelist<Head, Tail>, CurrentConfig, typename Head::Configuration>::value};
+ };
- enum{IsPlaceHolder = IsSameType<PinConfigType, PlaceHolderType>::value};
- enum{NextIsPlaceHolder = IsSameType<NextConfig, PlaceHolderType>::value};
- typedef CheckSameConfig<Tail, PlaceHolderType, NextIsPlaceHolder> Iter;
+////////////////////////////////////////////////////////////////////////////////
+ template <class TList, class T, class ConfigT>
+ struct ErisePortsHelper;
- enum{EndOfList = 0};
- //public:
- enum{value = ((SameAsNext || IsPlaceHolder || NextIsPlaceHolder) && Iter::value) || Iter::EndOfList};
- };
+ template <class TList, class T>
+ struct ErasePortsWithConfig
+ {
+ typedef typename ErisePortsHelper<TList, T, typename TList::Head::Configuration>::Result Result;
+ };
- template <class Head, class Tail, class PlaceHolderType>
- struct CheckSameConfig<Typelist<Head, Tail>, PlaceHolderType, true>
+ template < class T>
+ struct ErasePortsWithConfig<NullType, T>
{
- typedef CheckSameConfig<Tail, PlaceHolderType, false> Next;
- enum{value = Next::value};
- enum{EndOfList = 0};
+ typedef NullType Result;
};
+ template <class T, class ConfigT>
+ struct ErisePortsHelper<NullType, T, ConfigT>
+ {
+ typedef NullType Result;
+ };
+
+ template <class Head, class Tail, class T>
+ struct ErisePortsHelper<Typelist<Head, Tail>, T, T>
+ {
+ // Go all the way down the list removing the type
+ typedef typename ErasePortsWithConfig<Tail, T>::Result Result;
+ };
+
+ template <class Head, class Tail, class T, class ConfigT>
+ struct ErisePortsHelper<Typelist<Head, Tail>, T, ConfigT>
+ {
+ // Go all the way down the list removing the type
+ typedef Typelist<Head,
+ typename ErasePortsWithConfig<Tail, T>::Result>
+ Result;
+ };
+
////////////////////////////////////////////////////////////////////////////////
template<unsigned BitsToShift>
@@ -572,19 +602,23 @@ namespace IO
typedef typename IoPrivate::GetPorts<ConfigPins>::Result PinsToConfigPorts;
typedef typename Loki::TL::NoDuplicates<PinsToPorts>::Result Ports;
- typedef typename Loki::TL::NoDuplicates<PinsToConfigPorts>::Result ConfigPorts;
+ typedef typename Loki::TL::NoDuplicates<PinsToConfigPorts>::Result AllConfigPorts;
+
+ typedef typename IoPrivate::ErasePortsWithConfig<
+ AllConfigPorts,
+ GpioBase::DontCareConfiguration
+ >::Result ConfigPorts;
static const unsigned Length = LengthEnum;
static const unsigned LastBitPosition = LastBitPositionEnum;
enum {PortsHasSameConfig =
- IoPrivate::CheckSameConfig
- <Ports, GpioBase::DontCareConfiguration, false>::value};
+ IoPrivate::CheckSameConfig<Ports>::value};
typedef typename IoPrivate::StaticIf
<
PortsHasSameConfig,
- NativePortBase,
+ typename Ports::Head::Base,
GpioBase
>::Result BasePortType;
@@ -610,15 +644,15 @@ namespace IO
class Skip: public PinSet< typename IoPrivate::SkipFirst<PINS, Num>::Result >
{};
- template<uint8_t StartIndex, uint8_t Size>
+ template<uint8_t StartIndex, uint8_t SliceSize>
class Slice: public PinSet
<
typename IoPrivate::SkipFirst<
- typename IoPrivate::TakeFirst<PINS, StartIndex + Size>::Result,
+ typename IoPrivate::TakeFirst<PINS, StartIndex + SliceSize>::Result,
StartIndex>::Result
>
{
- BOOST_STATIC_ASSERT(Size == Length);
+ BOOST_STATIC_ASSERT(SliceSize == Slice::Length);
};
template<uint8_t PIN>
Please sign in to comment.
Something went wrong with that request. Please try again.