diff --git a/src/RegEdit/RegEdit.c b/src/RegEdit/RegEdit.c index ef6f106..6042841 100644 --- a/src/RegEdit/RegEdit.c +++ b/src/RegEdit/RegEdit.c @@ -1,6 +1,6 @@ /* * Author: username - * Date: 2024 + * Date: 2024 * filename: RegEdit.c * description: module_purpose */ @@ -10,54 +10,51 @@ void RegEdit_SetRegister(void *reg) { uint8_t *reg_ptr = (uint8_t *)reg; - *reg_ptr = 0xFF; + *reg_ptr = 0xFF; } - void RegEdit_ClearRegister(void *reg) { uint8_t *reg_ptr = (uint8_t *)reg; - *reg_ptr = 0x00; + *reg_ptr = 0x00; } void RegEdit_SetBit(void *reg, uint8_t bit_num) { uint8_t *reg_ptr = (uint8_t *)reg; - *reg_ptr |= (uint8_t)(1< #include +#include /** - * + * * @param reg The register address. */ void RegEdit_SetRegister(void *reg); /** - * + * * @param reg The register address. */ void RegEdit_ClearRegister(void *reg); /** - * + * * @param reg The register address. * @param bit_num The bit location. */ void RegEdit_SetBit(void *reg, uint8_t bit_num); /** - * + * * @param reg The register address. * @param bit_num The bit location. */ void RegEdit_ClearBit(void *reg, uint8_t bit_num); /** - * + * * @param reg The register address. * @param bit_num The bit location. - * @return + * @return */ bool RegEdit_IsBitSet(void *reg, uint8_t bit_num); /** - * + * * @param reg The register address. * @param num The bit location. */ void RegEdit_OR_Num(void *reg, uint8_t num); /** - * + * * @param reg The register address. * @param num The bit location. */ void RegEdit_AND_Num(void *reg, uint8_t num); /** - * + * * @param reg The register address. * @param num The bit location. */ @@ -75,4 +74,4 @@ void RegEdit_SetNum(void *reg, uint8_t num); */ uint8_t RegEdit_ReadReg(void *reg); -#endif //REGEDIT_H +#endif // REGEDIT_H diff --git a/src/main.c b/src/main.c index c13ad5d..6654f46 100644 --- a/src/main.c +++ b/src/main.c @@ -4,35 +4,30 @@ * @date 15 June 2024 * @brief File contains the main function. * - * This file contains the main logic loop and exists to setup the values + * This file contains the main logic loop and exists to setup the values * specific to the micro-controller. All other functions and configuration are * extracted into separate source files and headers for configuration. */ #define F_CPU 3333333UL -//This can prevent issues with utils/delay.h library with the gcc toolchain +// This can prevent issues with utils/delay.h library with the gcc toolchain #define __DELAY_BACKWARD_COMPATIBLE__ -#include "config.h" #include "RegEdit.h" +#include "config.h" #include "timer.h" #include /* Required header file */ #include #include - - -//Set the function pointer for the delay func +// Set the function pointer for the delay func void (*Delay_MicroSeconds)(double us) = _delay_us; - int main(int argc, char **argv) -{ - - - - while(true){ - ; //Do nothing until new Power cycle/reset occurs +{ + while (true) + { + ; // Do nothing until new Power cycle/reset occurs } } diff --git a/src/timer/timer.c b/src/timer/timer.c index c9f1804..b1a56b3 100644 --- a/src/timer/timer.c +++ b/src/timer/timer.c @@ -7,7 +7,6 @@ * @file module_name.h */ - #include "timer.h" // dumb test function diff --git a/src/timer/timer.h b/src/timer/timer.h index fe40ebb..a915acf 100644 --- a/src/timer/timer.h +++ b/src/timer/timer.h @@ -1,8 +1,8 @@ /** - * @brief The AVR Timer module + * @brief The AVR Timer module * @details This file is used to interact with the hardware timers. - * @author Jake G - * @date 2024 + * @author Jake G + * @date 2024 * @copyright None * @file TIMER.h */ @@ -10,13 +10,10 @@ #ifndef TIMER #define TIMER - /** * A function that adds two to a number * @param a The first argument */ int add_two(int a); - - -#endif //TIMER +#endif // TIMER diff --git a/src/usart/usart.c b/src/usart/usart.c index 896adc0..cb79772 100644 --- a/src/usart/usart.c +++ b/src/usart/usart.c @@ -1,6 +1,6 @@ /* * Author: username - * Date: 2024 + * Date: 2024 * filename: usart.c * description: module_purpose */ @@ -13,52 +13,50 @@ #define F_PER F_CPU / 6 #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 +// 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); - - //setup Alternate pints on PA1 and PA2 + // Config TxD as output, and rx as input? + PORTB.DIR &= ~(1 << 3); + PORTB.DIR |= (1 << 2); + + // setup Alternate pints on PA1 and PA2 /* PORTMUX.CTRLB |= PORTMUX_USART0_ALTERNATE_gc; PORTA.DIRSET |= (1<<1); PORTA.DIRSET &= ~(1<<2); */ - //It says to set the TX pin high? - //PORTB.OUT |= (1<<2); - //PORTA.OUT |= (1<<11); + // It says to set the TX pin high? + // PORTB.OUT |= (1<<2); + // PORTA.OUT |= (1<<11); - //set buad rate. + // set buad rate. USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600); - //set the frame format. - USART0.CTRLC = 0x3; //setting 8-bit mode. + // 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; + // 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)){ + 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++) + 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 index d5e8af2..472c0c2 100644 --- a/src/usart/usart.h +++ b/src/usart/usart.h @@ -1,7 +1,7 @@ /** - * @brief Universal Asynchronout Serial library. - * @details This file contains the functions for using the avr usart0 periph. - * @author Jake G + * @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 @@ -10,15 +10,14 @@ #ifndef USART_H #define USART_H - /** - * @brief Initializes the USART0 peripheral. + * @brief Initializes the USART0 peripheral. */ void USART0_init(void); /** * @brief Sends a single char type variable over usart0. - * @param c The charecter to be sent over usart0. + * @param c The charecter to be sent over usart0. */ void USART0_sendChar(char c); @@ -28,6 +27,4 @@ void USART0_sendChar(char c); */ void USART0_sendString(char *str); - - -#endif //USART_H +#endif // USART_H