diff --git a/src/usart/CMakeLists.txt b/src/usart/CMakeLists.txt deleted file mode 100644 index dbaf727..0000000 --- a/src/usart/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -add_library(usart STATIC - usart.c -) - -target_include_directories(usart PUBLIC - ${CMAKE_CURRENT_LIST_DIR} -) diff --git a/src/usart/usart.c b/src/usart/usart.c deleted file mode 100644 index d929652..0000000 --- a/src/usart/usart.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: username - * Date: 2024 - * filename: usart.c - * description: module_purpose - */ - -#ifndef __AVR_ATtiny404__ -#define __AVR_ATtiny404__ -#endif - -#include "usart.h" -#include -#include - -// These are technically correct, but the libc requires F_CPU for delay stuff -// that doesn't match the actual F_CPU because it uses the value after the -// clock is divided. - -// #define F_CPU 3333333UL -// #define F_PER F_CPU / 6 - -#define F_PER 3333333UL -#define USART0_BAUD_RATE(BAUD_RATE) \ - ((float)(F_PER * 64 / (16 * (float)BAUD_RATE)) + 0.5) - -// RX PIN6, TX PIN7 -// ALT: RX PIN12 TX PIN11 -void USART0_Init(void) { - // Config TxD as output, and rx as input? - PORTB.DIR &= ~(1 << 3); - PORTB.DIR |= (1 << 2); - - // It says to set the TX pin high? - // PORTB.OUT |= (1<<2); - - // set buad rate. - USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600); - // USART0.BAUD = 1388; - - // set the frame format. - USART0.CTRLC = 0x3; // setting 8-bit mode. - - // Enable transmitter and receiver (USARTn.CTRLB) - // USART0.CTRLB |= (1<<7)|(1<<6); - USART0.CTRLB |= USART_TXEN_bm; -} - -void USART0_Alt_Init(void) { - // setup Alternate pints on PA1 and PA2 - PORTMUX.CTRLB |= PORTMUX_USART0_ALTERNATE_gc; - PORTA.DIR |= (1 << 1); - PORTA.DIR &= ~(1 << 2); - - // It says to set the TX pin high? - // PORTA.OUT |= (1<<11); - - // set buad rate. - USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600); - - // set the frame format. - USART0.CTRLC = 0x3; // setting 8-bit mode. - - // Enable transmitter and receiver (USARTn.CTRLB) - // USART0.CTRLB |= (1<<7)|(1<<6); - USART0.CTRLB |= USART_TXEN_bm; -} - -void USART0_sendChar(char c) { - while (!(USART0.STATUS & USART_DREIF_bm)) { - ; - } - USART0.TXDATAL = c; - USART0.TXDATAH = c; -} - -void USART0_sendString(char *str) { - for (size_t i = 0; i < strlen(str); i++) { - USART0_sendChar(str[i]); - } -} diff --git a/src/usart/usart.h b/src/usart/usart.h deleted file mode 100644 index 1670450..0000000 --- a/src/usart/usart.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @brief Universal Asynchronout Serial library. - * @details This file contains the functions for using the avr usart0 periph. - * @author Jake G - * @date 2024 - * @copyright None - * @file USART.h - */ - -#ifndef USART_H -#define USART_H - -/** - * @brief Initializes the USART0 peripheral. - */ -void USART0_Init(void); - -/** - * @brief Initializes the USART0 peripheral on Alternate pins. - */ -void USART0_Alt_Init(void); - -/** - * @brief Sends a single char type variable over usart0. - * @param c The charecter to be sent over usart0. - */ -void USART0_sendChar(char c); - -/** - * @brief Sends string over usart0 - * @param str A C-style string. - */ -void USART0_sendString(char *str); - -#endif // USART_H