Commit bebfc2eb authored by Alexander Detsch's avatar Alexander Detsch

Refactoring

parent 941323e2
......@@ -61,108 +61,110 @@
</com_atmel_avrdbg_tool_avrdragon>
<avrtoolinterface>ISP</avrtoolinterface>
<avrtoolinterfaceclock>125000</avrtoolinterfaceclock>
<ResetRule>0</ResetRule>
<EraseKey />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
<AvrGccCpp>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.OtherFlags>-fdata-sections</avrgcc.compiler.optimization.OtherFlags>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avrgcc.compiler.miscellaneous.OtherFlags>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\include</Value>
<Value>../common/applications/user_application/user_board/config</Value>
<Value>../src/config</Value>
<Value>../src</Value>
<Value>../src/ASF/common/boards/user_board</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
</AvrGccCpp>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.OtherFlags>-fdata-sections</avrgcc.compiler.optimization.OtherFlags>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avrgcc.compiler.miscellaneous.OtherFlags>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>NDEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.optimization.level>Optimize for size (-Os)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcccpp.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcccpp.compiler.warnings.AllWarnings>True</avrgcccpp.compiler.warnings.AllWarnings>
<avrgcccpp.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\include</Value>
<Value>../common/applications/user_application/user_board/config</Value>
<Value>../src/config</Value>
<Value>../src</Value>
<Value>../src/ASF/common/boards/user_board</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
</AvrGccCpp>
</ToolchainSettings>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<ToolchainSettings>
<AvrGccCpp>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.OtherFlags>-fdata-sections</avrgcc.compiler.optimization.OtherFlags>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Maximum (-g3)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avrgcc.compiler.miscellaneous.OtherFlags>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.optimization.level>Optimize (-O1)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<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.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\include</Value>
<Value>../common/applications/user_application/user_board/config</Value>
<Value>../src/config</Value>
<Value>../src</Value>
<Value>../src/ASF/common/boards/user_board</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
</AvrGccCpp>
<avrgcc.common.Device>-mmcu=atmega328p -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\gcc\dev\atmega328p"</avrgcc.common.Device>
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
<avrgcc.common.outputfiles.usersignatures>False</avrgcc.common.outputfiles.usersignatures>
<avrgcc.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcc.compiler.symbols.DefSymbols>
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
<avrgcc.compiler.optimization.OtherFlags>-fdata-sections</avrgcc.compiler.optimization.OtherFlags>
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
<avrgcc.compiler.optimization.DebugLevel>Maximum (-g3)</avrgcc.compiler.optimization.DebugLevel>
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
<avrgcc.compiler.miscellaneous.OtherFlags>-std=gnu99 -fno-strict-aliasing -Wstrict-prototypes -Wmissing-prototypes -Werror-implicit-function-declaration -Wpointer-arith -mrelax</avrgcc.compiler.miscellaneous.OtherFlags>
<avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>
<avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcccpp.compiler.general.ChangeDefaultBitFieldUnsigned>
<avrgcccpp.compiler.symbols.DefSymbols>
<ListValues>
<Value>DEBUG</Value>
<Value>F_CPU=8000000UL</Value>
</ListValues>
</avrgcccpp.compiler.symbols.DefSymbols>
<avrgcccpp.compiler.optimization.level>Optimize (-O1)</avrgcccpp.compiler.optimization.level>
<avrgcccpp.compiler.optimization.PackStructureMembers>True</avrgcccpp.compiler.optimization.PackStructureMembers>
<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.linker.libraries.Libraries>
<ListValues>
<Value>libm</Value>
</ListValues>
</avrgcccpp.linker.libraries.Libraries>
<avrgcccpp.assembler.general.IncludePaths>
<ListValues>
<Value>%24(PackRepoDir)\atmel\ATmega_DFP\1.0.98\include</Value>
<Value>../common/applications/user_application/user_board/config</Value>
<Value>../src/config</Value>
<Value>../src</Value>
<Value>../src/ASF/common/boards/user_board</Value>
</ListValues>
</avrgcccpp.assembler.general.IncludePaths>
<avrgcccpp.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcccpp.assembler.debugging.DebugLevel>
</AvrGccCpp>
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
......
/*
* CLOCK.cpp
* Clock.cpp
*
* Created: 11.04.2016 17:48:30
* Author: alex
*/
#include "CLOCK.h"
#include "Clock.h"
// default constructor
CLOCK::CLOCK()
Clock::Clock()
{
} //CLOCK
} //Clock
void CLOCK::update() {
void Clock::update() {
ds1307.obtainTime();
shiftTime(ds1307.getHour(false), ds1307.getMinute(false), ds1307.getSecond(false));
}
void CLOCK::shiftTime(uint8_t hour, uint8_t minute, uint8_t second) {
void Clock::shiftTime(uint8_t hour, uint8_t minute, uint8_t second) {
shiftr.shift(hour);
shiftr.shift(minute);
shiftr.shift(second, true);
}
void CLOCK::setTime(uint8_t day, uint8_t month, uint8_t year, uint8_t hour, uint8_t minute, uint8_t second) {
void Clock::setTime(uint8_t day, uint8_t month, uint8_t year, uint8_t hour, uint8_t minute, uint8_t second) {
ds1307.setTime(day, month, year, hour, minute, second);
}
// default destructor
CLOCK::~CLOCK()
Clock::~Clock()
{
} //~CLOCK
} //~Clock
/*
* CLOCK.h
* Clock.h
*
* Created: 11.04.2016 17:48:30
* Author: alex
......@@ -10,29 +10,29 @@
#define __CLOCK_H__
#include "DS1307.h"
#include "SHIFTREGISTER.h"
#include "Shiftregister.h"
class CLOCK
class Clock
{
//variables
public:
protected:
private:
DS1307 ds1307;
SHIFTREGISTER shiftr;
Shiftregister shiftr;
//functions
public:
CLOCK();
~CLOCK();
Clock();
~Clock();
void update();
void setTime(uint8_t day, uint8_t month, uint8_t year, uint8_t hour, uint8_t minute, uint8_t second);
protected:
private:
CLOCK( const CLOCK &c );
CLOCK& operator=( const CLOCK &c );
Clock( const Clock &c );
Clock& operator=( const Clock &c );
void shiftTime(uint8_t hour, uint8_t minute, uint8_t second);
}; //CLOCK
}; //Clock
#endif //__CLOCK_H__
/*
* SHIFTREGISTER.cpp
* Shiftregister.cpp
*
* Created: 03.04.2016 11:07:20
* Author: alex
*/
#include "SHIFTREGISTER.h"
#include "Shiftregister.h"
// default constructor
SHIFTREGISTER::SHIFTREGISTER()
{
Shiftregister::Shiftregister() {
SHIFT_DDR |= ( (1<<SHIFT_SCK) | (1<<SHIFT_RCK) | (1<<SHIFT_DATA) ); // Make that pins output
} //SHIFTREGISTER
} //Shiftregister
// Sends one C-clock-wide high pulse on SCK-clock-line (Shift-clock)
// --> next bit can be shifted in
void SHIFTREGISTER::pulse() {
void Shiftregister::pulse() {
SHIFT_PORT |= (1<<SHIFT_SCK);
SHIFT_PORT &= (~(1<<SHIFT_SCK));
}
// Sends one C-clock-wide high pulse on RCK-clock-line (Latch-clock)
// --> all shifted bits are applied for the output
void SHIFTREGISTER::latch() {
void Shiftregister::latch() {
SHIFT_PORT |= (1<<SHIFT_RCK);
SHIFT_PORT &= (~(1<<SHIFT_RCK));
}
// shift the data MSB-first
void SHIFTREGISTER::shift(uint8_t data, bool _latch) {
void Shiftregister::shift(uint8_t data, bool _latch) {
for (uint8_t i = 0; i < 8; i++) {
if (data & 0x80) SHIFT_DataHigh(); //check whether or not the MSB is set
else SHIFT_DataLow();
......@@ -42,6 +41,6 @@ void SHIFTREGISTER::shift(uint8_t data, bool _latch) {
}
// default destructor
SHIFTREGISTER::~SHIFTREGISTER()
Shiftregister::~Shiftregister()
{
} //~SHIFTREGISTER
\ No newline at end of file
} //~Shiftregister
\ No newline at end of file
/*
* SHIFTREGISTER.h
* Shiftregister.h
*
* Created: 03.04.2016 11:07:20
* Author: alex
......@@ -13,33 +13,32 @@
// Defines
#define SHIFT_PORT PORTD
#define SHIFT_DDR DDRD
#define SHIFT_DATA PD5 //Data pin (DS) pin location
#define SHIFT_SCK PD6 //Shift Clock (SH_CP) pin location
#define SHIFT_RCK PD7 //Store Clock (ST_CP) pin location
#define SHIFT_DATA PD5 // Data pin (DS) pin location
#define SHIFT_SCK PD6 // Shift Clock (SH_CP) pin location
#define SHIFT_RCK PD7 // Store Clock (ST_CP) pin location
// change data lines
#define SHIFT_DataHigh() (SHIFT_PORT |= (1<<SHIFT_DATA))
#define SHIFT_DataLow() (SHIFT_PORT &= (~(1<<SHIFT_DATA)))
class SHIFTREGISTER
{
//variables
class Shiftregister {
// variables
public:
protected:
private:
//functions
// functions
public:
SHIFTREGISTER();
~SHIFTREGISTER();
Shiftregister();
~Shiftregister();
void shift(uint8_t data, bool _latch = false);
protected:
private:
SHIFTREGISTER( const SHIFTREGISTER &c );
SHIFTREGISTER& operator=( const SHIFTREGISTER &c );
Shiftregister( const Shiftregister &c );
Shiftregister& operator=( const Shiftregister &c );
void pulse();
void latch();
}; //SHIFTREGISTER
}; //Shiftregister
#endif //__SHIFTREGISTER_H__
/*
* UART.cpp
*
* Created: 22.01.2015 22:40:20
* Author: Alexander
*/
/** \file Uart.cpp
* Implementation of the UART
* Abstraction Layer of the Hardware
*
* \date 22.01.2015 22:40:20
* \author Alexander Detsch
* \version 1.5
*/
#include "UART.h"
// DO NOT CHANGE DIRECTLY!
volatile bool uartStrComplete = 0; // 1 .. completely received string
volatile uint8_t uartStrCount = 0;
volatile char uartString[UART_MAXSTRLEN + 1] = "";
#include "Uart.h"
// default constructor
UART::UART(uint16_t baudrate)
{
UBRR0L = F_CPU / baudrate / 16 - 1; // calculation of the init-value from system clock and baudrate
UCSR0B |= (1 << TXEN0) | (1 << RXEN0) | (1 << RXCIE0); // Enable TX, RX, RX-Interrupt
UCSR0C |= (1 << UCSZ00) | (1 << UCSZ01); // Set frame format to 8N1
char Uart::receivedUartString[UART_MAXSTRLEN + 1] = {};
volatile bool Uart::uartStrComplete = false;
volatile uint8_t Uart::uartStrCount = 0;
volatile uint8_t Uart::uartString[UART_MAXSTRLEN + 1] = {};
Uart::Uart() {
} //Uart
// default destructor
Uart::~Uart() {
} //~Uart
void Uart::begin(uint32_t baudrate, uint8_t config) {
cli();
// set baudrate and asynchronous double speed
uint16_t baud = (F_CPU / 4 / baudrate - 1) / 2;
UBRR0H = baud >> 8;
UBRR0L = baud;
UCSR0A |= (1 << U2X0);
/*
// set baudrate and asynchronous normal speed
uint16_t baud = (F_CPU / 8 / baudrate - 1) / 2;
UBRR0H = baud >> 8;
UBRR0L = baud;
*/
UCSR0B |= (1 << TXEN0) | (1 << RXEN0) | (1 << RXCIE0); // Enable TX, RX, RX-Interrupt
UCSR0C = config; // set mode of the UART such as 8N1, 8N2, ...
receivedUartString[0] = 0;
// Flush Receive-Buffer (entfernen evtl. vorhandener ungültiger Werte)
do {
UDR0;
} while (UCSR0A & (1 << RXC0));
sei();
} //UART
}
void Uart::begin(uint32_t baudrate) {
begin(baudrate, SERIAL_8N1); // use 8N1 as standard
}
/**
Send a single char directly over the UART
Wait until the transmit buffer is empty and then send the byte.
@param data byte that should be transmitted
@ingroup physTransmit
*/
void Uart::putChar(char data) {
while(!(UCSR0A & (1 << UDRE0))); // wait until UDR empty USR = UCSRA
UDR0 = data; // send
}
/**
Send a single byte directly over the UART
Wait until the transmit buffer is empty and then send the byte.
UART::UART() {}
@param data byte that should be transmitted
@ingroup physTransmit
*/
void Uart::putByte(uint8_t data) {
while(!(UCSR0A & (1 << UDRE0))); // wait until UDR empty USR = UCSRA
UDR0 = data; // send
}
void UART::putChar(char data)
{
/**
Empty the receive buffer, reset the data to null
@ingroup transmit
*/
void Uart::empty() {
uartStrCount = 0;
uartStrComplete = false;
for (uint8_t i = 0; i < UART_MAXSTRLEN; i++) {
receivedUartString[i] = 0;
uartString[i] = 0;
}
}
/**
Empty the transmit buffer
Wait until the transmit buffer is empty and then returns.
@ingroup physTransmit
*/
void Uart::flush() {
while(!(UCSR0A & (1 << UDRE0))); // wait until UDR empty USR = UCSRA
UDR0 = data; // send
}
}
/**
Send a bunch of chars over the UART.
Sends all passed chars in the array one after another
void UART::printChar(char const buffer[])
{
@param buffer char array that should be transmitted
@ingroup transmit
*/
void Uart::printChar(char const buffer[]) {
for(uint8_t i = 0; buffer[i] != 0; i++)
putChar(buffer[i]);
putChar(buffer[i]);
}
void UART::print(char const *szFormat, ...)
{
char floatArray[50];
/**
Send a formatted string over the UART
All format options for printf can be used.
@param string String that should be send
@param formatOptions all format options known from standard-printf
@ingroup transmit
*/
void Uart::print(char const *szFormat, ...) {
char data[UART_MAX_SEND_LENGTH];
va_list pArgs;
va_start(pArgs, szFormat);
vsnprintf(floatArray, sizeof(floatArray)-1, szFormat, pArgs);
vsnprintf(data, sizeof(data)-1, szFormat, pArgs);
va_end(pArgs);
printChar(floatArray);
printChar(data);
}
// just a f..ing bunch of wrappers. Nothing special.
void UART::print(float number) {
/**
@name Print Numbers in different flavours.
No CR at the end of the transmission.
@param number number that should be formatted and transmitted.
@ingroup print
*/
//@{
///Print float
void Uart::print(float number) {
print("%f", (double)number);
}
void UART::print(double number) {
/**
@brief Print double
@param number number that should be formatted and transmitted.
*/
void Uart::print(double number) {
print("%f", number);
}
void UART::print(uint32_t number) {
/**
@brief Print 32-bit unsigned Integer
@param number number that should be formatted and transmitted.
*/
void Uart::