Replaced class variables with defines

This commit is contained in:
BlackMark 2016-05-19 22:13:06 +02:00
parent 6ac7d71530
commit 11ba283d0e
5 changed files with 178 additions and 154 deletions

View File

@ -7,7 +7,7 @@
#ifndef CLOCK_H #ifndef CLOCK_H
#define CLOCK_H #define CLOCK_H
#define F_CPU 16000000 #define F_CPU 8000000
#include <util/delay.h> #include <util/delay.h>

View File

@ -30,11 +30,11 @@ void USART0::setRXState( bool bEnable )
{ {
if( bEnable ) if( bEnable )
{ {
*m_vui8pUCSRB |= ( 1 << m_ui8RXEN ); *m_vui8pUCSRB |= ( 1 << RXEN_D );
} }
else else
{ {
*m_vui8pUCSRB &= ~( 1 << m_ui8RXEN ); *m_vui8pUCSRB &= ~( 1 << RXEN_D );
} }
} }
@ -43,11 +43,11 @@ void USART0::setTXState( bool bEnable )
{ {
if( bEnable ) if( bEnable )
{ {
*m_vui8pUCSRB |= ( 1 << m_ui8TXEN ); *m_vui8pUCSRB |= ( 1 << TXEN_D );
} }
else else
{ {
*m_vui8pUCSRB &= ~( 1 << m_ui8TXEN ); *m_vui8pUCSRB &= ~( 1 << TXEN_D );
} }
} }
@ -80,28 +80,28 @@ void USART0::setDataBits( uint8_t ui8DataBits )
if( bZeroBit ) if( bZeroBit )
{ {
ui8UCSRC |= ( 1 << m_ui8UCSZ0 ); ui8UCSRC |= ( 1 << UCSZ0_D );
} }
else else
{ {
ui8UCSRC &= ~( 1 << m_ui8UCSZ0 ); ui8UCSRC &= ~( 1 << UCSZ0_D );
} }
if( bOneBit ) if( bOneBit )
{ {
ui8UCSRC |= ( 1 << m_ui8UCSZ1 ); ui8UCSRC |= ( 1 << UCSZ1_D );
} }
else else
{ {
ui8UCSRC &= ~( 1 << m_ui8UCSZ1 ); ui8UCSRC &= ~( 1 << UCSZ1_D );
} }
*m_vui8pUCSRB &= ~( 1 << m_ui8UCSZ2 ); *m_vui8pUCSRB &= ~( 1 << UCSZ2_D );
} }
else else
{ {
ui8UCSRC |= ( 1 << m_ui8UCSZ1 ) | ( 1 << m_ui8UCSZ0 ); ui8UCSRC |= ( 1 << UCSZ1_D ) | ( 1 << UCSZ0_D );
*m_vui8pUCSRB |= ( 1 << m_ui8UCSZ2 ); *m_vui8pUCSRB |= ( 1 << UCSZ2_D );
} }
setUCSRC( ui8UCSRC ); setUCSRC( ui8UCSRC );
@ -114,16 +114,16 @@ void USART0::setParity( Parity enmParity )
if( enmParity == Parity::DISABLED ) if( enmParity == Parity::DISABLED )
{ {
ui8UCSRC &= ~( ( 1 << m_ui8UPM1 ) | ( 1 << m_ui8UPM0 ) ); ui8UCSRC &= ~( ( 1 << UPM1_D ) | ( 1 << UPM0_D ) );
} }
else if( enmParity == Parity::ODD ) else if( enmParity == Parity::ODD )
{ {
ui8UCSRC |= ( ( 1 << m_ui8UPM1 ) | ( 1 << m_ui8UPM0 ) ); ui8UCSRC |= ( ( 1 << UPM1_D ) | ( 1 << UPM0_D ) );
} }
else if( enmParity == Parity::EVEN ) else if( enmParity == Parity::EVEN )
{ {
ui8UCSRC &= ~( ( 1 << m_ui8UPM0 ) ); ui8UCSRC &= ~( ( 1 << UPM0_D ) );
ui8UCSRC |= ( ( 1 << m_ui8UPM1 ) ); ui8UCSRC |= ( ( 1 << UPM1_D ) );
} }
setUCSRC( ui8UCSRC ); setUCSRC( ui8UCSRC );
@ -136,11 +136,11 @@ void USART0::setStopBits( StopBit enmStopBits )
if( enmStopBits == StopBit::ONE ) if( enmStopBits == StopBit::ONE )
{ {
ui8UCSRC &= ~( 1 << m_ui8USBS ); ui8UCSRC &= ~( 1 << USBS_D );
} }
else if( enmStopBits == StopBit::TWO ) else if( enmStopBits == StopBit::TWO )
{ {
ui8UCSRC |= ( 1 << m_ui8USBS ); ui8UCSRC |= ( 1 << USBS_D );
} }
setUCSRC( ui8UCSRC ); setUCSRC( ui8UCSRC );
@ -154,25 +154,25 @@ void USART0::setMode( Mode enmMode )
#ifdef USART_SPI #ifdef USART_SPI
if( enmMode == Mode::ASYNCHRONOUS ) if( enmMode == Mode::ASYNCHRONOUS )
{ {
ui8UCSRC &= ~( ( 1 << m_ui8UMSEL1 ) | ( 1 << m_ui8UMSEL0 ) ); ui8UCSRC &= ~( ( 1 << UMSEL1_D ) | ( 1 << UMSEL0_D ) );
} }
else if( enmMode == Mode::SYNCHRONOUS ) else if( enmMode == Mode::SYNCHRONOUS )
{ {
ui8UCSRC &= ~( 1 << m_ui8UMSEL1 ); ui8UCSRC &= ~( 1 << UMSEL1_D );
ui8UCSRC |= ( 1 << m_ui8UMSEL0 ); ui8UCSRC |= ( 1 << UMSEL0_D );
} }
else if( enmMode == Mode::MASTERSPI ) else if( enmMode == Mode::MASTERSPI )
{ {
ui8UCSRC |= ( ( 1 << m_ui8UMSEL1 ) | ( 1 << m_ui8UMSEL0 ) ); ui8UCSRC |= ( ( 1 << UMSEL1_D ) | ( 1 << UMSEL0_D ) );
} }
#else #else
if( enmMode == Mode::ASYNCHRONOUS ) if( enmMode == Mode::ASYNCHRONOUS )
{ {
ui8UCSRC &= ~( 1 << m_ui8UMSEL ); ui8UCSRC &= ~( 1 << UMSEL_D );
} }
else if( enmMode == Mode::SYNCHRONOUS ) else if( enmMode == Mode::SYNCHRONOUS )
{ {
ui8UCSRC |= ( 1 << m_ui8UMSEL ); ui8UCSRC |= ( 1 << UMSEL_D );
} }
#endif #endif
@ -193,17 +193,6 @@ USART0::USART0( uint32_t ui32BaudRate, uint8_t ui8DataBits, Parity enmParity, St
m_vui8pUBRRH = &UBRRH; m_vui8pUBRRH = &UBRRH;
m_vui8pUBRRL = &UBRRL; m_vui8pUBRRL = &UBRRL;
m_vui8pUDR = &UDR; m_vui8pUDR = &UDR;
m_ui8RXEN = RXEN;
m_ui8TXEN = TXEN;
m_ui8UCSZ0 = UCSZ0;
m_ui8UCSZ1 = UCSZ1;
m_ui8UCSZ2 = UCSZ2;
m_ui8UPM0 = UPM0;
m_ui8UPM1 = UPM1;
m_ui8USBS = USBS;
m_ui8RXC = RXC;
m_ui8UDRE = UDRE;
#endif #endif
#ifndef USART_SHAREDIO #ifndef USART_SHAREDIO
@ -213,24 +202,6 @@ USART0::USART0( uint32_t ui32BaudRate, uint8_t ui8DataBits, Parity enmParity, St
m_vui8pUBRRH = &UBRR0H; m_vui8pUBRRH = &UBRR0H;
m_vui8pUBRRL = &UBRR0L; m_vui8pUBRRL = &UBRR0L;
m_vui8pUDR = &UDR0; m_vui8pUDR = &UDR0;
m_ui8RXEN = RXEN0;
m_ui8TXEN = TXEN0;
m_ui8UCSZ0 = UCSZ00;
m_ui8UCSZ1 = UCSZ01;
m_ui8UCSZ2 = UCSZ02;
m_ui8UPM0 = UPM00;
m_ui8UPM1 = UPM01;
m_ui8USBS = USBS0;
m_ui8RXC = RXC0;
m_ui8UDRE = UDRE0;
#endif
#ifdef USART_SPI
m_ui8UMSEL0 = UMSEL00;
m_ui8UMSEL1 = UMSEL01;
#else
m_ui8UMSEL = UMSEL;
#endif #endif
init( ui32BaudRate, ui8DataBits, enmParity, enmStopBits, enmMode ); init( ui32BaudRate, ui8DataBits, enmParity, enmStopBits, enmMode );
@ -263,7 +234,7 @@ bool USART0::receiveByte( unsigned char &chData, uint32_t ui32DelayMS )
do do
{ {
if( ( *m_vui8pUCSRA & ( 1 << m_ui8RXC ) ) ) if( ( *m_vui8pUCSRA & ( 1 << RXC_D ) ) )
{ {
chData = *m_vui8pUDR; chData = *m_vui8pUDR;
return true; return true;
@ -276,7 +247,7 @@ bool USART0::receiveByte( unsigned char &chData, uint32_t ui32DelayMS )
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
unsigned char USART0::receiveByte() unsigned char USART0::receiveByte()
{ {
while( !( *m_vui8pUCSRA & ( 1 << m_ui8RXC ) ) ); while( !( *m_vui8pUCSRA & ( 1 << RXC_D ) ) );
return *m_vui8pUDR; return *m_vui8pUDR;
} }
@ -431,7 +402,7 @@ void USART0::receive( long double &ldReceived )
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void USART0::transmitByte( unsigned char byteData ) void USART0::transmitByte( unsigned char byteData )
{ {
while( !( *m_vui8pUCSRA & ( 1 << m_ui8UDRE ) ) ); while( !( *m_vui8pUCSRA & ( 1 << UDRE_D ) ) );
*m_vui8pUDR = byteData; *m_vui8pUDR = byteData;
} }
@ -563,19 +534,6 @@ USART1::USART1( uint32_t ui32BaudRate, uint8_t ui8DataBits, Parity enmParity, St
m_vui8pUBRRL = &UBRR1L; m_vui8pUBRRL = &UBRR1L;
m_vui8pUDR = &UDR1; m_vui8pUDR = &UDR1;
m_ui8RXEN = RXEN1;
m_ui8TXEN = TXEN1;
m_ui8UCSZ0 = UCSZ10;
m_ui8UCSZ1 = UCSZ11;
m_ui8UCSZ2 = UCSZ12;
m_ui8UPM0 = UPM10;
m_ui8UPM1 = UPM11;
m_ui8USBS = USBS1;
m_ui8RXC = RXC1;
m_ui8UDRE = UDRE1;
m_ui8UMSEL0 = UMSEL10;
m_ui8UMSEL1 = UMSEL11;
init( ui32BaudRate, ui8DataBits, enmParity, enmStopBits, enmMode ); init( ui32BaudRate, ui8DataBits, enmParity, enmStopBits, enmMode );
} }

View File

@ -36,7 +36,7 @@
<dependencies> <dependencies>
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.31.0" /> <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.31.0" />
</dependencies> </dependencies>
</framework-data> </framework-data>
</AsfFrameworkConfig> </AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.stk500</avrtool> <avrtool>com.atmel.avrdbg.tool.stk500</avrtool>
<avrtoolserialnumber /> <avrtoolserialnumber />
@ -60,6 +60,7 @@
<ToolchainSettings> <ToolchainSettings>
<AvrGccCpp> <AvrGccCpp>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"</avrgcc.common.Device> <avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex> <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss> <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep> <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
@ -67,25 +68,49 @@
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures> <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned> <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned> <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.directories.IncludePaths><ListValues><Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value></ListValues></avrgcc.compiler.directories.IncludePaths> <avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcc.compiler.directories.IncludePaths>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers> <avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum> <avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings> <avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned> <avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned> <avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.directories.IncludePaths><ListValues><Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value></ListValues></avrgcccpp.compiler.directories.IncludePaths> <avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcccpp.compiler.directories.IncludePaths>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers> <avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum> <avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings> <avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.warnings.Pedantic>True</avrgcccpp.compiler.warnings.Pedantic> <avrgcccpp.compiler.warnings.Pedantic>True</avrgcccpp.compiler.warnings.Pedantic>
<avrgcccpp.compiler.miscellaneous.OtherFlags>-Wextra -std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags> <avrgcccpp.compiler.miscellaneous.OtherFlags>-Wextra -std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags>
<avrgcccpp.linker.libraries.Libraries><ListValues><Value>libm</Value></ListValues></avrgcccpp.linker.libraries.Libraries> <avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths><ListValues><Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value></ListValues></avrgcccpp.assembler.general.IncludePaths> <ListValues>
<avrgcc.compiler.symbols.DefSymbols><ListValues><Value>NDEBUG</Value></ListValues></avrgcc.compiler.symbols.DefSymbols> <Value>libm</Value>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level> </ListValues>
<avrgcccpp.compiler.symbols.DefSymbols><ListValues><Value>NDEBUG</Value></ListValues></avrgcccpp.compiler.symbols.DefSymbols> </avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level> <avrgcccpp.assembler.general.IncludePaths>
</AvrGccCpp> <ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
</AvrGccCpp>
</ToolchainSettings> </ToolchainSettings>
<PreBuildEvent>echo "C:\avrdude-6.2\avrdude.exe" -v -p$(avrdevice) %%* -Uflash:w:"$(OutputDirectory)\$(Name).hex":i &gt; "$(MSBuildProjectDirectory)\avrdude.bat"</PreBuildEvent> <PreBuildEvent>echo "C:\avrdude-6.2\avrdude.exe" -v -p$(avrdevice) %%* -Uflash:w:"$(OutputDirectory)\$(Name).hex":i &gt; "$(MSBuildProjectDirectory)\avrdude.bat"</PreBuildEvent>
</PropertyGroup> </PropertyGroup>
@ -93,6 +118,7 @@
<ToolchainSettings> <ToolchainSettings>
<AvrGccCpp> <AvrGccCpp>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"</avrgcc.common.Device> <avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.optimization.RelaxBranches>True</avrgcc.common.optimization.RelaxBranches>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex> <avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss> <avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep> <avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
@ -100,28 +126,52 @@
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures> <avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned> <avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned> <avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcc.compiler.directories.IncludePaths><ListValues><Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value></ListValues></avrgcc.compiler.directories.IncludePaths> <avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\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.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum> <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.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned> <avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned> <avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.directories.IncludePaths><ListValues><Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value></ListValues></avrgcccpp.compiler.directories.IncludePaths> <avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.directories.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcccpp.compiler.directories.IncludePaths>
<avrgcccpp.compiler.optimization.level>Optimize (-O1)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers> <avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum> <avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.optimization.DebugLevel>Default (-g2)</avrgcccpp.compiler.optimization.DebugLevel>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings> <avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.compiler.warnings.Pedantic>True</avrgcccpp.compiler.warnings.Pedantic> <avrgcccpp.compiler.warnings.Pedantic>True</avrgcccpp.compiler.warnings.Pedantic>
<avrgcccpp.compiler.miscellaneous.OtherFlags>-Wextra -std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags> <avrgcccpp.compiler.miscellaneous.OtherFlags>-Wextra -std=c++11</avrgcccpp.compiler.miscellaneous.OtherFlags>
<avrgcccpp.linker.libraries.Libraries><ListValues><Value>libm</Value></ListValues></avrgcccpp.linker.libraries.Libraries> <avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths><ListValues><Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value></ListValues></avrgcccpp.assembler.general.IncludePaths> <ListValues>
<avrgcc.compiler.symbols.DefSymbols><ListValues><Value>DEBUG</Value></ListValues></avrgcc.compiler.symbols.DefSymbols> <Value>libm</Value>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level> </ListValues>
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel> </avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.compiler.symbols.DefSymbols><ListValues><Value>DEBUG</Value></ListValues></avrgcccpp.compiler.symbols.DefSymbols> <avrgcccpp.assembler.general.IncludePaths>
<avrgcccpp.compiler.optimization.level>Optimize (-O1)</avrgcccpp.compiler.optimization.level> <ListValues>
<avrgcccpp.compiler.optimization.DebugLevel>Default (-g2)</avrgcccpp.compiler.optimization.DebugLevel> <Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.106\include</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel> <avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
</AvrGccCpp> </AvrGccCpp>
</ToolchainSettings> </ToolchainSettings>
<PreBuildEvent>echo "C:\avrdude-6.2\avrdude.exe" -v -p$(avrdevice) %%* -Uflash:w:"$(OutputDirectory)\$(Name).hex":i &gt; "$(MSBuildProjectDirectory)\avrdude.bat"</PreBuildEvent> <PreBuildEvent>echo "C:\avrdude-6.2\avrdude.exe" -v -p$(avrdevice) %%* -Uflash:w:"$(OutputDirectory)\$(Name).hex":i &gt; "$(MSBuildProjectDirectory)\avrdude.bat"</PreBuildEvent>
</PropertyGroup> </PropertyGroup>

View File

@ -26,6 +26,37 @@
#define SECOND_USART #define SECOND_USART
#endif #endif
#ifdef USART_SHAREDIO
#define RXEN_D RXEN
#define TXEN_D TXEN
#define UCSZ0_D UCSZ0
#define UCSZ1_D UCSZ1
#define UCSZ2_D UCSZ2
#define UPM0_D UPM0
#define UPM1_D UPM1
#define USBS_D USBS
#define RXC_D RXC
#define UDRE_D UDRE
#else
#define RXEN_D RXEN0
#define TXEN_D TXEN0
#define UCSZ0_D UCSZ00
#define UCSZ1_D UCSZ01
#define UCSZ2_D UCSZ02
#define UPM0_D UPM00
#define UPM1_D UPM01
#define USBS_D USBS0
#define RXC_D RXC0
#define UDRE_D UDRE0
#endif
#ifdef USART_SPI
#define UMSEL0_D UMSEL00
#define UMSEL1_D UMSEL01
#else
#define UMSEL_D UMSEL
#endif
class USART0 class USART0
{ {
public: public:
@ -59,24 +90,6 @@ protected:
volatile uint8_t *m_vui8pUBRRL; volatile uint8_t *m_vui8pUBRRL;
volatile uint8_t *m_vui8pUDR; volatile uint8_t *m_vui8pUDR;
uint8_t m_ui8RXEN;
uint8_t m_ui8TXEN;
uint8_t m_ui8UCSZ0;
uint8_t m_ui8UCSZ1;
uint8_t m_ui8UCSZ2;
uint8_t m_ui8UPM0;
uint8_t m_ui8UPM1;
uint8_t m_ui8USBS;
uint8_t m_ui8RXC;
uint8_t m_ui8UDRE;
#ifdef USART_SPI
uint8_t m_ui8UMSEL0;
uint8_t m_ui8UMSEL1;
#else
uint8_t m_ui8UMSEL;
#endif
private: private:
uint8_t readUCSRC(); uint8_t readUCSRC();
void setUCSRC( uint8_t ui8UCSRC ); void setUCSRC( uint8_t ui8UCSRC );

View File

@ -28,6 +28,9 @@ int main()
cUSART << "sizeof( float ) = " << sizeof( float ) << "\r\n"; cUSART << "sizeof( float ) = " << sizeof( float ) << "\r\n";
cUSART << "sizeof( double ) = " << sizeof( double ) << "\r\n"; cUSART << "sizeof( double ) = " << sizeof( double ) << "\r\n";
cUSART << "sizeof( long double ) = " << sizeof( long double ) << "\r\n\r\n"; cUSART << "sizeof( long double ) = " << sizeof( long double ) << "\r\n\r\n";
cUSART << "sizeof( void* ) = " << sizeof( void* ) << "\r\n";
cUSART << "sizeof( unsigned char* ) = " << sizeof( unsigned char* ) << "\r\n";
cUSART << "sizeof( unsigned int* ) = " << sizeof( unsigned int* ) << "\r\n\r\n";
while( true ) while( true )
{ {