// Author: Sam Cohen
// Date: 1/11/25
// File Name: serial.h
// Desc: Description of serial output from AVR microcontroller.

#ifndef SERIAL_H
#define SERIAL_H

#include <avr/io.h>
#include <stdint.h>

#define F_CPU 16000000UL
#define BAUD 9600

#include <stdio.h>




/**
 * @brief This function initializes UART, sets the appropriate registers for transmission and reception of 8 bit data 
 * at the users desired baud rate.
 * 
 * @param baud_rate Need more research to understand what makes a baud rate good, 9600 seems like a common value.
 * @return size_t 
 */
size_t init_UART(unsigned long baud_rate);

/**
 * @brief Transmits a single byte via the serial stream using UART. UART must be initiatlized prior to running.
 * 
 * @param data_byte 
 * @return int 
 */
int transmit_byte_UART(unsigned char data_byte);

/**
 * @brief mimics printf functionality but with a maximum of 256 characters, may need to shrink this as thats an awful 
 * lot of the stack for simple messages
 * 
 * @param text 
 * @param ... 
 * @return size_t 
 */
size_t UART_printf(const char* text, ...);

/**
 * @brief UNIMPLEMENTED, recieves a single byte via UART. Needs a source parameter
 * 
 * @param data_byte 
 */
unsigned char receive_byte_UART();
















#endif