Don't send newline when outputting carriage return

main
Michael Hayes 14 years ago
parent 3705a9a84f
commit 3db5bdae02

@ -38,7 +38,7 @@ usart1_init (const usart1_cfg_t *cfg)
} }
/* Return non-zero if there is a character ready to be read. */ /** Return non-zero if there is a character ready to be read. */
bool bool
usart1_read_ready_p (void) usart1_read_ready_p (void)
{ {
@ -46,7 +46,7 @@ usart1_read_ready_p (void)
} }
/* Return non-zero if a character can be written without blocking. */ /** Return non-zero if a character can be written without blocking. */
bool bool
usart1_write_ready_p (void) usart1_write_ready_p (void)
{ {
@ -54,7 +54,7 @@ usart1_write_ready_p (void)
} }
/* Return non-zero if transmitter finished. */ /** Return non-zero if transmitter finished. */
bool bool
usart1_write_finished_p (void) usart1_write_finished_p (void)
{ {
@ -62,22 +62,19 @@ usart1_write_finished_p (void)
} }
/* Write character to USART1. */ /** Write character to USART1. This blocks until the character can be
int8_t written into transmit register. */
void
usart1_putc (char ch) usart1_putc (char ch)
{ {
if (ch == '\n')
usart1_putc ('\r');
while (!usart1_write_ready_p ()) while (!usart1_write_ready_p ())
continue; continue;
UDR1 = ch; UDR1 = ch;
return 1;
} }
/* Read character from USART1. This blocks until a character is read. */ /** Read character from USART1. This blocks until a character is read. */
int8_t int8_t
usart1_getc (void) usart1_getc (void)
{ {
@ -89,7 +86,7 @@ usart1_getc (void)
} }
/* Write string to USART1. This blocks until the string is written. */ /** Write string to USART1. This blocks until the string is written. */
void void
usart1_puts (const char *str) usart1_puts (const char *str)
{ {

@ -21,39 +21,39 @@ typedef struct usart1_cfg_struct
#define USART1_BAUD_DIVISOR(BAUD_RATE) ((F_CPU / 16) / (BAUD_RATE)) #define USART1_BAUD_DIVISOR(BAUD_RATE) ((F_CPU / 16) / (BAUD_RATE))
/* Return non-zero if there is a character ready to be read. */ /** Return non-zero if there is a character ready to be read. */
bool bool
usart1_read_ready_p (void); usart1_read_ready_p (void);
/* Read character from USART1. This blocks if nothing is available to /** Read character from USART1. This blocks if nothing is available to
read. */ read. */
int8_t int8_t
usart1_getc (void); usart1_getc (void);
/* Return non-zero if a character can be written without blocking. */ /** Return non-zero if a character can be written without blocking. */
bool bool
usart1_write_ready_p (void); usart1_write_ready_p (void);
/* Return non-zero if transmitter finished. */ /** Return non-zero if transmitter finished. */
bool bool
usart1_write_finished_p (void); usart1_write_finished_p (void);
/* Write character to USART1. This returns zero if the character /** Write character to USART1. This blocks until the character can be
could not be written. */ written into transmit register. */
int8_t void
usart1_putc (char ch); usart1_putc (char ch);
/* Write string to USART1. */ /** Write string to USART1. */
void void
usart1_puts (const char *str); usart1_puts (const char *str);
/* Initialise usart1 and set baud rate. */ /** Initialise usart1 and set baud rate. */
uint8_t uint8_t
usart1_init (const usart1_cfg_t *cfg); usart1_init (const usart1_cfg_t *cfg);

Loading…
Cancel
Save