108 lines
2.9 KiB
C++
108 lines
2.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 = USART0::inst();
|
|
cUSART.init();
|
|
|
|
uint32_t ui32Counter = 0;
|
|
|
|
constexpr size_t sizeBUFFER_SIZE = 64;
|
|
char szBuffer[sizeBUFFER_SIZE];
|
|
|
|
cUSART.transmitString( "\r\nSizes: \r\n" );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( char ) );
|
|
cUSART.transmitString( "sizeof( char ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( unsigned char ) );
|
|
cUSART.transmitString( "sizeof( unsigned char ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( short int ) );
|
|
cUSART.transmitString( "sizeof( short int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( unsigned short int ) );
|
|
cUSART.transmitString( "sizeof( unsigned short int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( int ) );
|
|
cUSART.transmitString( "sizeof( int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( unsigned int ) );
|
|
cUSART.transmitString( "sizeof( unsigned int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( long int ) );
|
|
cUSART.transmitString( "sizeof( long int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( unsigned long int ) );
|
|
cUSART.transmitString( "sizeof( unsigned long int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( long long int ) );
|
|
cUSART.transmitString( "sizeof( long long int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( unsigned long long int ) );
|
|
cUSART.transmitString( "sizeof( unsigned long long int ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( float ) );
|
|
cUSART.transmitString( "sizeof( float ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( double ) );
|
|
cUSART.transmitString( "sizeof( double ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n", sizeof( long double ) );
|
|
cUSART.transmitString( "sizeof( long double ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
sprintf( szBuffer, "%d\r\n\r\n", sizeof( void* ) );
|
|
cUSART.transmitString( "sizeof( void* ) = " );
|
|
cUSART.transmitString( szBuffer );
|
|
|
|
while( true )
|
|
{
|
|
sprintf( szBuffer, "%lu", ui32Counter++ );
|
|
cUSART.transmitString( "This has been running for \"" );
|
|
cUSART.transmitString( szBuffer );
|
|
cUSART.transmitString( "\" seconds!\r\n" );
|
|
|
|
if( !cUSART.receiveLine( szBuffer, sizeBUFFER_SIZE, "\r" ) )
|
|
{
|
|
cUSART.transmitString( "Receive error: " );
|
|
}
|
|
else
|
|
{
|
|
cUSART.transmitString( "Echo: " );
|
|
}
|
|
|
|
cUSART.transmitString( szBuffer );
|
|
cUSART.transmitString( "\r\n" );
|
|
|
|
uint8_t ui8Byte;
|
|
|
|
if( cUSART.receiveByte( ui8Byte, 1000 ) )
|
|
{
|
|
cUSART.transmitByte( ui8Byte );
|
|
cUSART.transmitString( "\r\n" );
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
} |