Adapted to new interface
This commit is contained in:
parent
2d54e4ea45
commit
9b4b0cac67
@ -6,14 +6,13 @@
|
|||||||
|
|
||||||
#include "flash/flash.hpp"
|
#include "flash/flash.hpp"
|
||||||
#include "io/io.hpp"
|
#include "io/io.hpp"
|
||||||
#include "uart/uart.h"
|
|
||||||
#include "uart/uart.hpp"
|
#include "uart/uart.hpp"
|
||||||
#include "uart/usart.h"
|
|
||||||
|
|
||||||
void newUartUsage()
|
void newUartUsage()
|
||||||
{
|
{
|
||||||
using namespace uart;
|
using namespace uart;
|
||||||
Uart<Hardware1<Mode::ASYNCHRONOUS, Config<>, Driven::INTERRUPT>> serial1;
|
Uart<Hardware1<Mode::ASYNCHRONOUS, Config<>, Driven::INTERRUPT>> serial1;
|
||||||
|
serial1.init();
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
serial1 << F("Hello World from RAM. ") << F("Hello World from flash\r\n");
|
serial1 << F("Hello World from RAM. ") << F("Hello World from flash\r\n");
|
||||||
@ -21,7 +20,7 @@ void newUartUsage()
|
|||||||
while (true) {
|
while (true) {
|
||||||
uint8_t received = 0;
|
uint8_t received = 0;
|
||||||
|
|
||||||
while (!serial1.peek(received))
|
while (!serial1.peek())
|
||||||
;
|
;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -46,27 +45,15 @@ void newUartUsage2()
|
|||||||
|
|
||||||
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::BLOCKING>;
|
using uart0 = Hardware0<Mode::ASYNCHRONOUS, config, Driven::BLOCKING>;
|
||||||
using softuart = Software<io::P::B1, io::P::B2, config>;
|
|
||||||
|
|
||||||
Uart<uart0> serial;
|
Uart<uart0> serial;
|
||||||
Uart<softuart> softSerial;
|
serial.init();
|
||||||
|
|
||||||
serial << "Hello World from RAM. " << F("Hello World from flash\r\n");
|
serial << "Hello World from RAM. " << F("Hello World from flash\r\n");
|
||||||
// softSerial << "Hello World using finalized software interface!" << F("\r\nAlso greetz from progmem\r\n");
|
|
||||||
|
|
||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void oldUsartUsage()
|
|
||||||
{
|
|
||||||
USART0 &serial = USART0::inst();
|
|
||||||
serial.init(9600);
|
|
||||||
|
|
||||||
serial << "Hello World from RAM. "
|
|
||||||
<< "Hello World from flash\r\n";
|
|
||||||
|
|
||||||
_delay_ms(1000);
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
namespace spi {
|
namespace spi {
|
||||||
|
|
||||||
@ -145,17 +132,17 @@ void spiTest()
|
|||||||
*/
|
*/
|
||||||
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);
|
UBRR1 = static_cast<uint16_t>((F_CPU / (16 * baudRate)) - 1);
|
||||||
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
|
UCSR1C = (1 << UCSZ11) | (1 << UCSZ10);
|
||||||
UCSR0B = (1 << RXEN0) | (1 << TXEN0);
|
UCSR1B = (1 << RXEN1) | (1 << TXEN1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void txUart(uint8_t byte)
|
static inline void txUart(uint8_t byte)
|
||||||
{
|
{
|
||||||
while (!(UCSR0A & (1 << UDRE0)))
|
while (!(UCSR1A & (1 << UDRE1)))
|
||||||
;
|
;
|
||||||
|
|
||||||
UDR0 = byte;
|
UDR1 = byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void txString(const char *str)
|
static inline void txString(const char *str)
|
||||||
@ -185,26 +172,10 @@ void optimalUartTest()
|
|||||||
_delay_ms(1000);
|
_delay_ms(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cUartLibTest()
|
|
||||||
{
|
|
||||||
auto ramString = "Hello World from RAM. ";
|
|
||||||
auto flashString = F("Hello World from flash\r\n");
|
|
||||||
|
|
||||||
uart1_init(UART_BAUD_SELECT(9600, F_CPU));
|
|
||||||
sei();
|
|
||||||
|
|
||||||
uart1_puts(ramString);
|
|
||||||
uart1_puts_p(reinterpret_cast<const char *>(flashString));
|
|
||||||
|
|
||||||
_delay_ms(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
newUartUsage();
|
newUartUsage();
|
||||||
// oldUsartUsage();
|
|
||||||
// optimalUartTest();
|
// optimalUartTest();
|
||||||
// cUartLibTest();
|
|
||||||
|
|
||||||
// spiTest();
|
// spiTest();
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 925bb56f9895ff46a81209fe5f0f6b59f6c809f9
|
Subproject commit fe9e67036e4acfb539499d0fa31afbc9ef99315d
|
@ -42,8 +42,8 @@
|
|||||||
<ToolNumber>070000004699</ToolNumber>
|
<ToolNumber>070000004699</ToolNumber>
|
||||||
<ToolName>JTAGICE mkII</ToolName>
|
<ToolName>JTAGICE mkII</ToolName>
|
||||||
</com_atmel_avrdbg_tool_jtagicemkii>
|
</com_atmel_avrdbg_tool_jtagicemkii>
|
||||||
<avrtoolinterface>ISP</avrtoolinterface>
|
<avrtoolinterface>JTAG</avrtoolinterface>
|
||||||
<avrtoolinterfaceclock>125000</avrtoolinterfaceclock>
|
<avrtoolinterfaceclock>5000000</avrtoolinterfaceclock>
|
||||||
<AAFDebugger>
|
<AAFDebugger>
|
||||||
<AAFDebugFiles>
|
<AAFDebugFiles>
|
||||||
<DebugFile>
|
<DebugFile>
|
||||||
@ -75,8 +75,9 @@
|
|||||||
<ToolOptions>
|
<ToolOptions>
|
||||||
<InterfaceProperties>
|
<InterfaceProperties>
|
||||||
<IspClock>125000</IspClock>
|
<IspClock>125000</IspClock>
|
||||||
|
<JtagDbgClock>5000000</JtagDbgClock>
|
||||||
</InterfaceProperties>
|
</InterfaceProperties>
|
||||||
<InterfaceName>ISP</InterfaceName>
|
<InterfaceName>JTAG</InterfaceName>
|
||||||
</ToolOptions>
|
</ToolOptions>
|
||||||
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
|
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
|
||||||
<ToolNumber>J41800099437</ToolNumber>
|
<ToolNumber>J41800099437</ToolNumber>
|
||||||
@ -213,34 +214,31 @@
|
|||||||
<Compile Include="main.cpp">
|
<Compile Include="main.cpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<None Include="uart\usart.cpp">
|
<Compile Include="uart\config.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</None>
|
</Compile>
|
||||||
<Compile Include="uart\hardware.hpp">
|
<Compile Include="uart\hardware.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="uart\hardware0.cpp">
|
||||||
|
<SubType>compile</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="uart\hardware0.hpp">
|
<Compile Include="uart\hardware0.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="uart\hardware1.hpp">
|
<Compile Include="uart\hardware1.cpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="uart\config.hpp">
|
<Compile Include="uart\hardware1.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="uart\software.hpp">
|
<Compile Include="uart\software.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<None Include="uart\uart.cpp">
|
|
||||||
<SubType>compile</SubType>
|
|
||||||
</None>
|
|
||||||
<Compile Include="uart\uart.h">
|
|
||||||
<SubType>compile</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="uart\uart.hpp">
|
<Compile Include="uart\uart.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="uart\usart.h">
|
<Compile Include="uart\utils.hpp">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user