Fixed stream setup io function declarations
This commit is contained in:
parent
2c80adbda4
commit
145b1154f9
|
@ -11,8 +11,8 @@ bool hw_5v_ref = false;
|
||||||
Afsk *AFSK_modem;
|
Afsk *AFSK_modem;
|
||||||
|
|
||||||
// Forward declerations
|
// Forward declerations
|
||||||
int afsk_getchar(void);
|
int afsk_getchar(FILE *strem);
|
||||||
void afsk_putchar(char c);
|
int afsk_putchar(char c, FILE *stream);
|
||||||
|
|
||||||
void AFSK_hw_refDetect(void) {
|
void AFSK_hw_refDetect(void) {
|
||||||
// This is manual for now
|
// 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);
|
AFSK_txStart(AFSK_modem);
|
||||||
while(fifo_isfull_locked(&AFSK_modem->txFifo)) { /* Wait */ }
|
while(fifo_isfull_locked(&AFSK_modem->txFifo)) { /* Wait */ }
|
||||||
fifo_push_locked(&AFSK_modem->txFifo, c);
|
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)) {
|
if (fifo_isempty_locked(&AFSK_modem->rxFifo)) {
|
||||||
return EOF;
|
return EOF;
|
||||||
} else {
|
} else {
|
||||||
|
@ -112,7 +113,7 @@ void AFSK_transmit(char *buffer, size_t size) {
|
||||||
fifo_flush(&AFSK_modem->txFifo);
|
fifo_flush(&AFSK_modem->txFifo);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (size--) {
|
while (size--) {
|
||||||
afsk_putchar(buffer[i++]);
|
afsk_putchar(buffer[i++], NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ void serial_init(Serial *serial) {
|
||||||
UCSR0B = _BV(RXEN0) | _BV(TXEN0);
|
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, uart0_getchar, _FDEV_SETUP_RW);
|
||||||
|
//FILE uart0_fd = FDEV_SETUP_STREAM(uart0_putchar, NULL, _FDEV_SETUP_WRITE);
|
||||||
|
|
||||||
serial->uart0 = uart0_fd;
|
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);
|
loop_until_bit_is_set(UCSR0A, UDRE0);
|
||||||
UDR0 = c;
|
UDR0 = c;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char uart0_getchar(void) {
|
int uart0_getchar(FILE *stream) {
|
||||||
loop_until_bit_is_set(UCSR0A, RXC0);
|
loop_until_bit_is_set(UCSR0A, RXC0);
|
||||||
return UDR0;
|
return UDR0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ typedef struct Serial {
|
||||||
|
|
||||||
void serial_init(Serial *serial);
|
void serial_init(Serial *serial);
|
||||||
bool serial_available(uint8_t index);
|
bool serial_available(uint8_t index);
|
||||||
void uart0_putchar(char c);
|
int uart0_putchar(char c, FILE *stream);
|
||||||
char uart0_getchar(void);
|
int uart0_getchar(FILE *stream);
|
||||||
char uart0_getchar_nowait(void);
|
char uart0_getchar_nowait(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue