From 145b1154f9f6b20d7069e5668a08140bf0e0fd2f Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 24 Apr 2018 14:38:48 +0200 Subject: [PATCH] Fixed stream setup io function declarations --- hardware/AFSK.c | 11 ++++++----- hardware/Serial.c | 6 ++++-- hardware/Serial.h | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/hardware/AFSK.c b/hardware/AFSK.c index 00a57ed..7c234c2 100755 --- a/hardware/AFSK.c +++ b/hardware/AFSK.c @@ -11,8 +11,8 @@ bool hw_5v_ref = false; Afsk *AFSK_modem; // Forward declerations -int afsk_getchar(void); -void afsk_putchar(char c); +int afsk_getchar(FILE *strem); +int afsk_putchar(char c, FILE *stream); void AFSK_hw_refDetect(void) { // This is manual for now @@ -94,13 +94,14 @@ static void AFSK_txStart(Afsk *afsk) { } } -void afsk_putchar(char c) { +int afsk_putchar(char c, FILE *stream) { AFSK_txStart(AFSK_modem); while(fifo_isfull_locked(&AFSK_modem->txFifo)) { /* Wait */ } fifo_push_locked(&AFSK_modem->txFifo, c); + return 1; } -int afsk_getchar(void) { +int afsk_getchar(FILE *stream) { if (fifo_isempty_locked(&AFSK_modem->rxFifo)) { return EOF; } else { @@ -112,7 +113,7 @@ void AFSK_transmit(char *buffer, size_t size) { fifo_flush(&AFSK_modem->txFifo); int i = 0; while (size--) { - afsk_putchar(buffer[i++]); + afsk_putchar(buffer[i++], NULL); } } diff --git a/hardware/Serial.c b/hardware/Serial.c index fa90d11..9c035aa 100755 --- a/hardware/Serial.c +++ b/hardware/Serial.c @@ -19,6 +19,7 @@ void serial_init(Serial *serial) { UCSR0B = _BV(RXEN0) | _BV(TXEN0); FILE uart0_fd = FDEV_SETUP_STREAM(uart0_putchar, uart0_getchar, _FDEV_SETUP_RW); + //FILE uart0_fd = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE); serial->uart0 = uart0_fd; } @@ -31,12 +32,13 @@ bool serial_available(uint8_t index) { } -void uart0_putchar(char c) { +int uart0_putchar(char c, FILE *stream) { loop_until_bit_is_set(UCSR0A, UDRE0); UDR0 = c; + return 1; } -char uart0_getchar(void) { +int uart0_getchar(FILE *stream) { loop_until_bit_is_set(UCSR0A, RXC0); return UDR0; } diff --git a/hardware/Serial.h b/hardware/Serial.h index 7671c28..22f69b0 100755 --- a/hardware/Serial.h +++ b/hardware/Serial.h @@ -13,8 +13,8 @@ typedef struct Serial { void serial_init(Serial *serial); bool serial_available(uint8_t index); -void uart0_putchar(char c); -char uart0_getchar(void); +int uart0_putchar(char c, FILE *stream); +int uart0_getchar(FILE *stream); char uart0_getchar_nowait(void); #endif \ No newline at end of file