uart/usart/main.cpp

62 lines
1.9 KiB
C++

/*
* Copyright (c) by BlackMark 2015-2016
* Date 05/01/2016
* Version 1.4
*/
#include <stdio.h>
#include "clock.h"
#include "usart.h"
int main()
{
USART0 cUSART;
cUSART.init();
uint32_t ui32Counter = 0;
cUSART << "\r\nSizes: \r\n";
cUSART << "sizeof( char ) = " << sizeof( char ) << "\r\n";
cUSART << "sizeof( unsigned char ) = " << sizeof( unsigned char ) << "\r\n";
cUSART << "sizeof( short int ) = " << sizeof( short int ) << "\r\n";
cUSART << "sizeof( unsigned short int ) = " << sizeof( unsigned short int ) << "\r\n";
cUSART << "sizeof( int ) = " << sizeof( int ) << "\r\n";
cUSART << "sizeof( unsigned int ) = " << sizeof( unsigned int ) << "\r\n";
cUSART << "sizeof( long int ) = " << sizeof( long int ) << "\r\n";
cUSART << "sizeof( unsigned long int ) = " << sizeof( unsigned long int ) << "\r\n";
cUSART << "sizeof( long long int ) = " << sizeof( long long int ) << "\r\n";
cUSART << "sizeof( unsigned long long int ) = " << sizeof( unsigned long long int ) << "\r\n";
cUSART << "sizeof( float ) = " << sizeof( float ) << "\r\n";
cUSART << "sizeof( double ) = " << sizeof( double ) << "\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 )
{
cUSART << "This has been running for \"" << ui32Counter++ << "\" seconds!\r\n\r\n";
cUSART << "Please enter a number: ";
int iNumber;
cUSART >> iNumber;
cUSART << "\r\nYou entered: " << iNumber << "\r\n\r\n";
cUSART << "Please enter a decimal number: ";
double dNumber;
cUSART >> dNumber;
cUSART << "\r\nYou entered: " << dNumber << "\r\n\r\n";
unsigned char uchByte;
cUSART.receiveByte( uchByte, 1000 );
_delay_ms( 1000 );
}
return 0;
}