Skip to content

Commit

Permalink
Cleaned up headers
Browse files Browse the repository at this point in the history
Style: Avoid system reserved identifiers
(cherry picked from commit 0df7127)
  • Loading branch information
dzid26 committed Jul 12, 2024
1 parent 3ef0747 commit 7a36d05
Show file tree
Hide file tree
Showing 29 changed files with 45 additions and 83 deletions.
5 changes: 1 addition & 4 deletions src/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
#include <stdint.h>
#include <stdio.h>
#include "stm8s.h"
#include "pins.h"
#include "stm8s_adc1.h"
#include "stm8s_gpio.h"
#include "adc.h"
#include "ebike_app.h"
#include "motor.h"
#include "common.h"


void adc_init(void) {
Expand Down
5 changes: 2 additions & 3 deletions src/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Released under the GPL License, Version 3
*/

#ifndef _ADC_H
#define _ADC_H
#ifndef ADC_H_
#define ADC_H_

#include "main.h"

// for AIN6: 0x53E0 + 2*6 = 0x53E8
//#define UI8_ADC_BATTERY_VOLTAGE (*(uint8_t*)(0x53EC)) // AIN6
Expand Down
7 changes: 1 addition & 6 deletions src/brake.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
* Released under the GPL License, Version 3
*/

#include <stdint.h>
#include "stm8s.h"
#include "stm8s_it.h"
#include "stm8s_gpio.h"
#include "pins.h"
#include "main.h"
#include "interrupts.h"
#include "brake.h"
#include "motor.h"

void brake_init(void) {
// brake pin as external input pin interrupt
Expand Down
6 changes: 2 additions & 4 deletions src/brake.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _BRAKE_H
#define _BRAKE_H

#include "main.h"
#ifndef BRAKE_H_
#define BRAKE_H_

void brake_init (void);
//BitStatus brake_is_set (void);
Expand Down
1 change: 0 additions & 1 deletion src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

#include <stdint.h>
#include "stm8s.h"
#include "common.h"

int16_t map_ui16(int16_t x, int16_t in_min, int16_t in_max, int16_t out_min, int16_t out_max) {
Expand Down
5 changes: 1 addition & 4 deletions src/ebike_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@
#include <stdint.h>
#include "stm8s.h"
#include "stm8s_uart2.h"
#include "stm8s_gpio.h"
#include "main.h"
#include "interrupts.h"
#include "adc.h"
#include "motor.h"
#include "pwm.h"
#include "uart.h"
#include "brake.h"
#include "eeprom.h"
#include "lights.h"
#include "common.h"
#include "config.h"

volatile struct_configuration_variables m_configuration_variables;

Expand Down
5 changes: 2 additions & 3 deletions src/ebike_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* Released under the GPL License, Version 3
*/

#ifndef _EBIKE_APP_H_
#define _EBIKE_APP_H_
#ifndef EBIKE_APP_H_
#define EBIKE_APP_H_

#include <stdint.h>
#include "main.h"

// startup boost mode
#define CADENCE 0
Expand Down
1 change: 1 addition & 0 deletions src/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

#include <stdint.h>
#include "main.h"
#include "stm8s.h"
#include "stm8s_flash.h"
#include "eeprom.h"
Expand Down
6 changes: 3 additions & 3 deletions src/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* Released under the GPL License, Version 3
*/

#ifndef _EEPROM_H_
#define _EEPROM_H_
#ifndef EEPROM_H_
#define EEPROM_H_

#include "main.h"
#include <stdint.h>

#define EEPROM_BASE_ADDRESS 0x4000

Expand Down
5 changes: 3 additions & 2 deletions src/interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* Released under the GPL License, Version 3
*/

#ifndef _INTERRUPTS_H_
#define _INTERRUPTS_H_
#ifndef INTERRUPTS_H_
#define INTERRUPTS_H_


#define EXTI_HALL_A_IRQ 7 // ITC_IRQ_PORTE - Hall sensor A rise/fall detection
#define EXTI_HALL_B_IRQ 6 // ITC_IRQ_PORTD - Hall sensor B rise/fall detection
Expand Down
1 change: 0 additions & 1 deletion src/lights.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

#include <stdint.h>
#include "stm8s.h"
#include "pins.h"
#include "stm8s_gpio.h"

Expand Down
6 changes: 3 additions & 3 deletions src/lights.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
* Released under the GPL License, Version 3
*/

#ifndef _LIGHTS_H_
#define _LIGHTS_H_
#ifndef LIGHTS_H_
#define LIGHTS_H_

#include "main.h"
#include <stdint.h>

void lights_init(void);
void lights_set_state(uint8_t ui8_state);
Expand Down
1 change: 0 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <stdint.h>
#include "interrupts.h"
#include "stm8s.h"
#include "pins.h"
#include "uart.h"
#include "pwm.h"
#include "motor.h"
Expand Down
5 changes: 3 additions & 2 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* Released under the GPL License, Version 3
*/

#ifndef _MAIN_H_
#define _MAIN_H_
#ifndef MAIN_H_
#define MAIN_H_

#include <stdint.h>
#include "config.h"
#include "common.h"

Expand Down
6 changes: 1 addition & 5 deletions src/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,13 @@
*/

#include <stdint.h>
#include <math.h>
#include "main.h"
#include "motor.h"
#include "interrupts.h"
#include "stm8s_gpio.h"
#include "stm8s_tim1.h"
#include "ebike_app.h"
#include "pins.h"
#include "pwm.h"
#include "adc.h"
#include "uart.h"
#include "common.h"
#include "eeprom.h"

#define SVM_TABLE_LEN 256
Expand Down
4 changes: 2 additions & 2 deletions src/motor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _MOTOR_H_
#define _MOTOR_H_
#ifndef MOTOR_H_
#define MOTOR_H_

#include <stdint.h>

Expand Down
7 changes: 1 addition & 6 deletions src/pas.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@
* Released under the GPL License, Version 3
*/

#include <stdint.h>
#include "stm8s.h"
#include "stm8s_gpio.h"
#include "pins.h"
#include "interrupts.h"
#include "motor.h"
#include "main.h"
#include "ebike_app.h"

void pas_init(void) {
//PAS1 pin as external input pin
Expand Down
6 changes: 2 additions & 4 deletions src/pas.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _PAS_H_
#define _PAS_H_

#include "main.h"
#ifndef PAS_H_
#define PAS_H_

void pas_init(void);
void pas2_init(void);
Expand Down
4 changes: 2 additions & 2 deletions src/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _PINS_H_
#define _PINS_H_
#ifndef PINS_H_
#define PINS_H_

#include "stm8s_gpio.h"

Expand Down
2 changes: 0 additions & 2 deletions src/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#include "stm8s_tim1.h"
#include "stm8s_flash.h"
#include "main.h"
#include "interrupts.h"
#include "pwm.h"
#include "pins.h"

void pwm_init(void) {
// verify if PWM N channels are active on option bytes, if not, enable
Expand Down
4 changes: 2 additions & 2 deletions src/pwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _PWM_H
#define _PWM_H
#ifndef PWM_H_
#define PWM_H_

void pwm_init(void);

Expand Down
1 change: 1 addition & 0 deletions src/timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Released under the GPL License, Version 3
*/

#include "timers.h"
#include "stm8s.h"
#include "interrupts.h"

Expand Down
6 changes: 4 additions & 2 deletions src/timers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
* Released under the GPL License, Version 3
*/

#ifndef _TIMERS_H_
#define _TIMERS_H_
#ifndef TIMERS_H_
#define TIMERS_H_

#include <stdint.h>

void timers_init(void);

Expand Down
1 change: 0 additions & 1 deletion src/torque_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* Released under the GPL License, Version 3
*/

#include "stm8s.h"
#include "stm8s_gpio.h"
#include "pins.h"
#include "torque_sensor.h"
Expand Down
7 changes: 2 additions & 5 deletions src/torque_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _TORQUE_SENSOR_H_
#define _TORQUE_SENSOR_H_

#include "main.h"
#include "stm8s_gpio.h"
#ifndef TORQUE_SENSOR_H_
#define TORQUE_SENSOR_H_

void torque_sensor_init(void);

Expand Down
5 changes: 1 addition & 4 deletions src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
* Released under the GPL License, Version 3
*/

#include <stdint.h>
#include "uart.h"
#include <stdio.h>

#include "stm8s.h"
#include "stm8s_uart2.h"
#include "main.h"
#include "interrupts.h"


Expand Down
6 changes: 2 additions & 4 deletions src/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _UART_H
#define _UART_H

#include "main.h"
#ifndef UART_H_
#define UART_H_

void uart2_init(void);

Expand Down
6 changes: 1 addition & 5 deletions src/wheel_speed_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@
* Released under the GPL License, Version 3
*/

#include <stdint.h>
#include "stm8s.h"
#include "stm8s_gpio.h"
#include "pins.h"
#include "main.h"
#include "interrupts.h"
#include "motor.h"

void wheel_speed_sensor_init(void) {
//wheel speed sensor pin as input pull-up, no external interrupt
Expand Down
4 changes: 2 additions & 2 deletions src/wheel_speed_sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Released under the GPL License, Version 3
*/

#ifndef _WHELL_SPEED_SENSOR_H_
#define _WHELL_SPEED_SENSOR_H_
#ifndef WHELL_SPEED_SENSOR_H_
#define WHELL_SPEED_SENSOR_H_

void wheel_speed_sensor_init(void);

Expand Down

0 comments on commit 7a36d05

Please sign in to comment.