Ran clang-format on project files.

This commit is contained in:
Jake Goodwin 2024-08-04 11:29:00 -07:00
parent 1f652b7c37
commit 427a5d1786
7 changed files with 62 additions and 80 deletions

View File

@ -10,32 +10,31 @@
void RegEdit_SetRegister(void *reg) void RegEdit_SetRegister(void *reg)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr = 0xFF; *reg_ptr = 0xFF;
} }
void RegEdit_ClearRegister(void *reg) void RegEdit_ClearRegister(void *reg)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr = 0x00; *reg_ptr = 0x00;
} }
void RegEdit_SetBit(void *reg, uint8_t bit_num) void RegEdit_SetBit(void *reg, uint8_t bit_num)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr |= (uint8_t)(1<<bit_num); *reg_ptr |= (uint8_t)(1 << bit_num);
} }
void RegEdit_ClearBit(void *reg, uint8_t bit_num) void RegEdit_ClearBit(void *reg, uint8_t bit_num)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr &= ~(1<<bit_num); *reg_ptr &= ~(1 << bit_num);
} }
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num) bool RegEdit_IsBitSet(void *reg, uint8_t bit_num)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
return *reg_ptr & (1<<bit_num); return *reg_ptr & (1 << bit_num);
} }
void RegEdit_OR_Num(void *reg, uint8_t num) void RegEdit_OR_Num(void *reg, uint8_t num)
@ -46,7 +45,6 @@ void RegEdit_OR_Num(void *reg, uint8_t num)
void RegEdit_AND_Num(void *reg, uint8_t num) void RegEdit_AND_Num(void *reg, uint8_t num)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr &= num; *reg_ptr &= num;
} }
@ -54,10 +52,9 @@ void RegEdit_AND_Num(void *reg, uint8_t num)
void RegEdit_SetNum(void *reg, uint8_t num) void RegEdit_SetNum(void *reg, uint8_t num)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;
*reg_ptr = num; *reg_ptr = num;
} }
uint8_t RegEdit_ReadReg(void *reg) uint8_t RegEdit_ReadReg(void *reg)
{ {
uint8_t *reg_ptr = (uint8_t *)reg; uint8_t *reg_ptr = (uint8_t *)reg;

View File

@ -10,9 +10,8 @@
#ifndef REGEDIT_H #ifndef REGEDIT_H
#define REGEDIT_H #define REGEDIT_H
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
/** /**
* *
@ -75,4 +74,4 @@ void RegEdit_SetNum(void *reg, uint8_t num);
*/ */
uint8_t RegEdit_ReadReg(void *reg); uint8_t RegEdit_ReadReg(void *reg);
#endif //REGEDIT_H #endif // REGEDIT_H

View File

@ -11,28 +11,23 @@
#define F_CPU 3333333UL #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__ #define __DELAY_BACKWARD_COMPATIBLE__
#include "config.h"
#include "RegEdit.h" #include "RegEdit.h"
#include "config.h"
#include "timer.h" #include "timer.h"
#include <avr/cpufunc.h> /* Required header file */ #include <avr/cpufunc.h> /* Required header file */
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h> #include <util/delay.h>
// Set the function pointer for the delay func
//Set the function pointer for the delay func
void (*Delay_MicroSeconds)(double us) = _delay_us; void (*Delay_MicroSeconds)(double us) = _delay_us;
int main(int argc, char **argv) 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
} }
} }

View File

@ -7,7 +7,6 @@
* @file module_name.h * @file module_name.h
*/ */
#include "timer.h" #include "timer.h"
// dumb test function // dumb test function

View File

@ -10,13 +10,10 @@
#ifndef TIMER #ifndef TIMER
#define TIMER #define TIMER
/** /**
* A function that adds two to a number * A function that adds two to a number
* @param a The first argument * @param a The first argument
*/ */
int add_two(int a); int add_two(int a);
#endif // TIMER
#endif //TIMER

View File

@ -13,52 +13,50 @@
#define F_PER F_CPU / 6 #define F_PER F_CPU / 6
#define USART0_BAUD_RATE(BAUD_RATE) ((float)(F_PER * 64 / (16 * (float)BAUD_RATE)) + 0.5) #define USART0_BAUD_RATE(BAUD_RATE) ((float)(F_PER * 64 / (16 * (float)BAUD_RATE)) + 0.5)
//RX PIN6, TX PIN7 // RX PIN6, TX PIN7
//ALT: RX PIN12 TX PIN11 // ALT: RX PIN12 TX PIN11
void USART0_init(void) void USART0_init(void)
{ {
//Config TxD as output, and rx as input? // Config TxD as output, and rx as input?
PORTB.DIR &= ~(1<<3); PORTB.DIR &= ~(1 << 3);
PORTB.DIR |= (1<<2); PORTB.DIR |= (1 << 2);
//setup Alternate pints on PA1 and PA2 // setup Alternate pints on PA1 and PA2
/* /*
PORTMUX.CTRLB |= PORTMUX_USART0_ALTERNATE_gc; PORTMUX.CTRLB |= PORTMUX_USART0_ALTERNATE_gc;
PORTA.DIRSET |= (1<<1); PORTA.DIRSET |= (1<<1);
PORTA.DIRSET &= ~(1<<2); PORTA.DIRSET &= ~(1<<2);
*/ */
//It says to set the TX pin high? // It says to set the TX pin high?
//PORTB.OUT |= (1<<2); // PORTB.OUT |= (1<<2);
//PORTA.OUT |= (1<<11); // PORTA.OUT |= (1<<11);
//set buad rate. // set buad rate.
USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600); USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600);
//set the frame format. // set the frame format.
USART0.CTRLC = 0x3; //setting 8-bit mode. USART0.CTRLC = 0x3; // setting 8-bit mode.
//Enable transmitter and receiver (USARTn.CTRLB) // Enable transmitter and receiver (USARTn.CTRLB)
//USART0.CTRLB |= (1<<7)|(1<<6); // USART0.CTRLB |= (1<<7)|(1<<6);
USART0.CTRLB |= USART_TXEN_bm; USART0.CTRLB |= USART_TXEN_bm;
} }
void USART0_sendChar(char c) void USART0_sendChar(char c)
{ {
while (!(USART0.STATUS & USART_DREIF_bm)){ while (!(USART0.STATUS & USART_DREIF_bm))
{
; ;
} }
USART0.TXDATAL = c; USART0.TXDATAL = c;
USART0.TXDATAH = c; USART0.TXDATAH = c;
} }
void USART0_sendString(char *str) 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]); USART0_sendChar(str[i]);
} }
} }

View File

@ -10,7 +10,6 @@
#ifndef USART_H #ifndef USART_H
#define USART_H #define USART_H
/** /**
* @brief Initializes the USART0 peripheral. * @brief Initializes the USART0 peripheral.
*/ */
@ -28,6 +27,4 @@ void USART0_sendChar(char c);
*/ */
void USART0_sendString(char *str); void USART0_sendString(char *str);
#endif // USART_H
#endif //USART_H