Skip to content

Commit 140a788

Browse files
committed
init
0 parents  commit 140a788

File tree

110 files changed

+104376
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+104376
-0
lines changed

.cproject

+182
Large diffs are not rendered by default.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/Debug/
2+
/Release/

.mxproject

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[PreviousLibFiles]
2+
LibFiles=Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usb.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_adc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_adc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_i2c.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim_ex.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_core.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ctlreq.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_def.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ioreq.h;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc\usbd_cdc.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pcd_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_ll_usb.h;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_def.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_rcc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_gpio_ex.h;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_dma.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_cortex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_flash_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_exti.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_adc.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_adc_ex.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_i2c.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim.h;Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_tim_ex.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_core.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ctlreq.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_def.h;Middlewares\ST\STM32_USB_Device_Library\Core\Inc\usbd_ioreq.h;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc\usbd_cdc.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f103xb.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Include\system_stm32f1xx.h;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
3+
4+
[PreviousUsedCubeIDEFiles]
5+
SourceFiles=Core\Src\main.c;USB_DEVICE\App\usb_device.c;USB_DEVICE\Target\usbd_conf.c;USB_DEVICE\App\usbd_desc.c;USB_DEVICE\App\usbd_cdc_if.c;Core\Src\stm32f1xx_it.c;Core\Src\stm32f1xx_hal_msp.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Core\Src\system_stm32f1xx.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pcd_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_ll_usb.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_rcc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_gpio.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_dma.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_cortex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_pwr.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_flash_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_exti.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_adc_ex.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_i2c.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim.c;Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_tim_ex.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\system_stm32f1xx.c;Core\Src\system_stm32f1xx.c;;;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_core.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ctlreq.c;Middlewares\ST\STM32_USB_Device_Library\Core\Src\usbd_ioreq.c;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Src\usbd_cdc.c;
6+
HeaderPath=Drivers\STM32F1xx_HAL_Driver\Inc;Drivers\STM32F1xx_HAL_Driver\Inc\Legacy;Middlewares\ST\STM32_USB_Device_Library\Core\Inc;Middlewares\ST\STM32_USB_Device_Library\Class\CDC\Inc;Drivers\CMSIS\Device\ST\STM32F1xx\Include;Drivers\CMSIS\Include;USB_DEVICE\App;USB_DEVICE\Target;Core\Inc;
7+
CDefines=USE_HAL_DRIVER;STM32F103xB;USE_HAL_DRIVER;USE_HAL_DRIVER;
8+
9+
[PreviousGenFiles]
10+
AdvancedFolderStructure=true
11+
HeaderFileListSize=7
12+
HeaderFiles#0=..\USB_DEVICE\App\usb_device.h
13+
HeaderFiles#1=..\USB_DEVICE\Target\usbd_conf.h
14+
HeaderFiles#2=..\USB_DEVICE\App\usbd_desc.h
15+
HeaderFiles#3=..\USB_DEVICE\App\usbd_cdc_if.h
16+
HeaderFiles#4=..\Core\Inc\stm32f1xx_it.h
17+
HeaderFiles#5=..\Core\Inc\stm32f1xx_hal_conf.h
18+
HeaderFiles#6=..\Core\Inc\main.h
19+
HeaderFolderListSize=3
20+
HeaderPath#0=..\USB_DEVICE\App
21+
HeaderPath#1=..\USB_DEVICE\Target
22+
HeaderPath#2=..\Core\Inc
23+
HeaderFiles=;
24+
SourceFileListSize=7
25+
SourceFiles#0=..\USB_DEVICE\App\usb_device.c
26+
SourceFiles#1=..\USB_DEVICE\Target\usbd_conf.c
27+
SourceFiles#2=..\USB_DEVICE\App\usbd_desc.c
28+
SourceFiles#3=..\USB_DEVICE\App\usbd_cdc_if.c
29+
SourceFiles#4=..\Core\Src\stm32f1xx_it.c
30+
SourceFiles#5=..\Core\Src\stm32f1xx_hal_msp.c
31+
SourceFiles#6=..\Core\Src\main.c
32+
SourceFolderListSize=3
33+
SourcePath#0=..\USB_DEVICE\App
34+
SourcePath#1=..\USB_DEVICE\Target
35+
SourcePath#2=..\Core\Src
36+
SourceFiles=;
37+

.project

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>STM32F103_BLDC_Driver</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10+
<triggers>clean,full,incremental,</triggers>
11+
<arguments>
12+
</arguments>
13+
</buildCommand>
14+
<buildCommand>
15+
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
16+
<triggers>full,incremental,</triggers>
17+
<arguments>
18+
</arguments>
19+
</buildCommand>
20+
</buildSpec>
21+
<natures>
22+
<nature>com.st.stm32cube.ide.mcu.MCUProjectNature</nature>
23+
<nature>com.st.stm32cube.ide.mcu.MCUCubeProjectNature</nature>
24+
<nature>org.eclipse.cdt.core.cnature</nature>
25+
<nature>com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature</nature>
26+
<nature>com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature</nature>
27+
<nature>com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature</nature>
28+
<nature>com.st.stm32cube.ide.mcu.MCURootProjectNature</nature>
29+
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
30+
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
31+
</natures>
32+
</projectDescription>

.settings/language.settings.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project>
3+
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1592256444" name="Debug">
4+
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
5+
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
6+
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
7+
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
8+
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1737427050015012847" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
9+
<language-scope id="org.eclipse.cdt.core.gcc"/>
10+
<language-scope id="org.eclipse.cdt.core.g++"/>
11+
</provider>
12+
</extension>
13+
</configuration>
14+
<configuration id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.release.750930067" name="Release">
15+
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
16+
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
17+
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
18+
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
19+
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="1737427050015012847" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
20+
<language-scope id="org.eclipse.cdt.core.gcc"/>
21+
<language-scope id="org.eclipse.cdt.core.g++"/>
22+
</provider>
23+
</extension>
24+
</configuration>
25+
</project>

.settings/stm32cubeide.project.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
66BE74F758C12D739921AEA421D593D3=1
2+
8DF89ED150041C4CBC7CB9A9CAA90856=3C032167BDC971B9B2B0655F6BF40811
3+
DC22A860405A8BF2F2C095E5B6529F12=3C032167BDC971B9B2B0655F6BF40811
4+
eclipse.preferences.version=1

Core/Inc/as5600.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* as5600.h
3+
*
4+
* Created on: Mar 5, 2022
5+
* Author: kosik
6+
*/
7+
8+
#ifndef INC_AS5600_H_
9+
#define INC_AS5600_H_
10+
11+
#define AS5600_I2C_ADDR 0x36 << 1 // ADRES URZADZENIA
12+
13+
14+
HAL_StatusTypeDef as5600_WriteCommand(I2C_HandleTypeDef *hi2c, uint8_t conf_register_addr, uint8_t setting);
15+
HAL_StatusTypeDef as5600_Init(I2C_HandleTypeDef *hi2c);
16+
HAL_StatusTypeDef as5600_ReadPosition(I2C_HandleTypeDef *hi2c, uint16_t *angle);
17+
HAL_StatusTypeDef as5600_ReadRawPosition(I2C_HandleTypeDef *hi2c, uint16_t *angle);
18+
HAL_StatusTypeDef as5600_ReadConfig(I2C_HandleTypeDef *hi2c, uint16_t *config);
19+
uint8_t as5600_StatusMagnet(I2C_HandleTypeDef *hi2c);
20+
21+
#endif /* INC_AS5600_H_ */

Core/Inc/bldc.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* bldc.h
3+
*
4+
* Created on: Apr 9, 2022
5+
* Author: KoSik
6+
7+
*
8+
* version: 1.0
9+
*/
10+
11+
#ifndef INC_BLDC_H_
12+
#define INC_BLDC_H_
13+
14+
struct BLDCMotorSt{
15+
uint32_t pwmU;
16+
uint32_t pwmV;
17+
uint32_t pwmW;
18+
int16_t fieldPosition; //ustawiona pozycja pola magnetycznego dla kompletnego obrotu - 4095 pozycji
19+
int16_t fieldLastPosition;
20+
uint16_t expectedPosition; // oczekiwana pozycja silnika
21+
uint8_t direction; // kierunek 0-L 1-R
22+
double distance; // dystans od punktu oczekiwanego do aktualnego
23+
double speed;
24+
//double accelerate;
25+
double expectedPower;
26+
double actualPower;
27+
//double expectedAcceleration;
28+
double actualAcceleration;
29+
double actualSpeed;
30+
double expectedSpeed;
31+
double actualSpeedARRReg; //zmienna przechowujaca ustawienie ARR timera 2
32+
//uint16_t expectedDeadZone; // martwa strefa
33+
};
34+
35+
struct BLDCencoderSt{
36+
uint8_t status;
37+
uint16_t angle; //pozycja enkodera RAW
38+
uint16_t calculatedAngle; // pozycja z enkodera po obliczeniu offsetu
39+
uint8_t magnetStatus;
40+
uint16_t offset; // offset ustawiony przy inicjalizacji
41+
};
42+
43+
#define DLUGOSC_SPOCZYNKU 9
44+
#define PWM_MAX 1023
45+
#define MOTOR_RESOLUTION 819.0 // 5 x 819 = 4095
46+
47+
#define ARR_MIN 400
48+
#define ACCELERATION_MAX 25 // ilosc krokow pola magnetycznego ktore mozna przeskoczyc jednym krokiem
49+
50+
51+
52+
void bldcCalc(TIM_HandleTypeDef *tim);
53+
HAL_StatusTypeDef bldcInit(TIM_HandleTypeDef *tim, uint32_t channel1, uint32_t channel2, uint32_t channel3);
54+
HAL_StatusTypeDef bldcSyncWithEncoder(uint8_t divide);
55+
void bldcSetNewPosition(uint16_t deadZone, uint16_t stepsToChange);
56+
uint8_t bldcCheckReachedPosition(uint16_t zeroPoint);
57+
void bldcHapticSwitch(uint16_t point1, uint16_t point2);
58+
void setMotorPosition(uint16_t position, float power);
59+
uint16_t createFocPoint(uint16_t punktX);
60+
void createFocArray(uint16_t *tab);
61+
void setField(int16_t pozycja_silnika, float moc_silnika);
62+
void delay_us(uint32_t delay_us);
63+
64+
#endif /* INC_BLDC_H_ */

Core/Inc/main.h

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/* USER CODE BEGIN Header */
2+
/**
3+
******************************************************************************
4+
* @file : main.h
5+
* @brief : Header for main.c file.
6+
* This file contains the common defines of the application.
7+
******************************************************************************
8+
* @attention
9+
*
10+
* Copyright (c) 2022 STMicroelectronics.
11+
* All rights reserved.
12+
*
13+
* This software is licensed under terms that can be found in the LICENSE file
14+
* in the root directory of this software component.
15+
* If no LICENSE file comes with this software, it is provided AS-IS.
16+
*
17+
******************************************************************************
18+
*/
19+
/* USER CODE END Header */
20+
21+
/* Define to prevent recursive inclusion -------------------------------------*/
22+
#ifndef __MAIN_H
23+
#define __MAIN_H
24+
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
/* Includes ------------------------------------------------------------------*/
30+
#include "stm32f1xx_hal.h"
31+
32+
/* Private includes ----------------------------------------------------------*/
33+
/* USER CODE BEGIN Includes */
34+
35+
/* USER CODE END Includes */
36+
37+
/* Exported types ------------------------------------------------------------*/
38+
/* USER CODE BEGIN ET */
39+
40+
/* USER CODE END ET */
41+
42+
/* Exported constants --------------------------------------------------------*/
43+
/* USER CODE BEGIN EC */
44+
45+
/* USER CODE END EC */
46+
47+
/* Exported macro ------------------------------------------------------------*/
48+
/* USER CODE BEGIN EM */
49+
50+
/* USER CODE END EM */
51+
52+
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
53+
54+
/* Exported functions prototypes ---------------------------------------------*/
55+
void Error_Handler(void);
56+
57+
/* USER CODE BEGIN EFP */
58+
59+
/* USER CODE END EFP */
60+
61+
/* Private defines -----------------------------------------------------------*/
62+
#define LEDR_Pin GPIO_PIN_13
63+
#define LEDR_GPIO_Port GPIOC
64+
#define LEDG_Pin GPIO_PIN_14
65+
#define LEDG_GPIO_Port GPIOC
66+
#define HALL1_Pin GPIO_PIN_0
67+
#define HALL1_GPIO_Port GPIOA
68+
#define HALL2_Pin GPIO_PIN_1
69+
#define HALL2_GPIO_Port GPIOA
70+
#define HALL3_Pin GPIO_PIN_2
71+
#define HALL3_GPIO_Port GPIOA
72+
#define HALL4_Pin GPIO_PIN_3
73+
#define HALL4_GPIO_Port GPIOA
74+
#define TEMP_Pin GPIO_PIN_4
75+
#define TEMP_GPIO_Port GPIOA
76+
/* USER CODE BEGIN Private defines */
77+
78+
/* USER CODE END Private defines */
79+
80+
#ifdef __cplusplus
81+
}
82+
#endif
83+
84+
#endif /* __MAIN_H */

0 commit comments

Comments
 (0)