Ran clang-format on project files.
This commit is contained in:
parent
1f652b7c37
commit
427a5d1786
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Author: username
|
* Author: username
|
||||||
* Date: 2024
|
* Date: 2024
|
||||||
* filename: RegEdit.c
|
* filename: RegEdit.c
|
||||||
* description: module_purpose
|
* description: module_purpose
|
||||||
*/
|
*/
|
||||||
|
@ -10,54 +10,51 @@
|
||||||
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)
|
||||||
{
|
{
|
||||||
uint8_t *reg_ptr = (uint8_t *)reg;
|
uint8_t *reg_ptr = (uint8_t *)reg;
|
||||||
*reg_ptr |= num;
|
*reg_ptr |= 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/**
|
/**
|
||||||
* @brief Register Editing Interface
|
* @brief Register Editing Interface
|
||||||
* @details This file is an abstraction to all the bitwise operations
|
* @details This file is an abstraction to all the bitwise operations
|
||||||
* @author Jake G
|
* @author Jake G
|
||||||
* @date 2024
|
* @date 2024
|
||||||
* @copyright None
|
* @copyright None
|
||||||
* @file MockRegEdit.h
|
* @file MockRegEdit.h
|
||||||
*/
|
*/
|
||||||
|
@ -10,60 +10,59 @@
|
||||||
#ifndef REGEDIT_H
|
#ifndef REGEDIT_H
|
||||||
#define REGEDIT_H
|
#define REGEDIT_H
|
||||||
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
*/
|
*/
|
||||||
void RegEdit_SetRegister(void *reg);
|
void RegEdit_SetRegister(void *reg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
*/
|
*/
|
||||||
void RegEdit_ClearRegister(void *reg);
|
void RegEdit_ClearRegister(void *reg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
* @param bit_num The bit location.
|
* @param bit_num The bit location.
|
||||||
*/
|
*/
|
||||||
void RegEdit_SetBit(void *reg, uint8_t bit_num);
|
void RegEdit_SetBit(void *reg, uint8_t bit_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
* @param bit_num The bit location.
|
* @param bit_num The bit location.
|
||||||
*/
|
*/
|
||||||
void RegEdit_ClearBit(void *reg, uint8_t bit_num);
|
void RegEdit_ClearBit(void *reg, uint8_t bit_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
* @param bit_num The bit location.
|
* @param bit_num The bit location.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num);
|
bool RegEdit_IsBitSet(void *reg, uint8_t bit_num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
* @param num The bit location.
|
* @param num The bit location.
|
||||||
*/
|
*/
|
||||||
void RegEdit_OR_Num(void *reg, uint8_t num);
|
void RegEdit_OR_Num(void *reg, uint8_t num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
* @param num The bit location.
|
* @param num The bit location.
|
||||||
*/
|
*/
|
||||||
void RegEdit_AND_Num(void *reg, uint8_t num);
|
void RegEdit_AND_Num(void *reg, uint8_t num);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param reg The register address.
|
* @param reg The register address.
|
||||||
* @param num The bit location.
|
* @param num The bit location.
|
||||||
*/
|
*/
|
||||||
|
@ -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
|
||||||
|
|
21
src/main.c
21
src/main.c
|
@ -4,35 +4,30 @@
|
||||||
* @date 15 June 2024
|
* @date 15 June 2024
|
||||||
* @brief File contains the main function.
|
* @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
|
* specific to the micro-controller. All other functions and configuration are
|
||||||
* extracted into separate source files and headers for configuration.
|
* extracted into separate source files and headers for configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
* @file module_name.h
|
* @file module_name.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
|
|
||||||
// dumb test function
|
// dumb test function
|
||||||
|
|
|
@ -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.
|
* @details This file is used to interact with the hardware timers.
|
||||||
* @author Jake G
|
* @author Jake G
|
||||||
* @date 2024
|
* @date 2024
|
||||||
* @copyright None
|
* @copyright None
|
||||||
* @file TIMER.h
|
* @file TIMER.h
|
||||||
*/
|
*/
|
||||||
|
@ -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
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Author: username
|
* Author: username
|
||||||
* Date: 2024
|
* Date: 2024
|
||||||
* filename: usart.c
|
* filename: usart.c
|
||||||
* description: module_purpose
|
* description: module_purpose
|
||||||
*/
|
*/
|
||||||
|
@ -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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* @brief Universal Asynchronout Serial library.
|
* @brief Universal Asynchronout Serial library.
|
||||||
* @details This file contains the functions for using the avr usart0 periph.
|
* @details This file contains the functions for using the avr usart0 periph.
|
||||||
* @author Jake G
|
* @author Jake G
|
||||||
* @date 2024
|
* @date 2024
|
||||||
* @copyright None
|
* @copyright None
|
||||||
* @file USART.h
|
* @file USART.h
|
||||||
|
@ -10,15 +10,14 @@
|
||||||
#ifndef USART_H
|
#ifndef USART_H
|
||||||
#define USART_H
|
#define USART_H
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the USART0 peripheral.
|
* @brief Initializes the USART0 peripheral.
|
||||||
*/
|
*/
|
||||||
void USART0_init(void);
|
void USART0_init(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sends a single char type variable over usart0.
|
* @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);
|
void USART0_sendChar(char c);
|
||||||
|
|
||||||
|
@ -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
|
|
||||||
|
|
Loading…
Reference in New Issue