Formatting cleanup of quiet sources
This commit is contained in:
@ -23,8 +23,8 @@
|
||||
#define MarlinSerial_h
|
||||
#include "Marlin.h"
|
||||
|
||||
#if !defined(SERIAL_PORT)
|
||||
#define SERIAL_PORT 0
|
||||
#ifndef SERIAL_PORT
|
||||
#define SERIAL_PORT 0
|
||||
#endif
|
||||
|
||||
// The presence of the UBRRH register is used to detect a UART.
|
||||
@ -36,9 +36,9 @@
|
||||
// requires two levels of indirection to expand macro values properly)
|
||||
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
|
||||
#if SERIAL_PORT == 0 && (!defined(UBRR0H) || !defined(UDR0)) // use un-numbered registers if necessary
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##suffix
|
||||
#else
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
|
||||
#define SERIAL_REGNAME_INTERNAL(registerbase,number,suffix) registerbase##number##suffix
|
||||
#endif
|
||||
|
||||
// Registers used by MarlinSerial class (these are expanded
|
||||
@ -57,7 +57,6 @@
|
||||
#define M_U2Xx SERIAL_REGNAME(U2X,SERIAL_PORT,)
|
||||
|
||||
|
||||
|
||||
#define DEC 10
|
||||
#define HEX 16
|
||||
#define OCT 8
|
||||
@ -73,8 +72,7 @@
|
||||
#define RX_BUFFER_SIZE 128
|
||||
|
||||
|
||||
struct ring_buffer
|
||||
{
|
||||
struct ring_buffer {
|
||||
unsigned char buffer[RX_BUFFER_SIZE];
|
||||
int head;
|
||||
int tail;
|
||||
@ -84,8 +82,7 @@ struct ring_buffer
|
||||
extern ring_buffer rx_buffer;
|
||||
#endif
|
||||
|
||||
class MarlinSerial //: public Stream
|
||||
{
|
||||
class MarlinSerial { //: public Stream
|
||||
|
||||
public:
|
||||
MarlinSerial();
|
||||
@ -94,24 +91,20 @@ class MarlinSerial //: public Stream
|
||||
int peek(void);
|
||||
int read(void);
|
||||
void flush(void);
|
||||
|
||||
FORCE_INLINE int available(void)
|
||||
{
|
||||
|
||||
FORCE_INLINE int available(void) {
|
||||
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
FORCE_INLINE void write(uint8_t c)
|
||||
{
|
||||
|
||||
FORCE_INLINE void write(uint8_t c) {
|
||||
while (!((M_UCSRxA) & (1 << M_UDREx)))
|
||||
;
|
||||
|
||||
M_UDRx = c;
|
||||
}
|
||||
|
||||
|
||||
FORCE_INLINE void checkRx(void)
|
||||
{
|
||||
if((M_UCSRxA & (1<<M_RXCx)) != 0) {
|
||||
|
||||
FORCE_INLINE void checkRx(void) {
|
||||
if ((M_UCSRxA & (1<<M_RXCx)) != 0) {
|
||||
unsigned char c = M_UDRx;
|
||||
int i = (unsigned int)(rx_buffer.head + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
@ -125,39 +118,17 @@ class MarlinSerial //: public Stream
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
void printNumber(unsigned long, uint8_t);
|
||||
void printFloat(double, uint8_t);
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
FORCE_INLINE void write(const char *str)
|
||||
{
|
||||
while (*str)
|
||||
write(*str++);
|
||||
}
|
||||
FORCE_INLINE void write(const char *str) { while (*str) write(*str++); }
|
||||
FORCE_INLINE void write(const uint8_t *buffer, size_t size) { while (size--) write(*buffer++); }
|
||||
FORCE_INLINE void print(const String &s) { for (int i = 0; i < (int)s.length(); i++) write(s[i]); }
|
||||
FORCE_INLINE void print(const char *str) { write(str); }
|
||||
|
||||
|
||||
FORCE_INLINE void write(const uint8_t *buffer, size_t size)
|
||||
{
|
||||
while (size--)
|
||||
write(*buffer++);
|
||||
}
|
||||
|
||||
FORCE_INLINE void print(const String &s)
|
||||
{
|
||||
for (int i = 0; i < (int)s.length(); i++) {
|
||||
write(s[i]);
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE void print(const char *str)
|
||||
{
|
||||
write(str);
|
||||
}
|
||||
void print(char, int = BYTE);
|
||||
void print(unsigned char, int = BYTE);
|
||||
void print(int, int = DEC);
|
||||
|
Reference in New Issue
Block a user