From 8541c5cb7c70627dec4b38e531a9aceb65b1d54f Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 28 Dec 2023 16:20:30 +0100 Subject: [PATCH] Refactor with clang-format --- .vscode/c_cpp_properties.json | 19 ----------------- .vscode/settings.json | 10 --------- src/commands.c | 1 - src/include/commands.h | 1 - src/include/pins.h | 1 - src/include/pwm.h | 1 - src/include/statemachine.h | 1 - src/include/timer.h | 1 - src/include/uart.h | 1 - src/inverter.c | 39 +++++++++++++++++------------------ src/pins.c | 1 - src/pwm.c | 24 +++++++-------------- src/statemachine.c | 1 - 13 files changed, 27 insertions(+), 74 deletions(-) delete mode 100644 .vscode/c_cpp_properties.json delete mode 100644 .vscode/settings.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index c140ecc..0000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "/usr/avr/include", - "${workspaceFolder}/**" - ], - "defines": [ - "__AVR_ATmega32U4__" - ], - "compilerPath": "/usr/bin/avr-gcc", - "cStandard": "c17", - "cppStandard": "c++14", - "intelliSenseMode": "linux-gcc-x64" - } - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 9104aa4..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "files.associations": { - "io.h": "c", - "sfr_defs.h": "c", - "string.h": "c", - "random": "c", - "math.h": "c", - "bridge.h": "c" - } -} \ No newline at end of file diff --git a/src/commands.c b/src/commands.c index d690bfe..a5a8a6e 100644 --- a/src/commands.c +++ b/src/commands.c @@ -167,4 +167,3 @@ int cmd_handle_switch_timer(void) { return timer1_on; } - diff --git a/src/include/commands.h b/src/include/commands.h index b712132..2c50e12 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -10,4 +10,3 @@ void cmd_handle(cmd_t *command); void cmd_handle_set(char *op1, char *op2); void cmd_handle_switch(char *op1, char *op2); int cmd_handle_switch_timer(void); - diff --git a/src/include/pins.h b/src/include/pins.h index 42c429d..ff553dc 100644 --- a/src/include/pins.h +++ b/src/include/pins.h @@ -3,4 +3,3 @@ void togglePin(volatile uint8_t *port, unsigned int pin); void unsetPin(volatile uint8_t *port, unsigned int pin); void setPin(volatile uint8_t *port, unsigned int pin); - diff --git a/src/include/pwm.h b/src/include/pwm.h index c326970..5202993 100644 --- a/src/include/pwm.h +++ b/src/include/pwm.h @@ -3,4 +3,3 @@ void pwm_init(void); void pwm_worker(void); void pwm_interrupt(void); - diff --git a/src/include/statemachine.h b/src/include/statemachine.h index add736c..3bfae28 100644 --- a/src/include/statemachine.h +++ b/src/include/statemachine.h @@ -12,4 +12,3 @@ typedef struct { } sm_t; void sm_handleTransition(sm_t *statemachine, sm_state_t to); - diff --git a/src/include/timer.h b/src/include/timer.h index a780edd..3e6418f 100644 --- a/src/include/timer.h +++ b/src/include/timer.h @@ -16,4 +16,3 @@ void tmr_enableT1(void); void tmr_disableT1(void); void tmr_setT1CompareMatch(uint16_t cm); uint16_t tmr_getT1Top(void); - diff --git a/src/include/uart.h b/src/include/uart.h index 91b1709..6a120be 100644 --- a/src/include/uart.h +++ b/src/include/uart.h @@ -3,4 +3,3 @@ void uart_init(unsigned int baud); void uart_sendByte(uint8_t byte); int uart_printf(char var, FILE *stream); - diff --git a/src/inverter.c b/src/inverter.c index 1cdf6c5..1a825cf 100644 --- a/src/inverter.c +++ b/src/inverter.c @@ -1,33 +1,32 @@ -#include #include +#include #include -#include "uart.h" -#include "timer.h" #include "commands.h" #include "pins.h" #include "pwm.h" +#include "timer.h" +#include "uart.h" -int main(void) -{ - sei(); +int main(void) { + sei(); - /* With this MCU frequency (16 MHz), 25 is a baudrate of 38.4k baud */ - uart_init(25); - pwm_init(); - tmr_initT1(); - tmr_enableT1(); + /* With this MCU frequency (16 MHz), 25 is a baudrate of 38.4k baud */ + uart_init(25); + pwm_init(); + tmr_initT1(); + tmr_enableT1(); - /* Arduino Leonardo has a LED that we turn off here */ - DDRC |= (1 << DDC7); - unsetPin(&PORTC, PIN7); + /* Arduino Leonardo has a LED that we turn off here */ + DDRC |= (1 << DDC7); + unsetPin(&PORTC, PIN7); - printf("Up and running.\n\r"); + printf("Up and running.\n\r"); - while (1) { - cmd_worker(); - pwm_worker(); - } + while (1) { + cmd_worker(); + pwm_worker(); + } - return 0; + return 0; } diff --git a/src/pins.c b/src/pins.c index 246ed28..38d4640 100644 --- a/src/pins.c +++ b/src/pins.c @@ -12,4 +12,3 @@ void unsetPin(volatile uint8_t *port, unsigned int pin) { void togglePin(volatile uint8_t *port, unsigned int pin) { *port ^= (1 << pin); } - diff --git a/src/pwm.c b/src/pwm.c index bb59271..1eb453e 100644 --- a/src/pwm.c +++ b/src/pwm.c @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include #include "pwm.h" #include "timer.h" @@ -8,19 +8,11 @@ int interrupt_received = 0; uint32_t interrupt_counter = 0; -void pwm_init(void) -{ - tmr_subToT1Overflow(pwm_interrupt); +void pwm_init(void) { tmr_subToT1Overflow(pwm_interrupt); } + +void pwm_worker(void) { + if (!interrupt_received) + return; } -void pwm_worker(void) -{ - if (!interrupt_received) - return; - -} - -void pwm_interrupt(void) -{ - -} +void pwm_interrupt(void) {} diff --git a/src/statemachine.c b/src/statemachine.c index da3ecff..7015b70 100644 --- a/src/statemachine.c +++ b/src/statemachine.c @@ -1,4 +1,3 @@ #include "statemachine.h" void sm_handleTransition(sm_t *statemachine, sm_state_t to) {} -