Skip to content

Commit

Permalink
Merge pull request #247 from HyperloopUPV-H8/development
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
alejandrogonzalvo authored May 2, 2023
2 parents 94daf7a + 3fdd0e7 commit d75f873
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 37 deletions.
48 changes: 12 additions & 36 deletions .cproject

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-x64",
"configurationProvider": "ms-vscode.cmake-tools",
"compileCommands": "compile_commands.json"
}
],
"version": 4
}
21 changes: 21 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"files.exclude": {
"**/.cache": true,
"**/.cproject": true,
"**/.gitignore": true,
"**/.mxproject": true,
"**/.project": true,
"**/.settings": true,
"**/arm-none-eabi.cmake": true,
"**/build": true,
"**/cmake_install.cmake": true,
"**/CMakeFiles": true,
"**/CMakeLists.txt": true,
"**/compile_commands.json": true,
"**/Debug": true,
"**/libst-lib.a": true,
"**/Makefile": true
},
"C_Cpp.default.cppStandard": "c++20",
"C_Cpp.default.cStandard": "c17"
}
2 changes: 2 additions & 0 deletions Inc/HALAL/Services/PWM/PWM/PWM.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PWM {
TimerPeripheral* peripheral;
uint32_t channel;
float duty_cycle;
uint32_t frequency;

PWM() = default;

Expand All @@ -28,6 +29,7 @@ class PWM {
void turn_off();
void set_duty_cycle(float duty_cycle);
void set_frequency(uint32_t frequency);
uint32_t get_frequency();

friend class DualPWM;
friend class PhasedPWM;
Expand Down
1 change: 1 addition & 0 deletions Inc/ST-LIB_LOW/HalfBridge/HalfBridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HalfBridge {
void set_duty_cycle(float duty_cycle);
void set_frequency(int32_t frequency);
void set_phase(float phase);
float get_phase();

private:
bool is_dual;
Expand Down
1 change: 0 additions & 1 deletion Src/HALAL/Models/HALconfig/Halconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ void HALconfig::system_clock() {
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0;

#else
static_assert(false, "No TARGET is choosen. Choose NUCLEO or BOARD");
#endif
Expand Down
5 changes: 5 additions & 0 deletions Src/HALAL/Services/PWM/PWM/PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ void PWM::set_duty_cycle(float duty_cycle) {
}

void PWM::set_frequency(uint32_t frequency) {
this->frequency = frequency;
TIM_TypeDef& timer = *peripheral->handle->Instance;
timer.ARR = (HAL_RCC_GetPCLK1Freq()*2 / (timer.PSC+1)) / frequency;
set_duty_cycle(duty_cycle);
}

uint32_t PWM::get_frequency() {
return frequency;
}
4 changes: 4 additions & 0 deletions Src/ST-LIB_LOW/HalfBridge/HalfBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ void HalfBridge::set_phase(float phase) {
positive_pwm.set_phase(phase);
negative_pwm.set_phase(-phase);
}

float HalfBridge::get_phase() {
return positive_pwm.phase;
}

0 comments on commit d75f873

Please sign in to comment.