Skip to content

Commit

Permalink
vscode, intelisense, cleaned up warnings, typo
Browse files Browse the repository at this point in the history
  • Loading branch information
dzid26 committed Apr 8, 2024
1 parent cb8b032 commit ed39d59
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 11 deletions.
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-vscode.cpptools"
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"C_Cpp.default.includePath": [
"./src/controller",
"./src/common",
"./src/common/STM8S_StdPeriph_Lib/inc"
],
"C_Cpp.default.defines": [
"STM8S105",
"__interrupt(SDCC_IntelliSense_Hack)="
],
"C_Cpp.default.cStandard": "c99",
"C_Cpp.default.intelliSenseMode": "gcc-arm"
}
47 changes: 47 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "SDCC build",
"command": "make",
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": false,
"clear": false
},
"args": [
"all"
],
"options": {
"cwd": "${workspaceFolder}/src/controller/"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "shell",
"label": "STM8 Flash",
"command": "start-process",
"args": [
"flash.bat"
],
"options": {
"cwd": "${workspaceFolder}/src/controller"
},
"dependsOn": [
"SDCC build"
],
}
],


}
2 changes: 2 additions & 0 deletions src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef COMMON_COMMON_H_
#define COMMON_COMMON_H_

#include <stdint.h>

// riding modes
#define OFF_MODE 0
#define POWER_ASSIST_MODE 1
Expand Down
3 changes: 2 additions & 1 deletion src/controller/ebike_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdio.h>
#include "stm8s.h"
#include "stm8s_uart2.h"
#include "stm8s_gpio.h"
#include "main.h"
#include "interrupts.h"
Expand Down Expand Up @@ -3353,7 +3354,7 @@ static void uart_send_package(void)
// send the full package to UART
for(ui8_i = 0; ui8_i < UART_TX_BUFFER_LEN; ui8_i++)
{
putchar(ui8_tx_buffer[ui8_i]);
uart_put_char(ui8_tx_buffer[ui8_i]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#define THROTTLE_DUTY_CYCLE_RAMP_UP_INVERSE_STEP_DEFAULT 98 // 80 at 15.625KHz
#define THROTTLE_DUTY_CYCLE_RAMP_UP_INVERSE_STEP_MIN 49 // 40 at 15.625KHz

#define MOTOR_SPEED_FIELD_WEAKEANING_MIN 300 // ERPS
#define MOTOR_SPEED_FIELD_WEAKENING_MIN 300 // ERPS

// cadence
#define CADENCE_SENSOR_CALC_COUNTER_MIN 4266 // 3500 at 15.625KHz
Expand Down
2 changes: 1 addition & 1 deletion src/controller/motor.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ void TIM1_CAP_COM_IRQHandler(void) __interrupt(TIM1_CAP_COM_IRQHANDLER)
}
#if FIELD_WEAKENING_ENABLED
} else if ((ui8_g_duty_cycle == PWM_DUTY_CYCLE_MAX)
&& (ui16_motor_speed_erps > MOTOR_SPEED_FIELD_WEAKEANING_MIN) // do not enable at low motor speed / low cadence
&& (ui16_motor_speed_erps > MOTOR_SPEED_FIELD_WEAKENING_MIN) // do not enable at low motor speed / low cadence
&& (ui8_fw_angle_max > 0)
&& (ui8_adc_battery_current_filtered < ui8_controller_adc_battery_current_target)) {
// reset duty cycle ramp down counter (filter)
Expand Down
8 changes: 4 additions & 4 deletions src/controller/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void uart2_init(void) {
}

#if __SDCC_REVISION < 9624
void putchar(char c)
void uart_put_char(char c)
{
//Write a character to the UART2
UART2_SendData8(c);
Expand All @@ -41,7 +41,7 @@ void putchar(char c)
while (UART2_GetFlagStatus(UART2_FLAG_TXE) == RESET);
}
#else
int putchar(int c)
int uart_put_char(int c)
{
//Write a character to the UART2
UART2_SendData8(c);
Expand All @@ -54,9 +54,9 @@ int putchar(int c)
#endif

#if __SDCC_REVISION < 9989
char getchar(void)
char uart_get_char(void)
#else
int getchar(void)
int uart_get_char(void)
#endif
{
uint8_t c = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/controller/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
void uart2_init(void);

#if __SDCC_REVISION < 9624
void putchar(char c);
void uart_put_char(char c);
#else
int putchar(int c);
int uart_put_char(int c);
#endif

#if __SDCC_REVISION < 9989
char getchar(void);
char uart_get_char(void);
#else
int getchar(void);
int uart_get_char(void);
#endif

#endif /* _UART_H */
Expand Down

0 comments on commit ed39d59

Please sign in to comment.