-
Notifications
You must be signed in to change notification settings - Fork 3
/
uart.h
42 lines (30 loc) · 815 Bytes
/
uart.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef UART_H
#define UART_H
#include "queue.h"
#include <stdbool.h>
#include <stdint.h>
#define FOSC_UART 16000000UL // Clock Speed
#define BAUD_UART 9600
#define UBRR_UART (FOSC_UART/16/BAUD_UART-1)
#define UART_QUEUE_MAX_LENGTH 30
//Possible messages to receive and send
typedef enum {
MESSAGE_1 = 0,
MESSAGE_2
} UART_commands;
Queue *rx_queue;
Queue *tx_queue;
uint8_t rx_queue_length;
uint8_t tx_queue_length;
volatile bool rx_overflow_flag;
void init_UART(unsigned ubrr);
bool UART_enqueue(char entry_);
bool UART_enqueue_urgent(char to_write);
bool UART_enqueue_string(char* str);
bool UART_write();
bool UART_write_flush();
char UART_read();
void UART_interpret(); //For ISR
void UART_receive(); //For ISR (doing the work in the actual ISR seems better)
void UART_test_return_chars();
#endif