File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1+ {
2+ "configurations" : [
3+ {
4+ "name" : " Linux" ,
5+ "includePath" : [
6+ " ${workspaceFolder}/**"
7+ ],
8+ "defines" : [],
9+ "compilerPath" : " /usr/bin/gcc" ,
10+ "cStandard" : " c17" ,
11+ "cppStandard" : " c++20" ,
12+ "intelliSenseMode" : " linux-gcc-x64" ,
13+ "configurationProvider" : " ms-vscode.cmake-tools" ,
14+ "compileCommands" : " compile_commands.json"
15+ }
16+ ],
17+ "version" : 4
18+ }
Original file line number Diff line number Diff line change 1+ {
2+ "files.exclude" : {
3+ "**/.cache" : true ,
4+ "**/.cproject" : true ,
5+ "**/.gitignore" : true ,
6+ "**/.mxproject" : true ,
7+ "**/.project" : true ,
8+ "**/.settings" : true ,
9+ "**/arm-none-eabi.cmake" : true ,
10+ "**/build" : true ,
11+ "**/cmake_install.cmake" : true ,
12+ "**/CMakeFiles" : true ,
13+ "**/CMakeLists.txt" : true ,
14+ "**/compile_commands.json" : true ,
15+ "**/Debug" : true ,
16+ "**/libst-lib.a" : true ,
17+ "**/Makefile" : true
18+ },
19+ "C_Cpp.default.cppStandard" : " c++20" ,
20+ "C_Cpp.default.cStandard" : " c17"
21+ }
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ class PWM {
1818 TimerPeripheral* peripheral;
1919 uint32_t channel;
2020 float duty_cycle;
21+ uint32_t frequency;
2122
2223 PWM () = default ;
2324
@@ -28,6 +29,7 @@ class PWM {
2829 void turn_off ();
2930 void set_duty_cycle (float duty_cycle);
3031 void set_frequency (uint32_t frequency);
32+ uint32_t get_frequency ();
3133
3234 friend class DualPWM ;
3335 friend class PhasedPWM ;
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ class HalfBridge {
2424 void set_duty_cycle (float duty_cycle);
2525 void set_frequency (int32_t frequency);
2626 void set_phase (float phase);
27+ float get_phase ();
2728
2829private:
2930 bool is_dual;
Original file line number Diff line number Diff line change @@ -45,7 +45,6 @@ void HALconfig::system_clock() {
4545 RCC_OscInitStruct.PLL .PLLRGE = RCC_PLL1VCIRANGE_2;
4646 RCC_OscInitStruct.PLL .PLLVCOSEL = RCC_PLL1VCOWIDE;
4747 RCC_OscInitStruct.PLL .PLLFRACN = 0 ;
48-
4948#else
5049static_assert (false , " No TARGET is choosen. Choose NUCLEO or BOARD" );
5150#endif
Original file line number Diff line number Diff line change @@ -49,7 +49,12 @@ void PWM::set_duty_cycle(float duty_cycle) {
4949}
5050
5151void PWM::set_frequency (uint32_t frequency) {
52+ this ->frequency = frequency;
5253 TIM_TypeDef& timer = *peripheral->handle ->Instance ;
5354 timer.ARR = (HAL_RCC_GetPCLK1Freq ()*2 / (timer.PSC +1 )) / frequency;
5455 set_duty_cycle (duty_cycle);
5556}
57+
58+ uint32_t PWM::get_frequency () {
59+ return frequency;
60+ }
Original file line number Diff line number Diff line change @@ -45,3 +45,7 @@ void HalfBridge::set_phase(float phase) {
4545 positive_pwm.set_phase (phase);
4646 negative_pwm.set_phase (-phase);
4747}
48+
49+ float HalfBridge::get_phase () {
50+ return positive_pwm.phase ;
51+ }
You can’t perform that action at this time.
0 commit comments