Initial commit of files
This commit is contained in:
87
src/libPIC/ser_puts.c
Normal file
87
src/libPIC/ser_puts.c
Normal file
@ -0,0 +1,87 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (C) 2008
|
||||
* ProbeStar Telematics, LLC
|
||||
* All Rights Reserved. Proprietary and Confidential.
|
||||
*============================================================================
|
||||
* Serial String Output
|
||||
*----------------------------------------------------------------------------
|
||||
* Details
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* includes
|
||||
*****************************************************************************/
|
||||
|
||||
#include "serial.h"
|
||||
#include "types.h"
|
||||
|
||||
/*****************************************************************************
|
||||
* defines
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* macros
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef __linux__
|
||||
#define putch(C) putchar(C)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
* structs & typedefs
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* global constants
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* global variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* static constants
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* static variables
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* static prototypes
|
||||
*****************************************************************************/
|
||||
|
||||
/*****************************************************************************
|
||||
* C functions
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef SERIAL_PUTS
|
||||
int serial_puts( const BYTE *s, WORD n )
|
||||
{
|
||||
int r = n;
|
||||
while ( n-- )
|
||||
putch( *s++ );
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
int puts( const char *s )
|
||||
{
|
||||
char c;
|
||||
int n = 0;
|
||||
|
||||
while ( c = *s++ )
|
||||
{
|
||||
if ( c == '\n' )
|
||||
{
|
||||
putch( '\r' );
|
||||
n++;
|
||||
}
|
||||
putch( c );
|
||||
n++;
|
||||
}
|
||||
putch( '\r' );
|
||||
putch( '\n' );
|
||||
|
||||
return n+2;
|
||||
}
|
||||
Reference in New Issue
Block a user