Compare commits
34 Commits
feature-ca
...
master
Author | SHA1 | Date | |
---|---|---|---|
cd69f0b894 | |||
323db30bc1 | |||
1125ab934c | |||
0c3b449a2c | |||
cae4a46d18 | |||
fea59a5004 | |||
bf1b2f34bd | |||
8d755d42e7 | |||
e361066e0b | |||
c8f29ccb9f | |||
f01a34c109 | |||
b307e1bc79 | |||
3a872bcd58 | |||
fa0c149352 | |||
1161ed6c42 | |||
e60c2fa6d2 | |||
5ebd6e6779 | |||
70ef49418b | |||
96a6424baa | |||
6436fecd85 | |||
3b4e67d740 | |||
c21ad44f9c | |||
abe066df79 | |||
da24c84835 | |||
7ed695dace | |||
c194308080 | |||
3e768dbdef | |||
e2b823c901 | |||
0b661709da | |||
a88af55928 | |||
274466e017 | |||
94ded84e82 | |||
57e57a07bb | |||
6ec3740aaf |
33
.github/workflows/workflow.yml
vendored
Normal file
33
.github/workflows/workflow.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
# pull_request:
|
||||
# types: [opened, synchronize, reopened]
|
||||
|
||||
# checkout, install make and try to build
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config: [motortest, motortest_peter, feedcode-front, feedcode-back, greyhash, pcbv2_front, pcbv2_back, pcbv2_test, commander_v2_front, commander_v2_back]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: 'true'
|
||||
|
||||
- name: Install make
|
||||
run: |
|
||||
sudo apt update -y
|
||||
sudo apt install -y binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi cmake make
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
run: |
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make -j$(nproc) ${{ matrix.config }}
|
17
.gitignore
vendored
17
.gitignore
vendored
@ -3,3 +3,20 @@ CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
|
||||
build/
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
.cache/
|
||||
|
||||
# Jetbrains
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
|
||||
# other
|
||||
hover.map
|
||||
libemanuel_foc_model.a
|
||||
libstm32_hal.a
|
||||
/*.bin
|
||||
/*elf
|
||||
|
437
CMakeLists.txt
437
CMakeLists.txt
@ -10,10 +10,11 @@ SET(CMAKE_SYSTEM_NAME Generic)
|
||||
|
||||
set(COMMON_FLAGS "-mcpu=cortex-m3 -mthumb -Wall -fdata-sections -ffunction-sections")
|
||||
set(CMAKE_ASM_FLAGS "${COMMON_FLAGS} -x assembler-with-cpp")
|
||||
set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=gnu11")
|
||||
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++17")
|
||||
set(CMAKE_C_FLAGS "${COMMON_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -Wno-volatile")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
set(COMMON_LINKER_FLAGS "-specs=nosys.specs -T${CMAKE_SOURCE_DIR}/STM32F103RCTx_FLASH.ld -lc -lm -lnosys -lstdc++ -Wl,--gc-sections -Wl,-Map=${CMAKE_BINARY_DIR}/hover.map,--cref")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${COMMON_LINKER_FLAGS}")
|
||||
@ -21,7 +22,7 @@ set(CMAKE_SHARED_LINKER_FLAGS "${COMMON_LINKER_FLAGS}")
|
||||
|
||||
project(bobbycar-controller-firmware ASM C CXX)
|
||||
|
||||
add_definitions(-DUSE_HAL_DRIVER -DSTM32F103xE -DFEATURE_CAN)
|
||||
add_definitions(-DUSE_HAL_DRIVER -DSTM32F103xE)
|
||||
|
||||
include_directories(
|
||||
.
|
||||
@ -33,12 +34,7 @@ include_directories(
|
||||
bobbycar-protocol
|
||||
)
|
||||
|
||||
#add_definitions(-DMOTOR_TEST)
|
||||
#add_definitions(-DFEATURE_IGNORE_OTHER_MOTOR)
|
||||
add_definitions(-DFEATURE_BUTTON)
|
||||
#add_definitions(-DPETERS_PLATINE)
|
||||
|
||||
add_executable(firmware.elf
|
||||
add_library(stm32_hal STATIC
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c
|
||||
@ -55,42 +51,417 @@ add_executable(firmware.elf
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c
|
||||
STM32CubeF1/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c
|
||||
startup_stm32f103xe.s
|
||||
system_stm32f1xx.c
|
||||
)
|
||||
|
||||
add_library(emanuel_foc_model STATIC
|
||||
bobbycar-foc-model/BLDC_controller.h
|
||||
bobbycar-foc-model/BLDC_controller.c
|
||||
bobbycar-foc-model/BLDC_controller_data.c
|
||||
bobbycar-foc-model/rtwtypes.h
|
||||
|
||||
bobbycar-protocol/protocol.h
|
||||
|
||||
startup_stm32f103xe.s
|
||||
system_stm32f1xx.c
|
||||
|
||||
config.h
|
||||
defines.h
|
||||
main.cpp
|
||||
can.c
|
||||
can_feedc0de.cpp
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT firmware.hex
|
||||
COMMAND arm-none-eabi-objcopy -O ihex firmware.elf firmware.hex
|
||||
DEPENDS firmware.elf)
|
||||
add_library(bobbycar-protocol INTERFACE
|
||||
)
|
||||
|
||||
add_custom_command(OUTPUT firmware.bin
|
||||
COMMAND arm-none-eabi-objcopy -O binary -S firmware.elf firmware.bin
|
||||
DEPENDS firmware.elf)
|
||||
|
||||
add_custom_target(firmware ALL
|
||||
SOURCES firmware.hex firmware.bin)
|
||||
|
||||
add_custom_target(flash
|
||||
COMMAND st-flash --reset write firmware.bin 0x8000000
|
||||
SOURCES firmware.bin)
|
||||
|
||||
#
|
||||
# motor test
|
||||
#
|
||||
add_executable(motortest.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(motortest.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(motortest.elf PRIVATE
|
||||
-DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
# -DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
# -DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT motortest.hex COMMAND arm-none-eabi-objcopy -O ihex motortest.elf motortest.hex DEPENDS motortest.elf)
|
||||
add_custom_command(OUTPUT motortest.bin COMMAND arm-none-eabi-objcopy -O binary -S motortest.elf motortest.bin DEPENDS motortest.elf)
|
||||
add_custom_target(motortest ALL SOURCES motortest.hex motortest.bin)
|
||||
add_custom_target(flash-motortest COMMAND st-flash --reset write motortest.bin 0x8000000 SOURCES motortest.bin DEPENDS motortest.bin)
|
||||
|
||||
#
|
||||
# motor test peter
|
||||
#
|
||||
add_executable(motortest_peter.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(motortest_peter.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(motortest_peter.elf PRIVATE
|
||||
#-DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
-DHALL_ABC
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DFEATURE_INVERT_HALL
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
-DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT motortest_peter.hex COMMAND arm-none-eabi-objcopy -O ihex motortest_peter.elf motortest_peter.hex DEPENDS motortest_peter.elf)
|
||||
add_custom_command(OUTPUT motortest_peter.bin COMMAND arm-none-eabi-objcopy -O binary -S motortest_peter.elf motortest_peter.bin DEPENDS motortest_peter.elf)
|
||||
add_custom_target(motortest_peter ALL SOURCES motortest_peter.hex motortest_peter.bin)
|
||||
add_custom_target(flash-motortest_peter COMMAND st-flash --reset write motortest_peter.bin 0x8000000 SOURCES motortest_peter.bin DEPENDS motortest_peter.bin)
|
||||
|
||||
|
||||
#
|
||||
# feedc0de front
|
||||
#
|
||||
add_executable(feedcode-front.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(feedcode-front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(feedcode-front.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
-DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT feedcode-front.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode-front.elf feedcode-front.hex DEPENDS feedcode-front.elf)
|
||||
add_custom_command(OUTPUT feedcode-front.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode-front.elf feedcode-front.bin DEPENDS feedcode-front.elf)
|
||||
add_custom_target(feedcode-front ALL SOURCES feedcode-front.hex feedcode-front.bin)
|
||||
add_custom_target(flash-feedcode-front COMMAND st-flash --reset write feedcode-front.bin 0x8000000 SOURCES feedcode-front.bin DEPENDS feedcode-front.bin)
|
||||
|
||||
#
|
||||
# feedc0de back
|
||||
#
|
||||
add_executable(feedcode-back.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(feedcode-back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(feedcode-back.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
-DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT feedcode-back.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode-back.elf feedcode-back.hex DEPENDS feedcode-back.elf)
|
||||
add_custom_command(OUTPUT feedcode-back.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode-back.elf feedcode-back.bin DEPENDS feedcode-back.elf)
|
||||
add_custom_target(feedcode-back ALL SOURCES feedcode-back.hex feedcode-back.bin)
|
||||
add_custom_target(flash-feedcode-back COMMAND st-flash --reset write feedcode-back.bin 0x8000000 SOURCES feedcode-back.bin DEPENDS feedcode-back.bin)
|
||||
|
||||
|
||||
#
|
||||
# feedc0de 2 front
|
||||
#
|
||||
add_executable(feedcode2-front.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(feedcode2-front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(feedcode2-front.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
-DLEFT_HALL_ABC
|
||||
-DRIGHT_HALL_ABC
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT feedcode2-front.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode2-front.elf feedcode2-front.hex DEPENDS feedcode2-front.elf)
|
||||
add_custom_command(OUTPUT feedcode2-front.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode2-front.elf feedcode2-front.bin DEPENDS feedcode2-front.elf)
|
||||
add_custom_target(feedcode2-front ALL SOURCES feedcode2-front.hex feedcode2-front.bin)
|
||||
add_custom_target(flash-feedcode2-front COMMAND st-flash --reset write feedcode2-front.bin 0x8000000 SOURCES feedcode2-front.bin DEPENDS feedcode2-front.bin)
|
||||
|
||||
#
|
||||
# feedc0de 2 back
|
||||
#
|
||||
add_executable(feedcode2-back.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(feedcode2-back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(feedcode2-back.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
-DLEFT_HALL_ACB
|
||||
-DRIGHT_HALL_ACB
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
-DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT feedcode2-back.hex COMMAND arm-none-eabi-objcopy -O ihex feedcode2-back.elf feedcode2-back.hex DEPENDS feedcode2-back.elf)
|
||||
add_custom_command(OUTPUT feedcode2-back.bin COMMAND arm-none-eabi-objcopy -O binary -S feedcode2-back.elf feedcode2-back.bin DEPENDS feedcode2-back.elf)
|
||||
add_custom_target(feedcode2-back ALL SOURCES feedcode2-back.hex feedcode2-back.bin)
|
||||
add_custom_target(flash-feedcode2-back COMMAND st-flash --reset write feedcode2-back.bin 0x8000000 SOURCES feedcode2-back.bin DEPENDS feedcode2-back.bin)
|
||||
|
||||
#
|
||||
# greyhash
|
||||
#
|
||||
add_executable(greyhash.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(greyhash.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(greyhash.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
-DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
-DHUART3
|
||||
-DFEATURE_SERIAL_CONTROL
|
||||
-DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
# -DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
)
|
||||
add_custom_command(OUTPUT greyhash.hex COMMAND arm-none-eabi-objcopy -O ihex greyhash.elf greyhash.hex DEPENDS greyhash.elf)
|
||||
add_custom_command(OUTPUT greyhash.bin COMMAND arm-none-eabi-objcopy -O binary -S greyhash.elf greyhash.bin DEPENDS greyhash.elf)
|
||||
add_custom_target(greyhash ALL SOURCES greyhash.hex greyhash.bin)
|
||||
add_custom_target(flash-greyhash COMMAND st-flash --reset write greyhash.bin 0x8000000 SOURCES greyhash.bin DEPENDS greyhash.bin)
|
||||
|
||||
#
|
||||
# peters platine v2 front
|
||||
#
|
||||
add_executable(pcbv2_front.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(pcbv2_front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(pcbv2_front.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
-DAMPERE2BIT_CONV=28
|
||||
)
|
||||
add_custom_command(OUTPUT pcbv2_front.hex COMMAND arm-none-eabi-objcopy -O ihex pcbv2_front.elf pcbv2_front.hex DEPENDS pcbv2_front.elf)
|
||||
add_custom_command(OUTPUT pcbv2_front.bin COMMAND arm-none-eabi-objcopy -O binary -S pcbv2_front.elf pcbv2_front.bin DEPENDS pcbv2_front.elf)
|
||||
add_custom_target(pcbv2_front ALL SOURCES pcbv2_front.hex pcbv2_front.bin)
|
||||
add_custom_target(flash-pcbv2_front COMMAND st-flash --reset write pcbv2_front.bin 0x8000000 SOURCES pcbv2_front.bin DEPENDS pcbv2_front.bin)
|
||||
|
||||
#
|
||||
# peters platine v2 back
|
||||
#
|
||||
add_executable(pcbv2_back.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(pcbv2_back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(pcbv2_back.elf PRIVATE
|
||||
# -DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
-DIS_BACK
|
||||
-DAMPERE2BIT_CONV=28
|
||||
)
|
||||
add_custom_command(OUTPUT pcbv2_back.hex COMMAND arm-none-eabi-objcopy -O ihex pcbv2_back.elf pcbv2_back.hex DEPENDS pcbv2_back.elf)
|
||||
add_custom_command(OUTPUT pcbv2_back.bin COMMAND arm-none-eabi-objcopy -O binary -S pcbv2_back.elf pcbv2_back.bin DEPENDS pcbv2_back.elf)
|
||||
add_custom_target(pcbv2_back ALL SOURCES pcbv2_back.hex pcbv2_back.bin)
|
||||
add_custom_target(flash-pcbv2_back COMMAND st-flash --reset write pcbv2_back.bin 0x8000000 SOURCES pcbv2_back.bin DEPENDS pcbv2_back.bin)
|
||||
|
||||
#
|
||||
# peters platine v2 motortest
|
||||
#
|
||||
add_executable(pcbv2_test.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(pcbv2_test.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(pcbv2_test.elf PRIVATE
|
||||
-DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
# -DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
-DAMPERE2BIT_CONV=28
|
||||
-DLEFT_HALL_ABC
|
||||
#-DLEFT_HALL_ACB
|
||||
#-DLEFT_HALL_BAC
|
||||
#-DLEFT_HALL_BCA
|
||||
#-DLEFT_HALL_CAB
|
||||
#-DLEFT_HALL_CBA
|
||||
|
||||
-DRIGHT_HALL_ABC
|
||||
#-DRIGHT_HALL_ACB
|
||||
#-DRIGHT_HALL_BAC
|
||||
#-DRIGHT_HALL_BCA
|
||||
#-DRIGHT_HALL_CAB
|
||||
#-DRIGHT_HALL_CBA
|
||||
|
||||
#-DFEATURE_BETTER_FOC_CONFIG
|
||||
#-DLEFT_PHASE_MEAS_AB
|
||||
#-DLEFT_PHASE_MEAS_AC
|
||||
#-DLEFT_PHASE_MEAS_BC
|
||||
|
||||
#-DRIGHT_PHASE_MEAS_AB
|
||||
#-DRIGHT_PHASE_MEAS_AC
|
||||
#-DRIGHT_PHASE_MEAS_BC
|
||||
)
|
||||
add_custom_command(OUTPUT pcbv2_test.hex COMMAND arm-none-eabi-objcopy -O ihex pcbv2_test.elf pcbv2_test.hex DEPENDS pcbv2_test.elf)
|
||||
add_custom_command(OUTPUT pcbv2_test.bin COMMAND arm-none-eabi-objcopy -O binary -S pcbv2_test.elf pcbv2_test.bin DEPENDS pcbv2_test.elf)
|
||||
add_custom_target(pcbv2_test ALL SOURCES pcbv2_test.hex pcbv2_test.bin)
|
||||
add_custom_target(flash-pcbv2_test COMMAND st-flash --reset write pcbv2_test.bin 0x8000000 SOURCES pcbv2_test.bin DEPENDS pcbv2_test.bin)
|
||||
|
||||
|
||||
#
|
||||
# commander v2 front
|
||||
#
|
||||
add_executable(commander_v2_front.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(commander_v2_front.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(commander_v2_front.elf PRIVATE
|
||||
#-DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
# -DIS_BACK
|
||||
#-DAMPERE2BIT_CONV=28
|
||||
-DLEFT_HALL_ABC
|
||||
#-DLEFT_HALL_ACB
|
||||
#-DLEFT_HALL_BAC
|
||||
#-DLEFT_HALL_BCA
|
||||
#-DLEFT_HALL_CAB
|
||||
#-DLEFT_HALL_CBA
|
||||
|
||||
-DRIGHT_HALL_ABC
|
||||
#-DRIGHT_HALL_ACB
|
||||
#-DRIGHT_HALL_BAC
|
||||
#-DRIGHT_HALL_BCA
|
||||
#-DRIGHT_HALL_CAB
|
||||
#-DRIGHT_HALL_CBA
|
||||
|
||||
#-DFEATURE_BETTER_FOC_CONFIG
|
||||
#-DLEFT_PHASE_MEAS_AB
|
||||
#-DLEFT_PHASE_MEAS_AC
|
||||
#-DLEFT_PHASE_MEAS_BC
|
||||
|
||||
#-DRIGHT_PHASE_MEAS_AB
|
||||
#-DRIGHT_PHASE_MEAS_AC
|
||||
#-DRIGHT_PHASE_MEAS_BC
|
||||
)
|
||||
add_custom_command(OUTPUT commander_v2_front.hex COMMAND arm-none-eabi-objcopy -O ihex commander_v2_front.elf commander_v2_front.hex DEPENDS commander_v2_front.elf)
|
||||
add_custom_command(OUTPUT commander_v2_front.bin COMMAND arm-none-eabi-objcopy -O binary -S commander_v2_front.elf commander_v2_front.bin DEPENDS commander_v2_front.elf)
|
||||
add_custom_target(commander_v2_front ALL SOURCES commander_v2_front.hex commander_v2_front.bin)
|
||||
add_custom_target(flash-commander_v2_front COMMAND st-flash --reset write commander_v2_front.bin 0x8000000 SOURCES commander_v2_front.bin DEPENDS commander_v2_front.bin)
|
||||
|
||||
|
||||
#
|
||||
# commander v2 back
|
||||
#
|
||||
add_executable(commander_v2_back.elf config.h defines.h main.cpp)
|
||||
target_link_libraries(commander_v2_back.elf stm32_hal emanuel_foc_model bobbycar-protocol)
|
||||
target_compile_options(commander_v2_back.elf PRIVATE
|
||||
#-DMOTOR_TEST
|
||||
-DFEATURE_IGNORE_OTHER_MOTOR
|
||||
# -DHALL_BCA
|
||||
# -DPWM_FREQ_12KHZ
|
||||
# -DFEATURE_BUTTON
|
||||
-DPETERS_PLATINE
|
||||
# -DHUART2
|
||||
# -DHUART3
|
||||
# -DFEATURE_SERIAL_CONTROL
|
||||
# -DFEATURE_SERIAL_FEEDBACK
|
||||
# -DLOG_TO_SERIAL
|
||||
-DFEATURE_CAN
|
||||
# -DCAN_LOG_UNKNOWN_ADDR
|
||||
-DIS_BACK
|
||||
#-DAMPERE2BIT_CONV=28
|
||||
-DLEFT_HALL_ABC
|
||||
#-DLEFT_HALL_ACB
|
||||
#-DLEFT_HALL_BAC
|
||||
#-DLEFT_HALL_BCA
|
||||
#-DLEFT_HALL_CAB
|
||||
#-DLEFT_HALL_CBA
|
||||
|
||||
-DRIGHT_HALL_ABC
|
||||
#-DRIGHT_HALL_ACB
|
||||
#-DRIGHT_HALL_BAC
|
||||
#-DRIGHT_HALL_BCA
|
||||
#-DRIGHT_HALL_CAB
|
||||
#-DRIGHT_HALL_CBA
|
||||
|
||||
#-DFEATURE_BETTER_FOC_CONFIG
|
||||
#-DLEFT_PHASE_MEAS_AB
|
||||
#-DLEFT_PHASE_MEAS_AC
|
||||
#-DLEFT_PHASE_MEAS_BC
|
||||
|
||||
#-DRIGHT_PHASE_MEAS_AB
|
||||
#-DRIGHT_PHASE_MEAS_AC
|
||||
#-DRIGHT_PHASE_MEAS_BC
|
||||
)
|
||||
add_custom_command(OUTPUT commander_v2_back.hex COMMAND arm-none-eabi-objcopy -O ihex commander_v2_back.elf commander_v2_back.hex DEPENDS commander_v2_back.elf)
|
||||
add_custom_command(OUTPUT commander_v2_back.bin COMMAND arm-none-eabi-objcopy -O binary -S commander_v2_back.elf commander_v2_back.bin DEPENDS commander_v2_back.elf)
|
||||
add_custom_target(commander_v2_back ALL SOURCES commander_v2_back.hex commander_v2_back.bin)
|
||||
add_custom_target(flash-commander_v2_back COMMAND st-flash --reset write commander_v2_back.bin 0x8000000 SOURCES commander_v2_back.bin DEPENDS commander_v2_back.bin)
|
||||
|
||||
|
||||
# util targets
|
||||
add_custom_target(debug
|
||||
COMMAND openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg)
|
||||
|
||||
add_custom_target(unlock0
|
||||
COMMAND openocd -f interface/stlink-v2.cfg -f target/stm32f1x.cfg -c init -c "reset halt" -c "stm32f1x unlock 0")
|
||||
add_custom_target(unlock1
|
||||
|
@ -8,6 +8,7 @@ sudo pacman -Sy --noconfirm \
|
||||
arm-none-eabi-gdb \
|
||||
arm-none-eabi-newlib \
|
||||
cmake \
|
||||
make \
|
||||
openocd \
|
||||
stlink
|
||||
|
||||
@ -15,7 +16,10 @@ git clone --recursive git@github.com:bobbycar-graz/bobbycar-controller-firmware.
|
||||
cd bobbycar-controller-firmware/
|
||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make unlock0 # needed only once per board
|
||||
make flash
|
||||
make flash-motortest
|
||||
make flash-feedc0de-front
|
||||
make flash-feedc0de-back
|
||||
make flash-greyhash
|
||||
```
|
||||
|
||||
## Hardware
|
||||
|
Submodule bobbycar-foc-model updated: 88f8d8b2ce...79db2855e9
Submodule bobbycar-protocol updated: 39f76cb62b...496e2556f4
347
can.c
347
can.c
@ -1,347 +0,0 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#include "can_feedc0de.h"
|
||||
#include "can.h"
|
||||
|
||||
/* Definition for CANx clock resources */
|
||||
#define CANx CAN1
|
||||
#define CANx_CLK_ENABLE() __HAL_RCC_CAN1_CLK_ENABLE()
|
||||
#define CANx_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
|
||||
|
||||
#define CANx_FORCE_RESET() __HAL_RCC_CAN1_FORCE_RESET()
|
||||
#define CANx_RELEASE_RESET() __HAL_RCC_CAN1_RELEASE_RESET()
|
||||
|
||||
/* Definition for CANx Pins */
|
||||
#define CANx_TX_PIN GPIO_PIN_9
|
||||
#define CANx_TX_GPIO_PORT GPIOB
|
||||
#define CANx_RX_PIN GPIO_PIN_8
|
||||
#define CANx_RX_GPIO_PORT GPIOB
|
||||
|
||||
/* Definition for CANx AFIO Remap */
|
||||
#define CANx_AFIO_REMAP_CLK_ENABLE() __HAL_RCC_AFIO_CLK_ENABLE()
|
||||
#define CANx_AFIO_REMAP_RX_TX_PIN() __HAL_AFIO_REMAP_CAN1_2()
|
||||
|
||||
/* Definition for CAN's NVIC */
|
||||
#define CANx_RX_IRQn USB_LP_CAN1_RX0_IRQn
|
||||
#define CANx_RX_IRQHandler USB_LP_CAN1_RX0_IRQHandler
|
||||
#define CANx_TX_IRQn USB_HP_CAN1_TX_IRQn
|
||||
#define CANx_TX_IRQHandler USB_HP_CAN1_TX_IRQHandler
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file CAN/CAN_Networking/Src/main.c
|
||||
* @author MCD Application Team
|
||||
* @brief This example shows how to configure the CAN peripheral
|
||||
* to send and receive CAN frames in normal mode. The sent frames
|
||||
* are used to control Leds by pressing KEY Push Button.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2016 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
uint8_t ubKeyNumber = 0x0;
|
||||
CAN_HandleTypeDef CanHandle;
|
||||
CAN_TxHeaderTypeDef TxHeader;
|
||||
CAN_RxHeaderTypeDef RxHeader;
|
||||
uint8_t TxData[8];
|
||||
uint8_t RxData[8];
|
||||
uint32_t TxMailbox;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static void __NO_RETURN Error_Handler(void);
|
||||
static void CAN_MspInit(CAN_HandleTypeDef *hcan);
|
||||
static void CAN_MspDeInit(CAN_HandleTypeDef *hcan);
|
||||
static void CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan);
|
||||
static void CAN_TxMailboxCompleteCallback(CAN_HandleTypeDef *hcan);
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
static uint32_t len_to_dlc(uint8_t len)
|
||||
{
|
||||
uint32_t len_u32 = len;
|
||||
|
||||
if (len_u32 <= 8)
|
||||
return len_u32;
|
||||
|
||||
// CAN-FD-only lengths currently not supported
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
static uint8_t dlc_to_len(uint32_t dlc)
|
||||
{
|
||||
// Check if DLC valid
|
||||
if (dlc & ~0xFu)
|
||||
Error_Handler();
|
||||
|
||||
// CAN-FD-only lengths currently not supported
|
||||
if (dlc > 8)
|
||||
Error_Handler();
|
||||
|
||||
return dlc;
|
||||
}
|
||||
|
||||
void can_tx(uint16_t id, const uint8_t* data, uint8_t len)
|
||||
{
|
||||
TxHeader.StdId = id;
|
||||
TxHeader.DLC = len_to_dlc(len);
|
||||
|
||||
while (HAL_CAN_GetTxMailboxesFreeLevel(&CanHandle) < 1)
|
||||
{
|
||||
}
|
||||
|
||||
/* Start the Transmission process */
|
||||
if (HAL_CAN_AddTxMessage(&CanHandle, &TxHeader, (uint8_t *)data, &TxMailbox) != HAL_OK)
|
||||
{
|
||||
/* Transmission request Error */
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void __NO_RETURN Error_Handler(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the CAN.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void can_init(void)
|
||||
{
|
||||
CAN_FilterTypeDef sFilterConfig;
|
||||
|
||||
/* Configure the CAN peripheral */
|
||||
CanHandle.Instance = CANx;
|
||||
|
||||
CanHandle.MspInitCallback = CAN_MspInit;
|
||||
CanHandle.MspDeInitCallback = CAN_MspDeInit;
|
||||
|
||||
CanHandle.Init.TimeTriggeredMode = DISABLE;
|
||||
CanHandle.Init.AutoBusOff = ENABLE;
|
||||
CanHandle.Init.AutoWakeUp = DISABLE;
|
||||
CanHandle.Init.AutoRetransmission = ENABLE;
|
||||
CanHandle.Init.ReceiveFifoLocked = DISABLE;
|
||||
CanHandle.Init.TransmitFifoPriority = DISABLE;
|
||||
CanHandle.Init.Mode = CAN_MODE_NORMAL;
|
||||
CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||
CanHandle.Init.TimeSeg1 = CAN_BS1_6TQ;
|
||||
CanHandle.Init.TimeSeg2 = CAN_BS2_1TQ;
|
||||
CanHandle.Init.Prescaler = 4;
|
||||
|
||||
if (HAL_CAN_Init(&CanHandle) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Configure the CAN Filter */
|
||||
sFilterConfig.FilterBank = 0;
|
||||
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
|
||||
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
|
||||
sFilterConfig.FilterIdHigh = 0x0000;
|
||||
sFilterConfig.FilterIdLow = CAN_ID_BOARD | (BOARD_INDEX << 4) | CAN_DIRECTION_STW_TO_BOARD;
|
||||
sFilterConfig.FilterMaskIdHigh = 0x0000;
|
||||
sFilterConfig.FilterMaskIdLow = 0x07F1;
|
||||
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
|
||||
sFilterConfig.FilterActivation = ENABLE;
|
||||
sFilterConfig.SlaveStartFilterBank = 14;
|
||||
|
||||
if (HAL_CAN_ConfigFilter(&CanHandle, &sFilterConfig) != HAL_OK)
|
||||
{
|
||||
/* Filter configuration Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_CAN_RegisterCallback(&CanHandle, HAL_CAN_RX_FIFO0_MSG_PENDING_CB_ID, CAN_RxFifo0MsgPendingCallback) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_CAN_RegisterCallback(&CanHandle, HAL_CAN_TX_MAILBOX0_COMPLETE_CB_ID, CAN_TxMailboxCompleteCallback) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_CAN_RegisterCallback(&CanHandle, HAL_CAN_TX_MAILBOX1_COMPLETE_CB_ID, CAN_TxMailboxCompleteCallback) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (HAL_CAN_RegisterCallback(&CanHandle, HAL_CAN_TX_MAILBOX2_COMPLETE_CB_ID, CAN_TxMailboxCompleteCallback) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Start the CAN peripheral */
|
||||
if (HAL_CAN_Start(&CanHandle) != HAL_OK)
|
||||
{
|
||||
/* Start Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Activate CAN RX notification */
|
||||
if (HAL_CAN_ActivateNotification(&CanHandle, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
|
||||
{
|
||||
/* Notification Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Activate CAN TX notification */
|
||||
if (HAL_CAN_ActivateNotification(&CanHandle, CAN_IT_TX_MAILBOX_EMPTY) != HAL_OK)
|
||||
{
|
||||
/* Notification Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Configure Transmission process */
|
||||
TxHeader.StdId = 0x321;
|
||||
TxHeader.ExtId = 0x01;
|
||||
TxHeader.RTR = CAN_RTR_DATA;
|
||||
TxHeader.IDE = CAN_ID_STD;
|
||||
TxHeader.DLC = 2;
|
||||
TxHeader.TransmitGlobalTime = DISABLE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rx Fifo 0 message pending callback in non blocking mode
|
||||
* @param CanHandle: pointer to a CAN_HandleTypeDef structure that contains
|
||||
* the configuration information for the specified CAN.
|
||||
* @retval None
|
||||
*/
|
||||
static void CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *CanHandle)
|
||||
{
|
||||
/* Get RX message */
|
||||
if (HAL_CAN_GetRxMessage(CanHandle, CAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK)
|
||||
{
|
||||
/* Reception Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
if (RxHeader.IDE == CAN_ID_STD &&
|
||||
(RxHeader.StdId == CAN_ID_COMMAND_STW_TO_BOARD(BOARD_INDEX) ||
|
||||
RxHeader.StdId == CAN_ID_FEEDBACK_STW_TO_BOARD(BOARD_INDEX)))
|
||||
{
|
||||
can_feedc0de_handle_frame(RxHeader.StdId, RxData, dlc_to_len(RxHeader.DLC));
|
||||
}
|
||||
|
||||
// slightly yucky, but we don't want to block inside the IRQ handler
|
||||
if (HAL_CAN_GetTxMailboxesFreeLevel(CanHandle) >= 2)
|
||||
{
|
||||
can_feedc0de_poll();
|
||||
}
|
||||
}
|
||||
|
||||
static void CAN_TxMailboxCompleteCallback(CAN_HandleTypeDef *hcan)
|
||||
{
|
||||
// slightly yucky, but we don't want to block inside the IRQ handler
|
||||
if (HAL_CAN_GetTxMailboxesFreeLevel(hcan) >= 2)
|
||||
{
|
||||
can_feedc0de_poll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAN MSP Initialization
|
||||
* This function configures the hardware resources used in this example:
|
||||
* - Peripheral's clock enable
|
||||
* - Peripheral's GPIO Configuration
|
||||
* - NVIC configuration for DMA interrupt request enable
|
||||
* @param hcan: CAN handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
static void CAN_MspInit(CAN_HandleTypeDef *hcan)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/*##-1- Enable peripherals and GPIO Clocks #################################*/
|
||||
/* CAN1 Periph clock enable */
|
||||
CANx_CLK_ENABLE();
|
||||
/* Enable GPIO clock ****************************************/
|
||||
CANx_GPIO_CLK_ENABLE();
|
||||
/* Enable AFIO clock and Remap CAN PINs to PB8 and PB9*******/
|
||||
CANx_AFIO_REMAP_CLK_ENABLE();
|
||||
CANx_AFIO_REMAP_RX_TX_PIN();
|
||||
|
||||
/*##-2- Configure peripheral GPIO ##########################################*/
|
||||
/* CAN1 TX GPIO pin configuration */
|
||||
GPIO_InitStruct.Pin = CANx_TX_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
|
||||
HAL_GPIO_Init(CANx_TX_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
/* CAN1 RX GPIO pin configuration */
|
||||
GPIO_InitStruct.Pin = CANx_RX_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
|
||||
HAL_GPIO_Init(CANx_RX_GPIO_PORT, &GPIO_InitStruct);
|
||||
|
||||
/*##-3- Configure the NVIC #################################################*/
|
||||
/* NVIC configuration for CAN1 Reception complete interrupt */
|
||||
HAL_NVIC_SetPriority(CANx_RX_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(CANx_RX_IRQn);
|
||||
|
||||
HAL_NVIC_SetPriority(CANx_TX_IRQn, 1, 0);
|
||||
HAL_NVIC_EnableIRQ(CANx_TX_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAN MSP De-Initialization
|
||||
* This function frees the hardware resources used in this example:
|
||||
* - Disable the Peripheral's clock
|
||||
* - Revert GPIO to their default state
|
||||
* @param hcan: CAN handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
static void CAN_MspDeInit(CAN_HandleTypeDef *hcan)
|
||||
{
|
||||
/*##-1- Reset peripherals ##################################################*/
|
||||
CANx_FORCE_RESET();
|
||||
CANx_RELEASE_RESET();
|
||||
|
||||
/*##-2- Disable peripherals and GPIO Clocks ################################*/
|
||||
/* De-initialize the CAN1 TX GPIO pin */
|
||||
HAL_GPIO_DeInit(CANx_TX_GPIO_PORT, CANx_TX_PIN);
|
||||
/* De-initialize the CAN1 RX GPIO pin */
|
||||
HAL_GPIO_DeInit(CANx_RX_GPIO_PORT, CANx_RX_PIN);
|
||||
|
||||
/*##-4- Disable the NVIC for CAN reception #################################*/
|
||||
HAL_NVIC_DisableIRQ(CANx_RX_IRQn);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles CAN1 RX0 interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void CANx_RX_IRQHandler(void)
|
||||
{
|
||||
HAL_CAN_IRQHandler(&CanHandle);
|
||||
}
|
||||
|
||||
void CANx_TX_IRQHandler(void)
|
||||
{
|
||||
HAL_CAN_IRQHandler(&CanHandle);
|
||||
}
|
38
can.h
38
can.h
@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#define BOARD_INDEX 0
|
||||
|
||||
#define CAN_ID_BOARD 0x300
|
||||
|
||||
#define CAN_SUBID_COMMAND 0x000
|
||||
#define CAN_SUBID_FEEDBACK 0x002
|
||||
#define CAN_SUBID_RESERVED0 0x004
|
||||
#define CAN_SUBID_RESERVED1 0x006
|
||||
#define CAN_SUBID_RESERVED2 0x008
|
||||
#define CAN_SUBID_RESERVED3 0x00a
|
||||
#define CAN_SUBID_RESERVED4 0x00c
|
||||
#define CAN_SUBID_RESERVED5 0x00e
|
||||
|
||||
#define CAN_DIRECTION_STW_TO_BOARD 0x000
|
||||
#define CAN_DIRECTION_BOARD_TO_STW 0x001
|
||||
|
||||
#define CAN_ID_COMMAND_STW_TO_BOARD(board_index) \
|
||||
(CAN_ID_BOARD | ((board_index) << 4) | CAN_SUBID_COMMAND | CAN_DIRECTION_STW_TO_BOARD)
|
||||
#define CAN_ID_COMMAND_BOARD_TO_STW(board_index) \
|
||||
(CAN_ID_BOARD | ((board_index) << 4) | CAN_SUBID_COMMAND | CAN_DIRECTION_BOARD_TO_STW)
|
||||
#define CAN_ID_FEEDBACK_STW_TO_BOARD(board_index) \
|
||||
(CAN_ID_BOARD | ((board_index) << 4) | CAN_SUBID_FEEDBACK | CAN_DIRECTION_STW_TO_BOARD)
|
||||
#define CAN_ID_FEEDBACK_BOARD_TO_STW(board_index) \
|
||||
(CAN_ID_BOARD | ((board_index) << 4) | CAN_SUBID_FEEDBACK | CAN_DIRECTION_BOARD_TO_STW)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void can_init(void);
|
||||
void can_tx(uint16_t address, const uint8_t* data, uint8_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
216
can_fc.h
216
can_fc.h
@ -1,216 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
#include "can.h"
|
||||
|
||||
//#define FC_STRICT
|
||||
|
||||
#define FC_PROTOCOL_ERROR()
|
||||
#define Error_Handler() while(1)
|
||||
|
||||
constexpr const uint8_t FC_CHUNK_SIZE = 7;
|
||||
constexpr const uint8_t FC_TAG_INIT = 0x45;
|
||||
constexpr const uint8_t FC_TAG_END = 0x7d;
|
||||
|
||||
static uint8_t next_tag(uint8_t tag)
|
||||
{
|
||||
if (tag == 0)
|
||||
{
|
||||
return FC_TAG_INIT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return tag + 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
class FCSender
|
||||
{
|
||||
public:
|
||||
FCSender(uint16_t id) : id(id)
|
||||
{
|
||||
}
|
||||
|
||||
bool tx_pending()
|
||||
{
|
||||
return pos_sent != len && pos_sent == pos_acked;
|
||||
}
|
||||
|
||||
bool transfer_in_progress()
|
||||
{
|
||||
return data != nullptr && pos_acked != len;
|
||||
}
|
||||
|
||||
bool transfer_finished()
|
||||
{
|
||||
return data != nullptr && pos_acked == len;
|
||||
}
|
||||
|
||||
void reset(const uint8_t* data, size_t len)
|
||||
{
|
||||
pos_sent = 0;
|
||||
pos_acked = 0;
|
||||
tag_sent = 0;
|
||||
|
||||
this->data = data;
|
||||
this->len = len;
|
||||
}
|
||||
|
||||
void handle_frame(const uint8_t* payload, uint8_t payload_len)
|
||||
{
|
||||
if (pos_sent == 0)
|
||||
return;
|
||||
|
||||
if (payload_len != 1)
|
||||
return;
|
||||
|
||||
if (payload[0] != tag_sent)
|
||||
return;
|
||||
|
||||
pos_acked = pos_sent;
|
||||
}
|
||||
|
||||
void tx()
|
||||
{
|
||||
uint8_t payload[1 + FC_CHUNK_SIZE];
|
||||
|
||||
// Still waiting for ack, or done transmitting
|
||||
if (!tx_pending())
|
||||
return;
|
||||
|
||||
size_t new_pos_sent = std::min(pos_sent + FC_CHUNK_SIZE, len);
|
||||
uint8_t sent_size = new_pos_sent - pos_sent;
|
||||
uint8_t new_tag_sent = next_tag(tag_sent);
|
||||
if (new_tag_sent == FC_TAG_END)
|
||||
Error_Handler();
|
||||
|
||||
payload[0] = new_tag_sent;
|
||||
memcpy(&payload[1], data + pos_sent, sent_size);
|
||||
can_tx(id, payload, 1 + sent_size);
|
||||
|
||||
pos_sent = new_pos_sent;
|
||||
tag_sent = new_tag_sent;
|
||||
}
|
||||
|
||||
private:
|
||||
uint16_t id;
|
||||
const uint8_t* data;
|
||||
size_t len;
|
||||
size_t pos_sent;
|
||||
size_t pos_acked;
|
||||
uint8_t tag_sent;
|
||||
};
|
||||
|
||||
class FCReceiver
|
||||
{
|
||||
public:
|
||||
FCReceiver(uint16_t id, uint8_t* data, size_t len) : id(id)
|
||||
{
|
||||
reset(data, len);
|
||||
}
|
||||
|
||||
bool ack_pending()
|
||||
{
|
||||
return pos_received != pos_acked;
|
||||
}
|
||||
|
||||
bool transfer_in_progress()
|
||||
{
|
||||
return ready && data != nullptr && pos_acked != len;
|
||||
}
|
||||
|
||||
bool transfer_finished()
|
||||
{
|
||||
return ready && data != nullptr && pos_acked == len;
|
||||
}
|
||||
|
||||
void reset(uint8_t* data, size_t len)
|
||||
{
|
||||
// Poor man's mutex
|
||||
ready = false;
|
||||
|
||||
pos_received = 0;
|
||||
pos_acked = 0;
|
||||
tag_expected = next_tag(0);
|
||||
|
||||
this->data = data;
|
||||
this->len = len;
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
void handle_frame(const uint8_t* payload, uint8_t payload_len)
|
||||
{
|
||||
if (!transfer_in_progress())
|
||||
return;
|
||||
|
||||
if (tag_expected == FC_TAG_END)
|
||||
return;
|
||||
|
||||
if (payload_len < 1)
|
||||
return;
|
||||
|
||||
// Reset receiver if frame with FC_TAG_INIT received when expecting different one
|
||||
if (payload[0] == FC_TAG_INIT && tag_expected != FC_TAG_INIT)
|
||||
reset(data, len);
|
||||
|
||||
// Don't accept new data if we haven't acked the previous data yet
|
||||
if (ack_pending())
|
||||
return;
|
||||
|
||||
uint8_t data_len = payload_len - 1;
|
||||
if (data_len > len - pos_received)
|
||||
return;
|
||||
|
||||
// Ignore all other tags
|
||||
if (payload[0] != tag_expected)
|
||||
return;
|
||||
|
||||
memcpy(&data[pos_received], &payload[1], data_len);
|
||||
|
||||
pos_received += data_len;
|
||||
}
|
||||
|
||||
void ack()
|
||||
{
|
||||
uint8_t payload[1];
|
||||
|
||||
if (!ack_pending())
|
||||
return;
|
||||
|
||||
// Poor man's mutex
|
||||
ready = false;
|
||||
|
||||
// ISR may have called reset() in the mean time
|
||||
if (!ack_pending())
|
||||
{
|
||||
ready = true;
|
||||
return;
|
||||
}
|
||||
|
||||
payload[0] = tag_expected;
|
||||
can_tx(id, payload, sizeof(payload));
|
||||
|
||||
pos_acked = pos_received;
|
||||
tag_expected = next_tag(tag_expected);
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
private:
|
||||
bool ready;
|
||||
|
||||
uint16_t id;
|
||||
uint8_t* data;
|
||||
size_t len;
|
||||
size_t pos_received;
|
||||
size_t pos_acked;
|
||||
uint8_t tag_expected;
|
||||
};
|
||||
|
||||
#endif // __cplusplus
|
100
can_feedc0de.cpp
100
can_feedc0de.cpp
@ -1,100 +0,0 @@
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
#include "config.h"
|
||||
#include "protocol.h"
|
||||
#include "can_fc.h"
|
||||
|
||||
#include "can_feedc0de.h"
|
||||
|
||||
|
||||
static_assert((sizeof(Command) + FC_CHUNK_SIZE - 1) / FC_CHUNK_SIZE < 15);
|
||||
|
||||
template <class Sent, class Received>
|
||||
void CANFeedc0de<Sent, Received>::poll()
|
||||
{
|
||||
feedc0de_fcs.tx();
|
||||
feedc0de_fcr.ack();
|
||||
}
|
||||
|
||||
template <class Sent, class Received>
|
||||
void CANFeedc0de<Sent, Received>::send(const Sent& in)
|
||||
{
|
||||
sent = in;
|
||||
feedc0de_fcs.reset(((uint8_t*)&sent) + 2, sizeof(sent) - 4);
|
||||
}
|
||||
|
||||
template <class Sent, class Received>
|
||||
bool CANFeedc0de<Sent, Received>::get(Received& out)
|
||||
{
|
||||
if (!feedc0de_fcr.transfer_finished())
|
||||
return false;
|
||||
|
||||
out = received;
|
||||
feedc0de_fcr.reset(((uint8_t*)&received) + 2, sizeof(received) - 4);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class Sent, class Received>
|
||||
bool CANFeedc0de<Sent, Received>::handle_frame(uint16_t id, uint8_t* frame, uint8_t len)
|
||||
{
|
||||
if (id == fcs_rx_can_id)
|
||||
{
|
||||
feedc0de_fcs.handle_frame(frame, len);
|
||||
return true;
|
||||
}
|
||||
else if (id == fcr_rx_can_id)
|
||||
{
|
||||
feedc0de_fcr.handle_frame(frame, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef CAN_FEEDCODE_STW
|
||||
template class CANFeedc0de<Command, Feedback>;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void can_feedc0de_handle_frame(uint16_t id, uint8_t* frame, uint8_t len)
|
||||
{
|
||||
extern CANFeedc0de<Command, Feedback> can_instances[NUM_BOARDS_MAX];
|
||||
|
||||
bool handled = false;
|
||||
for (size_t i = 0; i < NUM_BOARDS_MAX; i++)
|
||||
{
|
||||
if (can_instances[i].handle_frame(id, frame, len))
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if (!handled)
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
template class CANFeedc0de<Feedback, Command>;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void can_feedc0de_handle_frame(uint16_t id, uint8_t* frame, uint8_t len)
|
||||
{
|
||||
extern CANFeedc0de<Feedback, Command> can_feedc0de;
|
||||
if (!can_feedc0de.handle_frame(id, frame, len))
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
void can_feedc0de_poll()
|
||||
{
|
||||
extern CANFeedc0de<Feedback, Command> can_feedc0de;
|
||||
can_feedc0de.poll();
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
@ -1,46 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <cstdint>
|
||||
#include "protocol.h"
|
||||
#include "can_fc.h"
|
||||
|
||||
template <class Sent, class Received>
|
||||
class CANFeedc0de
|
||||
{
|
||||
public:
|
||||
CANFeedc0de(uint16_t fcs_tx_can_id, uint16_t fcs_rx_can_id,
|
||||
uint16_t fcr_tx_can_id, uint16_t fcr_rx_can_id)
|
||||
: fcs_rx_can_id(fcs_rx_can_id),
|
||||
fcr_rx_can_id(fcr_rx_can_id),
|
||||
feedc0de_fcs(fcs_tx_can_id),
|
||||
feedc0de_fcr(fcr_tx_can_id, (uint8_t *)&received + 2, sizeof(received) - 4)
|
||||
{
|
||||
};
|
||||
|
||||
void poll();
|
||||
bool handle_frame(uint16_t id, uint8_t* frame, uint8_t len);
|
||||
void send(const Sent& in);
|
||||
bool get(Received& out);
|
||||
|
||||
private:
|
||||
Sent sent;
|
||||
Received received;
|
||||
|
||||
uint16_t fcs_rx_can_id;
|
||||
uint16_t fcr_rx_can_id;
|
||||
|
||||
FCSender feedc0de_fcs;
|
||||
FCReceiver feedc0de_fcr;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void can_feedc0de_handle_frame(uint16_t id, uint8_t* frame, uint8_t len);
|
||||
void can_feedc0de_poll();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
28
config.h
28
config.h
@ -1,18 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef PETERS_PLATINE
|
||||
#ifdef PWM_FREQ_12KHZ
|
||||
#define PWM_FREQ 12000 // PWM frequency in Hz
|
||||
#else
|
||||
#define PWM_FREQ 16000 // PWM frequency in Hz
|
||||
#endif
|
||||
#define DEAD_TIME 48 // PWM deadtime
|
||||
//#ifdef MOTOR_TEST
|
||||
// #define DELAY_IN_MAIN_LOOP 10
|
||||
//#else
|
||||
#define DELAY_IN_MAIN_LOOP 5
|
||||
//#endif
|
||||
#define TIMEOUT 5 // number of wrong / missing input commands before emergency off
|
||||
#define A2BIT_CONV 50 // A to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
|
||||
|
||||
#ifndef AMPERE2BIT_CONV
|
||||
#define AMPERE2BIT_CONV 50 // Ampere to bit for current conversion on ADC. Example: 1 A = 50, 2 A = 100, etc
|
||||
#endif
|
||||
|
||||
// ADC conversion time definitions
|
||||
#define ADC_CONV_TIME_1C5 (14) //Total ADC clock cycles / conversion = ( 1.5+12.5)
|
||||
@ -50,13 +47,7 @@
|
||||
#define BAT_CALIB_REAL_VOLTAGE 3970 // input voltage measured by multimeter (multiplied by 100). For example 43.00 V * 100 = 4300
|
||||
#define BAT_CALIB_ADC 1492 // adc-value measured by mainboard (value nr 5 on UART debug output)
|
||||
|
||||
#define BAT_CELLS 10 // battery number of cells. Normal Hoverboard battery: 10s
|
||||
#define BAT_LOW_LVL1_ENABLE 0 // to beep or not to beep, 1 or 0
|
||||
#define BAT_LOW_LVL2_ENABLE 1 // to beep or not to beep, 1 or 0
|
||||
#define BAT_LOW_LVL1 (360 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // gently beeps at this voltage level. [V*100/cell]. In this case 3.60 V/cell
|
||||
#define BAT_LOW_LVL2 (350 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // your battery is almost empty. Charge now! [V*100/cell]. In this case 3.50 V/cell
|
||||
#define BAT_LOW_DEAD (337 * BAT_CELLS * BAT_CALIB_ADC) / BAT_CALIB_REAL_VOLTAGE // undervoltage poweroff. (while not driving) [V*100/cell]. In this case 3.37 V/cell
|
||||
|
||||
#define BAT_CELLS 12 // battery number of cells. Normal Hoverboard battery: 10s
|
||||
|
||||
/* Board overheat detection: the sensor is inside the STM/GD chip.
|
||||
* It is very inaccurate without calibration (up to 45°C). So only enable this funcion after calibration!
|
||||
@ -70,13 +61,6 @@
|
||||
#define TEMP_CAL_LOW_DEG_C 358 // temperature 1: measured temperature [°C * 10]. Here 35.8 °C
|
||||
#define TEMP_CAL_HIGH_ADC 1588 // temperature 2: ADC value
|
||||
#define TEMP_CAL_HIGH_DEG_C 489 // temperature 2: measured temperature [°C * 10]. Here 48.9 °C
|
||||
#define TEMP_WARNING_ENABLE 0 // to beep or not to beep, 1 or 0, DO NOT ACTIVITE WITHOUT CALIBRATION!
|
||||
#define TEMP_WARNING 600 // annoying fast beeps [°C * 10]. Here 60.0 °C
|
||||
#define TEMP_POWEROFF_ENABLE 0 // to poweroff or not to poweroff, 1 or 0, DO NOT ACTIVITE WITHOUT CALIBRATION!
|
||||
#define TEMP_POWEROFF 650 // overheat poweroff. (while not driving) [°C * 10]. Here 65.0 °C
|
||||
|
||||
#define INACTIVITY_TIMEOUT 8 // minutes of not driving until poweroff. it is not very precise.
|
||||
|
||||
|
||||
|
||||
// ############################### INPUT ###############################
|
||||
|
69
defines.h
69
defines.h
@ -23,33 +23,96 @@
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
#ifdef PETERS_PLATINE
|
||||
|
||||
#ifdef LEFT_HALL_CAB
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_11
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_12
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
||||
#elif LEFT_HALL_CBA
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_11
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_10
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
||||
#elif LEFT_HALL_BAC
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_12
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_11
|
||||
#elif LEFT_HALL_BCA
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_10
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_12
|
||||
#elif LEFT_HALL_ABC
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_12
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_10
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_11
|
||||
#else //LEFT_HALL_ACB
|
||||
#ifndef LEFT_HALL_ACB
|
||||
#warning "No left Hall configuration defined, using default ACB"
|
||||
#endif
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_12
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_11
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_10
|
||||
#endif
|
||||
|
||||
#define LEFT_HALL_U_PORT GPIOC
|
||||
#define LEFT_HALL_V_PORT GPIOC
|
||||
#define LEFT_HALL_W_PORT GPIOC
|
||||
#define LEFT_HALL_U_PORT GPIOC
|
||||
#define LEFT_HALL_V_PORT GPIOC
|
||||
#define LEFT_HALL_W_PORT GPIOC
|
||||
|
||||
#ifdef RIGHT_HALL_CAB
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_6
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_5
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
||||
#elif RIGHT_HALL_CBA
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_6
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_7
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
||||
#elif RIGHT_HALL_BAC
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_5
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_6
|
||||
#elif RIGHT_HALL_BCA
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_7
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_5
|
||||
#elif RIGHT_HALL_ABC
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_5
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_7
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_6
|
||||
#else //RIGHT_HALL_ACB
|
||||
#ifndef RIGHT_HALL_ACB
|
||||
#warning "No right Hall configuration defined, using default ACB"
|
||||
#endif
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_5
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_6
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_7
|
||||
#endif
|
||||
|
||||
#define RIGHT_HALL_U_PORT GPIOB
|
||||
#define RIGHT_HALL_V_PORT GPIOB
|
||||
#define RIGHT_HALL_W_PORT GPIOB
|
||||
#else // defined(PETERS_PLATINE)
|
||||
#ifdef HALL_BCA
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_7
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_6
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_5
|
||||
#else
|
||||
#define LEFT_HALL_U_PIN GPIO_PIN_5
|
||||
#define LEFT_HALL_V_PIN GPIO_PIN_6
|
||||
#define LEFT_HALL_W_PIN GPIO_PIN_7
|
||||
#endif
|
||||
|
||||
#define LEFT_HALL_U_PORT GPIOB
|
||||
#define LEFT_HALL_V_PORT GPIOB
|
||||
#define LEFT_HALL_W_PORT GPIOB
|
||||
|
||||
#ifdef HALL_BCA
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_12
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_11
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_10
|
||||
#else
|
||||
#define RIGHT_HALL_U_PIN GPIO_PIN_10
|
||||
#define RIGHT_HALL_V_PIN GPIO_PIN_11
|
||||
#define RIGHT_HALL_W_PIN GPIO_PIN_12
|
||||
#endif
|
||||
|
||||
#define RIGHT_HALL_U_PORT GPIOC
|
||||
#define RIGHT_HALL_V_PORT GPIOC
|
||||
|
@ -129,7 +129,7 @@ extern "C" {
|
||||
#define PREFETCH_ENABLE 1U
|
||||
|
||||
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 1U /* CAN register callback disabled */
|
||||
#define USE_HAL_CAN_REGISTER_CALLBACKS 1 /* CAN register callback disabled */
|
||||
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
|
||||
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
|
||||
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
|
||||
|
Reference in New Issue
Block a user