OpenModem/hardware/Serial.h

47 lines
1.2 KiB
C
Raw Normal View History

2014-12-02 17:10:06 -07:00
#ifndef SERIAL_H
#define SERIAL_H
#include "device.h"
#include <stdio.h>
#include <stdbool.h>
#include <avr/io.h>
2019-01-08 12:56:58 -07:00
#include "util/FIFO.h"
2019-01-12 07:12:51 -07:00
#include "hardware/LED.h"
2014-12-02 17:10:06 -07:00
typedef struct Serial {
FILE uart0;
2019-02-04 09:02:19 -07:00
FILE uart1;
2014-12-02 17:10:06 -07:00
} Serial;
2019-02-04 09:02:19 -07:00
FIFOBuffer uart0FIFO;
2020-06-01 05:45:26 -06:00
uint8_t uart0Buf[CONFIG_UART0_BUFFER_SIZE+1];
2019-02-04 09:02:19 -07:00
FIFOBuffer uart1FIFO;
2020-06-01 05:45:26 -06:00
uint8_t uart1Buf[CONFIG_UART1_BUFFER_SIZE+1];
2019-01-08 12:56:58 -07:00
2014-12-02 17:10:06 -07:00
void serial_init(Serial *serial);
bool serial_available(uint8_t index);
2019-02-04 09:02:19 -07:00
int uart0_putchar(char c, FILE *stream);
int uart0_getchar(FILE *stream);
2014-12-02 17:10:06 -07:00
char uart0_getchar_nowait(void);
2019-02-04 09:02:19 -07:00
int uart1_putchar(char c, FILE *stream);
int uart1_getchar(FILE *stream);
char uart1_getchar_nowait(void);
void serial_setbaudrate_1200(uint8_t port);
void serial_setbaudrate_2400(uint8_t port);
void serial_setbaudrate_4800(uint8_t port);
void serial_setbaudrate_9600(uint8_t port);
void serial_setbaudrate_14400(uint8_t port);
void serial_setbaudrate_19200(uint8_t port);
void serial_setbaudrate_28800(uint8_t port);
void serial_setbaudrate_38400(uint8_t port);
void serial_setbaudrate_57600(uint8_t port);
void serial_setbaudrate_76800(uint8_t port);
void serial_setbaudrate_115200(uint8_t port);
void serial_setbaudrate_230400(uint8_t port);
2019-01-29 08:41:27 -07:00
2014-12-02 17:10:06 -07:00
#endif