Automated formatting to styling guideline

This commit is contained in:
Jake Goodwin 2024-08-24 09:04:57 -07:00
parent 624b57e56a
commit 43a64678eb
7 changed files with 124 additions and 129 deletions

View File

@ -5,7 +5,6 @@
* description: Abstract LED interface and control. * description: Abstract LED interface and control.
*/ */
#ifndef __AVR_ATtiny404__ #ifndef __AVR_ATtiny404__
#define __AVR_ATtiny404__ #define __AVR_ATtiny404__
#endif #endif
@ -22,17 +21,11 @@
#define HALF_BYTE_BM #define HALF_BYTE_BM
typedef struct LedController {
void *port;
uint8_t pins[BITS_IN_BYTE];
}LedController;
static LedController controller;
//static LedController controller;
void LedControler_SetPortADefault(void); void LedControler_SetPortADefault(void);
/* /*
* Uses pins: 9, 8, 12, 13 * Uses pins: 9, 8, 12, 13
*/ */
@ -45,7 +38,6 @@ void LedController_SetLedBitNum(void * port, uint8_t pin, uint8_t bit);
void LedController_ShowByte(uint8_t byte); void LedController_ShowByte(uint8_t byte);
void LedControler_ShowHalfByte(uint8_t byte) void LedControler_ShowHalfByte(uint8_t byte)
{ {
byte = byte & 0x0F; byte = byte & 0x0F;
@ -60,21 +52,24 @@ void LedControler_ShowHalfByte(uint8_t byte)
// 15 = 0b1111 // 15 = 0b1111
// PORTA.OUT |= (byte & 0x0F); // PORTA.OUT |= (byte & 0x0F);
if(byte & 0x01){ if (byte & 0x01)
{
PORTA.OUT |= PA_B1; PORTA.OUT |= PA_B1;
} }
if(byte & 0x02){ if (byte & 0x02)
{
PORTA.OUT |= PA_B2; PORTA.OUT |= PA_B2;
} }
if(byte & 0x04){ if (byte & 0x04)
{
PORTA.OUT |= PA_B3; PORTA.OUT |= PA_B3;
} }
if(byte & 0x08){ if (byte & 0x08)
{
PORTA.OUT |= PA_B4; PORTA.OUT |= PA_B4;
} }
} }
void LedControler_ClearHalfByte(void) void LedControler_ClearHalfByte(void)
{ {
// PORTA.OUT &= HALF_BYTE_BM; // PORTA.OUT &= HALF_BYTE_BM;

View File

@ -10,8 +10,20 @@
#ifndef LEDCONTROLLER #ifndef LEDCONTROLLER
#define LEDCONTROLLER #define LEDCONTROLLER
#include <stdint.h> #include <stdint.h>
#include "stdbool.h"
/**
* A structure representing an LED
*/
typedef struct Led
{
uint8_t *port;
uint8_t pin_num;
bool state;
}Led;
/** /**
* Sets the default PORTB pins for output. * Sets the default PORTB pins for output.
@ -23,7 +35,6 @@ void LedControler_SetPortADefault(void);
*/ */
void LedControler_SetPortBDefault(void); void LedControler_SetPortBDefault(void);
/** /**
* Allows the setting or changing of which pins represent which bits. * Allows the setting or changing of which pins represent which bits.
* @param port The address of the port. * @param port The address of the port.
@ -37,13 +48,11 @@ void LedController_SetLedBitNum(void * port, uint8_t pin, uint8_t bit);
*/ */
void LedController_ShowByte(uint8_t byte); void LedController_ShowByte(uint8_t byte);
/** /**
* Displays the the first 4 bits of a byte. * Displays the the first 4 bits of a byte.
*/ */
void LedControler_ShowHalfByte(uint8_t byte); void LedControler_ShowHalfByte(uint8_t byte);
/** /**
* Clears out the halfbyte led representation * Clears out the halfbyte led representation
*/ */

View File

@ -15,8 +15,8 @@
// 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 "RegEdit.h"
#include "LedController.h" #include "LedController.h"
#include "RegEdit.h"
#include "config.h" #include "config.h"
#include "timer.h" #include "timer.h"
#include <avr/cpufunc.h> /* Required header file */ #include <avr/cpufunc.h> /* Required header file */
@ -28,7 +28,6 @@
#define RELAYPIN (1 << 1) #define RELAYPIN (1 << 1)
#define RELAYREADINGPIN (1 << 2) // It would be better to use PA7 so USART worked #define RELAYREADINGPIN (1 << 2) // It would be better to use PA7 so USART worked
// 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;
@ -44,7 +43,6 @@ void SW2_Wait(void)
while (PORTA.IN & SW2PIN) {} while (PORTA.IN & SW2PIN) {}
} }
void Activate_Relay(void) void Activate_Relay(void)
{ {
PORTA.OUT |= RELAYPIN; PORTA.OUT |= RELAYPIN;
@ -55,17 +53,21 @@ void Deactivate_Relay(void)
PORTA.OUT &= ~RELAYPIN; PORTA.OUT &= ~RELAYPIN;
} }
void WaitForRelayConnect(void) void WaitForRelayConnect(void)
{ {
while(!(PORTB.IN & RELAYREADINGPIN)){;} while (!(PORTB.IN & RELAYREADINGPIN))
{
;
}
} }
void WaitForRelayDisconnect(void) void WaitForRelayDisconnect(void)
{ {
while(PORTB.IN & RELAYREADINGPIN){;} while (PORTB.IN & RELAYREADINGPIN)
{
;
}
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@ -74,12 +76,12 @@ int main(int argc, char **argv)
PORTA.DIR &= ~SW1PIN; PORTA.DIR &= ~SW1PIN;
PORTA.DIR &= ~SW2PIN; PORTA.DIR &= ~SW2PIN;
uint16_t make_time = 0; uint16_t make_time = 0;
uint16_t break_time = 0; uint16_t break_time = 0;
uint8_t temp = 0; uint8_t temp = 0;
while(true) { while (true)
{
SW1_Wait(); SW1_Wait();
Activate_Relay(); Activate_Relay();
@ -130,8 +132,6 @@ int main(int argc, char **argv)
LedControler_ClearHalfByte(); LedControler_ClearHalfByte();
/* /*
USART0_sendString(maketime_msg); USART0_sendString(maketime_msg);
USART0_sendChar((uint8_t)(0xFF & make_time)); USART0_sendChar((uint8_t)(0xFF & make_time));

View File

@ -13,8 +13,8 @@
#endif #endif
#include "timer.h" #include "timer.h"
#include <avr/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/io.h>
#define FCLK_PER 3333333UL #define FCLK_PER 3333333UL
#define DIV8 0x3 #define DIV8 0x3
@ -26,10 +26,8 @@
#define OVERHEAD_TWO 151 #define OVERHEAD_TWO 151
#define OVERHEAD_THREE 75 #define OVERHEAD_THREE 75
static uint16_t overflow_count = 0; static uint16_t overflow_count = 0;
uint16_t Timer_GetOverflowCount(void) uint16_t Timer_GetOverflowCount(void)
{ {
return overflow_count; return overflow_count;
@ -61,7 +59,6 @@ void Timer_Start(void)
TCA0.SINGLE.CTRLA |= TCA_SINGLE_ENABLE_bm; TCA0.SINGLE.CTRLA |= TCA_SINGLE_ENABLE_bm;
} }
void Timer_Disable(void) void Timer_Disable(void)
{ {
cli(); cli();

View File

@ -10,15 +10,14 @@
#ifndef TIMER #ifndef TIMER
#define TIMER #define TIMER
#include "stdbool.h"
#include "inttypes.h" #include "inttypes.h"
#include "stdbool.h"
/** /**
* *
* @param a The first argument * @param a The first argument
*/ */
void Timer_Start(void); void Timer_Start(void);
void Timer_Disable(void); void Timer_Disable(void);

View File

@ -5,7 +5,6 @@
* description: module_purpose * description: module_purpose
*/ */
#ifndef __AVR_ATtiny404__ #ifndef __AVR_ATtiny404__
#define __AVR_ATtiny404__ #define __AVR_ATtiny404__
#endif #endif
@ -21,11 +20,9 @@
// #define F_CPU 3333333UL // #define F_CPU 3333333UL
// #define F_PER F_CPU / 6 // #define F_PER F_CPU / 6
#define F_PER 3333333UL #define F_PER 3333333UL
#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)
@ -51,7 +48,6 @@ void USART0_Init(void)
void USART0_Alt_Init(void) void USART0_Alt_Init(void)
{ {
// 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.DIR |= (1 << 1); PORTA.DIR |= (1 << 1);

View File

@ -15,7 +15,6 @@
*/ */
void USART0_Init(void); void USART0_Init(void);
/** /**
* @brief Initializes the USART0 peripheral on Alternate pins. * @brief Initializes the USART0 peripheral on Alternate pins.
*/ */