Changed example to use rx as well
This commit is contained in:
parent
e891e1019f
commit
408ab83afb
@ -13,9 +13,17 @@
|
|||||||
void newUartUsage()
|
void newUartUsage()
|
||||||
{
|
{
|
||||||
using namespace uart;
|
using namespace uart;
|
||||||
Uart1<> serial1;
|
Uart<Hardware1<Mode::ASYNCHRONOUS, Config<>, Driven::INTERRUPT>> serial1;
|
||||||
|
sei();
|
||||||
|
|
||||||
serial1 << "Hello World from RAM. " << F("Hello World from flash\r\n");
|
serial1 << F("Hello World from RAM. ") << F("Hello World from flash\r\n");
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
uint8_t received = 0;
|
||||||
|
|
||||||
|
if (serial1.rxByte(received))
|
||||||
|
serial1.txByte(received);
|
||||||
|
}
|
||||||
|
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
}
|
}
|
||||||
@ -25,7 +33,7 @@ void newUartUsage2()
|
|||||||
using namespace uart;
|
using namespace uart;
|
||||||
|
|
||||||
using config = Config<9600, DataBits::EIGHT, Parity::NONE, StopBits::ONE>;
|
using config = Config<9600, DataBits::EIGHT, Parity::NONE, StopBits::ONE>;
|
||||||
using uart0 = Hardware0<Mode::ASYNCHRONOUS, config, Driven::INTERRUPT>;
|
using uart0 = Hardware0<Mode::ASYNCHRONOUS, config, Driven::BLOCKING>;
|
||||||
using softuart = Software<io::P::B1, io::P::B2, config>;
|
using softuart = Software<io::P::B1, io::P::B2, config>;
|
||||||
|
|
||||||
Uart<uart0> serial;
|
Uart<uart0> serial;
|
||||||
@ -47,7 +55,7 @@ void oldUsartUsage()
|
|||||||
|
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
namespace spi {
|
namespace spi {
|
||||||
|
|
||||||
enum class Cpol {
|
enum class Cpol {
|
||||||
@ -122,7 +130,7 @@ void spiTest()
|
|||||||
|
|
||||||
spi::spi<uartspi> uartSpi;
|
spi::spi<uartspi> uartSpi;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
static inline void initUart(const uint32_t baudRate)
|
static inline void initUart(const uint32_t baudRate)
|
||||||
{
|
{
|
||||||
UBRR0 = static_cast<uint16_t>((F_CPU / (16 * baudRate)) - 1);
|
UBRR0 = static_cast<uint16_t>((F_CPU / (16 * baudRate)) - 1);
|
||||||
@ -170,11 +178,11 @@ void cUartLibTest()
|
|||||||
auto ramString = "Hello World from RAM. ";
|
auto ramString = "Hello World from RAM. ";
|
||||||
auto flashString = F("Hello World from flash\r\n");
|
auto flashString = F("Hello World from flash\r\n");
|
||||||
|
|
||||||
uart_init(UART_BAUD_SELECT(9600, F_CPU));
|
uart1_init(UART_BAUD_SELECT(9600, F_CPU));
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
uart_puts(ramString);
|
uart1_puts(ramString);
|
||||||
uart_puts_p(reinterpret_cast<const char *>(flashString));
|
uart1_puts_p(reinterpret_cast<const char *>(flashString));
|
||||||
|
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 92c96bbc72e8784f10d38e85073c5bd010ab877e
|
Subproject commit 0bfd303a26a8aad77607e9cefb1039997952af09
|
@ -95,21 +95,33 @@
|
|||||||
<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.symbols.DefSymbols>
|
||||||
|
<ListValues>
|
||||||
|
<Value>NDEBUG</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcc.compiler.symbols.DefSymbols>
|
||||||
<avrgcc.compiler.directories.IncludePaths>
|
<avrgcc.compiler.directories.IncludePaths>
|
||||||
<ListValues>
|
<ListValues>
|
||||||
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include</Value>
|
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include</Value>
|
||||||
</ListValues>
|
</ListValues>
|
||||||
</avrgcc.compiler.directories.IncludePaths>
|
</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.symbols.DefSymbols>
|
||||||
|
<ListValues>
|
||||||
|
<Value>NDEBUG</Value>
|
||||||
|
</ListValues>
|
||||||
|
</avrgcccpp.compiler.symbols.DefSymbols>
|
||||||
<avrgcccpp.compiler.directories.IncludePaths>
|
<avrgcccpp.compiler.directories.IncludePaths>
|
||||||
<ListValues>
|
<ListValues>
|
||||||
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include</Value>
|
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include</Value>
|
||||||
</ListValues>
|
</ListValues>
|
||||||
</avrgcccpp.compiler.directories.IncludePaths>
|
</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>
|
||||||
@ -125,18 +137,6 @@
|
|||||||
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include</Value>
|
<Value>%24(PackRepoDir)\Atmel\ATmega_DFP\1.3.300\include</Value>
|
||||||
</ListValues>
|
</ListValues>
|
||||||
</avrgcccpp.assembler.general.IncludePaths>
|
</avrgcccpp.assembler.general.IncludePaths>
|
||||||
<avrgcc.compiler.symbols.DefSymbols>
|
|
||||||
<ListValues>
|
|
||||||
<Value>NDEBUG</Value>
|
|
||||||
</ListValues>
|
|
||||||
</avrgcc.compiler.symbols.DefSymbols>
|
|
||||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
|
||||||
<avrgcccpp.compiler.symbols.DefSymbols>
|
|
||||||
<ListValues>
|
|
||||||
<Value>NDEBUG</Value>
|
|
||||||
</ListValues>
|
|
||||||
</avrgcccpp.compiler.symbols.DefSymbols>
|
|
||||||
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
|
|
||||||
</AvrGccCpp>
|
</AvrGccCpp>
|
||||||
</ToolchainSettings>
|
</ToolchainSettings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user