Initial commit of files
This commit is contained in:
88
src/libPIC/ser_putn.c
Normal file
88
src/libPIC/ser_putn.c
Normal file
@ -0,0 +1,88 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (C) 2008
|
||||
* ProbeStar Telematics, LLC
|
||||
* All Rights Reserved. Proprietary and Confidential.
|
||||
*============================================================================
|
||||
* Serial Number Output
|
||||
*----------------------------------------------------------------------------
|
||||
* Details
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* includes
|
||||
*****************************************************************************/
|
||||
|
||||
#include "serial.h"
|
||||
#include "types.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* defines
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* structs & typedefs
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* global constants
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* global variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* static constants
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* static variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* static prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* C functions
|
||||
*****************************************************************************/
|
||||
|
||||
// warning, only does 8 digits
|
||||
void putun( DWORD l )
|
||||
{
|
||||
BYTE i = 0;
|
||||
DWORD o = 0;
|
||||
|
||||
while ( l )
|
||||
{
|
||||
o <<= 4;
|
||||
o |= ( l % 10 );
|
||||
l /= 10;
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( i == 0 )
|
||||
i++;
|
||||
|
||||
while ( i-- )
|
||||
{
|
||||
putch( (o & 0xf) + '0' );
|
||||
o >>= 4;
|
||||
}
|
||||
|
||||
putch( ' ' );
|
||||
}
|
||||
|
||||
void putn( long n )
|
||||
{
|
||||
if ( n < 0 )
|
||||
{
|
||||
putch( '-' );
|
||||
n = -n;
|
||||
}
|
||||
putun( n );
|
||||
}
|
||||
Reference in New Issue
Block a user