MODIF - Changed all functions to inline.

REMOVE - Hex utility functions


git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@141 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b
master
mlalondesvn 16 years ago
parent e444588173
commit 64380d09c9

@ -1,37 +0,0 @@
#include "../global.h"
// call with printString(PSTR("My string"))
void SPrint_P(const char *data)
{
char ch;
for (;;) {
ch = pgm_read_byte( data++ );
if ( !ch ) return;
Serial.print(ch);
}
}
void SPrintln_P(const char *data)
{
SPrint_P(data);
SPrint_P(PSTR("\r\n"));
}
void SPrintHex_P(const char *data)
{
char ch;
for (;;) {
ch = pgm_read_byte( data++ );
if ( !ch ) return;
Serial.print(ch, HEX);
}
}
void SPrintlnHex_P(const char *data)
{
printString(data);
Serial.println();
}

@ -1,3 +1,12 @@
extern "C" {
#include <avr/pgmspace.h>
#include <inttypes.h>
#include "wiring_private.h"
#include "WConstants.h"
#include <HardwareSerial.h>
}
#ifndef staticPrint_H
#define staticPrint_H
@ -9,17 +18,31 @@
#define SPrintln(str) SPrintln_P(PSTR(str))
#endif
#ifndef SPrintHex
#define SPrintHex(str) SPrintHex_P(PSTR(str))
#endif
static inline void SPrint_P(const char *data)
{
char ch;
#ifndef SPrint
#define SPrintlnHex(str) SPrintlnHex_P(PSTR(str))
for (;;) {
ch = pgm_read_byte( data++ );
if ( !ch ) return;
#if defined(__AVR_ATmega8__)
while (!(UCSRA & (1 << UDRE)))
;
UDR = c;
#else
while (!(UCSR0A & (1 << UDRE0)))
;
UDR0 = c;
#endif
}
}
void SPrint_P(const char *data);
void SPrintln_P(const char *data);
void SPrintHex_P(const char *data);
void SPrintlnHex_P(const char *data);
static inline void SPrintln_P(const char *data)
{
SPrint_P(data);
SPrint_P(PSTR("\r\n"));
}
#endif

Loading…
Cancel
Save