Compare commits

...

10 Commits

908 changed files with 28492 additions and 286337 deletions

220
.config
View File

@ -10,9 +10,7 @@
#
# rt_vsnprintf options
#
# CONFIG_RT_KLIBC_USING_LIBC_VSNPRINTF is not set
# CONFIG_RT_KLIBC_USING_VSNPRINTF_LONGLONG is not set
# CONFIG_RT_KLIBC_USING_VSNPRINTF_STANDARD is not set
CONFIG_RT_KLIBC_USING_LIBC_VSNPRINTF=y
# end of rt_vsnprintf options
#
@ -172,7 +170,7 @@ CONFIG_RT_USING_HEAP=y
# end of Memory Management
CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_DEVICE_OPS is not set
CONFIG_RT_USING_DEVICE_OPS=y
# CONFIG_RT_USING_INTERRUPT_INFO is not set
# CONFIG_RT_USING_THREADSAFE_PRINTF is not set
CONFIG_RT_USING_CONSOLE=y
@ -219,10 +217,28 @@ CONFIG_FINSH_USING_OPTION_COMPLETION=y
#
# DFS: device virtual file system
#
# CONFIG_RT_USING_DFS is not set
CONFIG_RT_USING_DFS=y
CONFIG_DFS_USING_POSIX=y
CONFIG_DFS_USING_WORKDIR=y
# CONFIG_RT_USING_DFS_MNTTABLE is not set
CONFIG_DFS_FD_MAX=16
CONFIG_RT_USING_DFS_V1=y
# CONFIG_RT_USING_DFS_V2 is not set
CONFIG_DFS_FILESYSTEMS_MAX=4
CONFIG_DFS_FILESYSTEM_TYPES_MAX=4
# CONFIG_RT_USING_DFS_ELMFAT is not set
CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_CROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_TMPFS is not set
# CONFIG_RT_USING_DFS_MQUEUE is not set
# end of DFS: device virtual file system
# CONFIG_RT_USING_FAL is not set
CONFIG_RT_USING_FAL=y
CONFIG_FAL_USING_DEBUG=y
CONFIG_FAL_PART_HAS_TABLE_CFG=y
# CONFIG_FAL_USING_SFUD_PORT is not set
#
# Device Drivers
@ -236,29 +252,29 @@ CONFIG_RT_USING_SERIAL=y
CONFIG_RT_USING_SERIAL_V1=y
# CONFIG_RT_USING_SERIAL_V2 is not set
CONFIG_RT_SERIAL_USING_DMA=y
CONFIG_RT_SERIAL_RB_BUFSZ=1024
CONFIG_RT_SERIAL_RB_BUFSZ=64
# CONFIG_RT_USING_SERIAL_BYPASS is not set
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PHY is not set
# CONFIG_RT_USING_PHY_V2 is not set
# CONFIG_RT_USING_ADC is not set
CONFIG_RT_USING_ADC=y
# CONFIG_RT_USING_DAC is not set
# CONFIG_RT_USING_NULL is not set
# CONFIG_RT_USING_ZERO is not set
# CONFIG_RT_USING_RANDOM is not set
# CONFIG_RT_USING_PWM is not set
CONFIG_RT_USING_PWM=y
# CONFIG_RT_USING_PULSE_ENCODER is not set
# CONFIG_RT_USING_INPUT_CAPTURE is not set
# CONFIG_RT_USING_MTD_NOR is not set
CONFIG_RT_USING_MTD_NOR=y
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
CONFIG_RT_USING_SPI=y
# CONFIG_RT_USING_SOFT_SPI is not set
# CONFIG_RT_USING_QSPI is not set
CONFIG_RT_USING_QSPI=y
# CONFIG_RT_USING_SPI_MSD is not set
# CONFIG_RT_USING_SFUD is not set
# CONFIG_RT_USING_ENC28J60 is not set
@ -275,7 +291,63 @@ CONFIG_RT_USING_SPI=y
CONFIG_RT_USING_PIN=y
CONFIG_RT_USING_KTIME=y
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CHERRYUSB is not set
CONFIG_RT_USING_CHERRYUSB=y
CONFIG_RT_CHERRYUSB_DEVICE=y
CONFIG_RT_CHERRYUSB_DEVICE_SPEED_FS=y
# CONFIG_RT_CHERRYUSB_DEVICE_SPEED_HS is not set
# CONFIG_RT_CHERRYUSB_DEVICE_SPEED_AUTO is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_FSDEV_ST is not set
# CONFIG_RT_CHERRYUSB_DEVICE_FSDEV_CUSTOM is not set
CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ST=y
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ESP is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_KENDRYTE is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_AT is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_HC is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_NATION is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_GD is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_ES is not set
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_SUNXI is not set
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_BK is not set
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_SIFLI is not set
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CHIPIDEA_MCX is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CHIPIDEA_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_MCX is not set
# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_MM32 is not set
# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_CUSTOM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_BL is not set
# CONFIG_RT_CHERRYUSB_DEVICE_HPM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_AIC is not set
# CONFIG_RT_CHERRYUSB_DEVICE_RP2040 is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CH32 is not set
# CONFIG_RT_CHERRYUSB_DEVICE_PUSB2 is not set
# CONFIG_RT_CHERRYUSB_DEVICE_NRF5X is not set
CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM=y
# CONFIG_RT_CHERRYUSB_DEVICE_HID is not set
CONFIG_RT_CHERRYUSB_DEVICE_MSC=y
# CONFIG_RT_CHERRYUSB_DEVICE_AUDIO is not set
# CONFIG_RT_CHERRYUSB_DEVICE_VIDEO is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_RNDIS is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_ECM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_NCM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_MTP is not set
# CONFIG_RT_CHERRYUSB_DEVICE_ADB is not set
# CONFIG_RT_CHERRYUSB_DEVICE_DFU is not set
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV is not set
CONFIG_CONFIG_USBDEV_REQUEST_BUFFER_LEN=1024
CONFIG_CONFIG_USBDEV_MSC_MAX_BUFSIZE=1024
# CONFIG_CONFIG_USBDEV_RNDIS_USING_LWIP is not set
# CONFIG_CONFIG_USBDEV_CDC_ECM_USING_LWIP is not set
CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_NONE=y
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM is not set
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_MSC is not set
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_MSC_BLKDEV is not set
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM_MSC is not set
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV1 is not set
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV2_CDC is not set
# CONFIG_RT_CHERRYUSB_HOST is not set
# end of Device Drivers
#
@ -324,7 +396,7 @@ CONFIG_PTHREAD_NUM_MAX=8
CONFIG_RT_USING_CPLUSPLUS=y
# CONFIG_RT_USING_CPLUSPLUS11 is not set
# CONFIG_RT_USING_CPP_WRAPPER is not set
# CONFIG_RT_USING_CPP_EXCEPTIONS is not set
CONFIG_RT_USING_CPP_EXCEPTIONS=y
# end of C/C++ and POSIX layer
#
@ -360,8 +432,20 @@ CONFIG_RT_USING_CPLUSPLUS=y
#
# Using USB legacy version
#
CONFIG_RT_USING_USB=y
# CONFIG_RT_USING_USB_HOST is not set
# CONFIG_RT_USING_USB_DEVICE is not set
CONFIG_RT_USING_USB_DEVICE=y
CONFIG_RT_USBD_THREAD_STACK_SZ=4096
CONFIG_USB_VENDOR_ID=0x0FFE
CONFIG_USB_PRODUCT_ID=0x0001
# CONFIG_RT_USB_DEVICE_COMPOSITE is not set
CONFIG__RT_USB_DEVICE_NONE=y
# CONFIG__RT_USB_DEVICE_CDC is not set
# CONFIG__RT_USB_DEVICE_MSTORAGE is not set
# CONFIG__RT_USB_DEVICE_HID is not set
# CONFIG__RT_USB_DEVICE_WINUSB is not set
# CONFIG__RT_USB_DEVICE_AUDIO is not set
CONFIG_RT_USB_DEVICE_NONE=y
# end of Using USB legacy version
# CONFIG_RT_USING_FDT is not set
@ -560,6 +644,7 @@ CONFIG_RT_USING_CPLUSPLUS=y
# CONFIG_PKG_USING_U8G2 is not set
# end of u8g2: a monochrome graphic library
# CONFIG_PKG_USING_NES_SIMULATOR is not set
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
# CONFIG_PKG_USING_STEMWIN is not set
@ -585,6 +670,9 @@ CONFIG_RT_USING_CPLUSPLUS=y
#
# tools packages
#
# CONFIG_PKG_USING_VECTOR is not set
# CONFIG_PKG_USING_SORCH is not set
# CONFIG_PKG_USING_DICT is not set
# CONFIG_PKG_USING_CMBACKTRACE is not set
# CONFIG_PKG_USING_MCOREDUMP is not set
# CONFIG_PKG_USING_EASYFLASH is not set
@ -697,7 +785,38 @@ CONFIG_PKG_CMSIS_CORE_VER="latest"
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_DFS_YAFFS is not set
# CONFIG_PKG_USING_LITTLEFS is not set
CONFIG_PKG_USING_LITTLEFS=y
CONFIG_PKG_LITTLEFS_PATH="/packages/system/littlefs"
# CONFIG_PKG_USING_LITTLEFS_V090 is not set
# CONFIG_PKG_USING_LITTLEFS_V170 is not set
# CONFIG_PKG_USING_LITTLEFS_V172 is not set
# CONFIG_PKG_USING_LITTLEFS_V201 is not set
# CONFIG_PKG_USING_LITTLEFS_V205 is not set
# CONFIG_PKG_USING_LITTLEFS_V214 is not set
# CONFIG_PKG_USING_LITTLEFS_V220 is not set
# CONFIG_PKG_USING_LITTLEFS_V221 is not set
# CONFIG_PKG_USING_LITTLEFS_V230 is not set
# CONFIG_PKG_USING_LITTLEFS_V250 is not set
# CONFIG_PKG_USING_LITTLEFS_V293 is not set
# CONFIG_PKG_USING_LITTLEFS_V2112 is not set
CONFIG_PKG_USING_LITTLEFS_LATEST_VERSION=y
CONFIG_LFS_READ_SIZE=256
CONFIG_LFS_PROG_SIZE=256
CONFIG_LFS_BLOCK_SIZE=4096
# CONFIG_LFS_YES_TRACE is not set
CONFIG_LFS_NO_DEBUG=y
# CONFIG_LFS_NO_WARN is not set
# CONFIG_LFS_NO_ERROR is not set
# CONFIG_LFS_NO_ASSERT is not set
# CONFIG_LFS_NO_INTRINSICS is not set
# CONFIG_LFS_NO_MALLOC is not set
CONFIG_LFS_CACHE_SIZE=256
CONFIG_LFS_BLOCK_CYCLES=-1
# CONFIG_DFS_LFS_READONLY is not set
CONFIG_LFS_THREADSAFE=y
CONFIG_LFS_LOOKAHEAD_MAX=128
CONFIG_RT_DEF_LFS_DRIVERS=1
CONFIG_PKG_LITTLEFS_VER="latest"
# CONFIG_PKG_USING_DFS_JFFS2 is not set
# CONFIG_PKG_USING_DFS_UFFS is not set
# CONFIG_PKG_USING_LWEXT4 is not set
@ -735,6 +854,8 @@ CONFIG_PKG_CMSIS_CORE_VER="latest"
# CONFIG_PKG_USING_HEARTBEAT is not set
# CONFIG_PKG_USING_MICRO_ROS_RTTHREAD_PACKAGE is not set
# CONFIG_PKG_USING_CHERRYECAT is not set
# CONFIG_PKG_USING_EVENT_LOOP is not set
# CONFIG_PKG_USING_THREAD_MANAGER is not set
# end of system packages
#
@ -897,6 +1018,7 @@ CONFIG_PKG_STM32H7_CMSIS_DRIVER_VER="latest"
# CONFIG_PKG_USING_GD32_ARM_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_GD32_ARM_SERIES_DRIVER is not set
# CONFIG_PKG_USING_GD32_RISCV_SERIES_DRIVER is not set
# CONFIG_PKG_USING_GD32VW55X_WIFI is not set
# end of GD32 Drivers
#
@ -904,6 +1026,15 @@ CONFIG_PKG_STM32H7_CMSIS_DRIVER_VER="latest"
#
# CONFIG_PKG_USING_HPM_SDK is not set
# end of HPMicro SDK
#
# FT32 HAL & SDK Drivers
#
# CONFIG_PKG_USING_FT32F0_STD_DRIVER is not set
# CONFIG_PKG_USING_FT32F0_CMSIS_DRIVER is not set
# CONFIG_PKG_USING_FT32F4_STD_DRIVER is not set
# CONFIG_PKG_USING_FT32F4_CMSIS_DRIVER is not set
# end of FT32 HAL & SDK Drivers
# end of HAL & SDK Drivers
#
@ -982,6 +1113,7 @@ CONFIG_PKG_STM32H7_CMSIS_DRIVER_VER="latest"
# CONFIG_PKG_USING_P3T1755 is not set
# CONFIG_PKG_USING_QMI8658 is not set
# CONFIG_PKG_USING_ICM20948 is not set
# CONFIG_PKG_USING_SCD4X is not set
# end of sensors drivers
#
@ -999,6 +1131,7 @@ CONFIG_PKG_STM32H7_CMSIS_DRIVER_VER="latest"
# CONFIG_PKG_USING_CST812T is not set
# end of touch drivers
# CONFIG_PKG_USING_LCD_SPI_DRIVER is not set
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_BUTTON is not set
# CONFIG_PKG_USING_PCF8574 is not set
@ -1078,7 +1211,13 @@ CONFIG_PKG_STM32H7_CMSIS_DRIVER_VER="latest"
# CONFIG_PKG_USING_IC74HC165 is not set
# CONFIG_PKG_USING_IST8310 is not set
# CONFIG_PKG_USING_ST7789_SPI is not set
# CONFIG_PKG_USING_CAN_UDS is not set
# CONFIG_PKG_USING_ISOTP_C is not set
# CONFIG_PKG_USING_IKUNLED is not set
# CONFIG_PKG_USING_INS5T8025 is not set
# CONFIG_PKG_USING_IRUART is not set
# CONFIG_PKG_USING_ST7305 is not set
# CONFIG_PKG_USING_TM1668 is not set
# CONFIG_PKG_USING_SPI_TOOLS is not set
# end of peripheral libraries and drivers
@ -1366,7 +1505,10 @@ CONFIG_PKG_STM32H7_CMSIS_DRIVER_VER="latest"
# Data Processing
#
# CONFIG_PKG_USING_ARDUINO_KALMANFILTER is not set
# CONFIG_PKG_USING_ARDUINO_ARDUINOJSON is not set
CONFIG_PKG_USING_ARDUINO_ARDUINOJSON=y
CONFIG_PKG_ARDUINO_ARDUINOJSON_PATH="/packages/arduino/dataprocessing/ArduinoJson"
CONFIG_PKG_USING_ARDUINO_ARDUINOJSON_LATEST_VERSION=y
CONFIG_PKG_ARDUINO_ARDUINOJSON_VER="latest"
# CONFIG_PKG_USING_ARDUINO_TENSORFLOW_LITE_MICRO is not set
# CONFIG_PKG_USING_ARDUINO_RUNNINGMEDIAN is not set
# end of Data Processing
@ -1426,7 +1568,7 @@ CONFIG_SOC_SERIES_STM32H7=y
#
# Hardware Drivers Config
#
CONFIG_SOC_STM32H750XB=y
CONFIG_SOC_STM32H743VI=y
#
# Onboard Peripheral Drivers
@ -1441,6 +1583,8 @@ CONFIG_BSP_SCB_ENABLE_I_CACHE=y
# CONFIG_BSP_SCB_ENABLE_D_CACHE is not set
CONFIG_BSP_ENABLE_FPU=y
CONFIG_BSP_USING_GPIO=y
# CONFIG_BSP_USING_USBD is not set
CONFIG_BSP_USING_ON_CHIP_FLASH=y
CONFIG_BSP_USING_UART=y
CONFIG_BSP_STM32_UART_V1_TX_TIMEOUT=6000
CONFIG_BSP_USING_UART1=y
@ -1456,8 +1600,43 @@ CONFIG_BSP_UART3_RX_USING_DMA=y
# CONFIG_BSP_UART3_TX_USING_DMA is not set
CONFIG_BSP_UART3_RX_BUFSIZE=1024
CONFIG_BSP_UART3_TX_BUFSIZE=512
# CONFIG_BSP_USING_PWM is not set
CONFIG_BSP_USING_PWM=y
CONFIG_BSP_USING_PWM1=y
CONFIG_BSP_USING_PWM1_CH1=y
CONFIG_BSP_USING_PWM1_CH2=y
CONFIG_BSP_USING_PWM1_CH3=y
CONFIG_BSP_USING_PWM1_CH4=y
CONFIG_BSP_USING_PWM2=y
# CONFIG_BSP_USING_PWM2_CH1 is not set
# CONFIG_BSP_USING_PWM2_CH2 is not set
# CONFIG_BSP_USING_PWM2_CH3 is not set
# CONFIG_BSP_USING_PWM2_CH4 is not set
CONFIG_BSP_USING_PWM3=y
CONFIG_BSP_USING_PWM3_CH1=y
CONFIG_BSP_USING_PWM3_CH2=y
CONFIG_BSP_USING_PWM3_CH3=y
CONFIG_BSP_USING_PWM3_CH4=y
CONFIG_BSP_USING_PWM4=y
CONFIG_BSP_USING_PWM4_CH1=y
CONFIG_BSP_USING_PWM4_CH2=y
CONFIG_BSP_USING_PWM4_CH3=y
CONFIG_BSP_USING_PWM4_CH4=y
CONFIG_BSP_USING_PWM5=y
CONFIG_BSP_USING_PWM5_CH1=y
CONFIG_BSP_USING_PWM5_CH2=y
CONFIG_BSP_USING_PWM5_CH3=y
CONFIG_BSP_USING_PWM5_CH4=y
CONFIG_BSP_USING_PWM8=y
CONFIG_BSP_USING_PWM8_CH1=y
CONFIG_BSP_USING_PWM8_CH2=y
CONFIG_BSP_USING_PWM12=y
CONFIG_BSP_USING_PWM12_CH1=y
CONFIG_BSP_USING_PWM12_CH2=y
CONFIG_BSP_USING_PWM15=y
CONFIG_BSP_USING_PWM15_CH1=y
CONFIG_BSP_USING_PWM15_CH2=y
# CONFIG_BSP_USING_QSPI is not set
# CONFIG_BSP_USING_ADC is not set
# CONFIG_BSP_USING_SPI is not set
# CONFIG_BSP_USING_CRC is not set
# CONFIG_BSP_USING_RNG is not set
@ -1476,9 +1655,10 @@ CONFIG_BSP_USING_ERPC=y
CONFIG_ERPC_USING_RTT=y
CONFIG_ERPC_MODE=y
CONFIG_ERPC_MODE_SERVER=y
CONFIG_ERPC_MODE_CLIENT=y
# CONFIG_ERPC_MODE_CLIENT is not set
CONFIG_ERPC_TRANSPORTS=y
# CONFIG_ERPC_TRANSPORTS_SPI is not set
CONFIG_ERPC_TRANSPORTS_UART=y
# CONFIG_ERPC_TRANSPORTS_UART is not set
# CONFIG_ERPC_TRANSPORTS_TCP is not set
CONFIG_ERPC_TRANSPORTS_USB_CDC=y
# end of Third Packages Drivers

1
.idea/editor.xml generated
View File

@ -139,6 +139,7 @@
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOverrideWithDifferentVisibility/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />

5
.idea/misc.xml generated
View File

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="cmvr-head" />
</component>
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
<component name="WestSettings"><![CDATA[{}]]></component>
<component name="WestSettings">{}</component>
</project>

2
.idea/vcs.xml generated
View File

@ -2,7 +2,9 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/packages/ArduinoJson-latest" vcs="Git" />
<mapping directory="$PROJECT_DIR$/packages/CMSIS-Core-latest" vcs="Git" />
<mapping directory="$PROJECT_DIR$/packages/littlefs-latest" vcs="Git" />
<mapping directory="$PROJECT_DIR$/packages/stm32h7_cmsis_driver-latest" vcs="Git" />
<mapping directory="$PROJECT_DIR$/packages/stm32h7_hal_driver-latest" vcs="Git" />
</component>

View File

@ -13,7 +13,7 @@ SET(CMAKE_ASM_FLAGS " -c -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard
SET(CMAKE_C_COMPILER_WORKS TRUE)
SET(CMAKE_CXX_COMPILER "C:/tool/rtthread/env-windows/tools/bin/../../tools/gnu_gcc/arm_gcc/mingw/bin/arm-none-eabi-g++.exe")
SET(CMAKE_CXX_FLAGS " -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g -fno-exceptions -fno-rtti -ffunction-sections -fdata-sections -Wl,--gc-sections")
SET(CMAKE_CXX_FLAGS " -mcpu=cortex-m7 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -Dgcc -O0 -gdwarf-2 -g")
SET(CMAKE_CXX_COMPILER_WORKS TRUE)
SET(CMAKE_OBJCOPY "C:/tool/rtthread/env-windows/tools/bin/../../tools/gnu_gcc/arm_gcc/mingw/bin/arm-none-eabi-objcopy.exe")
@ -29,29 +29,57 @@ PROJECT(rtthread C CXX ASM)
INCLUDE_DIRECTORIES(
.
applications
applications/common
applications/controller
applications/erpc
applications/erpc/service
applications/erpc/client
applications/erpc/common
applications/erpc/proto/generated
applications/planner
applications/servo_manager
board
board/CubeMX_Config/Inc
board/ports/usb
board/ports/fal
libraries/HAL_Drivers/CMSIS/Include
packages/ArduinoJson-latest/src
packages/erpc-1.14.0/erpc_c
packages/erpc-1.14.0/erpc_c/config
packages/erpc-1.14.0/erpc_c/infra
packages/erpc-1.14.0/erpc_c/port
packages/erpc-1.14.0/erpc_c/setup
packages/erpc-1.14.0/erpc_c/transports
packages/littlefs-latest
rt-thread/include
rt-thread/libcpu/arm/common
rt-thread/libcpu/arm/cortex-m7
rt-thread/components/dfs/dfs_v1/include
rt-thread/components/dfs/dfs_v1/filesystems/devfs
rt-thread/components/drivers/include
rt-thread/components/drivers/ktime
rt-thread/components/drivers/ktime/inc
rt-thread/components/drivers/phy
rt-thread/components/drivers/smp_call
rt-thread/components/drivers/spi
rt-thread/components/drivers/usb/cherryusb
rt-thread/components/drivers/usb/cherryusb/common
rt-thread/components/drivers/usb/cherryusb/core
rt-thread/components/drivers/usb/cherryusb/class/hub
rt-thread/components/drivers/usb/cherryusb/class/cdc
rt-thread/components/drivers/usb/cherryusb/class/msc
rt-thread/components/drivers/usb/cherryusb/class/hid
rt-thread/components/drivers/usb/cherryusb/class/audio
rt-thread/components/drivers/usb/cherryusb/class/video
rt-thread/components/drivers/usb/cherryusb/class/wireless
rt-thread/components/drivers/usb/cherryusb/class/midi
rt-thread/components/drivers/usb/cherryusb/class/adb
rt-thread/components/drivers/usb/cherryusb/class/dfu
rt-thread/components/drivers/usb/cherryusb/class/vendor/net
rt-thread/components/drivers/usb/cherryusb/class/vendor/serial
rt-thread/components/drivers/usb/cherryusb/class/vendor/wifi
rt-thread/components/drivers/usb/cherryusb/osal
rt-thread/components/fal/inc
rt-thread/components/finsh
rt-thread/components/libc/compilers/common/include
rt-thread/components/libc/compilers/newlib
@ -69,11 +97,13 @@ INCLUDE_DIRECTORIES(
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Inc/Legacy
libraries/HAL_Drivers/drivers
libraries/HAL_Drivers/drivers/config
libraries/HAL_Drivers/drivers/drv_flash
libraries/HAL_Drivers
)
ADD_DEFINITIONS(
-DSTM32H750xx
-DSTM32H743xx
-DLFS_CONFIG=lfs_config.h
-D__RTTHREAD__
-DRT_USING_NEWLIBC
-DRT_USING_LIBC
@ -84,17 +114,35 @@ ADD_DEFINITIONS(
# Library source files
SET(RT_APP_ERPC_SOURCES
applications/erpc/service/src/erpc_server_main.cpp
applications/erpc/proto/generated/file_service_interface.cpp
applications/erpc/service/src/file_service_impl.cpp
applications/erpc/proto/generated/servo_service_interface.cpp
applications/erpc/proto/generated/servo_service_server.cpp
applications/erpc/service/src/servo_service_impl.cpp
applications/erpc/proto/generated/file_service_server.cpp
applications/erpc/common/src/erpc_error_handler.cpp
applications/erpc/service/src/head_service_impl.cpp
applications/erpc/proto/generated/head_service_server.cpp
applications/erpc/client/src/erpc_client_main.cpp
applications/erpc/proto/generated/head_service_interface.cpp
applications/erpc/proto/generated/head_service_client.cpp
)
SET(RT_APPLICATIONS_SOURCES
applications/servo.c
applications/main.c
applications/main.cpp
)
SET(RT_ARDUINOJSON_SOURCES
)
SET(RT_CHERRYUSB_SOURCES
rt-thread/components/drivers/usb/cherryusb/core/usbd_core.c
rt-thread/components/drivers/usb/cherryusb/class/msc/usbd_msc.c
rt-thread/components/drivers/usb/cherryusb/port/dwc2/usb_dc_dwc2.c
rt-thread/components/drivers/usb/cherryusb/class/cdc/usbd_cdc_acm.c
rt-thread/components/drivers/usb/cherryusb/osal/usb_osal_rtthread.c
rt-thread/components/drivers/usb/cherryusb/platform/rtthread/usb_msh.c
rt-thread/components/drivers/usb/cherryusb/platform/rtthread/usb_check.c
rt-thread/components/drivers/usb/cherryusb/port/dwc2/usb_glue_st.c
)
SET(RT_COMMON_SOURCES
applications/common/curve/src/s_curve.cpp
)
SET(RT_COMPILER_SOURCES
@ -107,6 +155,12 @@ SET(RT_COMPILER_SOURCES
rt-thread/components/libc/compilers/newlib/syscalls.c
)
SET(RT_CONTROLLER_SOURCES
applications/controller/src/pid_controller.cpp
applications/planner/s_curve_planner/src/s_curve_position_planner.cpp
applications/planner/s_curve_planner/src/s_curve_velocity_planner.cpp
)
SET(RT_CPP_SOURCES
rt-thread/components/libc/cplusplus/cxx_crt.cpp
rt-thread/components/libc/cplusplus/cxx_crt_init.c
@ -123,8 +177,12 @@ SET(RT_DEVICEDRIVERS_SOURCES
rt-thread/components/drivers/ipc/ringbuffer.c
rt-thread/components/drivers/ipc/waitqueue.c
rt-thread/components/drivers/ipc/workqueue.c
rt-thread/components/drivers/misc/adc.c
rt-thread/components/drivers/misc/rt_drv_pwm.c
rt-thread/components/drivers/mtd/mtd_nor.c
rt-thread/components/drivers/pin/dev_pin.c
rt-thread/components/drivers/serial/dev_serial.c
rt-thread/components/drivers/spi/dev_qspi_core.c
rt-thread/components/drivers/spi/dev_spi.c
rt-thread/components/drivers/spi/dev_spi_core.c
)
@ -132,42 +190,62 @@ SET(RT_DEVICEDRIVERS_SOURCES
SET(RT_DRIVERS_SOURCES
board/CubeMX_Config/Src/stm32h7xx_hal_msp.c
board/board.c
board/ports/qspi_flash_init.c
libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h750xx.s
board/ports/fal/fal_flashfs.c
board/ports/usb/usb_cdc_char_device.c
board/ports/usb/usb_cdc_init.c
libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc/startup_stm32h743xx.s
libraries/HAL_Drivers/drivers/drv_adc.c
libraries/HAL_Drivers/drivers/drv_flash/drv_flash_h7.c
libraries/HAL_Drivers/drivers/drv_gpio.c
libraries/HAL_Drivers/drivers/drv_pwm.c
libraries/HAL_Drivers/drivers/drv_qspi.c
libraries/HAL_Drivers/drivers/drv_spi.c
libraries/HAL_Drivers/drivers/drv_tim.c
libraries/HAL_Drivers/drivers/drv_usart.c
libraries/HAL_Drivers/drv_common.c
)
SET(RT_ERPC_SOURCES
packages/erpc-1.14.0/erpc_c/setup/erpc_setup_mbf_dynamic.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_server_setup.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_server.cpp
packages/erpc-1.14.0/erpc_c/port/erpc_port_rtt.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_setup_mbf_static.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_simple_server.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_setup_serial.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_pre_post_action.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_message_buffer.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_server.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_basic_codec.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_framed_transport.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_client_manager.cpp
packages/erpc-1.14.0/erpc_c/transports/erpc_serial_transport.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_message_loggers.cpp
packages/erpc-1.14.0/erpc_c/port/erpc_threading_pthreads.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_transport_arbitrator.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_arbitrated_client_manager.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_simple_server.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_server_setup.cpp
packages/erpc-1.14.0/erpc_c/transports/erpc_inter_thread_buffer_transport.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_transport_arbitrator.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_setup_mbf_dynamic.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_message_buffer.cpp
packages/erpc-1.14.0/erpc_c/port/erpc_threading_pthreads.cpp
packages/erpc-1.14.0/erpc_c/transports/erpc_usb_cdc_transport.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_crc16.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_arbitrated_client_setup.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_client_setup.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_message_loggers.cpp
packages/erpc-1.14.0/erpc_c/setup/erpc_setup_usb_cdc.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_framed_transport.cpp
packages/erpc-1.14.0/erpc_c/infra/erpc_pre_post_action.cpp
)
SET(RT_FAL_SOURCES
rt-thread/components/fal/src/fal.c
rt-thread/components/fal/src/fal_rtt.c
rt-thread/components/fal/src/fal_flash.c
rt-thread/components/fal/src/fal_partition.c
)
SET(RT_FILESYSTEM_SOURCES
rt-thread/components/dfs/dfs_v1/filesystems/devfs/devfs.c
rt-thread/components/dfs/dfs_v1/src/dfs.c
rt-thread/components/dfs/dfs_v1/src/dfs_file.c
rt-thread/components/dfs/dfs_v1/src/dfs_fs.c
rt-thread/components/dfs/dfs_v1/src/dfs_posix.c
)
SET(RT_FINSH_SOURCES
rt-thread/components/finsh/cmd.c
rt-thread/components/finsh/msh.c
rt-thread/components/finsh/msh_parse.c
rt-thread/components/finsh/msh_file.c
rt-thread/components/finsh/cmd.c
rt-thread/components/finsh/shell.c
rt-thread/components/finsh/msh_parse.c
)
SET(RT_KERNEL_SOURCES
@ -190,16 +268,15 @@ SET(RT_KERNEL_SOURCES
SET(RT_KLIBC_SOURCES
rt-thread/src/klibc/rt_vsscanf.c
rt-thread/src/klibc/rt_vsnprintf_tiny.c
rt-thread/src/klibc/kerrno.c
rt-thread/src/klibc/kstdio.c
rt-thread/src/klibc/kstring.c
rt-thread/src/klibc/kerrno.c
)
SET(RT_KTIME_SOURCES
rt-thread/components/drivers/ktime/src/hrtimer.c
rt-thread/components/drivers/ktime/src/boottime.c
rt-thread/components/drivers/ktime/src/cputimer.c
rt-thread/components/drivers/ktime/src/boottime.c
rt-thread/components/drivers/ktime/src/hrtimer.c
)
SET(RT_LIBCPU_SOURCES
@ -212,30 +289,45 @@ SET(RT_LIBCPU_SOURCES
)
SET(RT_LIBRARIES_SOURCES
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cec.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_comp.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sram.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_qspi.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cec.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_comp.c
libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Source/Templates/system_stm32h7xx.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_lptim.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rng.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_nor.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sram.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c
libraries/STM32H7xx_HAL/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c
)
SET(RT_LITTLEFS_SOURCES
packages/littlefs-latest/lfs_util.c
packages/littlefs-latest/dfs_lfs.c
packages/littlefs-latest/lfs_crc.c
packages/littlefs-latest/lfs.c
)
SET(RT_POSIX_SOURCES
@ -252,6 +344,13 @@ SET(RT_POSIX_SOURCES
rt-thread/components/libc/posix/tls/emutls.c
)
SET(RT_SERVO_CONTROL_SOURCES
applications/servo_manager/src/servo_config.cpp
applications/servo_manager/src/servo_manager.cpp
applications/servo_manager/src/servo_driver.cpp
applications/servo_manager/src/servo_control.cpp
)
SET(RT_UTC_UTEST_SOURCES
)
@ -276,20 +375,28 @@ SET(RT_COMPILER_LIBS
# Libraries
ADD_LIBRARY(rtt_app_erpc OBJECT ${RT_APP_ERPC_SOURCES})
ADD_LIBRARY(rtt_CherryUSB OBJECT ${RT_CHERRYUSB_SOURCES})
ADD_LIBRARY(rtt_common OBJECT ${RT_COMMON_SOURCES})
ADD_LIBRARY(rtt_Compiler OBJECT ${RT_COMPILER_SOURCES})
ADD_LIBRARY(rtt_controller OBJECT ${RT_CONTROLLER_SOURCES})
ADD_LIBRARY(rtt_CPP OBJECT ${RT_CPP_SOURCES})
ADD_LIBRARY(rtt_DeviceDrivers OBJECT ${RT_DEVICEDRIVERS_SOURCES})
ADD_LIBRARY(rtt_Drivers OBJECT ${RT_DRIVERS_SOURCES})
ADD_LIBRARY(rtt_erpc OBJECT ${RT_ERPC_SOURCES})
ADD_LIBRARY(rtt_Fal OBJECT ${RT_FAL_SOURCES})
ADD_LIBRARY(rtt_Filesystem OBJECT ${RT_FILESYSTEM_SOURCES})
ADD_LIBRARY(rtt_Finsh OBJECT ${RT_FINSH_SOURCES})
ADD_LIBRARY(rtt_Kernel OBJECT ${RT_KERNEL_SOURCES})
ADD_LIBRARY(rtt_klibc OBJECT ${RT_KLIBC_SOURCES})
ADD_LIBRARY(rtt_ktime OBJECT ${RT_KTIME_SOURCES})
ADD_LIBRARY(rtt_libcpu OBJECT ${RT_LIBCPU_SOURCES})
ADD_LIBRARY(rtt_Libraries OBJECT ${RT_LIBRARIES_SOURCES})
ADD_LIBRARY(rtt_littlefs OBJECT ${RT_LITTLEFS_SOURCES})
ADD_LIBRARY(rtt_POSIX OBJECT ${RT_POSIX_SOURCES})
ADD_LIBRARY(rtt_servo_control OBJECT ${RT_SERVO_CONTROL_SOURCES})
# Interface libraries
ADD_LIBRARY(rtt_ArduinoJson INTERFACE)
ADD_LIBRARY(rtt_utc_UTest INTERFACE)
ADD_LIBRARY(rtt_utestcases INTERFACE)
@ -303,18 +410,26 @@ TARGET_LINK_LIBRARIES(rtt_Compiler INTERFACE ${RT_COMPILER_LIBS})
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME}.elf ${RT_APPLICATIONS_SOURCES})
TARGET_LINK_LIBRARIES(${CMAKE_PROJECT_NAME}.elf
rtt_app_erpc
rtt_CherryUSB
rtt_common
rtt_Compiler
rtt_controller
rtt_CPP
rtt_DeviceDrivers
rtt_Drivers
rtt_erpc
rtt_Fal
rtt_Filesystem
rtt_Finsh
rtt_Kernel
rtt_klibc
rtt_ktime
rtt_libcpu
rtt_Libraries
rtt_littlefs
rtt_POSIX
rtt_servo_control
rtt_ArduinoJson
rtt_utc_UTest
rtt_utestcases
)

128
README.md
View File

@ -1,124 +1,12 @@
# BSP README 模板
为了暂时使用芯片上超出128k 的flash 当作config 文件的存储区,修改了
libraries/STM32H7xx_HAL/CMSIS/Device/ST/STM32H7xx/Include/stm32h750xx.h
## 简介
#define FLASH_END (0x0801FFFFUL) /*!< FLASH end address
本文档 xxx 开发板的 BSP (板级支持包) 说明。
主要内容如下:
#define FLASH_END (0x0803FFFFUL) /*!< FLASH end address
- 开发板资源介绍
- BSP 快速上手
- 进阶使用方法
通过阅读快速上手章节开发者可以快速地上手该 BSP将 RT-Thread 运行在开发板上。在进阶使用指南章节,将会介绍更多高级功能,帮助开发者利用 RT-Thread 驱动更多板载资源。
## 开发板介绍
【此处简单介绍一下开发板】
开发板外观如下图所示:
![board](figures/board.jpg)
该开发板常用 **板载资源** 如下:
- MCUSTM32H743主频 400MHz2MB FLASH 1MB RAM
- 外部 SDRAMW9825G6KH32MB
- 外部 NAND FLASHH27U4G8F2512MB
- 外部 FLASHW25Q25632MB
- 常用外设
- LED2个DS0红色PB1DS1绿色PB0
- 按键4个KEY_UP兼具唤醒功能PA0K0PH3K1PH2K2PC13
- 常用接口USB 转串口、SD 卡接口、以太网接口、LCD 接口等
- 调试接口,标准 JTAG/SWD
开发板更多详细信息请参考正点原子 [STM32阿波罗开发板介绍](https://eboard.taobao.com/index.htm)。
## 外设支持
本 BSP 目前对外设的支持情况如下:
| **板载外设** | **支持情况** | **备注** |
| :----------------- | :----------: | :------------------------------------- |
| USB 转串口 | 支持 | |
| QSPI Flash | 暂不支持 | |
| 以太网 | 暂不支持 | |
| SD卡 | 暂不支持 | |
| CAN | 暂不支持 | |
| SDRAM | 暂不支持 | |
| MPU9250六轴传感器 | 暂不支持 | |
| **片上外设** | **支持情况** | **备注** |
| GPIO | 支持 | PA0, PA1... PK15 ---> PIN: 0, 1...176 |
| UART | 支持 | |
| SPI | 暂不支持 | |
| I2C | 暂不支持 | |
| SDIO | 暂不支持 | 即将支持 |
| RTC | 暂不支持 | 即将支持 |
| PWM | 暂不支持 | 即将支持 |
| USB Device | 暂不支持 | 即将支持 |
| USB Host | 暂不支持 | 即将支持 |
| IWG | 暂不支持 | 即将支持 |
## 使用说明
使用说明分为如下两个章节:
- 快速上手
本章节是为刚接触 RT-Thread 的新手准备的使用说明,遵循简单的步骤即可将 RT-Thread 操作系统运行在该开发板上,看到实验效果 。
- 进阶使用
本章节是为需要在 RT-Thread 操作系统上使用更多开发板资源的开发者准备的。通过使用 ENV 工具对 BSP 进行配置,可以开启更多板载资源,实现更多高级功能。
### 快速上手
本 BSP 为开发者提供 MDK4、MDK5 和 IAR 工程,并且支持 GCC 开发环境。下面以 MDK5 开发环境为例,介绍如何将系统运行起来。
#### 硬件连接
使用数据线连接开发板到 PC打开电源开关。
#### 编译下载
双击 project.uvprojx 文件,打开 MDK5 工程,编译并下载程序到开发板。
> 工程默认配置使用 ST_LINK 仿真器下载程序,在通过 ST_LINK 连接开发板的基础上,点击下载按钮即可下载程序到开发板
#### 运行结果
下载程序成功之后系统会自动运行LED闪烁。
连接开发板对应串口到 PC , 在终端工具里打开相应的串口115200-8-1-N复位设备后可以看到 RT-Thread 的输出信息:
```bash
\ | /
- RT - Thread Operating System
/ | \ 4.0.1 build Mar 5 2019
2006 - 2019 Copyright by rt-thread team
msh >
```
### 进阶使用
此 BSP 默认只开启了 GPIO 和 串口1 的功能,如果需使用 SD 卡、Flash 等更多高级功能,需要利用 ENV 工具对BSP 进行配置,步骤如下:
1. 在 bsp 下打开 env 工具。
2. 输入`menuconfig`命令配置工程,配置好之后保存退出。
3. 输入`pkgs --update`命令更新软件包。
4. 输入`scons --target=mdk4/mdk5/iar` 命令重新生成工程。
本章节更多详细的介绍请参考 [STM32 系列 BSP 外设驱动使用教程](../docs/STM32系列BSP外设驱动使用教程.md)。
## 注意事项
- xxx
## 联系人信息
维护人:
- [xxx](https://个人主页), 邮箱:<xxx@xxx.com>
并在libraries/HAL_Drivers/drivers/drv_flash/drv_flash_h7.c 中添加了
const struct fal_flash_dev stm32_onchip_flash_256k = { "onchip_flash_256k", 0x08000000, (256 * 1024), (128 * 1024), {NULL, fal_flash_read_128k, fal_flash_write_128k, fal_flash_erase_128k},256 };

View File

@ -3,6 +3,7 @@ import os
cwd = GetCurrentDir()
src = Glob('*.c')
src += Glob('*.cpp')
CPPPATH = [cwd]
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = Glob('curve/src/*.cpp')
CPPPATH = [cwd]
group = DefineGroup('common', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

View File

@ -0,0 +1,167 @@
//
// Created by lgv on 2026/3/2.
//
/**
* @file s_curve.h
* @brief S 线
*
* 7 S 线
* 1.
* 2.
* 3. 0
* 4.
* 5.
* 6.
* 7. 0
*
* profile
*/
#pragma once
#include <algorithm>
#include <cmath>
#include <vector>
namespace cmvr
{
/**
* @brief S 线
*/
struct SCurveProfile
{
// 7 个阶段的持续时间
double t1; // 加加速度上升时间(加速阶段)
double t2; // 匀加速时间
double t3; // 加加速度下降时间(加速阶段结束)
double t4; // 匀速时间(巡航)
double t5; // 加加速度下降时间(减速阶段)
double t6; // 匀减速时间
double t7; // 加加速度上升时间(减速阶段结束)
double total_time;
// 运动约束
double j_max; // 最大加加速度 (rad/s³)
double a_max; // 最大加速度 (rad/s²)
double v_max; // 最大速度 (rad/s)
// 运动参数
double distance; // 运动总距离
double direction; // +1 或 -1
double v_cruise; // 实际达到的巡航速度
double a_limit; // 实际达到的加速度上限
// 初始条件
double p0; // 初始位置
double v0; // 初始速度
double a0; // 初始加速度
double vf; // 终止速度
SCurveProfile()
: t1(0), t2(0), t3(0), t4(0), t5(0), t6(0), t7(0)
, total_time(0)
, j_max(50.0), a_max(10.0), v_max(3.0)
, distance(0), direction(1.0), v_cruise(0), a_limit(0)
, p0(0), v0(0), a0(0), vf(0)
{}
};
/**
* @brief S 线
*/
class SCurve
{
public:
/**
* @brief
* @param max_velocity (rad/s)
* @param max_acceleration (rad/s²)
* @param max_jerk (rad/s³)
*/
SCurve(double max_velocity = 3.0,
double max_acceleration = 10.0,
double max_jerk = 50.0);
/**
* @brief
*/
void setConstraints(double max_velocity, double max_acceleration, double max_jerk);
/**
* @brief
*/
void getConstraints(double& max_velocity, double& max_acceleration, double& max_jerk) const;
/**
* @brief S 线
* @param start_position
* @param end_position
* @param start_velocity 0
* @param end_velocity 0
* @return
*/
SCurveProfile calculateProfile(double start_position, double end_position,
double start_velocity = 0.0, double end_velocity = 0.0);
/**
* @brief t
* @param profile S 线
* @param t
* @return t
*/
double getPositionAtTime(const SCurveProfile& profile, double t) const;
/**
* @brief t
* @param profile S 线
* @param t
* @return t
*/
double getVelocityAtTime(const SCurveProfile& profile, double t) const;
/**
* @brief t
* @param profile S 线
* @param t
* @return t
*/
double getAccelerationAtTime(const SCurveProfile& profile, double t) const;
/**
* @brief t
* @param profile S 线
* @param t
* @return t
*/
double getJerkAtTime(const SCurveProfile& profile, double t) const;
/**
* @brief
* @param profile S 线
* @param dt
* @param positions
* @param velocities
* @param accelerations
*/
void generateTrajectory(const SCurveProfile& profile, double dt,
std::vector<double>& positions,
std::vector<double>& velocities,
std::vector<double>& accelerations) const;
private:
double max_velocity_;
double max_acceleration_;
double max_jerk_;
static constexpr double EPSILON = 1e-9;
static constexpr double VELOCITY_THRESHOLD = 1e-6;
double computeSegmentJerk(const SCurveProfile& profile, double t) const;
void calculateShortProfile(SCurveProfile& profile) const;
void calculateLongProfile(SCurveProfile& profile) const;
};
} // namespace cmvr

View File

@ -0,0 +1,542 @@
//
// Created by lgv on 2026/3/2.
//
/**
* @file s_curve_generator.cpp
* @brief S 线
*/
#include "common/curve/include/s_curve.h"
#include <cmath>
#include <algorithm>
#include <stdexcept>
namespace cmvr
{
SCurve::SCurve(double max_velocity, double max_acceleration, double max_jerk)
: max_velocity_(std::abs(max_velocity))
, max_acceleration_(std::abs(max_acceleration))
, max_jerk_(std::abs(max_jerk))
{}
void SCurve::setConstraints(double max_velocity, double max_acceleration, double max_jerk)
{
max_velocity_ = std::abs(max_velocity);
max_acceleration_ = std::abs(max_acceleration);
max_jerk_ = std::abs(max_jerk);
}
void SCurve::getConstraints(double& max_velocity, double& max_acceleration, double& max_jerk) const
{
max_velocity = max_velocity_;
max_acceleration = max_acceleration_;
max_jerk = max_jerk_;
}
SCurveProfile SCurve::calculateProfile(double start_position, double end_position,
double start_velocity, double end_velocity)
{
SCurveProfile profile;
profile.j_max = max_jerk_;
profile.a_max = max_acceleration_;
profile.v_max = max_velocity_;
profile.p0 = start_position;
profile.v0 = start_velocity;
profile.a0 = 0.0; // Assume starting from zero acceleration
profile.vf = end_velocity;
double displacement = end_position - start_position;
profile.distance = std::abs(displacement);
profile.direction = (displacement >= 0) ? 1.0 : -1.0;
if (profile.distance < EPSILON) {
// 无需运动
profile.total_time = 0.0;
return profile;
}
const double start_speed = profile.direction * start_velocity;
const double end_speed = profile.direction * end_velocity;
if (start_speed < -VELOCITY_THRESHOLD || end_speed < -VELOCITY_THRESHOLD) {
profile.total_time = 0.0;
return profile;
}
if (std::abs(start_speed) > VELOCITY_THRESHOLD ||
std::abs(end_speed) > VELOCITY_THRESHOLD) {
auto calc_transition = [&](double v_from, double v_to,
double& t_j, double& t_a,
double& duration, double& distance) {
t_j = 0.0;
t_a = 0.0;
duration = 0.0;
distance = 0.0;
const double dv = std::abs(v_to - v_from);
if (dv <= 1e-12 || profile.a_max <= 1e-12 || profile.j_max <= 1e-12) {
return;
}
const double dv_switch = profile.a_max * profile.a_max / profile.j_max;
if (dv < dv_switch) {
t_j = std::sqrt(dv / profile.j_max);
t_a = 0.0;
} else {
t_j = profile.a_max / profile.j_max;
t_a = dv / profile.a_max - t_j;
}
duration = 2.0 * t_j + t_a;
distance = 0.5 * (v_from + v_to) * duration;
};
const double v_cap = std::max({profile.v_max, start_speed, end_speed});
const double v_peak_min = std::max(start_speed, end_speed);
double acc_tj = 0.0, acc_ta = 0.0, acc_duration = 0.0, acc_distance = 0.0;
double dec_tj = 0.0, dec_ta = 0.0, dec_duration = 0.0, dec_distance = 0.0;
calc_transition(start_speed, v_peak_min,
acc_tj, acc_ta, acc_duration, acc_distance);
calc_transition(v_peak_min, end_speed,
dec_tj, dec_ta, dec_duration, dec_distance);
const double d_min = acc_distance + dec_distance;
if (profile.distance + EPSILON < d_min) {
profile.total_time = 0.0;
return profile;
}
calc_transition(start_speed, v_cap,
acc_tj, acc_ta, acc_duration, acc_distance);
calc_transition(v_cap, end_speed,
dec_tj, dec_ta, dec_duration, dec_distance);
const double d_cap = acc_distance + dec_distance;
double v_peak = v_cap;
double t4 = 0.0;
if (profile.distance > d_cap + EPSILON) {
t4 = (profile.distance - d_cap) / std::max(v_peak, EPSILON);
} else {
double lo = v_peak_min;
double hi = v_cap;
for (int iter = 0; iter < 80; ++iter) {
const double mid = 0.5 * (lo + hi);
double mid_acc_tj = 0.0, mid_acc_ta = 0.0, mid_acc_duration = 0.0, mid_acc_distance = 0.0;
double mid_dec_tj = 0.0, mid_dec_ta = 0.0, mid_dec_duration = 0.0, mid_dec_distance = 0.0;
calc_transition(start_speed, mid,
mid_acc_tj, mid_acc_ta, mid_acc_duration, mid_acc_distance);
calc_transition(mid, end_speed,
mid_dec_tj, mid_dec_ta, mid_dec_duration, mid_dec_distance);
const double d_mid = mid_acc_distance + mid_dec_distance;
if (d_mid < profile.distance) {
lo = mid;
} else {
hi = mid;
}
}
v_peak = hi;
calc_transition(start_speed, v_peak,
acc_tj, acc_ta, acc_duration, acc_distance);
calc_transition(v_peak, end_speed,
dec_tj, dec_ta, dec_duration, dec_distance);
}
profile.t1 = acc_tj;
profile.t2 = acc_ta;
profile.t3 = acc_tj;
profile.t4 = t4;
profile.t5 = dec_tj;
profile.t6 = dec_ta;
profile.t7 = dec_tj;
profile.v_cruise = v_peak;
profile.a_limit = std::max(profile.j_max * profile.t1, profile.j_max * profile.t5);
profile.total_time = profile.t1 + profile.t2 + profile.t3 + profile.t4 +
profile.t5 + profile.t6 + profile.t7;
return profile;
}
const double j = profile.j_max;
const double a = profile.a_max;
const double v = profile.v_max;
const double t_j_a = a / j;
if (v < a * t_j_a) {
const double t_j_v = std::sqrt(v / j);
const double s_min = 2.0 * j * t_j_v * t_j_v * t_j_v;
if (profile.distance > s_min + EPSILON) {
calculateLongProfile(profile);
} else {
calculateShortProfile(profile);
}
} else {
const double t_a_v = v / a - t_j_a;
const double s_half_v =
a * (t_j_a * t_j_a + 1.5 * t_j_a * t_a_v + 0.5 * t_a_v * t_a_v);
const double s_min = 2.0 * s_half_v;
if (profile.distance > s_min + EPSILON) {
calculateLongProfile(profile);
} else {
calculateShortProfile(profile);
}
}
return profile;
}
void SCurve::calculateShortProfile(SCurveProfile& profile) const
{
// 短距离无巡航段t4 = 0与 moveL_SCurveLocal 中的 SCurveProfile1D 保持一致。
const double j = profile.j_max;
const double a = profile.a_max;
const double v = profile.v_max;
const double d = profile.distance;
const double t_j_a = a / j;
if (v < a * t_j_a) {
// 达不到 a_max极短距离时只有 4 个 jerk 段。
const double t1 = std::cbrt(d / (2.0 * j));
profile.t1 = t1;
profile.t2 = 0.0;
profile.t3 = t1;
profile.t4 = 0.0;
profile.t5 = t1;
profile.t6 = 0.0;
profile.t7 = t1;
profile.v_cruise = j * t1 * t1;
profile.a_limit = j * t1;
} else {
// 能达到 a_max但达不到 v_max求无巡航的匀加速持续时间。
const double D = t_j_a * t_j_a + 4.0 * (d / a);
double t2 = (-3.0 * t_j_a + std::sqrt(std::max(0.0, D))) * 0.5;
if (t2 < 0.0) {
const double t1 = std::cbrt(d / (2.0 * j));
profile.t1 = t1;
profile.t2 = 0.0;
profile.t3 = t1;
profile.t4 = 0.0;
profile.t5 = t1;
profile.t6 = 0.0;
profile.t7 = t1;
profile.v_cruise = j * t1 * t1;
profile.a_limit = j * t1;
} else {
profile.t1 = t_j_a;
profile.t2 = t2;
profile.t3 = t_j_a;
profile.t4 = 0.0;
profile.t5 = t_j_a;
profile.t6 = t2;
profile.t7 = t_j_a;
profile.v_cruise = a * (t2 + t_j_a);
profile.a_limit = a;
}
}
profile.total_time = profile.t1 + profile.t2 + profile.t3 + profile.t4 +
profile.t5 + profile.t6 + profile.t7;
}
void SCurve::calculateLongProfile(SCurveProfile& profile) const
{
// 含巡航段的完整 7 段式 S 曲线;与 SCurveProfile1D 的 full-profile 公式一致。
const double j = profile.j_max;
const double a = profile.a_max;
const double v = profile.v_max;
const double d = profile.distance;
const double t_j_a = a / j;
if (v < a * t_j_a) {
// 达不到 a_max但可以达到 v_max 并进入巡航。
const double t_j_v = std::sqrt(v / j);
const double s_min = 2.0 * j * t_j_v * t_j_v * t_j_v;
profile.t1 = t_j_v;
profile.t2 = 0.0;
profile.t3 = t_j_v;
profile.t4 = std::max(0.0, (d - s_min) / v);
profile.t5 = t_j_v;
profile.t6 = 0.0;
profile.t7 = t_j_v;
profile.v_cruise = v;
profile.a_limit = j * t_j_v;
} else {
// 能达到 a_max 和 v_max。
const double t_a = v / a - t_j_a;
const double s_half =
a * (t_j_a * t_j_a + 1.5 * t_j_a * t_a + 0.5 * t_a * t_a);
const double s_min = 2.0 * s_half;
profile.t1 = t_j_a;
profile.t2 = t_a;
profile.t3 = t_j_a;
profile.t4 = std::max(0.0, (d - s_min) / v);
profile.t5 = t_j_a;
profile.t6 = t_a;
profile.t7 = t_j_a;
profile.v_cruise = v;
profile.a_limit = a;
}
profile.total_time = profile.t1 + profile.t2 + profile.t3 + profile.t4 +
profile.t5 + profile.t6 + profile.t7;
}
double SCurve::computeSegmentJerk(const SCurveProfile& profile, double t) const
{
double j = profile.j_max * profile.direction;
// 判断所处阶段
double t_end1 = profile.t1;
double t_end2 = t_end1 + profile.t2;
double t_end3 = t_end2 + profile.t3;
double t_end4 = t_end3 + profile.t4;
double t_end5 = t_end4 + profile.t5;
double t_end6 = t_end5 + profile.t6;
// double t_end7 = t_end6 + profile.t7; // = total_time
if (t < t_end1) {
return j; // 段 1正加加速度加速
} else if (t < t_end2) {
return 0.0; // 段 2加加速度为 0匀加速
} else if (t < t_end3) {
return -j; // 段 3负加加速度减小加速度
} else if (t < t_end4) {
return 0.0; // 段 4加加速度为 0巡航
} else if (t < t_end5) {
return -j; // 段 5负加加速度开始减速
} else if (t < t_end6) {
return 0.0; // 段 6加加速度为 0匀减速
} else {
return j; // 段 7正加加速度减速结束
}
}
double SCurve::getPositionAtTime(const SCurveProfile& profile, double t) const
{
if (t <= 0) return profile.p0;
if (t >= profile.total_time) return profile.p0 + profile.distance * profile.direction;
double j = profile.j_max * profile.direction;
double p = profile.p0;
double v = profile.v0;
double a = profile.a0;
// 时间边界
double t_end1 = profile.t1;
double t_end2 = t_end1 + profile.t2;
double t_end3 = t_end2 + profile.t3;
double t_end4 = t_end3 + profile.t4;
double t_end5 = t_end4 + profile.t5;
double t_end6 = t_end5 + profile.t6;
// 依次处理各阶段
auto processSegment = [&](double dt, double jerk) {
p += v * dt + 0.5 * a * dt * dt + (1.0/6.0) * jerk * dt * dt * dt;
v += a * dt + 0.5 * jerk * dt * dt;
a += jerk * dt;
};
// 段 1
if (t <= t_end1) {
processSegment(t, j);
return p;
}
processSegment(profile.t1, j);
// 段 2
if (t <= t_end2) {
processSegment(t - t_end1, 0.0);
return p;
}
processSegment(profile.t2, 0.0);
// 段 3
if (t <= t_end3) {
processSegment(t - t_end2, -j);
return p;
}
processSegment(profile.t3, -j);
// 段 4巡航
if (t <= t_end4) {
processSegment(t - t_end3, 0.0);
return p;
}
processSegment(profile.t4, 0.0);
// 段 5
if (t <= t_end5) {
processSegment(t - t_end4, -j);
return p;
}
processSegment(profile.t5, -j);
// 段 6
if (t <= t_end6) {
processSegment(t - t_end5, 0.0);
return p;
}
processSegment(profile.t6, 0.0);
// 段 7
processSegment(t - t_end6, j);
return p;
}
double SCurve::getVelocityAtTime(const SCurveProfile& profile, double t) const
{
if (t <= 0) return profile.v0;
if (t >= profile.total_time) return profile.vf;
double j = profile.j_max * profile.direction;
double v = profile.v0;
double a = profile.a0;
// 时间边界
double t_end1 = profile.t1;
double t_end2 = t_end1 + profile.t2;
double t_end3 = t_end2 + profile.t3;
double t_end4 = t_end3 + profile.t4;
double t_end5 = t_end4 + profile.t5;
double t_end6 = t_end5 + profile.t6;
auto processSegment = [&](double dt, double jerk) {
v += a * dt + 0.5 * jerk * dt * dt;
a += jerk * dt;
};
if (t <= t_end1) {
v += a * t + 0.5 * j * t * t;
return v;
}
processSegment(profile.t1, j);
if (t <= t_end2) {
v += a * (t - t_end1);
return v;
}
processSegment(profile.t2, 0.0);
if (t <= t_end3) {
double dt = t - t_end2;
v += a * dt + 0.5 * (-j) * dt * dt;
return v;
}
processSegment(profile.t3, -j);
if (t <= t_end4) {
v += a * (t - t_end3);
return v;
}
processSegment(profile.t4, 0.0);
if (t <= t_end5) {
double dt = t - t_end4;
v += a * dt + 0.5 * (-j) * dt * dt;
return v;
}
processSegment(profile.t5, -j);
if (t <= t_end6) {
v += a * (t - t_end5);
return v;
}
processSegment(profile.t6, 0.0);
double dt = t - t_end6;
v += a * dt + 0.5 * j * dt * dt;
return v;
}
double SCurve::getAccelerationAtTime(const SCurveProfile& profile, double t) const
{
if (t <= 0 || t >= profile.total_time) return 0.0;
double j = profile.j_max * profile.direction;
double a = profile.a0;
// 时间边界
double t_end1 = profile.t1;
double t_end2 = t_end1 + profile.t2;
double t_end3 = t_end2 + profile.t3;
double t_end4 = t_end3 + profile.t4;
double t_end5 = t_end4 + profile.t5;
double t_end6 = t_end5 + profile.t6;
if (t <= t_end1) {
return a + j * t;
}
a += j * profile.t1;
if (t <= t_end2) {
return a;
}
if (t <= t_end3) {
return a + (-j) * (t - t_end2);
}
a += (-j) * profile.t3;
if (t <= t_end4) {
return a; // Should be ~0
}
if (t <= t_end5) {
return a + (-j) * (t - t_end4);
}
a += (-j) * profile.t5;
if (t <= t_end6) {
return a;
}
return a + j * (t - t_end6);
}
double SCurve::getJerkAtTime(const SCurveProfile& profile, double t) const
{
if (t <= 0.0 || t >= profile.total_time) {
return 0.0;
}
return computeSegmentJerk(profile, t);
}
void SCurve::generateTrajectory(const SCurveProfile& profile, double dt,
std::vector<double>& positions,
std::vector<double>& velocities,
std::vector<double>& accelerations) const
{
positions.clear();
velocities.clear();
accelerations.clear();
if (profile.total_time <= 0 || dt <= 0) {
positions.push_back(profile.p0);
velocities.push_back(profile.v0);
accelerations.push_back(profile.a0);
return;
}
int num_points = static_cast<int>(std::ceil(profile.total_time / dt)) + 1;
positions.reserve(num_points);
velocities.reserve(num_points);
accelerations.reserve(num_points);
for (double t = 0; t <= profile.total_time; t += dt) {
positions.push_back(getPositionAtTime(profile, t));
velocities.push_back(getVelocityAtTime(profile, t));
accelerations.push_back(getAccelerationAtTime(profile, t));
}
// 确保包含最终点
if (positions.empty() ||
std::abs(positions.back() - (profile.p0 + profile.distance * profile.direction)) > EPSILON) {
positions.push_back(profile.p0 + profile.distance * profile.direction);
velocities.push_back(profile.vf);
accelerations.push_back(0.0);
}
}
}

View File

@ -0,0 +1,9 @@
//
// Created by Administrator on 2026/4/22.
//
#ifndef RTTHREAD_COMMON_TYPE_H
#define RTTHREAD_COMMON_TYPE_H
#define PI (3.14159265358979323846)
#endif //RTTHREAD_COMMON_TYPE_H

View File

@ -0,0 +1,15 @@
//
// Created by Administrator on 2026/4/22.
//
#ifndef RTTHREAD_SERVO_TYPES_H
#define RTTHREAD_SERVO_TYPES_H
enum class MotionMode
{
Immediate,
SCurve,
Follow
};
#endif // RTTHREAD_SERVO_TYPES_H

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = Glob('src/*.cpp')
CPPPATH = [cwd]
group = DefineGroup('controller', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

View File

@ -0,0 +1,68 @@
//
// Created by Administrator on 2026/1/16.
//
#ifndef RTTHREAD_PID_CONTROLLER_H
#define RTTHREAD_PID_CONTROLLER_H
class PidController
{
public:
PidController();
// 设置目标(通用 target
void setTarget(double target);
// PID 增益
void setGains(double kp, double ki, double kd);
/// 设置积分上下限: lower <= I <= upper
/// 若 upper <= lower则不启用积分限幅
void setIntegralLimits(double lower, double upper);
/// 设置误差死区: |error| < deadzone 时视为 0
void setDeadzone(double deadzone);
/// 设置 D 项滤波系数(简单一阶滤波)
/// coeff <= 0 表示不启用滤波
void setDerivativeFilterCoeff(double coeff);
/// 重置内部状态(积分/上一拍误差/滤波器)
void reset(double integral = 0.0, double prev_error = 0.0);
/// 核心:根据当前值计算控制量
double compute(double x, double dt);
private:
// gains
double kp_;
double ki_;
double kd_;
// target
double target_;
// state
double integralError_;
double prevError_;
// integral clamp
double iLower_;
double iUpper_;
// deadzone
double deadzone_;
// derivative filter
double dFilterCoeff_;
double dErrorFiltered_;
bool initialized_;
};
#endif //RTTHREAD_PID_CONTROLLER_H

View File

@ -0,0 +1,96 @@
//
// Created by Administrator on 2026/1/16.
//
#include "controller/include/pid_controller.h"
#include <algorithm>
#include <cmath>
PidController::PidController()
: kp_(0.0),
ki_(0.0),
kd_(0.0),
target_(0.0),
integralError_(0.0),
prevError_(0.0),
iLower_(0.0),
iUpper_(0.0),
deadzone_(0.0),
dFilterCoeff_(0.0),
dErrorFiltered_(0.0),
initialized_(false) {}
void PidController::setTarget(double target) {
target_ = target;
}
void PidController::setGains(double kp, double ki, double kd) {
kp_ = kp;
ki_ = ki;
kd_ = kd;
}
void PidController::setIntegralLimits(double lower, double upper) {
iLower_ = lower;
iUpper_ = upper;
}
void PidController::setDeadzone(double deadzone) {
deadzone_ = std::max(0.0, deadzone);
}
void PidController::setDerivativeFilterCoeff(double coeff) {
dFilterCoeff_ = coeff;
if (dFilterCoeff_ <= 0.0) {
dErrorFiltered_ = 0.0;
}
}
void PidController::reset(double integral, double prev_error) {
integralError_ = integral;
prevError_ = prev_error;
dErrorFiltered_ = 0.0;
initialized_ = false;
}
double PidController::compute(double x, double dt) {
if (dt <= 0.0) return 0.0;
// 误差target - current
double error = target_ - x;
if (std::abs(error) < deadzone_) error = 0.0;
// 第一次调用时初始化 prevError避免 dError 突刺
if (!initialized_) {
prevError_ = error;
initialized_ = true;
}
// 积分
integralError_ += error * dt;
// 积分限幅(若启用)
if (iUpper_ > iLower_) {
integralError_ = std::clamp(integralError_, iLower_, iUpper_);
}
// 微分:对误差微分
const double dError = (error - prevError_) / dt;
// 一阶滤波y = y + a*(x - y)a = coeff*dt (夹到[0,1])
if (dFilterCoeff_ > 0.0) {
const double a = std::clamp(dFilterCoeff_ * dt, 0.0, 1.0);
dErrorFiltered_ = dErrorFiltered_ + a * (dError - dErrorFiltered_);
} else {
dErrorFiltered_ = dError;
}
prevError_ = error;
const double p = kp_ * error;
const double i = ki_ * integralError_;
const double d = kd_ * dErrorFiltered_;
return p + i + d;
}

View File

@ -22,13 +22,19 @@ if GetDepend(['ERPC_MODE_CLIENT']):
gen_dir = p('proto', 'generated')
# interface 建议始终编译(两端都可能需要)
src += [p('proto', 'generated', 'head_service_interface.cpp')]
src += [p('proto', 'generated', 'servo_service_interface.cpp')]
if os.path.exists(p('proto', 'generated', 'file_service_interface.cpp')):
src += [p('proto', 'generated', 'file_service_interface.cpp')]
src += [p('common', 'src', 'erpc_error_handler.cpp')]
if GetDepend(['ERPC_MODE_SERVER']):
src += [p('proto', 'generated', 'head_service_server.cpp')]
src += [p('proto', 'generated', 'servo_service_server.cpp')]
if os.path.exists(p('proto', 'generated', 'file_service_server.cpp')):
src += [p('proto', 'generated', 'file_service_server.cpp')]
if GetDepend(['ERPC_MODE_CLIENT']):
src += [p('proto', 'generated', 'head_service_client.cpp')]
src += [p('proto', 'generated', 'servo_service_client.cpp')]
if os.path.exists(p('proto', 'generated', 'file_service_client.cpp')):
src += [p('proto', 'generated', 'file_service_client.cpp')]
CPPPATH = [
cwd,

View File

@ -0,0 +1,39 @@
// file_service.erpc
program file_service
@id(2)
interface file_service
{
/**
* @brief 开始一次文件上传会话。
* @param path 目标文件路径;服务端会先写入 "<path>.part" 临时文件。
* @param total_size 本次上传的文件总字节数,用于服务端校验最终大小。
* @return RT_EOK 表示成功;负数表示 RT-Thread/POSIX 错误码。
*/
fileWriteBegin(string path, uint32 total_size) -> int32
/**
* @brief 写入一个文件分块。
* @param data 当前分块的二进制内容dataLength 是分块字节数data 是分块数据指针。
* @return RT_EOK 表示成功;负数表示 RT-Thread/POSIX 错误码。
*
* @note 单个分块会被封装进一次 eRPC 消息,最大可用长度受 ERPC_DEFAULT_BUFFER_SIZE 限制。
*/
fileWriteChunk(binary data) -> int32
/**
* @brief 完成上传会话。
* @return RT_EOK 表示成功;负数表示 RT-Thread/POSIX 错误码。
*
* @note 服务端会先校验已接收字节数是否等于 total_size然后把临时文件重命名为目标文件。
*/
fileWriteEnd() -> int32
/**
* @brief 取消当前上传会话。
* @return RT_EOK 表示成功;负数表示 RT-Thread/POSIX 错误码。
*
* @note 服务端会关闭当前文件并删除残留的 ".part" 临时文件。
*/
fileWriteAbort() -> int32
}

View File

@ -0,0 +1,77 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "c_file_service_client.h"
#include "file_service_client.hpp"
#include "erpc_manually_constructed.hpp"
using namespace erpc;
using namespace std;
using namespace erpcShim;
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
file_service_client *s_file_service_client = nullptr;
#else
ERPC_MANUALLY_CONSTRUCTED_STATIC(file_service_client, s_file_service_client);
#endif
int32_t fileWriteBegin(const char * path, uint32_t total_size)
{
int32_t result;
result = s_file_service_client->fileWriteBegin(path, total_size);
return result;
}
int32_t fileWriteChunk(const binary_t * data)
{
int32_t result;
result = s_file_service_client->fileWriteChunk(data);
return result;
}
int32_t fileWriteEnd(void)
{
int32_t result;
result = s_file_service_client->fileWriteEnd();
return result;
}
int32_t fileWriteAbort(void)
{
int32_t result;
result = s_file_service_client->fileWriteAbort();
return result;
}
void initfile_service_client(erpc_client_t client)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
erpc_assert(s_file_service_client == nullptr);
s_file_service_client = new file_service_client(reinterpret_cast<ClientManager *>(client));
#else
erpc_assert(!s_file_service_client.isUsed());
s_file_service_client.construct(reinterpret_cast<ClientManager *>(client));
#endif
}
void deinitfile_service_client(void)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
if (s_file_service_client != nullptr)
{
delete s_file_service_client;
s_file_service_client = nullptr;
}
#else
s_file_service_client.destroy();
#endif
}

View File

@ -0,0 +1,54 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_c_file_service_client_h_)
#define _c_file_service_client_h_
#include "file_service_common.h"
#include "erpc_client_manager.h"
#if defined(__cplusplus)
extern "C"
{
#endif
#if !defined(ERPC_FUNCTIONS_DEFINITIONS)
#define ERPC_FUNCTIONS_DEFINITIONS
/*! @brief file_service identifiers */
enum _file_service_ids
{
kfile_service_service_id = 2,
kfile_service_fileWriteBegin_id = 1,
kfile_service_fileWriteChunk_id = 2,
kfile_service_fileWriteEnd_id = 3,
kfile_service_fileWriteAbort_id = 4,
};
//! @name file_service
//@{
int32_t fileWriteBegin(const char * path, uint32_t total_size);
int32_t fileWriteChunk(const binary_t * data);
int32_t fileWriteEnd(void);
int32_t fileWriteAbort(void);
//@}
#endif // ERPC_FUNCTIONS_DEFINITIONS
void initfile_service_client(erpc_client_t client);
void deinitfile_service_client(void);
#if defined(__cplusplus)
}
#endif
#endif // _c_file_service_client_h_

View File

@ -0,0 +1,97 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include <new>
#include "c_file_service_server.h"
#include "file_service_server.hpp"
#include "erpc_manually_constructed.hpp"
using namespace erpc;
using namespace std;
using namespace erpcShim;
class file_service_server: public file_service_interface
{
public:
virtual ~file_service_server() {};
int32_t fileWriteBegin(const char * path, uint32_t total_size)
{
int32_t result;
result = ::fileWriteBegin(path, total_size);
return result;
}
int32_t fileWriteChunk(const binary_t * data)
{
int32_t result;
result = ::fileWriteChunk(data);
return result;
}
int32_t fileWriteEnd(void)
{
int32_t result;
result = ::fileWriteEnd();
return result;
}
int32_t fileWriteAbort(void)
{
int32_t result;
result = ::fileWriteAbort();
return result;
}
};
ERPC_MANUALLY_CONSTRUCTED_STATIC(file_service_service, s_file_service_service);
ERPC_MANUALLY_CONSTRUCTED_STATIC(file_service_server, s_file_service_server);
erpc_service_t create_file_service_service(void)
{
erpc_service_t service;
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
service = new (nothrow) file_service_service(new (nothrow)file_service_server());
#else
if (s_file_service_service.isUsed())
{
service = NULL;
}
else
{
s_file_service_server.construct();
s_file_service_service.construct(s_file_service_server.get());
service = s_file_service_service.get();
}
#endif
return service;
}
void destroy_file_service_service(erpc_service_t service)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
if (service)
{
delete (file_service_server *)(((file_service_service *)service)->getHandler());
delete (file_service_service *)service;
}
#else
(void)service;
erpc_assert(service == s_file_service_service.get());
s_file_service_service.destroy();
s_file_service_server.destroy();
#endif
}

View File

@ -0,0 +1,59 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_c_file_service_server_h_)
#define _c_file_service_server_h_
#include "file_service_common.h"
#if defined(__cplusplus)
extern "C"
{
#endif
typedef void * erpc_service_t;
#if !defined(ERPC_FUNCTIONS_DEFINITIONS)
#define ERPC_FUNCTIONS_DEFINITIONS
/*! @brief file_service identifiers */
enum _file_service_ids
{
kfile_service_service_id = 2,
kfile_service_fileWriteBegin_id = 1,
kfile_service_fileWriteChunk_id = 2,
kfile_service_fileWriteEnd_id = 3,
kfile_service_fileWriteAbort_id = 4,
};
//! @name file_service
//@{
int32_t fileWriteBegin(const char * path, uint32_t total_size);
int32_t fileWriteChunk(const binary_t * data);
int32_t fileWriteEnd(void);
int32_t fileWriteAbort(void);
//@}
#endif // ERPC_FUNCTIONS_DEFINITIONS
/*! @brief Return file_service_service service object. */
erpc_service_t create_file_service_service(void);
/*! @brief Destroy file_service_service service object. */
void destroy_file_service_service(erpc_service_t service);
#if defined(__cplusplus)
}
#endif
#endif // _c_file_service_server_h_

View File

@ -1,53 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "c_head_service_client.h"
#include "head_service_client.hpp"
#include "erpc_manually_constructed.hpp"
using namespace erpc;
using namespace std;
using namespace erpcShim;
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
demo_client *s_demo_client = nullptr;
#else
ERPC_MANUALLY_CONSTRUCTED_STATIC(demo_client, s_demo_client);
#endif
int32_t add(int32_t a, int32_t b)
{
int32_t result;
result = s_demo_client->add(a, b);
return result;
}
void initdemo_client(erpc_client_t client)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
erpc_assert(s_demo_client == nullptr);
s_demo_client = new demo_client(reinterpret_cast<ClientManager *>(client));
#else
erpc_assert(!s_demo_client.isUsed());
s_demo_client.construct(reinterpret_cast<ClientManager *>(client));
#endif
}
void deinitdemo_client(void)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
if (s_demo_client != nullptr)
{
delete s_demo_client;
s_demo_client = nullptr;
}
#else
s_demo_client.destroy();
#endif
}

View File

@ -1,45 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_c_head_service_client_h_)
#define _c_head_service_client_h_
#include "head_service_common.h"
#include "erpc_client_manager.h"
#if defined(__cplusplus)
extern "C"
{
#endif
#if !defined(ERPC_FUNCTIONS_DEFINITIONS)
#define ERPC_FUNCTIONS_DEFINITIONS
/*! @brief demo identifiers */
enum _demo_ids
{
kdemo_service_id = 1,
kdemo_add_id = 1,
};
//! @name demo
//@{
int32_t add(int32_t a, int32_t b);
//@}
#endif // ERPC_FUNCTIONS_DEFINITIONS
void initdemo_client(erpc_client_t client);
void deinitdemo_client(void);
#if defined(__cplusplus)
}
#endif
#endif // _c_head_service_client_h_

View File

@ -1,73 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include <new>
#include "c_head_service_server.h"
#include "head_service_server.hpp"
#include "erpc_manually_constructed.hpp"
using namespace erpc;
using namespace std;
using namespace erpcShim;
class demo_server: public demo_interface
{
public:
virtual ~demo_server() {};
int32_t add(int32_t a, int32_t b)
{
int32_t result;
result = ::add(a, b);
return result;
}
};
ERPC_MANUALLY_CONSTRUCTED_STATIC(demo_service, s_demo_service);
ERPC_MANUALLY_CONSTRUCTED_STATIC(demo_server, s_demo_server);
erpc_service_t create_demo_service(void)
{
erpc_service_t service;
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
service = new (nothrow) demo_service(new (nothrow)demo_server());
#else
if (s_demo_service.isUsed())
{
service = NULL;
}
else
{
s_demo_server.construct();
s_demo_service.construct(s_demo_server.get());
service = s_demo_service.get();
}
#endif
return service;
}
void destroy_demo_service(erpc_service_t service)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
if (service)
{
delete (demo_server *)(((demo_service *)service)->getHandler());
delete (demo_service *)service;
}
#else
(void)service;
erpc_assert(service == s_demo_service.get());
s_demo_service.destroy();
s_demo_server.destroy();
#endif
}

View File

@ -1,50 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_c_head_service_server_h_)
#define _c_head_service_server_h_
#include "head_service_common.h"
#if defined(__cplusplus)
extern "C"
{
#endif
typedef void * erpc_service_t;
#if !defined(ERPC_FUNCTIONS_DEFINITIONS)
#define ERPC_FUNCTIONS_DEFINITIONS
/*! @brief demo identifiers */
enum _demo_ids
{
kdemo_service_id = 1,
kdemo_add_id = 1,
};
//! @name demo
//@{
int32_t add(int32_t a, int32_t b);
//@}
#endif // ERPC_FUNCTIONS_DEFINITIONS
/*! @brief Return demo_service service object. */
erpc_service_t create_demo_service(void);
/*! @brief Destroy demo_service service object. */
void destroy_demo_service(erpc_service_t service);
#if defined(__cplusplus)
}
#endif
#endif // _c_head_service_server_h_

View File

@ -0,0 +1,93 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "c_servo_service_client.h"
#include "servo_service_client.hpp"
#include "erpc_manually_constructed.hpp"
using namespace erpc;
using namespace std;
using namespace erpcShim;
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
servo_service_client *s_servo_service_client = nullptr;
#else
ERPC_MANUALLY_CONSTRUCTED_STATIC(servo_service_client, s_servo_service_client);
#endif
bool setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad)
{
bool result;
result = s_servo_service_client->setConstraints(id, max_velocity_rad, max_acceleration_rad, max_jerk_rad);
return result;
}
bool setPositionGain(const char * id, float position_gain)
{
bool result;
result = s_servo_service_client->setPositionGain(id, position_gain);
return result;
}
bool setMode(RpcMotionMode mode)
{
bool result;
result = s_servo_service_client->setMode(mode);
return result;
}
bool setUpdatePeriodMs(uint32_t ms)
{
bool result;
result = s_servo_service_client->setUpdatePeriodMs(ms);
return result;
}
int32_t move(const list_ServoCmd_1_t * cmds)
{
int32_t result;
result = s_servo_service_client->move(cmds);
return result;
}
int32_t moveJ(const list_float_1_t * angles_rad)
{
int32_t result;
result = s_servo_service_client->moveJ(angles_rad);
return result;
}
void initservo_service_client(erpc_client_t client)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
erpc_assert(s_servo_service_client == nullptr);
s_servo_service_client = new servo_service_client(reinterpret_cast<ClientManager *>(client));
#else
erpc_assert(!s_servo_service_client.isUsed());
s_servo_service_client.construct(reinterpret_cast<ClientManager *>(client));
#endif
}
void deinitservo_service_client(void)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
if (s_servo_service_client != nullptr)
{
delete s_servo_service_client;
s_servo_service_client = nullptr;
}
#else
s_servo_service_client.destroy();
#endif
}

View File

@ -0,0 +1,60 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_c_servo_service_client_h_)
#define _c_servo_service_client_h_
#include "servo_service_common.h"
#include "erpc_client_manager.h"
#if defined(__cplusplus)
extern "C"
{
#endif
#if !defined(ERPC_FUNCTIONS_DEFINITIONS)
#define ERPC_FUNCTIONS_DEFINITIONS
/*! @brief servo_service identifiers */
enum _servo_service_ids
{
kservo_service_service_id = 1,
kservo_service_setConstraints_id = 1,
kservo_service_setPositionGain_id = 2,
kservo_service_setMode_id = 3,
kservo_service_setUpdatePeriodMs_id = 4,
kservo_service_move_id = 5,
kservo_service_moveJ_id = 6,
};
//! @name servo_service
//@{
bool setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad);
bool setPositionGain(const char * id, float position_gain);
bool setMode(RpcMotionMode mode);
bool setUpdatePeriodMs(uint32_t ms);
int32_t move(const list_ServoCmd_1_t * cmds);
int32_t moveJ(const list_float_1_t * angles_rad);
//@}
#endif // ERPC_FUNCTIONS_DEFINITIONS
void initservo_service_client(erpc_client_t client);
void deinitservo_service_client(void);
#if defined(__cplusplus)
}
#endif
#endif // _c_servo_service_client_h_

View File

@ -0,0 +1,113 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include <new>
#include "c_servo_service_server.h"
#include "servo_service_server.hpp"
#include "erpc_manually_constructed.hpp"
using namespace erpc;
using namespace std;
using namespace erpcShim;
class servo_service_server: public servo_service_interface
{
public:
virtual ~servo_service_server() {};
bool setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad)
{
bool result;
result = ::setConstraints(id, max_velocity_rad, max_acceleration_rad, max_jerk_rad);
return result;
}
bool setPositionGain(const char * id, float position_gain)
{
bool result;
result = ::setPositionGain(id, position_gain);
return result;
}
bool setMode(RpcMotionMode mode)
{
bool result;
result = ::setMode(mode);
return result;
}
bool setUpdatePeriodMs(uint32_t ms)
{
bool result;
result = ::setUpdatePeriodMs(ms);
return result;
}
int32_t move(const list_ServoCmd_1_t * cmds)
{
int32_t result;
result = ::move(cmds);
return result;
}
int32_t moveJ(const list_float_1_t * angles_rad)
{
int32_t result;
result = ::moveJ(angles_rad);
return result;
}
};
ERPC_MANUALLY_CONSTRUCTED_STATIC(servo_service_service, s_servo_service_service);
ERPC_MANUALLY_CONSTRUCTED_STATIC(servo_service_server, s_servo_service_server);
erpc_service_t create_servo_service_service(void)
{
erpc_service_t service;
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
service = new (nothrow) servo_service_service(new (nothrow)servo_service_server());
#else
if (s_servo_service_service.isUsed())
{
service = NULL;
}
else
{
s_servo_service_server.construct();
s_servo_service_service.construct(s_servo_service_server.get());
service = s_servo_service_service.get();
}
#endif
return service;
}
void destroy_servo_service_service(erpc_service_t service)
{
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
if (service)
{
delete (servo_service_server *)(((servo_service_service *)service)->getHandler());
delete (servo_service_service *)service;
}
#else
(void)service;
erpc_assert(service == s_servo_service_service.get());
s_servo_service_service.destroy();
s_servo_service_server.destroy();
#endif
}

View File

@ -0,0 +1,65 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_c_servo_service_server_h_)
#define _c_servo_service_server_h_
#include "servo_service_common.h"
#if defined(__cplusplus)
extern "C"
{
#endif
typedef void * erpc_service_t;
#if !defined(ERPC_FUNCTIONS_DEFINITIONS)
#define ERPC_FUNCTIONS_DEFINITIONS
/*! @brief servo_service identifiers */
enum _servo_service_ids
{
kservo_service_service_id = 1,
kservo_service_setConstraints_id = 1,
kservo_service_setPositionGain_id = 2,
kservo_service_setMode_id = 3,
kservo_service_setUpdatePeriodMs_id = 4,
kservo_service_move_id = 5,
kservo_service_moveJ_id = 6,
};
//! @name servo_service
//@{
bool setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad);
bool setPositionGain(const char * id, float position_gain);
bool setMode(RpcMotionMode mode);
bool setUpdatePeriodMs(uint32_t ms);
int32_t move(const list_ServoCmd_1_t * cmds);
int32_t moveJ(const list_float_1_t * angles_rad);
//@}
#endif // ERPC_FUNCTIONS_DEFINITIONS
/*! @brief Return servo_service_service service object. */
erpc_service_t create_servo_service_service(void);
/*! @brief Destroy servo_service_service service object. */
void destroy_servo_service_service(erpc_service_t service);
#if defined(__cplusplus)
}
#endif
#endif // _c_servo_service_server_h_

View File

@ -0,0 +1,302 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include "erpc_port.h"
#endif
#include "erpc_codec.hpp"
#include "file_service_client.hpp"
#include "erpc_manually_constructed.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
using namespace erpcShim;
//! @brief Function to write struct binary_t
static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data);
// Write struct binary_t function implementation
static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data)
{
if(NULL == data)
{
return;
}
codec->writeBinary(data->dataLength, data->data);
}
file_service_client::file_service_client(ClientManager *manager)
:m_clientManager(manager)
{
}
file_service_client::~file_service_client()
{
}
// file_service interface fileWriteBegin function client shim.
int32_t file_service_client::fileWriteBegin(const char * path, uint32_t total_size)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_fileWriteBeginId, request.getSequence());
{
uint32_t path_len = strlen((const char*)path);
codec->writeString(path_len, (const char*)path);
}
codec->write(total_size);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_fileWriteBeginId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}
// file_service interface fileWriteChunk function client shim.
int32_t file_service_client::fileWriteChunk(const binary_t * data)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_fileWriteChunkId, request.getSequence());
write_binary_t_struct(codec, data);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_fileWriteChunkId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}
// file_service interface fileWriteEnd function client shim.
int32_t file_service_client::fileWriteEnd(void)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_fileWriteEndId, request.getSequence());
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_fileWriteEndId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}
// file_service interface fileWriteAbort function client shim.
int32_t file_service_client::fileWriteAbort(void)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_fileWriteAbortId, request.getSequence());
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_fileWriteAbortId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}

View File

@ -0,0 +1,40 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_file_service_client_hpp_)
#define _file_service_client_hpp_
#include "file_service_interface.hpp"
#include "erpc_client_manager.h"
namespace erpcShim
{
class file_service_client: public file_service_interface
{
public:
file_service_client(erpc::ClientManager *manager);
virtual ~file_service_client();
virtual int32_t fileWriteBegin(const char * path, uint32_t total_size);
virtual int32_t fileWriteChunk(const binary_t * data);
virtual int32_t fileWriteEnd(void);
virtual int32_t fileWriteAbort(void);
protected:
erpc::ClientManager *m_clientManager;
};
} // erpcShim
#endif // _file_service_client_hpp_

View File

@ -0,0 +1,47 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_file_service_common_h_)
#define _file_service_common_h_
#if defined(__cplusplus)
extern "C"
{
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "erpc_version.h"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
#if !defined(ERPC_TYPE_DEFINITIONS_FILE_SERVICE)
#define ERPC_TYPE_DEFINITIONS_FILE_SERVICE
// Aliases data types declarations
typedef struct binary_t binary_t;
// Structures/unions data types declarations
struct binary_t
{
uint8_t * data;
uint32_t dataLength;
};
#endif // ERPC_TYPE_DEFINITIONS_FILE_SERVICE
#if defined(__cplusplus)
}
#endif
#endif // _file_service_common_h_

View File

@ -0,0 +1,39 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_file_service_common_hpp_)
#define _file_service_common_hpp_
#include <cstddef>
#include <cstdint>
#include "erpc_version.h"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
#if !defined(ERPC_TYPE_DEFINITIONS_FILE_SERVICE)
#define ERPC_TYPE_DEFINITIONS_FILE_SERVICE
// Aliases data types declarations
typedef struct binary_t binary_t;
// Structures/unions data types declarations
struct binary_t
{
uint8_t * data;
uint32_t dataLength;
};
#endif // ERPC_TYPE_DEFINITIONS_FILE_SERVICE
#endif // _file_service_common_hpp_

View File

@ -1,11 +1,11 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "head_service_interface.hpp"
#include "file_service_interface.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
@ -15,6 +15,6 @@
using namespace std;
using namespace erpcShim;
demo_interface::~demo_interface(void)
file_service_interface::~file_service_interface(void)
{
}

View File

@ -0,0 +1,41 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_file_service_interface_hpp_)
#define _file_service_interface_hpp_
#include "file_service_common.hpp"
namespace erpcShim
{
// Abstract base class for file_service
class file_service_interface
{
public:
static const uint8_t m_serviceId = 2;
static const uint8_t m_fileWriteBeginId = 1;
static const uint8_t m_fileWriteChunkId = 2;
static const uint8_t m_fileWriteEndId = 3;
static const uint8_t m_fileWriteAbortId = 4;
virtual ~file_service_interface(void);
virtual int32_t fileWriteBegin(const char * path, uint32_t total_size) = 0;
virtual int32_t fileWriteChunk(const binary_t * data) = 0;
virtual int32_t fileWriteEnd(void) = 0;
virtual int32_t fileWriteAbort(void) = 0;
private:
};
} // erpcShim
#endif // _file_service_interface_hpp_

View File

@ -0,0 +1,327 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "file_service_server.hpp"
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include <new>
#include "erpc_port.h"
#endif
#include "erpc_manually_constructed.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
using namespace erpcShim;
#if ERPC_NESTED_CALLS_DETECTION
extern bool nestingDetection;
#endif
//! @brief Function to read struct binary_t
static void read_binary_t_struct(erpc::Codec * codec, binary_t * data);
// Read struct binary_t function implementation
static void read_binary_t_struct(erpc::Codec * codec, binary_t * data)
{
if(NULL == data)
{
return;
}
uint8_t * data_local;
codec->readBinary(data->dataLength, &data_local);
if (data->dataLength > 0)
{
data->data = (uint8_t *) erpc_malloc(data->dataLength * sizeof(uint8_t));
if (data->data == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(data->data, data_local, data->dataLength);
}
}
else
{
data->data = NULL;
}
}
//! @brief Function to free space allocated inside struct binary_t
static void free_binary_t_struct(binary_t * data);
// Free space allocated inside struct binary_t function implementation
static void free_binary_t_struct(binary_t * data)
{
erpc_free(data->data);
}
file_service_service::file_service_service(file_service_interface *_file_service_interface)
: erpc::Service(file_service_interface::m_serviceId)
, m_handler(_file_service_interface)
{
}
file_service_service::~file_service_service()
{
}
// return service interface handler.
file_service_interface* file_service_service::getHandler(void)
{
return m_handler;
}
// Call the correct server shim based on method unique ID.
erpc_status_t file_service_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport)
{
erpc_status_t erpcStatus;
switch (methodId)
{
case file_service_interface::m_fileWriteBeginId:
{
erpcStatus = fileWriteBegin_shim(codec, messageFactory, transport, sequence);
break;
}
case file_service_interface::m_fileWriteChunkId:
{
erpcStatus = fileWriteChunk_shim(codec, messageFactory, transport, sequence);
break;
}
case file_service_interface::m_fileWriteEndId:
{
erpcStatus = fileWriteEnd_shim(codec, messageFactory, transport, sequence);
break;
}
case file_service_interface::m_fileWriteAbortId:
{
erpcStatus = fileWriteAbort_shim(codec, messageFactory, transport, sequence);
break;
}
default:
{
erpcStatus = kErpcStatus_InvalidArgument;
break;
}
}
return erpcStatus;
}
// Server shim for fileWriteBegin of file_service interface.
erpc_status_t file_service_service::fileWriteBegin_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
char * path = NULL;
uint32_t total_size;
int32_t result;
// startReadMessage() was already called before this shim was invoked.
{
uint32_t path_len;
char * path_local;
codec->readString(path_len, &path_local);
path = (char*) erpc_malloc((path_len + 1) * sizeof(char));
if ((path == NULL) || (path_local == NULL))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(path, path_local, path_len);
(path)[path_len] = 0;
}
}
codec->read(total_size);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->fileWriteBegin(path, total_size);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, file_service_interface::m_serviceId, file_service_interface::m_fileWriteBeginId, sequence);
codec->write(result);
err = codec->getStatus();
}
erpc_free(path);
return err;
}
// Server shim for fileWriteChunk of file_service interface.
erpc_status_t file_service_service::fileWriteChunk_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
binary_t *data = NULL;
data = (binary_t *) erpc_malloc(sizeof(binary_t));
if (data == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
int32_t result;
// startReadMessage() was already called before this shim was invoked.
read_binary_t_struct(codec, data);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->fileWriteChunk(data);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, file_service_interface::m_serviceId, file_service_interface::m_fileWriteChunkId, sequence);
codec->write(result);
err = codec->getStatus();
}
if (data)
{
free_binary_t_struct(data);
}
erpc_free(data);
return err;
}
// Server shim for fileWriteEnd of file_service interface.
erpc_status_t file_service_service::fileWriteEnd_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
// startReadMessage() was already called before this shim was invoked.
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->fileWriteEnd();
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, file_service_interface::m_serviceId, file_service_interface::m_fileWriteEndId, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}
// Server shim for fileWriteAbort of file_service interface.
erpc_status_t file_service_service::fileWriteAbort_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
// startReadMessage() was already called before this shim was invoked.
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->fileWriteAbort();
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, file_service_interface::m_serviceId, file_service_interface::m_fileWriteAbortId, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}

View File

@ -0,0 +1,58 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 12:01:23 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_file_service_server_hpp_)
#define _file_service_server_hpp_
#include "file_service_interface.hpp"
#include "erpc_server.hpp"
#include "erpc_codec.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
namespace erpcShim
{
/*!
* @brief Service subclass for file_service.
*/
class file_service_service : public erpc::Service
{
public:
file_service_service(file_service_interface *_file_service_interface);
virtual ~file_service_service();
/*! @brief return service interface handler. */
file_service_interface* getHandler(void);
/*! @brief Call the correct server shim based on method unique ID. */
virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport);
private:
file_service_interface *m_handler;
/*! @brief Server shim for fileWriteBegin of file_service interface. */
erpc_status_t fileWriteBegin_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for fileWriteChunk of file_service interface. */
erpc_status_t fileWriteChunk_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for fileWriteEnd of file_service interface. */
erpc_status_t fileWriteEnd_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for fileWriteAbort of file_service interface. */
erpc_status_t fileWriteAbort_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
};
} // erpcShim
#endif // _file_service_server_hpp_

View File

@ -1,97 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include "erpc_port.h"
#endif
#include "erpc_codec.hpp"
#include "head_service_client.hpp"
#include "erpc_manually_constructed.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
using namespace erpcShim;
demo_client::demo_client(ClientManager *manager)
:m_clientManager(manager)
{
}
demo_client::~demo_client()
{
}
// demo interface add function client shim.
int32_t demo_client::add(int32_t a, int32_t b)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_addId, request.getSequence());
codec->write(a);
codec->write(b);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_addId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}

View File

@ -1,34 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_head_service_client_hpp_)
#define _head_service_client_hpp_
#include "head_service_interface.hpp"
#include "erpc_client_manager.h"
namespace erpcShim
{
class demo_client: public demo_interface
{
public:
demo_client(erpc::ClientManager *manager);
virtual ~demo_client();
virtual int32_t add(int32_t a, int32_t b);
protected:
erpc::ClientManager *m_clientManager;
};
} // erpcShim
#endif // _head_service_client_hpp_

View File

@ -1,36 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_head_service_common_h_)
#define _head_service_common_h_
#if defined(__cplusplus)
extern "C"
{
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "erpc_version.h"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
#if !defined(ERPC_TYPE_DEFINITIONS_ERPCSHIM)
#define ERPC_TYPE_DEFINITIONS_ERPCSHIM
#endif // ERPC_TYPE_DEFINITIONS_ERPCSHIM
#if defined(__cplusplus)
}
#endif
#endif // _head_service_common_h_

View File

@ -1,28 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_head_service_common_hpp_)
#define _head_service_common_hpp_
#include <cstddef>
#include <cstdint>
#include "erpc_version.h"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
#if !defined(ERPC_TYPE_DEFINITIONS_ERPCSHIM)
#define ERPC_TYPE_DEFINITIONS_ERPCSHIM
#endif // ERPC_TYPE_DEFINITIONS_ERPCSHIM
#endif // _head_service_common_hpp_

View File

@ -1,32 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_head_service_interface_hpp_)
#define _head_service_interface_hpp_
#include "head_service_common.hpp"
namespace erpcShim
{
// Abstract base class for demo
class demo_interface
{
public:
static const uint8_t m_serviceId = 1;
static const uint8_t m_addId = 1;
virtual ~demo_interface(void);
virtual int32_t add(int32_t a, int32_t b) = 0;
private:
};
} // erpcShim
#endif // _head_service_interface_hpp_

View File

@ -1,112 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "head_service_server.hpp"
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include <new>
#include "erpc_port.h"
#endif
#include "erpc_manually_constructed.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
using namespace erpcShim;
#if ERPC_NESTED_CALLS_DETECTION
extern bool nestingDetection;
#endif
demo_service::demo_service(demo_interface *_demo_interface)
: erpc::Service(demo_interface::m_serviceId)
, m_handler(_demo_interface)
{
}
demo_service::~demo_service()
{
}
// return service interface handler.
demo_interface* demo_service::getHandler(void)
{
return m_handler;
}
// Call the correct server shim based on method unique ID.
erpc_status_t demo_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport)
{
erpc_status_t erpcStatus;
switch (methodId)
{
case demo_interface::m_addId:
{
erpcStatus = add_shim(codec, messageFactory, transport, sequence);
break;
}
default:
{
erpcStatus = kErpcStatus_InvalidArgument;
break;
}
}
return erpcStatus;
}
// Server shim for add of demo interface.
erpc_status_t demo_service::add_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
int32_t a;
int32_t b;
int32_t result;
// startReadMessage() was already called before this shim was invoked.
codec->read(a);
codec->read(b);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->add(a, b);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, demo_interface::m_serviceId, demo_interface::m_addId, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}

View File

@ -1,49 +0,0 @@
/*
* Generated by erpcgen 1.14.0 on Wed Dec 24 14:07:39 2025.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_head_service_server_hpp_)
#define _head_service_server_hpp_
#include "head_service_interface.hpp"
#include "erpc_server.hpp"
#include "erpc_codec.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
namespace erpcShim
{
/*!
* @brief Service subclass for demo.
*/
class demo_service : public erpc::Service
{
public:
demo_service(demo_interface *_demo_interface);
virtual ~demo_service();
/*! @brief return service interface handler. */
demo_interface* getHandler(void);
/*! @brief Call the correct server shim based on method unique ID. */
virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport);
private:
demo_interface *m_handler;
/*! @brief Server shim for add of demo interface. */
erpc_status_t add_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
};
} // erpcShim
#endif // _head_service_server_hpp_

View File

@ -0,0 +1,484 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include "erpc_port.h"
#endif
#include "erpc_codec.hpp"
#include "servo_service_client.hpp"
#include "erpc_manually_constructed.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
using namespace erpcShim;
//! @brief Function to write struct ServoCmd
static void write_ServoCmd_struct(erpc::Codec * codec, const ServoCmd * data);
//! @brief Function to write struct list_ServoCmd_1_t
static void write_list_ServoCmd_1_t_struct(erpc::Codec * codec, const list_ServoCmd_1_t * data);
//! @brief Function to write struct list_float_1_t
static void write_list_float_1_t_struct(erpc::Codec * codec, const list_float_1_t * data);
// Write struct ServoCmd function implementation
static void write_ServoCmd_struct(erpc::Codec * codec, const ServoCmd * data)
{
if(NULL == data)
{
return;
}
{
uint32_t id_len = strlen((const char*)data->id);
codec->writeString(id_len, (const char*)data->id);
}
codec->write(data->angle_rad);
}
// Write struct list_ServoCmd_1_t function implementation
static void write_list_ServoCmd_1_t_struct(erpc::Codec * codec, const list_ServoCmd_1_t * data)
{
if(NULL == data)
{
return;
}
codec->startWriteList(data->elementsCount);
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
{
write_ServoCmd_struct(codec, &(data->elements[listCount]));
}
}
// Write struct list_float_1_t function implementation
static void write_list_float_1_t_struct(erpc::Codec * codec, const list_float_1_t * data)
{
if(NULL == data)
{
return;
}
codec->startWriteList(data->elementsCount);
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
{
codec->write(data->elements[listCount]);
}
}
servo_service_client::servo_service_client(ClientManager *manager)
:m_clientManager(manager)
{
}
servo_service_client::~servo_service_client()
{
}
// servo_service interface setConstraints function client shim.
bool servo_service_client::setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad)
{
erpc_status_t err = kErpcStatus_Success;
bool result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_setConstraintsId, request.getSequence());
{
uint32_t id_len = strlen((const char*)id);
codec->writeString(id_len, (const char*)id);
}
codec->write(max_velocity_rad);
codec->write(max_acceleration_rad);
codec->write(max_jerk_rad);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_setConstraintsId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = false;
}
return result;
}
// servo_service interface setPositionGain function client shim.
bool servo_service_client::setPositionGain(const char * id, float position_gain)
{
erpc_status_t err = kErpcStatus_Success;
bool result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_setPositionGainId, request.getSequence());
{
uint32_t id_len = strlen((const char*)id);
codec->writeString(id_len, (const char*)id);
}
codec->write(position_gain);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_setPositionGainId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = false;
}
return result;
}
// servo_service interface setMode function client shim.
bool servo_service_client::setMode(RpcMotionMode mode)
{
erpc_status_t err = kErpcStatus_Success;
bool result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_setModeId, request.getSequence());
codec->write(static_cast<int32_t>(mode));
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_setModeId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = false;
}
return result;
}
// servo_service interface setUpdatePeriodMs function client shim.
bool servo_service_client::setUpdatePeriodMs(uint32_t ms)
{
erpc_status_t err = kErpcStatus_Success;
bool result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_setUpdatePeriodMsId, request.getSequence());
codec->write(ms);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_setUpdatePeriodMsId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = false;
}
return result;
}
// servo_service interface move function client shim.
int32_t servo_service_client::move(const list_ServoCmd_1_t * cmds)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_moveId, request.getSequence());
write_list_ServoCmd_1_t_struct(codec, cmds);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_moveId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}
// servo_service interface moveJ function client shim.
int32_t servo_service_client::moveJ(const list_float_1_t * angles_rad)
{
erpc_status_t err = kErpcStatus_Success;
int32_t result;
#if ERPC_PRE_POST_ACTION
pre_post_action_cb preCB = m_clientManager->getPreCB();
if (preCB)
{
preCB();
}
#endif
// Get a new request.
RequestContext request = m_clientManager->createRequest(false);
// Encode the request.
Codec * codec = request.getCodec();
if (codec == NULL)
{
err = kErpcStatus_MemoryError;
}
else
{
codec->startWriteMessage(message_type_t::kInvocationMessage, m_serviceId, m_moveJId, request.getSequence());
write_list_float_1_t_struct(codec, angles_rad);
// Send message to server
// Codec status is checked inside this function.
m_clientManager->performRequest(request);
codec->read(result);
err = codec->getStatus();
}
// Dispose of the request.
m_clientManager->releaseRequest(request);
// Invoke error handler callback function
m_clientManager->callErrorHandler(err, m_moveJId);
#if ERPC_PRE_POST_ACTION
pre_post_action_cb postCB = m_clientManager->getPostCB();
if (postCB)
{
postCB();
}
#endif
if (err != kErpcStatus_Success)
{
result = -1;
}
return result;
}

View File

@ -0,0 +1,44 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_servo_service_client_hpp_)
#define _servo_service_client_hpp_
#include "servo_service_interface.hpp"
#include "erpc_client_manager.h"
namespace erpcShim
{
class servo_service_client: public servo_service_interface
{
public:
servo_service_client(erpc::ClientManager *manager);
virtual ~servo_service_client();
virtual bool setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad);
virtual bool setPositionGain(const char * id, float position_gain);
virtual bool setMode(RpcMotionMode mode);
virtual bool setUpdatePeriodMs(uint32_t ms);
virtual int32_t move(const list_ServoCmd_1_t * cmds);
virtual int32_t moveJ(const list_float_1_t * angles_rad);
protected:
erpc::ClientManager *m_clientManager;
};
} // erpcShim
#endif // _servo_service_client_hpp_

View File

@ -0,0 +1,69 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_servo_service_common_h_)
#define _servo_service_common_h_
#if defined(__cplusplus)
extern "C"
{
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "erpc_version.h"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
#if !defined(ERPC_TYPE_DEFINITIONS_SERVO_SERVICE)
#define ERPC_TYPE_DEFINITIONS_SERVO_SERVICE
// Enumerators data types declarations
typedef enum RpcMotionMode
{
RpcMotionModeImmediate = 0,
RpcMotionModeSCurve = 1,
RpcMotionModeFollow = 2
} RpcMotionMode;
// Aliases data types declarations
typedef struct list_float_1_t list_float_1_t;
typedef struct ServoCmd ServoCmd;
typedef struct list_ServoCmd_1_t list_ServoCmd_1_t;
// Structures/unions data types declarations
struct list_float_1_t
{
float * elements;
uint32_t elementsCount;
};
struct ServoCmd
{
char * id;
float angle_rad;
};
struct list_ServoCmd_1_t
{
ServoCmd * elements;
uint32_t elementsCount;
};
#endif // ERPC_TYPE_DEFINITIONS_SERVO_SERVICE
#if defined(__cplusplus)
}
#endif
#endif // _servo_service_common_h_

View File

@ -0,0 +1,61 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_servo_service_common_hpp_)
#define _servo_service_common_hpp_
#include <cstddef>
#include <cstdint>
#include "erpc_version.h"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
#if !defined(ERPC_TYPE_DEFINITIONS_SERVO_SERVICE)
#define ERPC_TYPE_DEFINITIONS_SERVO_SERVICE
// Enumerators data types declarations
typedef enum RpcMotionMode
{
RpcMotionModeImmediate = 0,
RpcMotionModeSCurve = 1,
RpcMotionModeFollow = 2
} RpcMotionMode;
// Aliases data types declarations
typedef struct list_float_1_t list_float_1_t;
typedef struct ServoCmd ServoCmd;
typedef struct list_ServoCmd_1_t list_ServoCmd_1_t;
// Structures/unions data types declarations
struct list_float_1_t
{
float * elements;
uint32_t elementsCount;
};
struct ServoCmd
{
char * id;
float angle_rad;
};
struct list_ServoCmd_1_t
{
ServoCmd * elements;
uint32_t elementsCount;
};
#endif // ERPC_TYPE_DEFINITIONS_SERVO_SERVICE
#endif // _servo_service_common_hpp_

View File

@ -0,0 +1,20 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "servo_service_interface.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace std;
using namespace erpcShim;
servo_service_interface::~servo_service_interface(void)
{
}

View File

@ -0,0 +1,47 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_servo_service_interface_hpp_)
#define _servo_service_interface_hpp_
#include "servo_service_common.hpp"
namespace erpcShim
{
// Abstract base class for servo_service
class servo_service_interface
{
public:
static const uint8_t m_serviceId = 1;
static const uint8_t m_setConstraintsId = 1;
static const uint8_t m_setPositionGainId = 2;
static const uint8_t m_setModeId = 3;
static const uint8_t m_setUpdatePeriodMsId = 4;
static const uint8_t m_moveId = 5;
static const uint8_t m_moveJId = 6;
virtual ~servo_service_interface(void);
virtual bool setConstraints(const char * id, float max_velocity_rad, float max_acceleration_rad, float max_jerk_rad) = 0;
virtual bool setPositionGain(const char * id, float position_gain) = 0;
virtual bool setMode(RpcMotionMode mode) = 0;
virtual bool setUpdatePeriodMs(uint32_t ms) = 0;
virtual int32_t move(const list_ServoCmd_1_t * cmds) = 0;
virtual int32_t moveJ(const list_float_1_t * angles_rad) = 0;
private:
};
} // erpcShim
#endif // _servo_service_interface_hpp_

View File

@ -0,0 +1,539 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#include "servo_service_server.hpp"
#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
#include <new>
#include "erpc_port.h"
#endif
#include "erpc_manually_constructed.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
using namespace erpc;
using namespace std;
using namespace erpcShim;
#if ERPC_NESTED_CALLS_DETECTION
extern bool nestingDetection;
#endif
//! @brief Function to read struct ServoCmd
static void read_ServoCmd_struct(erpc::Codec * codec, ServoCmd * data);
//! @brief Function to read struct list_ServoCmd_1_t
static void read_list_ServoCmd_1_t_struct(erpc::Codec * codec, list_ServoCmd_1_t * data);
//! @brief Function to read struct list_float_1_t
static void read_list_float_1_t_struct(erpc::Codec * codec, list_float_1_t * data);
// Read struct ServoCmd function implementation
static void read_ServoCmd_struct(erpc::Codec * codec, ServoCmd * data)
{
if(NULL == data)
{
return;
}
{
uint32_t id_len;
char * id_local;
codec->readString(id_len, &id_local);
data->id = (char*) erpc_malloc((id_len + 1) * sizeof(char));
if ((data->id == NULL) || (id_local == NULL))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(data->id, id_local, id_len);
(data->id)[id_len] = 0;
}
}
codec->read(data->angle_rad);
}
// Read struct list_ServoCmd_1_t function implementation
static void read_list_ServoCmd_1_t_struct(erpc::Codec * codec, list_ServoCmd_1_t * data)
{
if(NULL == data)
{
return;
}
codec->startReadList(data->elementsCount);
data->elements = (ServoCmd *) erpc_malloc(data->elementsCount * sizeof(ServoCmd));
if ((data->elements == NULL) && (data->elementsCount > 0))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
{
read_ServoCmd_struct(codec, &(data->elements[listCount]));
}
}
// Read struct list_float_1_t function implementation
static void read_list_float_1_t_struct(erpc::Codec * codec, list_float_1_t * data)
{
if(NULL == data)
{
return;
}
codec->startReadList(data->elementsCount);
data->elements = (float *) erpc_malloc(data->elementsCount * sizeof(float));
if ((data->elements == NULL) && (data->elementsCount > 0))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
{
codec->read(data->elements[listCount]);
}
}
//! @brief Function to free space allocated inside struct ServoCmd
static void free_ServoCmd_struct(ServoCmd * data);
//! @brief Function to free space allocated inside struct list_ServoCmd_1_t
static void free_list_ServoCmd_1_t_struct(list_ServoCmd_1_t * data);
//! @brief Function to free space allocated inside struct list_float_1_t
static void free_list_float_1_t_struct(list_float_1_t * data);
// Free space allocated inside struct ServoCmd function implementation
static void free_ServoCmd_struct(ServoCmd * data)
{
erpc_free(data->id);
}
// Free space allocated inside struct list_ServoCmd_1_t function implementation
static void free_list_ServoCmd_1_t_struct(list_ServoCmd_1_t * data)
{
for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
{
free_ServoCmd_struct(&data->elements[listCount]);
}
erpc_free(data->elements);
}
// Free space allocated inside struct list_float_1_t function implementation
static void free_list_float_1_t_struct(list_float_1_t * data)
{
erpc_free(data->elements);
}
servo_service_service::servo_service_service(servo_service_interface *_servo_service_interface)
: erpc::Service(servo_service_interface::m_serviceId)
, m_handler(_servo_service_interface)
{
}
servo_service_service::~servo_service_service()
{
}
// return service interface handler.
servo_service_interface* servo_service_service::getHandler(void)
{
return m_handler;
}
// Call the correct server shim based on method unique ID.
erpc_status_t servo_service_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory, Transport * transport)
{
erpc_status_t erpcStatus;
switch (methodId)
{
case servo_service_interface::m_setConstraintsId:
{
erpcStatus = setConstraints_shim(codec, messageFactory, transport, sequence);
break;
}
case servo_service_interface::m_setPositionGainId:
{
erpcStatus = setPositionGain_shim(codec, messageFactory, transport, sequence);
break;
}
case servo_service_interface::m_setModeId:
{
erpcStatus = setMode_shim(codec, messageFactory, transport, sequence);
break;
}
case servo_service_interface::m_setUpdatePeriodMsId:
{
erpcStatus = setUpdatePeriodMs_shim(codec, messageFactory, transport, sequence);
break;
}
case servo_service_interface::m_moveId:
{
erpcStatus = move_shim(codec, messageFactory, transport, sequence);
break;
}
case servo_service_interface::m_moveJId:
{
erpcStatus = moveJ_shim(codec, messageFactory, transport, sequence);
break;
}
default:
{
erpcStatus = kErpcStatus_InvalidArgument;
break;
}
}
return erpcStatus;
}
// Server shim for setConstraints of servo_service interface.
erpc_status_t servo_service_service::setConstraints_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
char * id = NULL;
float max_velocity_rad;
float max_acceleration_rad;
float max_jerk_rad;
bool result;
// startReadMessage() was already called before this shim was invoked.
{
uint32_t id_len;
char * id_local;
codec->readString(id_len, &id_local);
id = (char*) erpc_malloc((id_len + 1) * sizeof(char));
if ((id == NULL) || (id_local == NULL))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(id, id_local, id_len);
(id)[id_len] = 0;
}
}
codec->read(max_velocity_rad);
codec->read(max_acceleration_rad);
codec->read(max_jerk_rad);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->setConstraints(id, max_velocity_rad, max_acceleration_rad, max_jerk_rad);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, servo_service_interface::m_serviceId, servo_service_interface::m_setConstraintsId, sequence);
codec->write(result);
err = codec->getStatus();
}
erpc_free(id);
return err;
}
// Server shim for setPositionGain of servo_service interface.
erpc_status_t servo_service_service::setPositionGain_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
char * id = NULL;
float position_gain;
bool result;
// startReadMessage() was already called before this shim was invoked.
{
uint32_t id_len;
char * id_local;
codec->readString(id_len, &id_local);
id = (char*) erpc_malloc((id_len + 1) * sizeof(char));
if ((id == NULL) || (id_local == NULL))
{
codec->updateStatus(kErpcStatus_MemoryError);
}
else
{
memcpy(id, id_local, id_len);
(id)[id_len] = 0;
}
}
codec->read(position_gain);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->setPositionGain(id, position_gain);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, servo_service_interface::m_serviceId, servo_service_interface::m_setPositionGainId, sequence);
codec->write(result);
err = codec->getStatus();
}
erpc_free(id);
return err;
}
// Server shim for setMode of servo_service interface.
erpc_status_t servo_service_service::setMode_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
RpcMotionMode mode;
int32_t _tmp_local_i32;
bool result;
// startReadMessage() was already called before this shim was invoked.
codec->read(_tmp_local_i32);
mode = static_cast<RpcMotionMode>(_tmp_local_i32);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->setMode(mode);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, servo_service_interface::m_serviceId, servo_service_interface::m_setModeId, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}
// Server shim for setUpdatePeriodMs of servo_service interface.
erpc_status_t servo_service_service::setUpdatePeriodMs_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
uint32_t ms;
bool result;
// startReadMessage() was already called before this shim was invoked.
codec->read(ms);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->setUpdatePeriodMs(ms);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, servo_service_interface::m_serviceId, servo_service_interface::m_setUpdatePeriodMsId, sequence);
codec->write(result);
err = codec->getStatus();
}
return err;
}
// Server shim for move of servo_service interface.
erpc_status_t servo_service_service::move_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
list_ServoCmd_1_t *cmds = NULL;
cmds = (list_ServoCmd_1_t *) erpc_malloc(sizeof(list_ServoCmd_1_t));
if (cmds == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
int32_t result;
// startReadMessage() was already called before this shim was invoked.
read_list_ServoCmd_1_t_struct(codec, cmds);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->move(cmds);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, servo_service_interface::m_serviceId, servo_service_interface::m_moveId, sequence);
codec->write(result);
err = codec->getStatus();
}
if (cmds)
{
free_list_ServoCmd_1_t_struct(cmds);
}
erpc_free(cmds);
return err;
}
// Server shim for moveJ of servo_service interface.
erpc_status_t servo_service_service::moveJ_shim(Codec * codec, MessageBufferFactory *messageFactory, Transport * transport, uint32_t sequence)
{
erpc_status_t err = kErpcStatus_Success;
list_float_1_t *angles_rad = NULL;
angles_rad = (list_float_1_t *) erpc_malloc(sizeof(list_float_1_t));
if (angles_rad == NULL)
{
codec->updateStatus(kErpcStatus_MemoryError);
}
int32_t result;
// startReadMessage() was already called before this shim was invoked.
read_list_float_1_t_struct(codec, angles_rad);
err = codec->getStatus();
if (err == kErpcStatus_Success)
{
// Invoke the actual served function.
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = true;
#endif
result = m_handler->moveJ(angles_rad);
#if ERPC_NESTED_CALLS_DETECTION
nestingDetection = false;
#endif
// preparing MessageBuffer for serializing data
err = messageFactory->prepareServerBufferForSend(codec->getBufferRef(), transport->reserveHeaderSize());
}
if (err == kErpcStatus_Success)
{
// preparing codec for serializing data
codec->reset(transport->reserveHeaderSize());
// Build response message.
codec->startWriteMessage(message_type_t::kReplyMessage, servo_service_interface::m_serviceId, servo_service_interface::m_moveJId, sequence);
codec->write(result);
err = codec->getStatus();
}
if (angles_rad)
{
free_list_float_1_t_struct(angles_rad);
}
erpc_free(angles_rad);
return err;
}

View File

@ -0,0 +1,64 @@
/*
* Generated by erpcgen 1.14.0 on Tue Apr 28 13:10:25 2026.
*
* AUTOGENERATED - DO NOT EDIT
*/
#if !defined(_servo_service_server_hpp_)
#define _servo_service_server_hpp_
#include "servo_service_interface.hpp"
#include "erpc_server.hpp"
#include "erpc_codec.hpp"
#if 11400 != ERPC_VERSION_NUMBER
#error "The generated shim code version is different to the rest of eRPC code."
#endif
namespace erpcShim
{
/*!
* @brief Service subclass for servo_service.
*/
class servo_service_service : public erpc::Service
{
public:
servo_service_service(servo_service_interface *_servo_service_interface);
virtual ~servo_service_service();
/*! @brief return service interface handler. */
servo_service_interface* getHandler(void);
/*! @brief Call the correct server shim based on method unique ID. */
virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport);
private:
servo_service_interface *m_handler;
/*! @brief Server shim for setConstraints of servo_service interface. */
erpc_status_t setConstraints_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for setPositionGain of servo_service interface. */
erpc_status_t setPositionGain_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for setMode of servo_service interface. */
erpc_status_t setMode_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for setUpdatePeriodMs of servo_service interface. */
erpc_status_t setUpdatePeriodMs_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for move of servo_service interface. */
erpc_status_t move_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
/*! @brief Server shim for moveJ of servo_service interface. */
erpc_status_t moveJ_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, erpc::Transport * transport, uint32_t sequence);
};
} // erpcShim
#endif // _servo_service_server_hpp_

View File

@ -1,3 +0,0 @@
interface demo {
add(int32 a, int32 b) -> int32
};

View File

@ -0,0 +1,34 @@
// servo_service.erpc
// Generator examples:
// .\erpcgen.exe -o .\generated\ -g c .\servo_service.erpc
// .\erpcgen.exe -g py .\servo_service.erpc
// 注意interface 客户端和服务端erpc里面的函数顺序一定要一样
program servo_service
enum RpcMotionMode {
RpcMotionModeImmediate = 0,
RpcMotionModeSCurve = 1,
RpcMotionModeFollow = 2
}
struct ServoCmd {
string id
float angle_rad
}
interface servo_service
{
setConstraints(string id,
float max_velocity_rad,
float max_acceleration_rad,
float max_jerk_rad) -> bool
setPositionGain(string id,
float position_gain) -> bool
setMode(RpcMotionMode mode)->bool
setUpdatePeriodMs(uint32 ms) -> bool
move(list<ServoCmd> cmds) -> int32
moveJ(list<float> angles_rad) -> int32
}

View File

@ -0,0 +1,43 @@
//
// Created by Administrator on 2026/4/27.
//
#ifndef RTTHREAD_HEAD_FILE_SERVICE_IMPL_H
#define RTTHREAD_HEAD_FILE_SERVICE_IMPL_H
#include <string>
#include "erpc/proto/generated/file_service_server.hpp"
#include <rtthread.h>
class FileServiceImpl : public erpcShim::file_service_interface
{
public:
FileServiceImpl();
~FileServiceImpl() override;
int32_t fileWriteBegin(const char* path, uint32_t total_size) override;
int32_t fileWriteChunk(const binary_t* data) override;
int32_t fileWriteEnd(void) override;
int32_t fileWriteAbort(void) override;
private:
// 当前实现一次只允许一个上传会话;下面的上传状态由 upload_mutex_ 保护。
rt_mutex_t upload_mutex_;
int upload_fd_;
uint32_t upload_expected_size_;
uint32_t upload_received_size_;
std::string upload_target_path_;
std::string upload_temp_path_;
// 规范化上传路径,并拒绝设备路径和父目录跳转。
static bool normalizeUploadPath(const char* path, std::string* normalized);
static int32_t posixErrorToRtError(void);
void resetUploadStateLocked(void);
// 调用方必须已经持有 upload_mutex_。
int32_t abortUploadLocked(void);
};
#endif

View File

@ -1,24 +0,0 @@
//
// Created by Administrator on 2025/12/24.
//
#ifndef RTTHREAD_HEAD_SERVICE_IMPL_H
#define RTTHREAD_HEAD_SERVICE_IMPL_H
#include <stdint.h>
#include "erpc/proto/generated/head_service_interface.hpp"
class HeadServiceImpl : public erpcShim::demo_interface
{
public:
HeadServiceImpl() = default;
virtual ~HeadServiceImpl() = default;
// 实现你 .erpc 里定义的方法(这里只举例 add
int32_t add(int32_t a, int32_t b) override;
};
#endif //RTTHREAD_HEAD_SERVICE_IMPL_H

View File

@ -0,0 +1,42 @@
//
// Created by Administrator on 2025/12/24.
//
#ifndef RTTHREAD_HEAD_SERVICE_IMPL_H
#define RTTHREAD_HEAD_SERVICE_IMPL_H
#include <stdint.h>
#include <vector>
#include "erpc/proto/generated/servo_service_server.hpp"
#include "servo_manager/include/servo_manager.h"
#include <rtthread.h>
class ServoServiceImpl : public erpcShim::servo_service_interface
{
public:
ServoServiceImpl();
~ServoServiceImpl() override;
bool setConstraints(const char* id,
float max_velocity_rad,
float max_acceleration_rad,
float max_jerk_rad) override;
bool setPositionGain(const char* id,
float position_gain) override;
bool setMode(RpcMotionMode mode) override;
bool setUpdatePeriodMs(uint32_t ms) override;
int32_t move(const list_ServoCmd_1_t* cmds) override;
int32_t moveJ(const list_float_1_t* angles_rad) override;
private:
ServoManager manager_;
rt_err_t init_err_;
MotionMode mode_;
rt_mutex_t mutex_;
};
#endif // RTTHREAD_HEAD_SERVICE_IMPL_H

View File

@ -10,22 +10,20 @@
#include "erpc_server_setup.h"
#include "erpc_transport_setup.h"
#include "erpc_mbf_setup.h"
#include "erpc_usb_cdc_transport.hpp"
#include "erpc/proto/generated/head_service_server.hpp"
#include "erpc/proto/generated/head_service_interface.hpp"
#include "erpc/service/include/head_service_impl.h"
#include "erpc/proto/generated/servo_service_server.hpp"
#include "erpc/proto/generated/servo_service_interface.hpp"
#include "erpc/service/include/servo_service_impl.h"
#include "erpc/common/include/erpc_error_handler.h"
// ====== 参数 ======
#ifndef ERPC_SERVER_UART_NAME
#define ERPC_SERVER_UART_NAME "uart2"
#endif
#ifndef ERPC_UART_BAUD
#define ERPC_UART_BAUD (921600 )
#endif
#include "erpc/proto/generated/file_service_server.hpp"
#include "erpc/proto/generated/file_service_interface.hpp"
#include "erpc/service/include/file_service_impl.h"
#ifndef ERPC_THREAD_STACK
#define ERPC_THREAD_STACK (4096)
@ -42,13 +40,15 @@
static void erpc_server_entry(void *parameter)
{
(void)parameter;
// rt_kprintf("CPACR=%08lx\n", SCB->CPACR);
rt_kprintf("[erpc] server init on %s, %d\r\n", ERPC_SERVER_UART_NAME, ERPC_UART_BAUD);
// 1) transport
erpc_transport_t transport = erpc_transport_serial_init(ERPC_SERVER_UART_NAME,ERPC_UART_BAUD);
static serial_port_usb_cdc_config_t cfg = {
.dev_name = "cdc0",
.rx_wait_ms = -1,
.tx_wait_ms = 2000,
};
erpc_transport_t transport = erpc_transport_usb_cdc_init(NULL, NULL, &cfg, NULL, 0);
// erpc_transport_t transport = erpc_transport_serial_init(ERPC_SERVER_UART_NAME,ERPC_UART_BAUD);
// erpc_transport_t transport = erpc_transport_cmsis_uart_init(ERPC_SERVER_UART_NAME);
if (!transport)
{
@ -72,12 +72,17 @@ static void erpc_server_entry(void *parameter)
return;
}
// 4) register service(你生成的是 demo_service + demo_interface
static HeadServiceImpl impl; // 必须继承 erpcShim::demo_interface
static erpcShim::demo_service service(&impl); // 生成的 service wrapper
// 4) register service
static ServoServiceImpl impl; // 必须继承 erpcShim::demo_interface
static erpcShim::servo_service_service service(&impl); // 生成的 service wrapper
erpc_add_service_to_server(server, &service);
static FileServiceImpl file_impl;
static erpcShim::file_service_service file_service(&file_impl);
erpc_add_service_to_server(server, &file_service);
rt_kprintf("[erpc] server run\r\n");
erpc_server_run(server);
while (true){

View File

@ -0,0 +1,278 @@
//
// Created by Administrator on 2026/4/27.
//
#include "erpc/service/include/file_service_impl.h"
#include <fcntl.h>
#include <unistd.h>
FileServiceImpl::FileServiceImpl()
: upload_mutex_(RT_NULL),
upload_fd_(-1),
upload_expected_size_(0),
upload_received_size_(0)
{
upload_mutex_ = rt_mutex_create("sv_file", RT_IPC_FLAG_PRIO);
}
FileServiceImpl::~FileServiceImpl()
{
if (upload_mutex_) {
rt_mutex_take(upload_mutex_, RT_WAITING_FOREVER);
(void)abortUploadLocked();
rt_mutex_release(upload_mutex_);
rt_mutex_delete(upload_mutex_);
upload_mutex_ = RT_NULL;
}
}
bool FileServiceImpl::normalizeUploadPath(const char* path, std::string* normalized)
{
std::string local_path;
if (!path || !normalized) {
return false;
}
local_path.assign(path);
if (local_path.empty()) {
return false;
}
if (local_path[0] != '/') {
local_path.insert(local_path.begin(), '/');
}
// 避免覆盖设备节点,也避免通过 ".." 跳出预期目录。
if (local_path == "/" ||
local_path.rfind("/dev", 0) == 0 ||
local_path.find("/../") != std::string::npos ||
(local_path.size() >= 3 && local_path.compare(local_path.size() - 3, 3, "/..") == 0)) {
return false;
}
*normalized = local_path;
return true;
}
int32_t FileServiceImpl::posixErrorToRtError(void)
{
const int err = rt_get_errno();
if (err > 0) {
return -err;
}
if (err < 0) {
return err;
}
return -RT_ERROR;
}
void FileServiceImpl::resetUploadStateLocked(void)
{
upload_fd_ = -1;
upload_expected_size_ = 0;
upload_received_size_ = 0;
upload_target_path_.clear();
upload_temp_path_.clear();
}
int32_t FileServiceImpl::abortUploadLocked(void)
{
// 取消上传时尽量关闭文件、删除残留的 .part 文件,并清空内存状态。
if (upload_fd_ >= 0) {
if (::close(upload_fd_) != 0) {
const int32_t err = posixErrorToRtError();
upload_fd_ = -1;
if (!upload_temp_path_.empty()) {
(void)::unlink(upload_temp_path_.c_str());
}
resetUploadStateLocked();
return err;
}
}
if (!upload_temp_path_.empty()) {
(void)::unlink(upload_temp_path_.c_str());
}
resetUploadStateLocked();
return RT_EOK;
}
int32_t FileServiceImpl::fileWriteBegin(const char* path, uint32_t total_size)
{
std::string normalized_path;
std::string temp_path;
int fd;
if (!upload_mutex_) {
rt_kprintf("[FileService][E] fileWriteBegin: upload mutex is null\n");
return -RT_ENOMEM;
}
if (!normalizeUploadPath(path, &normalized_path)) {
rt_kprintf("[FileService][E] fileWriteBegin: invalid path=%s\n",
path ? path : "(null)");
return -RT_EINVAL;
}
temp_path = normalized_path + ".part";
rt_mutex_take(upload_mutex_, RT_WAITING_FOREVER);
// 单会话上传可以避免多个客户端同时写同一组上传状态。
if (upload_fd_ >= 0) {
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteBegin: upload already active, path=%s\n",
upload_target_path_.c_str());
return -RT_EBUSY;
}
// 先写临时文件,只有 fileWriteEnd() 校验完整大小后才发布到目标路径。
(void)::unlink(temp_path.c_str());
fd = ::open(temp_path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0);
if (fd < 0) {
const int32_t err = posixErrorToRtError();
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteBegin: open failed, path=%s err=%d\n",
temp_path.c_str(),
(int)err);
return err;
}
upload_fd_ = fd;
upload_expected_size_ = total_size;
upload_received_size_ = 0;
upload_target_path_ = normalized_path;
upload_temp_path_ = temp_path;
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService] fileWriteBegin: path=%s size=%u\n",
upload_target_path_.c_str(),
(unsigned)upload_expected_size_);
return RT_EOK;
}
int32_t FileServiceImpl::fileWriteChunk(const binary_t* data)
{
uint32_t remaining;
const uint8_t* cursor;
if (!upload_mutex_) {
return -RT_ENOMEM;
}
if (!data || (!data->data && data->dataLength > 0)) {
rt_kprintf("[FileService][E] fileWriteChunk: invalid chunk\n");
return -RT_EINVAL;
}
rt_mutex_take(upload_mutex_, RT_WAITING_FOREVER);
if (upload_fd_ < 0) {
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteChunk: upload not started\n");
return -RT_ERROR;
}
// 防止客户端重传、偏移错误或长度错误导致写入超过声明的 total_size。
if (data->dataLength > (upload_expected_size_ - upload_received_size_)) {
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteChunk: chunk overflow, recv=%u chunk=%u total=%u\n",
(unsigned)upload_received_size_,
(unsigned)data->dataLength,
(unsigned)upload_expected_size_);
return -RT_EINVAL;
}
remaining = data->dataLength;
cursor = data->data;
// write() 可能只写入部分数据,因此循环直到当前 eRPC binary 块全部落盘。
while (remaining > 0) {
const ssize_t written = ::write(upload_fd_, cursor, remaining);
if (written <= 0) {
const int32_t err = posixErrorToRtError();
(void)abortUploadLocked();
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteChunk: write failed, err=%d\n", (int)err);
return err;
}
remaining -= (uint32_t)written;
cursor += written;
upload_received_size_ += (uint32_t)written;
}
rt_mutex_release(upload_mutex_);
return RT_EOK;
}
int32_t FileServiceImpl::fileWriteEnd(void)
{
if (!upload_mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(upload_mutex_, RT_WAITING_FOREVER);
if (upload_fd_ < 0) {
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteEnd: upload not started\n");
return -RT_ERROR;
}
// 最终大小必须完全一致,避免缺块时发布不完整文件。
if (upload_received_size_ != upload_expected_size_) {
const uint32_t received = upload_received_size_;
const uint32_t expected = upload_expected_size_;
(void)abortUploadLocked();
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteEnd: size mismatch, recv=%u expected=%u\n",
(unsigned)received,
(unsigned)expected);
return -RT_EINVAL;
}
if (::close(upload_fd_) != 0) {
const int32_t err = posixErrorToRtError();
upload_fd_ = -1;
(void)::unlink(upload_temp_path_.c_str());
resetUploadStateLocked();
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteEnd: close failed, err=%d\n", (int)err);
return err;
}
upload_fd_ = -1;
if (::rename(upload_temp_path_.c_str(), upload_target_path_.c_str()) != 0) {
(void)::unlink(upload_target_path_.c_str());
if (::rename(upload_temp_path_.c_str(), upload_target_path_.c_str()) != 0) {
const int32_t err = posixErrorToRtError();
(void)::unlink(upload_temp_path_.c_str());
resetUploadStateLocked();
rt_mutex_release(upload_mutex_);
rt_kprintf("[FileService][E] fileWriteEnd: rename failed, err=%d\n", (int)err);
return err;
}
}
rt_kprintf("[FileService] fileWriteEnd: path=%s size=%u\n",
upload_target_path_.c_str(),
(unsigned)upload_received_size_);
resetUploadStateLocked();
rt_mutex_release(upload_mutex_);
return RT_EOK;
}
int32_t FileServiceImpl::fileWriteAbort(void)
{
int32_t err;
if (!upload_mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(upload_mutex_, RT_WAITING_FOREVER);
err = abortUploadLocked();
rt_mutex_release(upload_mutex_);
return err;
}

View File

@ -1,17 +0,0 @@
//
// Created by Administrator on 2025/12/24.
//
#include "../include/head_service_impl.h"
#include <rtthread.h>
int32_t HeadServiceImpl::add(int32_t a, int32_t b)
{
int32_t r = a + b;
rt_tick_t now = rt_tick_get();
rt_uint32_t ms = (rt_uint32_t)((rt_uint64_t)now * 1000 / RT_TICK_PER_SECOND);
rt_kprintf("[%lu ms] [erpc service] add(%ld,%ld)=%ld\r\n",
(unsigned long)ms, (long)a, (long)b, (long)r);
return r;
}

View File

@ -0,0 +1,294 @@
//
// Created by Administrator on 2025/12/24.
//
#include "erpc/service/include/servo_service_impl.h"
#include <string>
ServoServiceImpl::ServoServiceImpl()
: manager_("/config/servo_config.json"),
init_err_(RT_EOK),
mode_(MotionMode::Immediate),
mutex_(RT_NULL)
{
mutex_ = rt_mutex_create("sv_svc", RT_IPC_FLAG_PRIO);
if (!mutex_) {
init_err_ = -RT_ENOMEM;
rt_kprintf("[ServoService][E] mutex create FAILED, err=%d\n", (int)init_err_);
return;
}
init_err_ = manager_.init(true, true);
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] init FAILED, err=%d\n", (int)init_err_);
return;
}
manager_.setUpdatePeriodMs(10);
init_err_ = manager_.start();
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] manager start FAILED, err=%d\n", (int)init_err_);
}
}
ServoServiceImpl::~ServoServiceImpl()
{
if (mutex_) {
rt_mutex_delete(mutex_);
mutex_ = RT_NULL;
}
}
bool ServoServiceImpl::setConstraints(const char* id,
float max_velocity_rad,
float max_acceleration_rad,
float max_jerk_rad)
{
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] setConstraints: service not ready, init_err=%d\n",
(int)init_err_);
return false;
}
if (!id) {
rt_kprintf("[ServoService][E] setConstraints: id is null\n");
return false;
}
if (max_velocity_rad <= 0.0f ||
max_acceleration_rad <= 0.0f ||
max_jerk_rad <= 0.0f) {
rt_kprintf("[ServoService][E] setConstraints: invalid constraints, id=%s v=%.4f a=%.4f j=%.4f\n",
id,
(double)max_velocity_rad,
(double)max_acceleration_rad,
(double)max_jerk_rad);
return false;
}
ServoControl* servo = manager_.get(std::string(id));
if (!servo) {
rt_kprintf("[ServoService][E] setConstraints: servo not found, id=%s\n", id);
return false;
}
servo->setConstraints(max_velocity_rad, max_acceleration_rad, max_jerk_rad);
rt_kprintf("[ServoService] setConstraints: id=%s v=%.4f a=%.4f j=%.4f\n",
id,
(double)max_velocity_rad,
(double)max_acceleration_rad,
(double)max_jerk_rad);
return true;
}
bool ServoServiceImpl::setPositionGain(const char* id, float position_gain)
{
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] setPositionGain: service not ready, init_err=%d\n",
(int)init_err_);
return false;
}
if (!id) {
rt_kprintf("[ServoService][E] setPositionGain: id is null\n");
return false;
}
if (position_gain < 0.0f) {
rt_kprintf("[ServoService][E] setPositionGain: invalid gain, id=%s gain=%.4f\n",
id,
(double)position_gain);
return false;
}
ServoControl* servo = manager_.get(std::string(id));
if (!servo) {
rt_kprintf("[ServoService][E] setPositionGain: servo not found, id=%s\n", id);
return false;
}
servo->setPositionGain(position_gain);
manager_.wake();
rt_kprintf("[ServoService] setPositionGain: id=%s gain=%.4f\n",
id,
(double)position_gain);
return true;
}
bool ServoServiceImpl::setMode(RpcMotionMode mode)
{
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] setMode: service not ready, init_err=%d\n",
(int)init_err_);
return false;
}
if (!mutex_) {
rt_kprintf("[ServoService][E] setMode: mutex is null\n");
return false;
}
MotionMode motion_mode;
switch (static_cast<int>(mode)) {
case RpcMotionModeImmediate:
motion_mode = MotionMode::Immediate;
break;
case RpcMotionModeSCurve:
motion_mode = MotionMode::SCurve;
break;
case 2:
motion_mode = MotionMode::Follow;
break;
default:
rt_kprintf("[ServoService][E] setMode: invalid mode=%d\n", (int)mode);
return false;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
mode_ = motion_mode;
rt_mutex_release(mutex_);
rt_kprintf("[ServoService] setMode: mode=%d\n", (int)mode);
return true;
}
bool ServoServiceImpl::setUpdatePeriodMs(uint32_t ms)
{
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] setUpdatePeriodMs: service not ready, init_err=%d\n",
(int)init_err_);
return false;
}
manager_.setUpdatePeriodMs(ms);
manager_.wake();
rt_kprintf("[ServoService] setUpdatePeriodMs: ms=%u\n", (unsigned)ms);
return true;
}
int32_t ServoServiceImpl::move(const list_ServoCmd_1_t* cmds)
{
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] move: service not ready, init_err=%d\n",
(int)init_err_);
return init_err_;
}
if (!cmds) {
rt_kprintf("[ServoService][E] move: cmds is null\n");
return -RT_EINVAL;
}
if (!cmds->elements || cmds->elementsCount == 0) {
rt_kprintf("[ServoService][E] move: empty list (elements=%p, count=%d)\n",
cmds->elements,
(int)cmds->elementsCount);
return -RT_EINVAL;
}
if (!mutex_) {
rt_kprintf("[ServoService][E] move: mutex is null\n");
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const MotionMode motion_mode = mode_;
rt_mutex_release(mutex_);
for (uint32_t i = 0; i < cmds->elementsCount; ++i) {
const char* id = cmds->elements[i].id;
if (!id) {
rt_kprintf("[ServoService][E] move: cmds[%d].id is null\n", (int)i);
return -RT_EINVAL;
}
ServoControl* servo = manager_.get(std::string(id));
if (!servo) {
rt_kprintf("[ServoService][E] move: servo not found, id=%s\n", id);
return -RT_ENOSYS;
}
const rt_err_t err = servo->move(cmds->elements[i].angle_rad, motion_mode);
if (err != RT_EOK) {
rt_kprintf("[ServoService][E] move: move failed, id=%s angle=%.4f mode=%d err=%d\n",
id,
(double)cmds->elements[i].angle_rad,
(int)motion_mode,
(int)err);
return err;
}
}
if (motion_mode != MotionMode::Immediate) {
manager_.wake();
}
return RT_EOK;
}
int32_t ServoServiceImpl::moveJ(const list_float_1_t* angles_rad)
{
if (init_err_ != RT_EOK) {
rt_kprintf("[ServoService][E] moveJ: service not ready, init_err=%d\n",
(int)init_err_);
return init_err_;
}
if (!angles_rad) {
rt_kprintf("[ServoService][E] moveJ: angles_rad is null\n");
return -RT_EINVAL;
}
if (!angles_rad->elements || angles_rad->elementsCount == 0) {
rt_kprintf("[ServoService][E] moveJ: empty list (elements=%p, count=%d)\n",
angles_rad->elements,
(int)angles_rad->elementsCount);
return -RT_EINVAL;
}
const size_t need = manager_.count();
const size_t got = (size_t)angles_rad->elementsCount;
if (got != need) {
rt_kprintf("[ServoService][E] moveJ: invalid angles count, need=%d got=%d\n",
(int)need,
(int)got);
return -RT_EINVAL;
}
if (!mutex_) {
rt_kprintf("[ServoService][E] moveJ: mutex is null\n");
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const MotionMode motion_mode = mode_;
rt_mutex_release(mutex_);
for (size_t i = 0; i < need; ++i) {
ServoControl* servo = manager_.get(i);
if (!servo) {
rt_kprintf("[ServoService][E] moveJ: servo not found, index=%d\n", (int)i);
return -RT_ENOSYS;
}
const rt_err_t err = servo->move(angles_rad->elements[i], motion_mode);
if (err != RT_EOK) {
rt_kprintf("[ServoService][E] moveJ: move failed, id=%s angle=%.4f mode=%d err=%d\n",
servo->id().c_str(),
(double)angles_rad->elements[i],
(int)motion_mode,
(int)err);
return err;
}
}
if (motion_mode != MotionMode::Immediate) {
manager_.wake();
}
return RT_EOK;
}

View File

@ -8,42 +8,29 @@
* 2019-03-05 whj4674672 first version
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <rtthread.h>
#include <board.h>
/* defined the LED0 pin: PB1 */
#define LED0_PIN GET_PIN(C, 13)
#include "fal.h"
/* defined the LED0 pin: PC13 */
#define LED0_PIN GET_PIN(A, 4)
int main(void)
{
int count = 1;
/* set LED0 pin mode to output */
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(GET_PIN(D, 0), PIN_MODE_OUTPUT);
fal_init();
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
while (count++)
{
rt_pin_write(LED0_PIN, PIN_HIGH);
rt_thread_mdelay(100);
rt_thread_mdelay(500);
rt_pin_write(LED0_PIN, PIN_LOW);
rt_thread_mdelay(100);
// rt_kprintf("Hello RT-Thread!\n");
rt_thread_mdelay(500);
}
return RT_EOK;
}
static inline int dwt_init(void)
{
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
return 0;
}
INIT_APP_EXPORT(dwt_init);

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = Glob('s_curve_planner/src/*.cpp')
CPPPATH = [cwd]
group = DefineGroup('controller', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

View File

@ -0,0 +1,100 @@
//
// Created by lgv on 2026/3/10.
//
#pragma once
#include "s_curve_velocity_planner.h"
#include <algorithm>
#include <cmath>
namespace cmvr
{
struct SCurvePositionPlannerState
{
double position;
double velocity;
double acceleration;
double jerk;
double target_position;
bool is_moving;
SCurvePositionPlannerState()
: position(0.0)
, velocity(0.0)
, acceleration(0.0)
, jerk(0.0)
, target_position(0.0)
, is_moving(false)
{}
};
/**
* @brief
*
*
* - position_error -> desired_velocity
* - SCurveVelocityPlanner1D jerk-limited
*
* profile
*/
class SCurvePositionPlanner1D
{
public:
SCurvePositionPlanner1D(double max_velocity = 3.0,
double max_acceleration = 10.0,
double max_jerk = 50.0);
void setConstraints(double max_velocity, double max_acceleration, double max_jerk);
void getConstraints(double& max_velocity, double& max_acceleration, double& max_jerk) const;
void setPositionGain(double position_gain);
double getPositionGain() const { return position_gain_; }
void initialize(double position, double velocity = 0.0, double acceleration = 0.0);
void reset();
void setTarget(double target_position);
double update(double dt);
const SCurvePositionPlannerState& getState() const { return state_; }
double getPosition() const { return state_.position; }
double getVelocity() const { return state_.velocity; }
double getAcceleration() const { return state_.acceleration; }
double getJerk() const { return state_.jerk; }
double getTargetPosition() const { return state_.target_position; }
bool isMoving() const { return state_.is_moving; }
private:
double max_velocity_;
double max_acceleration_;
double max_jerk_;
SCurvePositionPlannerState state_;
SCurveVelocityPlanner1D velocity_planner_;
double position_gain_;
static constexpr double EPSILON = 1e-9;
static constexpr double VELOCITY_THRESHOLD = 1e-6;
static constexpr double ACCELERATION_THRESHOLD = 1e-6;
static constexpr double POSITION_THRESHOLD = 1e-7;
double computeDesiredVelocity(double position_error) const;
double computePlannerStoppingDistance(double velocity, double acceleration) const;
static double clamp(double value, double min_val, double max_val)
{
return std::max(min_val, std::min(max_val, value));
}
static double sign(double value)
{
if (value > EPSILON) return 1.0;
if (value < -EPSILON) return -1.0;
return 0.0;
}
};
} // namespace cmvr

View File

@ -0,0 +1,240 @@
//
// Created by lgv on 2026/3/9.
//
#pragma once
#include <algorithm>
#include <cmath>
#include <vector>
namespace cmvr
{
/**
* @brief S 线
*
* (v0, a0) (vf, 0) 3 jerk-limited profile
*
* seg1: jerk = j1, duration = t1
* seg2: jerk = j2, duration = t2 ( j2 = 0)
* seg3: jerk = j3, duration = t3
*
* j1/j3 ±j_maxj2 0
*/
struct SCurveVelocityProfile
{
double t1;
double t2;
double t3;
double total_time;
double j1;
double j2;
double j3;
double v0;
double a0;
double vf;
bool valid;
SCurveVelocityProfile()
: t1(0.0), t2(0.0), t3(0.0)
, total_time(0.0)
, j1(0.0), j2(0.0), j3(0.0)
, v0(0.0), a0(0.0), vf(0.0)
, valid(false)
{}
};
/**
* @brief S 线
*/
struct SCurveVelocityPlannerState
{
double velocity;
double acceleration;
double jerk;
double target_velocity;
double elapsed_time;
bool has_active_profile;
bool is_moving;
SCurveVelocityPlannerState()
: velocity(0.0)
, acceleration(0.0)
, jerk(0.0)
, target_velocity(0.0)
, elapsed_time(0.0)
, has_active_profile(false)
, is_moving(false)
{}
};
/**
* @brief S 线
*
*
* - setTargetVelocity(v):
* - update(dt): active profile
* - overwriteState(v,a): profile
* - synchronizeAndReplan(v,a):
*
*
* - (v0, a0) (vf, 0)
* - |v| <= v_max, |a| <= a_max, |j| <= j_max
*/
class SCurveVelocityPlanner1D
{
public:
SCurveVelocityPlanner1D(double max_velocity = 1.0,
double max_acceleration = 1.0,
double max_jerk = 5.0);
void setConstraints(double max_velocity, double max_acceleration, double max_jerk);
void getConstraints(double& max_velocity, double& max_acceleration, double& max_jerk) const;
/**
* @brief
*
*
*/
void setTargetReplanThreshold(double threshold);
/**
* @brief
*
* profile
* synchronizeAndReplan() profile
*/
void setSynchronizeReplanThreshold(double threshold);
void initialize(double velocity = 0.0, double acceleration = 0.0);
void reset();
/**
* @brief profile
*
*
* -
* -
*/
void overwriteState(double velocity,
double acceleration = 0.0,
bool keep_target_velocity = true);
/**
* @brief
*
*
*/
void synchronizeAndReplan(double velocity,
double acceleration = 0.0);
/**
* @brief
*/
void setTargetVelocity(double target_velocity);
/**
* @brief
*/
void stop() { setTargetVelocity(0.0); }
/**
* @brief
* @param dt
* @return
*/
double update(double dt);
/**
* @brief
*/
SCurveVelocityProfile calculateProfile(double start_velocity,
double end_velocity,
double start_acceleration = 0.0) const;
/**
* @brief t
*/
double getVelocityAtTime(const SCurveVelocityProfile& profile, double t) const;
/**
* @brief t
*/
double getAccelerationAtTime(const SCurveVelocityProfile& profile, double t) const;
/**
* @brief t jerk
*/
double getJerkAtTime(const SCurveVelocityProfile& profile, double t) const;
/**
* @brief
*/
void generateTrajectory(const SCurveVelocityProfile& profile, double dt,
std::vector<double>& velocities,
std::vector<double>& accelerations,
std::vector<double>& jerks) const;
const SCurveVelocityPlannerState& getState() const { return state_; }
const SCurveVelocityProfile& getActiveProfile() const { return active_profile_; }
double getVelocity() const { return state_.velocity; }
double getAcceleration() const { return state_.acceleration; }
double getJerk() const { return state_.jerk; }
double getTargetVelocity() const { return state_.target_velocity; }
bool hasActiveProfile() const { return state_.has_active_profile; }
bool isMoving() const { return state_.is_moving; }
private:
double max_velocity_;
double max_acceleration_;
double max_jerk_;
double target_replan_threshold_;
double synchronize_replan_threshold_;
SCurveVelocityPlannerState state_;
SCurveVelocityProfile active_profile_;
static constexpr double EPSILON = 1e-9;
static constexpr double VELOCITY_THRESHOLD = 1e-6;
static constexpr double ACCELERATION_THRESHOLD = 1e-6;
static constexpr double DEFAULT_TARGET_REPLAN_THRESHOLD = 1e-9;
static constexpr double DEFAULT_SYNCHRONIZE_REPLAN_THRESHOLD = 5e-2;
private:
void updateIsMovingFlag();
/**
* @brief profile
*/
bool isVelocityLimitSatisfied(const SCurveVelocityProfile& profile) const;
/**
* @brief
*/
void integrateWholeProfile(const SCurveVelocityProfile& profile,
double& v_end,
double& a_end) const;
static double clamp(double value, double min_val, double max_val)
{
return std::max(min_val, std::min(max_val, value));
}
static double sign(double value)
{
if (value > EPSILON) return 1.0;
if (value < -EPSILON) return -1.0;
return 0.0;
}
};
} // namespace cmvr

View File

@ -0,0 +1,193 @@
//
// Created by lgv on 2026/3/10.
//
#include "planner/s_curve_planner/include/s_curve_position_planner.h"
#include <algorithm>
#include <cmath>
namespace cmvr
{
SCurvePositionPlanner1D::SCurvePositionPlanner1D(double max_velocity,
double max_acceleration,
double max_jerk)
: max_velocity_(std::abs(max_velocity))
, max_acceleration_(std::abs(max_acceleration))
, max_jerk_(std::abs(max_jerk))
, velocity_planner_(max_velocity_, max_acceleration_, max_jerk_)
, position_gain_(1.0)
{
velocity_planner_.setTargetReplanThreshold(std::max(1e-3, 0.02 * max_velocity_));
reset();
}
void SCurvePositionPlanner1D::setConstraints(double max_velocity,
double max_acceleration,
double max_jerk)
{
max_velocity_ = std::abs(max_velocity);
max_acceleration_ = std::abs(max_acceleration);
max_jerk_ = std::abs(max_jerk);
velocity_planner_.setConstraints(max_velocity_, max_acceleration_, max_jerk_);
velocity_planner_.setTargetReplanThreshold(std::max(1e-3, 0.02 * max_velocity_));
}
void SCurvePositionPlanner1D::getConstraints(double& max_velocity,
double& max_acceleration,
double& max_jerk) const
{
max_velocity = max_velocity_;
max_acceleration = max_acceleration_;
max_jerk = max_jerk_;
}
void SCurvePositionPlanner1D::setPositionGain(double position_gain)
{
position_gain_ = std::max(0.0, position_gain);
}
void SCurvePositionPlanner1D::initialize(double position, double velocity, double acceleration)
{
state_.position = position;
velocity_planner_.initialize(velocity, acceleration);
state_.velocity = velocity_planner_.getVelocity();
state_.acceleration = velocity_planner_.getAcceleration();
state_.jerk = 0.0;
state_.target_position = position;
state_.is_moving = false;
}
void SCurvePositionPlanner1D::reset()
{
state_ = SCurvePositionPlannerState();
velocity_planner_.reset();
}
void SCurvePositionPlanner1D::setTarget(double target_position)
{
state_.target_position = target_position;
}
double SCurvePositionPlanner1D::update(double dt)
{
if (dt <= 0.0 || dt > 0.1) {
return state_.position;
}
const double position_error = state_.target_position - state_.position;
if (std::abs(position_error) < POSITION_THRESHOLD &&
std::abs(velocity_planner_.getVelocity()) < VELOCITY_THRESHOLD &&
std::abs(velocity_planner_.getAcceleration()) < ACCELERATION_THRESHOLD) {
velocity_planner_.overwriteState(0.0, 0.0, false);
state_.position = state_.target_position;
state_.velocity = 0.0;
state_.acceleration = 0.0;
state_.jerk = 0.0;
state_.is_moving = false;
return state_.position;
}
velocity_planner_.setTargetVelocity(computeDesiredVelocity(position_error));
const double old_velocity = velocity_planner_.getVelocity();
const double new_velocity = velocity_planner_.update(dt);
state_.velocity = new_velocity;
state_.acceleration = velocity_planner_.getAcceleration();
state_.jerk = velocity_planner_.getJerk();
state_.position += 0.5 * (old_velocity + new_velocity) * dt;
const double updated_error = state_.target_position - state_.position;
if (std::abs(updated_error) < POSITION_THRESHOLD &&
std::abs(state_.velocity) < VELOCITY_THRESHOLD &&
std::abs(state_.acceleration) < ACCELERATION_THRESHOLD) {
velocity_planner_.overwriteState(0.0, 0.0, false);
state_.position = state_.target_position;
state_.velocity = 0.0;
state_.acceleration = 0.0;
state_.jerk = 0.0;
state_.is_moving = false;
return state_.position;
}
state_.is_moving = velocity_planner_.isMoving() ||
std::abs(updated_error) > POSITION_THRESHOLD;
return state_.position;
}
double SCurvePositionPlanner1D::computeDesiredVelocity(double position_error) const
{
if (std::abs(position_error) <= POSITION_THRESHOLD) {
return 0.0;
}
const double proportional_velocity =
clamp(position_gain_ * position_error, -max_velocity_, max_velocity_);
return proportional_velocity;
const double current_velocity = velocity_planner_.getVelocity();
const double current_acceleration = velocity_planner_.getAcceleration();
const double stopping_distance =
computePlannerStoppingDistance(current_velocity, current_acceleration);
if (std::abs(current_velocity) > VELOCITY_THRESHOLD &&
sign(current_velocity) != sign(position_error)) {
return 0.0;
}
if (std::abs(current_velocity) > VELOCITY_THRESHOLD &&
sign(current_velocity) == sign(position_error) &&
std::abs(position_error) <= std::abs(stopping_distance) * 1.05) {
return 0.0;
}
double low = 0.0;
double high = max_velocity_;
for (int i = 0; i < 40; ++i) {
const double mid = 0.5 * (low + high);
const double distance =
std::abs(computePlannerStoppingDistance(sign(position_error) * mid, 0.0));
if (distance <= std::abs(position_error)) {
low = mid;
} else {
high = mid;
}
}
return sign(position_error) *
std::min(std::abs(proportional_velocity), low);
}
double SCurvePositionPlanner1D::computePlannerStoppingDistance(double velocity,
double acceleration) const
{
if (std::abs(velocity) <= VELOCITY_THRESHOLD &&
std::abs(acceleration) <= ACCELERATION_THRESHOLD) {
return 0.0;
}
const auto profile = velocity_planner_.calculateProfile(velocity, 0.0, acceleration);
if (!profile.valid || profile.total_time <= EPSILON) {
return 0.0;
}
const int steps = std::max(16, static_cast<int>(std::ceil(profile.total_time / 0.002)));
const double dt = profile.total_time / static_cast<double>(steps);
double distance = 0.0;
double previous_time = 0.0;
double previous_velocity = velocity_planner_.getVelocityAtTime(profile, 0.0);
for (int i = 1; i <= steps; ++i) {
const double t = (i == steps) ? profile.total_time : i * dt;
const double current_velocity = velocity_planner_.getVelocityAtTime(profile, t);
distance += 0.5 * (previous_velocity + current_velocity) * (t - previous_time);
previous_time = t;
previous_velocity = current_velocity;
}
return distance;
}
} // namespace cmvr

View File

@ -0,0 +1,562 @@
//
// Created by lgv on 2026/3/9.
//
#include "../include/s_curve_velocity_planner.h"
#include <cmath>
#include <limits>
namespace cmvr
{
SCurveVelocityPlanner1D::SCurveVelocityPlanner1D(double max_velocity,
double max_acceleration,
double max_jerk)
: max_velocity_(std::abs(max_velocity))
, max_acceleration_(std::abs(max_acceleration))
, max_jerk_(std::abs(max_jerk))
, target_replan_threshold_(DEFAULT_TARGET_REPLAN_THRESHOLD)
, synchronize_replan_threshold_(DEFAULT_SYNCHRONIZE_REPLAN_THRESHOLD)
{
reset();
}
void SCurveVelocityPlanner1D::setConstraints(double max_velocity,
double max_acceleration,
double max_jerk)
{
max_velocity_ = std::abs(max_velocity);
max_acceleration_ = std::abs(max_acceleration);
max_jerk_ = std::abs(max_jerk);
state_.velocity = clamp(state_.velocity, -max_velocity_, max_velocity_);
state_.acceleration = clamp(state_.acceleration, -max_acceleration_, max_acceleration_);
state_.target_velocity = clamp(state_.target_velocity, -max_velocity_, max_velocity_);
if (state_.has_active_profile) {
active_profile_ = calculateProfile(state_.velocity,
state_.target_velocity,
state_.acceleration);
state_.elapsed_time = 0.0;
state_.has_active_profile = active_profile_.valid && active_profile_.total_time > EPSILON;
}
updateIsMovingFlag();
}
void SCurveVelocityPlanner1D::getConstraints(double& max_velocity,
double& max_acceleration,
double& max_jerk) const
{
max_velocity = max_velocity_;
max_acceleration = max_acceleration_;
max_jerk = max_jerk_;
}
void SCurveVelocityPlanner1D::setTargetReplanThreshold(double threshold)
{
target_replan_threshold_ = std::max(0.0, threshold);
}
void SCurveVelocityPlanner1D::setSynchronizeReplanThreshold(double threshold)
{
synchronize_replan_threshold_ = std::max(0.0, threshold);
}
void SCurveVelocityPlanner1D::initialize(double velocity, double acceleration)
{
state_ = SCurveVelocityPlannerState();
state_.velocity = clamp(velocity, -max_velocity_, max_velocity_);
state_.acceleration = clamp(acceleration, -max_acceleration_, max_acceleration_);
state_.jerk = 0.0;
state_.target_velocity = state_.velocity;
state_.elapsed_time = 0.0;
state_.has_active_profile = false;
active_profile_ = SCurveVelocityProfile();
active_profile_.v0 = state_.velocity;
active_profile_.a0 = state_.acceleration;
active_profile_.vf = state_.velocity;
active_profile_.valid = false;
updateIsMovingFlag();
}
void SCurveVelocityPlanner1D::reset()
{
state_ = SCurveVelocityPlannerState();
active_profile_ = SCurveVelocityProfile();
}
void SCurveVelocityPlanner1D::overwriteState(double velocity,
double acceleration,
bool keep_target_velocity)
{
state_.velocity = clamp(velocity, -max_velocity_, max_velocity_);
state_.acceleration = clamp(acceleration, -max_acceleration_, max_acceleration_);
state_.jerk = 0.0;
state_.elapsed_time = 0.0;
state_.has_active_profile = false;
if (!keep_target_velocity) {
state_.target_velocity = state_.velocity;
} else {
state_.target_velocity = clamp(state_.target_velocity, -max_velocity_, max_velocity_);
}
active_profile_ = SCurveVelocityProfile();
active_profile_.v0 = state_.velocity;
active_profile_.a0 = state_.acceleration;
active_profile_.vf = state_.target_velocity;
active_profile_.valid = false;
updateIsMovingFlag();
}
void SCurveVelocityPlanner1D::synchronizeAndReplan(double velocity,
double acceleration)
{
const double measured_velocity = clamp(velocity, -max_velocity_, max_velocity_);
const double measured_acceleration =
clamp(acceleration, -max_acceleration_, max_acceleration_);
if (!state_.has_active_profile &&
std::abs(measured_velocity - state_.target_velocity) <= VELOCITY_THRESHOLD) {
state_.velocity = state_.target_velocity;
state_.acceleration = 0.0;
state_.jerk = 0.0;
updateIsMovingFlag();
return;
}
// 如果测量值已经基本落在当前采样状态上,就继续沿现有 profile 走。
// 否则每拍都从同一目标重规划,会把已经进入的 jerk phase 反复打断。
if (state_.has_active_profile &&
std::abs(measured_velocity - state_.velocity) <= synchronize_replan_threshold_) {
state_.velocity = measured_velocity;
state_.acceleration = measured_acceleration;
state_.jerk = getJerkAtTime(active_profile_, state_.elapsed_time);
updateIsMovingFlag();
return;
}
state_.velocity = measured_velocity;
state_.acceleration = measured_acceleration;
state_.jerk = 0.0;
active_profile_ = calculateProfile(state_.velocity,
state_.target_velocity,
state_.acceleration);
state_.elapsed_time = 0.0;
state_.has_active_profile = active_profile_.total_time > EPSILON;
updateIsMovingFlag();
}
void SCurveVelocityPlanner1D::setTargetVelocity(double target_velocity)
{
const double new_target = clamp(target_velocity, -max_velocity_, max_velocity_);
const bool same_target =
std::abs(new_target - state_.target_velocity) <= target_replan_threshold_;
if (same_target &&
state_.has_active_profile) {
return;
}
if (same_target &&
!state_.has_active_profile &&
std::abs(state_.velocity - new_target) <= VELOCITY_THRESHOLD &&
std::abs(state_.acceleration) <= ACCELERATION_THRESHOLD) {
return;
}
state_.target_velocity = new_target;
active_profile_ = calculateProfile(state_.velocity,
state_.target_velocity,
state_.acceleration);
state_.elapsed_time = 0.0;
state_.has_active_profile = active_profile_.valid && active_profile_.total_time > EPSILON;
updateIsMovingFlag();
}
double SCurveVelocityPlanner1D::getVelocityAtTime(const SCurveVelocityProfile& profile, double t) const
{
if (!profile.valid) {
return profile.v0;
}
if (t <= 0.0) {
return profile.v0;
}
if (t >= profile.total_time) {
return profile.vf;
}
double v = profile.v0;
double a = profile.a0;
auto process_segment = [&](double dt, double jerk) {
v += a * dt + 0.5 * jerk * dt * dt;
a += jerk * dt;
};
// seg1
if (t <= profile.t1) {
process_segment(t, profile.j1);
return v;
}
process_segment(profile.t1, profile.j1);
// seg2
const double t_after_1 = t - profile.t1;
if (t_after_1 <= profile.t2) {
process_segment(t_after_1, profile.j2);
return v;
}
process_segment(profile.t2, profile.j2);
// seg3
const double t_after_2 = t_after_1 - profile.t2;
process_segment(t_after_2, profile.j3);
return v;
}
double SCurveVelocityPlanner1D::getAccelerationAtTime(const SCurveVelocityProfile& profile, double t) const
{
if (!profile.valid) {
return profile.a0;
}
if (t <= 0.0) {
return profile.a0;
}
if (t >= profile.total_time) {
return 0.0;
}
double a = profile.a0;
auto process_segment = [&](double dt, double jerk) {
a += jerk * dt;
};
// seg1
if (t <= profile.t1) {
process_segment(t, profile.j1);
return a;
}
process_segment(profile.t1, profile.j1);
// seg2
const double t_after_1 = t - profile.t1;
if (t_after_1 <= profile.t2) {
process_segment(t_after_1, profile.j2);
return a;
}
process_segment(profile.t2, profile.j2);
// seg3
const double t_after_2 = t_after_1 - profile.t2;
process_segment(t_after_2, profile.j3);
return a;
}
double SCurveVelocityPlanner1D::getJerkAtTime(const SCurveVelocityProfile& profile, double t) const
{
if (!profile.valid) {
return 0.0;
}
if (t <= 0.0 || t >= profile.total_time) {
return 0.0;
}
if (t <= profile.t1) {
return profile.j1;
}
if (t <= profile.t1 + profile.t2) {
return profile.j2;
}
return profile.j3;
}
void SCurveVelocityPlanner1D::integrateWholeProfile(const SCurveVelocityProfile& profile,
double& v_end,
double& a_end) const
{
double v = profile.v0;
double a = profile.a0;
auto process_segment = [&](double dt, double jerk) {
v += a * dt + 0.5 * jerk * dt * dt;
a += jerk * dt;
};
process_segment(profile.t1, profile.j1);
process_segment(profile.t2, profile.j2);
process_segment(profile.t3, profile.j3);
v_end = v;
a_end = a;
}
bool SCurveVelocityPlanner1D::isVelocityLimitSatisfied(const SCurveVelocityProfile& profile) const
{
if (!profile.valid) {
return true;
}
std::vector<double> check_times;
check_times.reserve(8);
check_times.push_back(0.0);
check_times.push_back(profile.t1);
check_times.push_back(profile.t1 + profile.t2);
check_times.push_back(profile.total_time);
// seg1 内部若 acceleration 过零,则 velocity 可能在段内出现极值
if (std::abs(profile.j1) > EPSILON && profile.t1 > EPSILON) {
const double tz = -profile.a0 / profile.j1;
if (tz > EPSILON && tz < profile.t1 - EPSILON) {
check_times.push_back(tz);
}
}
for (double t : check_times) {
const double v = getVelocityAtTime(profile, t);
if (std::abs(v) > max_velocity_ + 1e-7) {
return false;
}
}
return true;
}
SCurveVelocityProfile SCurveVelocityPlanner1D::calculateProfile(double start_velocity,
double end_velocity,
double start_acceleration) const
{
SCurveVelocityProfile best;
best.v0 = clamp(start_velocity, -max_velocity_, max_velocity_);
best.a0 = clamp(start_acceleration, -max_acceleration_, max_acceleration_);
best.vf = clamp(end_velocity, -max_velocity_, max_velocity_);
if (max_jerk_ <= EPSILON || max_acceleration_ <= EPSILON) {
// 退化情况:这里不做特殊退化规划,直接返回 invalid
return best;
}
const double v0 = best.v0;
const double a0 = best.a0;
const double vf = best.vf;
// 目标方向坐标尽量统一到“signed frame 下 Δv >= 0”
double s = sign(vf - v0);
if (std::abs(vf - v0) <= VELOCITY_THRESHOLD) {
s = 1.0;
}
const double dv = s * (vf - v0); // >= 0
const double a0s = s * a0; // signed frame 下的初始 acceleration
const double j = max_jerk_;
const double amax = max_acceleration_;
auto normalize_nonnegative = [](double x) {
return (x < 0.0 && x > -1e-10) ? 0.0 : x;
};
auto try_candidate = [&](double t1, double t2, double t3,
double j1s, double j2s, double j3s) {
t1 = normalize_nonnegative(t1);
t2 = normalize_nonnegative(t2);
t3 = normalize_nonnegative(t3);
if (t1 < 0.0 || t2 < 0.0 || t3 < 0.0) {
return;
}
SCurveVelocityProfile cand;
cand.t1 = t1;
cand.t2 = t2;
cand.t3 = t3;
cand.total_time = t1 + t2 + t3;
cand.j1 = s * j1s;
cand.j2 = s * j2s;
cand.j3 = s * j3s;
cand.v0 = v0;
cand.a0 = a0;
cand.vf = vf;
cand.valid = true;
double vend = 0.0;
double aend = 0.0;
integrateWholeProfile(cand, vend, aend);
if (std::abs(vend - vf) > 1e-5) {
return;
}
if (std::abs(aend) > 1e-5) {
return;
}
if (!isVelocityLimitSatisfied(cand)) {
return;
}
if (!best.valid || cand.total_time < best.total_time) {
best = cand;
}
};
// ---------------- UDU 三角形(无平台) ----------------
{
// Δv = (2A^2 - a0^2)/(2j)
const double A2 = 0.5 * (2.0 * j * dv + a0s * a0s);
if (A2 >= -1e-10) {
const double A = std::sqrt(std::max(0.0, A2));
if (A <= amax + 1e-10 && A >= a0s - 1e-10) {
const double t1 = (A - a0s) / j;
const double t2 = 0.0;
const double t3 = A / j;
try_candidate(t1, t2, t3, +j, 0.0, -j);
}
}
}
// ---------------- UDU 梯形(有平台) ----------------
{
const double A = amax;
if (A > EPSILON && A >= a0s - 1e-10) {
const double base = (2.0 * A * A - a0s * a0s) / (2.0 * j);
const double t1 = (A - a0s) / j;
const double t2 = (dv - base) / A;
const double t3 = A / j;
try_candidate(t1, t2, t3, +j, 0.0, -j);
}
}
// ---------------- DUD 三角形(无平台) ----------------
{
// Δv = (a0^2 - 2B^2)/(2j)
const double B2 = 0.5 * (a0s * a0s - 2.0 * j * dv);
if (B2 >= -1e-10) {
const double B = std::sqrt(std::max(0.0, B2));
if (B <= amax + 1e-10 && B >= -a0s - 1e-10) {
const double t1 = (a0s + B) / j;
const double t2 = 0.0;
const double t3 = B / j;
try_candidate(t1, t2, t3, -j, 0.0, +j);
}
}
}
// ---------------- DUD 梯形(有平台) ----------------
{
const double B = amax;
if (B > EPSILON && B >= -a0s - 1e-10) {
const double base = (a0s * a0s - 2.0 * B * B) / (2.0 * j);
const double t1 = (a0s + B) / j;
const double t2 = (base - dv) / B;
const double t3 = B / j;
try_candidate(t1, t2, t3, -j, 0.0, +j);
}
}
// 已到终点附近
if (!best.valid &&
std::abs(vf - v0) <= VELOCITY_THRESHOLD &&
std::abs(a0) <= ACCELERATION_THRESHOLD) {
best.valid = false;
best.total_time = 0.0;
best.v0 = v0;
best.a0 = a0;
best.vf = vf;
}
return best;
}
void SCurveVelocityPlanner1D::generateTrajectory(const SCurveVelocityProfile& profile, double dt,
std::vector<double>& velocities,
std::vector<double>& accelerations,
std::vector<double>& jerks) const
{
velocities.clear();
accelerations.clear();
jerks.clear();
if (!profile.valid || profile.total_time <= 0.0 || dt <= 0.0) {
velocities.push_back(profile.v0);
accelerations.push_back(profile.a0);
jerks.push_back(0.0);
return;
}
const int num_points = static_cast<int>(std::ceil(profile.total_time / dt)) + 1;
velocities.reserve(num_points);
accelerations.reserve(num_points);
jerks.reserve(num_points);
for (double t = 0.0; t <= profile.total_time; t += dt) {
velocities.push_back(getVelocityAtTime(profile, t));
accelerations.push_back(getAccelerationAtTime(profile, t));
jerks.push_back(getJerkAtTime(profile, t));
}
if (velocities.empty() || std::abs(velocities.back() - profile.vf) > VELOCITY_THRESHOLD) {
velocities.push_back(profile.vf);
accelerations.push_back(0.0);
jerks.push_back(0.0);
}
}
double SCurveVelocityPlanner1D::update(double dt)
{
if (dt <= 0.0) {
return state_.velocity;
}
if (!state_.has_active_profile || !active_profile_.valid) {
state_.jerk = 0.0;
updateIsMovingFlag();
return state_.velocity;
}
state_.elapsed_time += dt;
if (state_.elapsed_time >= active_profile_.total_time) {
state_.elapsed_time = active_profile_.total_time;
state_.velocity = active_profile_.vf;
state_.acceleration = 0.0;
state_.jerk = 0.0;
state_.has_active_profile = false;
updateIsMovingFlag();
return state_.velocity;
}
state_.velocity = getVelocityAtTime(active_profile_, state_.elapsed_time);
state_.acceleration = getAccelerationAtTime(active_profile_, state_.elapsed_time);
state_.jerk = getJerkAtTime(active_profile_, state_.elapsed_time);
updateIsMovingFlag();
return state_.velocity;
}
void SCurveVelocityPlanner1D::updateIsMovingFlag()
{
state_.is_moving =
state_.has_active_profile ||
std::abs(state_.velocity) > VELOCITY_THRESHOLD ||
std::abs(state_.target_velocity) > VELOCITY_THRESHOLD ||
std::abs(state_.acceleration) > ACCELERATION_THRESHOLD;
}
} // namespace cmvr

View File

@ -1,83 +0,0 @@
// #include <rtthread.h>
// #include <rtdevice.h>
// #include <board.h>
//
// #define PWM_DEV_NAME "pwm1"
// #define PWM_DEV_CHANNEL 1
//
// /* 常见舵机刷新周期 20ms (50Hz) */
// #define SERVO_PERIOD_NS 20000000UL
//
// /* 你的规格:脉宽限幅 */
// #define SERVO_MIN_US 800
// #define SERVO_MAX_US 2200
//
// /* 你的标定点:-50/0/+50 -> 1000/1500/2000 */
// #define SERVO_CENTER_US 1500
// #define SERVO_US_PER_DEG 10 /* 1° 对应 10us */
//
// static struct rt_device_pwm *pwm_dev = RT_NULL;
//
// static int clamp_int(int v, int lo, int hi)
// {
// if (v < lo) return lo;
// if (v > hi) return hi;
// return v;
// }
//
// /* 角度(°) -> 脉宽(us),按你的三点标定线性换算,并做 800~2200us 限幅 */
// static int angle_to_pulse_us(int angle_deg)
// {
// int pulse = SERVO_CENTER_US + angle_deg * SERVO_US_PER_DEG;
// return clamp_int(pulse, SERVO_MIN_US, SERVO_MAX_US);
// }
//
// /* 设置角度(单位:度),例如 -50 / 0 / +50 */
// static void servo_set_angle(int angle_deg)
// {
// int pulse_us = angle_to_pulse_us(angle_deg);
// rt_uint32_t pulse_ns = (rt_uint32_t)pulse_us * 1000UL; /* us -> ns */
// rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, SERVO_PERIOD_NS, pulse_ns);
// }
//
// static void servo_thread_entry(void *parameter)
// {
// while (1)
// {
// servo_set_angle(50);
// rt_thread_mdelay(1500);
// servo_set_angle(-50);
// rt_thread_mdelay(1500);
//
// }
// }
//
// static int servo_app_init(void)
// {
// pwm_dev = (struct rt_device_pwm *)rt_device_find(PWM_DEV_NAME);
// if (pwm_dev == RT_NULL)
// {
// rt_kprintf("can't find %s\n", PWM_DEV_NAME);
// return -RT_ERROR;
// }
//
// /* 中位 0° -> 1500us */
// rt_pwm_set(pwm_dev, PWM_DEV_CHANNEL, SERVO_PERIOD_NS, (rt_uint32_t)SERVO_CENTER_US * 1000UL);
// rt_pwm_enable(pwm_dev, PWM_DEV_CHANNEL);
//
// rt_thread_t tid = rt_thread_create("servo",
// servo_thread_entry,
// RT_NULL,
// 1024,
// 20,
// 10);
// if (tid == RT_NULL)
// {
// rt_kprintf("create servo thread failed\n");
// return -RT_ERROR;
// }
// rt_thread_startup(tid);
//
// return RT_EOK;
// }
// INIT_APP_EXPORT(servo_app_init);

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = Glob('src/*.cpp')
CPPPATH = [cwd]
group = DefineGroup('servo_control', src, depend = [''], CPPPATH = CPPPATH)
Return('group')

View File

@ -0,0 +1,26 @@
//
// Created by Administrator on 2026/4/28.
//
#ifndef SERVO_CONFIG_H
#define SERVO_CONFIG_H
#include <string>
#include <vector>
#include "servo_manager/include/servo_control.h"
#include "servo_manager/include/servo_driver.h"
struct ServoConfig
{
std::string id;
float limit_min_angle_rad;
float limit_max_angle_rad;
float home_angle_rad;
ServoDriver::Config driver;
ServoControl::Config control;
};
std::vector<ServoConfig> loadServoConfigsFromJsonFile(const std::string& json_file_path);
#endif // SERVO_CONFIG_H

View File

@ -0,0 +1,87 @@
//
// Created by Administrator on 2026/4/22.
//
#ifndef SERVO_CONTROL_H
#define SERVO_CONTROL_H
#include <stdint.h>
#include <string>
#include <rtthread.h>
#include "common/curve/include/s_curve.h"
#include "common/type/servo_types.h"
#include "planner/s_curve_planner/include/s_curve_position_planner.h"
#include "servo_manager/include/servo_driver.h"
struct ServoConfig;
class ServoControl
{
public:
struct Config
{
double max_velocity_rad{6.28};
double max_acceleration_rad{100.0};
double max_jerk_rad{500.0};
double position_gain{8.0};
};
explicit ServoControl(const ServoConfig& cfg);
~ServoControl();
rt_err_t init(bool enable_after_init = true, bool go_home = true);
rt_err_t move(float angle_rad, MotionMode mode);
rt_err_t stop();
void setConstraints(double max_velocity_rad,
double max_acceleration_rad,
double max_jerk_rad);
void setPositionGain(double position_gain);
void update(rt_tick_t now_tick);
const std::string& id() const;
float currentAngle() const;
float targetAngle() const;
float currentVelocity() const;
bool isActive() const;
private:
void sampleStateNoLock(rt_tick_t now_tick);
double ticksToSeconds(rt_tick_t delta_ticks) const;
private:
static constexpr float ESP = 1e-4f;
std::string id_;
float limit_min_angle_rad_;
float limit_max_angle_rad_;
float home_angle_rad_;
Config cfg_;
ServoDriver driver_;
cmvr::SCurve curve_;
cmvr::SCurvePositionPlanner1D follow_planner_;
float current_angle_rad_;
float current_velocity_rad_per_sec_;
float target_angle_rad_;
rt_tick_t start_tick_;
rt_tick_t last_update_tick_;
uint32_t generation_;
MotionMode active_mode_;
bool active_;
bool dirty_;
cmvr::SCurveProfile profile_;
rt_mutex_t mutex_;
};
#endif // SERVO_CONTROL_H

View File

@ -0,0 +1,60 @@
//
// Created by Administrator on 2026/4/22.
//
#ifndef RTTHREAD_SERVO_DRIVER_H
#define RTTHREAD_SERVO_DRIVER_H
#include <rtdevice.h>
#include <rtthread.h>
#include <stdint.h>
#include <string>
class ServoDriver
{
public:
struct Config
{
std::string pwm_dev_name;
int pwm_channel;
rt_uint32_t period_ns;
rt_uint32_t min_pulse_ns;
rt_uint32_t max_pulse_ns;
float min_angle_rad;
float max_angle_rad;
};
public:
ServoDriver(const Config& cfg, float limit_min_angle_rad, float limit_max_angle_rad);
~ServoDriver();
rt_err_t init(float initial_angle_rad, bool enable_after_init = true);
rt_err_t enable(bool on);
rt_err_t setAngle(float angle_rad);
const Config& config() const;
private:
rt_err_t enableNoLock(bool on);
rt_err_t setAngleNoLock(float angle_rad);
static float clampf(float v, float lo, float hi);
static rt_uint32_t angleToPulseNs(const Config& cfg, float angle_rad);
private:
Config cfg_;
float limit_min_angle_rad_;
float limit_max_angle_rad_;
rt_device_pwm* pwm_dev_;
rt_uint32_t last_pulse_;
bool inited_;
rt_mutex_t mutex_;
};
#endif //RTTHREAD_SERVO_DRIVER_H

View File

@ -0,0 +1,57 @@
//
// Created by Administrator on 2026/4/22.
//
#ifndef SERVO_MANAGER_H
#define SERVO_MANAGER_H
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <vector>
#include "servo_manager/include/servo_control.h"
#include "servo_manager/include/servo_config.h"
#include <rtthread.h>
class ServoManager
{
public:
explicit ServoManager(const std::vector<ServoConfig>& cfg);
explicit ServoManager(const std::string& json_file_path);
~ServoManager();
rt_err_t init(bool enable_after_init = true, bool go_home = true);
ServoControl* get(size_t index);
const ServoControl* get(size_t index) const;
ServoControl* get(const std::string& servo_id);
const ServoControl* get(const std::string& servo_id) const;
size_t count() const;
rt_err_t start();
void stop();
void setUpdatePeriodMs(rt_uint32_t update_period_ms);
void wake();
private:
static void threadEntry(void* parameter);
void run();
int findIndexByIdNoLock(const std::string& servo_id) const;
private:
std::vector<ServoControl> controls_;
rt_mutex_t mutex_;
rt_sem_t wake_sem_;
rt_thread_t thread_;
rt_uint32_t update_period_ms_{10};
volatile bool running_;
};
#endif // SERVO_MANAGER_H

View File

@ -0,0 +1,159 @@
//
// Created by Administrator on 2026/4/29.
//
#include "servo_manager/include/servo_config.h"
#include <ArduinoJson.h>
#include <dfs.h>
#include <sys/stat.h>
#include "sys/unistd.h"
std::vector<ServoConfig> loadServoConfigsFromJsonFile(const std::string& json_file_path)
{
std::vector<ServoConfig> configs;
if (json_file_path.empty()) {
rt_kprintf("json file path is empty\n");
return configs;
}
struct stat st;
if (stat(json_file_path.c_str(), &st) != 0) {
rt_kprintf("stat json file failed: %s\n", json_file_path.c_str());
return configs;
}
if (st.st_size <= 0) {
rt_kprintf("json file is empty: %s\n", json_file_path.c_str());
return configs;
}
char* json_buf = static_cast<char*>(rt_malloc((rt_size_t)st.st_size + 1));
if (json_buf == RT_NULL) {
rt_kprintf("malloc json buffer failed, size=%d\n", (int)st.st_size);
return configs;
}
int fd = open(json_file_path.c_str(), O_RDONLY);
if (fd < 0) {
rt_kprintf("open json file failed: %s\n", json_file_path.c_str());
rt_free(json_buf);
return configs;
}
int len = read(fd, json_buf, (size_t)st.st_size);
close(fd);
if (len <= 0) {
rt_kprintf("read json file failed: %s\n", json_file_path.c_str());
rt_free(json_buf);
return configs;
}
json_buf[len] = '\0';
JsonDocument doc;
DeserializationError error = deserializeJson(doc, json_buf);
rt_free(json_buf);
if (error) {
rt_kprintf("parse json failed: %s\n", error.c_str());
return configs;
}
const int version = doc["version"] | 1;
if (version != 1) {
rt_kprintf("unsupported servo config version: %d\n", version);
return configs;
}
JsonArray servos = doc["servos"].as<JsonArray>();
if (servos.isNull()) {
rt_kprintf("json field 'servos' missing or invalid\n");
return configs;
}
const int servo_count = doc["servo_count"] | -1;
if (servo_count >= 0 && servo_count != (int)servos.size()) {
rt_kprintf("servo_count mismatch, declared=%d actual=%d\n",
servo_count,
(int)servos.size());
return configs;
}
configs.reserve(servos.size());
for (JsonObject servo : servos) {
const char* servo_id = servo["id"] | "";
JsonObject driver = servo["driver"].as<JsonObject>();
JsonObject control = servo["control"].as<JsonObject>();
if (servo_id[0] == '\0' || driver.isNull()) {
rt_kprintf("invalid servo config: id empty or driver missing\n");
continue;
}
ServoConfig cfg;
cfg.id = servo_id;
cfg.driver.pwm_dev_name = driver["pwm_dev_name"] | "";
cfg.driver.pwm_channel = driver["pwm_channel"] | 0;
cfg.driver.period_ns = driver["period_ns"] | 20000000;
cfg.driver.min_pulse_ns = driver["min_pulse_ns"] | 500000;
cfg.driver.max_pulse_ns = driver["max_pulse_ns"] | 2500000;
cfg.driver.min_angle_rad = driver["min_angle_rad"] | -1.5707963f;
cfg.driver.max_angle_rad = driver["max_angle_rad"] | 1.5707963f;
cfg.limit_min_angle_rad = servo["limit_min_angle_rad"] | cfg.driver.min_angle_rad;
cfg.limit_max_angle_rad = servo["limit_max_angle_rad"] | cfg.driver.max_angle_rad;
cfg.home_angle_rad = servo["home_angle_rad"] | 0.0f;
cfg.control.max_velocity_rad = control["max_velocity_rad"] | 6.28;
cfg.control.max_acceleration_rad = control["max_acceleration_rad"] | 100.0;
cfg.control.max_jerk_rad = control["max_jerk_rad"] | 500.0;
cfg.control.position_gain = control["position_gain"] | 8.0;
if (cfg.driver.pwm_dev_name.empty() ||
cfg.driver.pwm_channel <= 0 ||
cfg.driver.period_ns == 0 ||
cfg.driver.min_pulse_ns >= cfg.driver.max_pulse_ns ||
cfg.driver.min_angle_rad >= cfg.driver.max_angle_rad ||
cfg.limit_min_angle_rad < cfg.driver.min_angle_rad ||
cfg.limit_max_angle_rad > cfg.driver.max_angle_rad ||
cfg.limit_min_angle_rad >= cfg.limit_max_angle_rad ||
cfg.home_angle_rad < cfg.limit_min_angle_rad ||
cfg.home_angle_rad > cfg.limit_max_angle_rad ||
cfg.control.max_velocity_rad <= 0.0 ||
cfg.control.max_acceleration_rad <= 0.0 ||
cfg.control.max_jerk_rad <= 0.0 ||
cfg.control.position_gain < 0.0) {
rt_kprintf("invalid servo config values, id=%s\n", cfg.id.c_str());
continue;
}
bool duplicated = false;
for (const auto& existing : configs) {
if (existing.id == cfg.id) {
duplicated = true;
break;
}
}
if (duplicated) {
rt_kprintf("duplicate servo id in config: %s\n", cfg.id.c_str());
continue;
}
configs.push_back(cfg);
}
rt_kprintf("load servo config from %s, count=%d\n",
json_file_path.c_str(),
(int)configs.size());
return configs;
}

View File

@ -0,0 +1,365 @@
//
// Created by Administrator on 2026/4/22.
//
#include "servo_manager/include/servo_control.h"
#include "servo_manager/include/servo_config.h"
#include <algorithm>
#include <cmath>
ServoControl::ServoControl(const ServoConfig& cfg)
: id_(cfg.id),
limit_min_angle_rad_(cfg.limit_min_angle_rad),
limit_max_angle_rad_(cfg.limit_max_angle_rad),
home_angle_rad_(cfg.home_angle_rad),
cfg_(cfg.control),
driver_(cfg.driver, cfg.limit_min_angle_rad, cfg.limit_max_angle_rad),
curve_(),
follow_planner_(cfg.control.max_velocity_rad,
cfg.control.max_acceleration_rad,
cfg.control.max_jerk_rad),
current_angle_rad_(cfg.home_angle_rad),
current_velocity_rad_per_sec_(0.0f),
target_angle_rad_(cfg.home_angle_rad),
start_tick_(0),
last_update_tick_(0),
generation_(0),
active_mode_(MotionMode::Immediate),
active_(false),
dirty_(false),
profile_(),
mutex_(RT_NULL)
{
curve_.setConstraints(cfg_.max_velocity_rad,
cfg_.max_acceleration_rad,
cfg_.max_jerk_rad);
follow_planner_.setPositionGain(cfg_.position_gain);
mutex_ = rt_mutex_create("sv_ctl", RT_IPC_FLAG_PRIO);
}
ServoControl::~ServoControl()
{
if (mutex_) {
rt_mutex_delete(mutex_);
mutex_ = RT_NULL;
}
}
rt_err_t ServoControl::init(bool enable_after_init, bool go_home)
{
const float init_angle = go_home ? home_angle_rad_
: driver_.config().min_angle_rad;
const rt_err_t err = driver_.init(init_angle, enable_after_init);
if (err != RT_EOK) {
return err;
}
if (!mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const rt_tick_t now_tick = rt_tick_get();
current_angle_rad_ = init_angle;
current_velocity_rad_per_sec_ = 0.0f;
target_angle_rad_ = init_angle;
start_tick_ = now_tick;
last_update_tick_ = now_tick;
generation_ = 0;
active_mode_ = MotionMode::Immediate;
active_ = false;
dirty_ = false;
profile_ = cmvr::SCurveProfile();
follow_planner_.initialize(init_angle, 0.0, 0.0);
follow_planner_.setTarget(init_angle);
rt_mutex_release(mutex_);
return RT_EOK;
}
rt_err_t ServoControl::move(float angle_rad, MotionMode mode)
{
if (!mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
angle_rad = std::max(limit_min_angle_rad_, std::min(angle_rad, limit_max_angle_rad_));
const rt_tick_t now_tick = rt_tick_get();
sampleStateNoLock(now_tick);
++generation_;
target_angle_rad_ = angle_rad;
if (mode == MotionMode::Immediate) {
current_angle_rad_ = angle_rad;
current_velocity_rad_per_sec_ = 0.0f;
start_tick_ = now_tick;
last_update_tick_ = now_tick;
active_mode_ = MotionMode::Immediate;
active_ = false;
dirty_ = false;
rt_mutex_release(mutex_);
return driver_.setAngle(angle_rad);
}
if (mode == MotionMode::SCurve) {
const float start_angle_rad = current_angle_rad_;
const float start_velocity_rad_per_sec = current_velocity_rad_per_sec_;
profile_ = curve_.calculateProfile(
current_angle_rad_, angle_rad, current_velocity_rad_per_sec_, 0.0);
if (profile_.total_time <= 0.0) {
profile_ = curve_.calculateProfile(
current_angle_rad_, angle_rad, 0.0, 0.0);
}
start_tick_ = now_tick;
last_update_tick_ = now_tick;
active_mode_ = MotionMode::SCurve;
if (profile_.total_time <= 0.0) {
if (std::fabs(angle_rad - start_angle_rad) > ESP) {
rt_kprintf("[ServoControl][W] scurve fallback to immediate, id=%s start=%.4f target=%.4f vel=%.4f\n",
id().c_str(),
(double)start_angle_rad,
(double)angle_rad,
(double)start_velocity_rad_per_sec);
}
current_angle_rad_ = angle_rad;
current_velocity_rad_per_sec_ = 0.0f;
active_mode_ = MotionMode::Immediate;
active_ = false;
dirty_ = false;
rt_mutex_release(mutex_);
return driver_.setAngle(angle_rad);
}
const double tick_sec = 1.0 / RT_TICK_PER_SECOND;
if (profile_.total_time <= tick_sec) {
rt_kprintf("[ServoControl][W] scurve duration too short, id=%s duration=%.6f tick=%.6f\n",
id().c_str(),
profile_.total_time,
tick_sec);
}
active_ = true;
dirty_ = false;
rt_mutex_release(mutex_);
return RT_EOK;
}
if (mode == MotionMode::Follow) {
if (active_mode_ != MotionMode::Follow) {
follow_planner_.initialize(current_angle_rad_,
current_velocity_rad_per_sec_,
0.0);
}
follow_planner_.setTarget(angle_rad);
start_tick_ = now_tick;
last_update_tick_ = now_tick;
active_mode_ = MotionMode::Follow;
active_ = true;
dirty_ = false;
rt_mutex_release(mutex_);
return RT_EOK;
}
rt_mutex_release(mutex_);
return -RT_EINVAL;
}
rt_err_t ServoControl::stop()
{
if (!mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const rt_tick_t now_tick = rt_tick_get();
sampleStateNoLock(now_tick);
++generation_;
target_angle_rad_ = current_angle_rad_;
current_velocity_rad_per_sec_ = 0.0f;
start_tick_ = now_tick;
last_update_tick_ = now_tick;
active_mode_ = MotionMode::Immediate;
active_ = false;
dirty_ = false;
const float hold_angle = current_angle_rad_;
rt_mutex_release(mutex_);
return driver_.setAngle(hold_angle);
}
void ServoControl::setConstraints(double max_velocity_rad,
double max_acceleration_rad,
double max_jerk_rad)
{
if (!mutex_) {
curve_.setConstraints(max_velocity_rad, max_acceleration_rad, max_jerk_rad);
follow_planner_.setConstraints(max_velocity_rad, max_acceleration_rad, max_jerk_rad);
return;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
curve_.setConstraints(max_velocity_rad, max_acceleration_rad, max_jerk_rad);
follow_planner_.setConstraints(max_velocity_rad, max_acceleration_rad, max_jerk_rad);
rt_mutex_release(mutex_);
}
void ServoControl::setPositionGain(double position_gain)
{
if (!mutex_) {
follow_planner_.setPositionGain(position_gain);
return;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
follow_planner_.setPositionGain(position_gain);
rt_mutex_release(mutex_);
}
void ServoControl::update(rt_tick_t now_tick)
{
if (!mutex_) {
return;
}
float output_angle = 0.0f;
bool should_write = false;
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const float previous_angle = current_angle_rad_;
sampleStateNoLock(now_tick);
if (dirty_ || std::fabs(current_angle_rad_ - previous_angle) > ESP) {
output_angle = current_angle_rad_;
dirty_ = false;
should_write = true;
}
rt_mutex_release(mutex_);
if (should_write) {
const rt_err_t err = driver_.setAngle(output_angle);
if (err != RT_EOK) {
rt_kprintf("[ServoControl][E] setAngle failed, id=%s angle=%.4f err=%d\n",
id().c_str(),
(double)output_angle,
(int)err);
}
}
}
const std::string& ServoControl::id() const
{
return id_;
}
float ServoControl::currentAngle() const
{
if (!mutex_) {
return current_angle_rad_;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const float v = current_angle_rad_;
rt_mutex_release(mutex_);
return v;
}
float ServoControl::targetAngle() const
{
if (!mutex_) {
return target_angle_rad_;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const float v = target_angle_rad_;
rt_mutex_release(mutex_);
return v;
}
float ServoControl::currentVelocity() const
{
if (!mutex_) {
return current_velocity_rad_per_sec_;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const float v = current_velocity_rad_per_sec_;
rt_mutex_release(mutex_);
return v;
}
bool ServoControl::isActive() const
{
if (!mutex_) {
return active_;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const bool v = active_;
rt_mutex_release(mutex_);
return v;
}
void ServoControl::sampleStateNoLock(rt_tick_t now_tick)
{
if (!active_) {
return;
}
if (active_mode_ == MotionMode::SCurve) {
const double elapsed_sec = ticksToSeconds(now_tick - start_tick_);
if (elapsed_sec >= profile_.total_time) {
current_angle_rad_ = target_angle_rad_;
current_velocity_rad_per_sec_ = 0.0f;
active_ = false;
return;
}
current_angle_rad_ = static_cast<float>(
curve_.getPositionAtTime(profile_, elapsed_sec));
current_velocity_rad_per_sec_ = static_cast<float>(
curve_.getVelocityAtTime(profile_, elapsed_sec));
return;
}
if (active_mode_ == MotionMode::Follow) {
const double dt = ticksToSeconds(now_tick - last_update_tick_);
if (dt <= 0.0) {
return;
}
last_update_tick_ = now_tick;
current_angle_rad_ = static_cast<float>(follow_planner_.update(dt));
current_velocity_rad_per_sec_ = static_cast<float>(follow_planner_.getVelocity());
target_angle_rad_ = static_cast<float>(follow_planner_.getTargetPosition());
active_ = follow_planner_.isMoving();
return;
}
}
double ServoControl::ticksToSeconds(rt_tick_t delta_ticks) const
{
return static_cast<double>(delta_ticks) / RT_TICK_PER_SECOND;
}

View File

@ -0,0 +1,180 @@
//
// Created by Administrator on 2026/4/22.
//
#include "servo_manager/include/servo_driver.h"
ServoDriver::ServoDriver(const Config& cfg, float limit_min_angle_rad, float limit_max_angle_rad)
: cfg_(cfg),
limit_min_angle_rad_(limit_min_angle_rad),
limit_max_angle_rad_(limit_max_angle_rad),
pwm_dev_(RT_NULL),
last_pulse_(0),
inited_(false),
mutex_(RT_NULL)
{
mutex_ = rt_mutex_create("sv_drv", RT_IPC_FLAG_PRIO);
}
ServoDriver::~ServoDriver()
{
if (mutex_) {
rt_mutex_delete(mutex_);
mutex_ = RT_NULL;
}
}
rt_err_t ServoDriver::init(float initial_angle_rad, bool enable_after_init)
{
if (cfg_.pwm_dev_name.empty()) {
rt_kprintf("[ServoDriver][E] init: invalid cfg, pwm is empty\n");
return -RT_EINVAL;
}
if (!mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
pwm_dev_ = (rt_device_pwm*)rt_device_find(cfg_.pwm_dev_name.c_str());
if (!pwm_dev_) {
rt_kprintf("[ServoDriver][E] init: rt_device_find failed, pwm=%s ch=%d\n",
cfg_.pwm_dev_name.c_str(),
cfg_.pwm_channel);
rt_mutex_release(mutex_);
return -RT_ENOSYS;
}
const float limited_angle = clampf(initial_angle_rad, limit_min_angle_rad_, limit_max_angle_rad_);
const rt_uint32_t pulse = angleToPulseNs(cfg_, limited_angle);
rt_err_t err = rt_pwm_set(pwm_dev_, cfg_.pwm_channel, cfg_.period_ns, pulse);
if (err != RT_EOK) {
rt_kprintf("[ServoDriver][E] init: rt_pwm_set failed, ch=%d pulse=%u err=%d\n",
cfg_.pwm_channel,
(unsigned)pulse,
(int)err);
rt_mutex_release(mutex_);
return err;
}
last_pulse_ = pulse;
inited_ = true;
if (enable_after_init) {
err = rt_pwm_enable(pwm_dev_, cfg_.pwm_channel);
if (err != RT_EOK) {
rt_kprintf("[ServoDriver][E] init: rt_pwm_enable failed, ch=%d err=%d\n",
cfg_.pwm_channel,
(int)err);
rt_mutex_release(mutex_);
return err;
}
}
rt_mutex_release(mutex_);
rt_kprintf("[ServoDriver] init OK: pwm=%s ch=%d enable=%d initial=%.4f\n",
cfg_.pwm_dev_name.c_str(),
cfg_.pwm_channel,
(int)enable_after_init,
(double)initial_angle_rad);
return RT_EOK;
}
rt_err_t ServoDriver::enable(bool on)
{
if (!mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const rt_err_t err = enableNoLock(on);
rt_mutex_release(mutex_);
return err;
}
rt_err_t ServoDriver::setAngle(float angle_rad)
{
if (!mutex_) {
return -RT_ENOMEM;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const rt_err_t err = setAngleNoLock(angle_rad);
rt_mutex_release(mutex_);
return err;
}
const ServoDriver::Config& ServoDriver::config() const
{
return cfg_;
}
rt_err_t ServoDriver::enableNoLock(bool on)
{
if (!inited_ || !pwm_dev_) {
return -RT_ERROR;
}
return on ? rt_pwm_enable(pwm_dev_, cfg_.pwm_channel)
: rt_pwm_disable(pwm_dev_, cfg_.pwm_channel);
}
rt_err_t ServoDriver::setAngleNoLock(float angle_rad)
{
if (!inited_ || !pwm_dev_) {
return -RT_ERROR;
}
const float limited_angle = clampf(angle_rad, limit_min_angle_rad_, limit_max_angle_rad_);
const rt_uint32_t pulse = angleToPulseNs(cfg_, limited_angle);
if (pulse == last_pulse_) {
return RT_EOK;
}
const rt_err_t err = rt_pwm_set(pwm_dev_, cfg_.pwm_channel, cfg_.period_ns, pulse);
if (err != RT_EOK) {
return err;
}
last_pulse_ = pulse;
return RT_EOK;
}
float ServoDriver::clampf(float v, float lo, float hi)
{
if (v < lo) {
return lo;
}
if (v > hi) {
return hi;
}
return v;
}
rt_uint32_t ServoDriver::angleToPulseNs(const Config& cfg, float angle_rad)
{
const float a = clampf(angle_rad, cfg.min_angle_rad, cfg.max_angle_rad);
const float in_span = cfg.max_angle_rad - cfg.min_angle_rad;
const float out_span = (float)(cfg.max_pulse_ns - cfg.min_pulse_ns);
float t = 0.0f;
if (in_span > 1e-6f) {
t = (a - cfg.min_angle_rad) / in_span;
}
float pulse = (float)cfg.min_pulse_ns + t * out_span;
if (pulse < (float)cfg.min_pulse_ns) {
pulse = (float)cfg.min_pulse_ns;
}
if (pulse > (float)cfg.max_pulse_ns) {
pulse = (float)cfg.max_pulse_ns;
}
return (rt_uint32_t)(pulse + 0.5f);
}

View File

@ -0,0 +1,248 @@
//
// Created by Administrator on 2026/4/22.
//
#include "servo_manager/include/servo_manager.h"
ServoManager::ServoManager(const std::vector<ServoConfig>& cfg)
: controls_(),
mutex_(RT_NULL),
wake_sem_(RT_NULL),
thread_(RT_NULL),
running_(false)
{
controls_.reserve(cfg.size());
for (const auto& c : cfg) {
controls_.emplace_back(c);
}
mutex_ = rt_mutex_create("sv_mgr", RT_IPC_FLAG_PRIO);
wake_sem_ = rt_sem_create("sv_wk", 0, RT_IPC_FLAG_PRIO);
}
ServoManager::ServoManager(const std::string& json_file_path)
: ServoManager(loadServoConfigsFromJsonFile(json_file_path))
{
}
ServoManager::~ServoManager()
{
stop();
if (mutex_) {
rt_mutex_delete(mutex_);
mutex_ = RT_NULL;
}
if (wake_sem_) {
rt_sem_delete(wake_sem_);
wake_sem_ = RT_NULL;
}
}
rt_err_t ServoManager::init(bool enable_after_init, bool go_home)
{
if (!mutex_) {
return -RT_ENOMEM;
}
if (controls_.empty()) {
rt_kprintf("[ServoManager][E] init: no servo config\n");
return -RT_EINVAL;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
for (size_t i = 0; i < controls_.size(); ++i) {
const rt_err_t err = controls_[i].init(enable_after_init, go_home);
if (err != RT_EOK) {
rt_mutex_release(mutex_);
return err;
}
}
rt_mutex_release(mutex_);
return RT_EOK;
}
ServoControl* ServoManager::get(size_t index)
{
if (!mutex_) {
return RT_NULL;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
ServoControl* control = (index < controls_.size()) ? &controls_[index] : RT_NULL;
rt_mutex_release(mutex_);
return control;
}
const ServoControl* ServoManager::get(size_t index) const
{
if (!mutex_) {
return RT_NULL;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const ServoControl* control = (index < controls_.size()) ? &controls_[index] : RT_NULL;
rt_mutex_release(mutex_);
return control;
}
ServoControl* ServoManager::get(const std::string& servo_id)
{
if (!mutex_) {
return RT_NULL;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const int index = findIndexByIdNoLock(servo_id);
ServoControl* control = (index >= 0) ? &controls_[(size_t)index] : RT_NULL;
rt_mutex_release(mutex_);
return control;
}
const ServoControl* ServoManager::get(const std::string& servo_id) const
{
if (!mutex_) {
return RT_NULL;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
const int index = findIndexByIdNoLock(servo_id);
const ServoControl* control = (index >= 0) ? &controls_[(size_t)index] : RT_NULL;
rt_mutex_release(mutex_);
return control;
}
size_t ServoManager::count() const
{
return controls_.size();
}
rt_err_t ServoManager::start()
{
if (!mutex_ || !wake_sem_) {
return -RT_ENOMEM;
}
if (running_) {
return RT_EOK;
}
running_ = true;
thread_ = rt_thread_create("sv_mgr",
ServoManager::threadEntry,
this,
4096,
20,
1);
if (!thread_) {
running_ = false;
return -RT_ENOMEM;
}
const rt_err_t err = rt_thread_startup(thread_);
if (err != RT_EOK) {
running_ = false;
rt_thread_delete(thread_);
thread_ = RT_NULL;
return err;
}
return RT_EOK;
}
void ServoManager::stop()
{
if (!running_) {
return;
}
running_ = false;
wake();
if (thread_) {
rt_thread_mdelay((rt_int32_t)(update_period_ms_ + 1));
rt_thread_delete(thread_);
thread_ = RT_NULL;
}
}
void ServoManager::setUpdatePeriodMs(rt_uint32_t update_period_ms)
{
const rt_uint32_t clamped = (update_period_ms == 0) ? 1 : update_period_ms;
if (!mutex_) {
update_period_ms_ = clamped;
return;
}
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
update_period_ms_ = clamped;
rt_mutex_release(mutex_);
}
void ServoManager::wake()
{
if (thread_ && wake_sem_) {
rt_sem_release(wake_sem_);
}
}
void ServoManager::threadEntry(void* parameter)
{
ServoManager* self = static_cast<ServoManager*>(parameter);
if (!self) {
return;
}
self->run();
}
void ServoManager::run()
{
while (running_) {
rt_tick_t wait_ticks = rt_tick_from_millisecond(update_period_ms_);
if (wait_ticks == 0) {
wait_ticks = 1;
}
if (wake_sem_) {
rt_sem_take(wake_sem_, wait_ticks);
} else {
rt_thread_mdelay((rt_int32_t)update_period_ms_);
}
if (!running_) {
break;
}
const rt_tick_t now_tick = rt_tick_get();
rt_mutex_take(mutex_, RT_WAITING_FOREVER);
for (size_t i = 0; i < controls_.size(); ++i) {
controls_[i].update(now_tick);
}
rt_mutex_release(mutex_);
}
thread_ = RT_NULL;
}
int ServoManager::findIndexByIdNoLock(const std::string& servo_id) const
{
if (servo_id.empty()) {
return -1;
}
for (size_t i = 0; i < controls_.size(); ++i) {
if (controls_[i].id() == servo_id) {
return (int)i;
}
}
return -1;
}

File diff suppressed because one or more lines are too long

View File

@ -5,54 +5,88 @@ CAD.provider=
CORTEX_M7.IPParameters=default_mode_Activation
CORTEX_M7.default_mode_Activation=1
File.Version=6
GPIO.groupedBy=Group By Peripherals
GPIO.groupedBy=
KeepUserPlacement=false
MMTAppRegionsCount=0
MMTConfigApplied=false
MMTSectionSuffix=
Mcu.CPN=STM32H750XBH6
Mcu.CPN=STM32H743VIT6
Mcu.Family=STM32H7
Mcu.IP0=CORTEX_M7
Mcu.IP1=DEBUG
Mcu.IP10=USART3
Mcu.IP10=TIM5
Mcu.IP11=TIM8
Mcu.IP12=TIM12
Mcu.IP13=TIM13
Mcu.IP14=TIM14
Mcu.IP15=TIM15
Mcu.IP16=TIM16
Mcu.IP17=TIM17
Mcu.IP18=USART1
Mcu.IP19=USB_DEVICE
Mcu.IP2=MEMORYMAP
Mcu.IP20=USB_OTG_FS
Mcu.IP3=NVIC
Mcu.IP4=QUADSPI
Mcu.IP5=RCC
Mcu.IP6=SPI5
Mcu.IP7=SYS
Mcu.IP8=USART1
Mcu.IP9=USART2
Mcu.IPNb=11
Mcu.Name=STM32H750XBHx
Mcu.Package=TFBGA240
Mcu.Pin0=PD5
Mcu.Pin1=PD6
Mcu.Pin10=PH0-OSC_IN (PH0)
Mcu.Pin11=PK0
Mcu.Pin12=PF6
Mcu.Pin13=PF7
Mcu.Pin14=PF8
Mcu.Pin15=PF10
Mcu.Pin16=PF9
Mcu.Pin17=PJ10
Mcu.Pin18=PE9
Mcu.Pin19=PD9
Mcu.Pin2=PA14 (JTCK/SWCLK)
Mcu.Pin20=PD8
Mcu.Pin21=VP_SYS_VS_Systick
Mcu.Pin22=VP_MEMORYMAP_VS_MEMORYMAP
Mcu.Pin3=PC15-OSC32_OUT (OSC32_OUT)
Mcu.Pin4=PC14-OSC32_IN (OSC32_IN)
Mcu.Pin5=PA13 (JTMS/SWDIO)
Mcu.Pin6=PA10
Mcu.Pin7=PA9
Mcu.Pin8=PG6
Mcu.Pin9=PH1-OSC_OUT (PH1)
Mcu.PinsNb=23
Mcu.IP4=RCC
Mcu.IP5=SYS
Mcu.IP6=TIM1
Mcu.IP7=TIM2
Mcu.IP8=TIM3
Mcu.IP9=TIM4
Mcu.IPNb=21
Mcu.Name=STM32H743VITx
Mcu.Package=LQFP100
Mcu.Pin0=PE5
Mcu.Pin1=PE6
Mcu.Pin10=PB0
Mcu.Pin11=PB1
Mcu.Pin12=PE9
Mcu.Pin13=PE11
Mcu.Pin14=PE13
Mcu.Pin15=PE14
Mcu.Pin16=PB10
Mcu.Pin17=PB11
Mcu.Pin18=PB14
Mcu.Pin19=PB15
Mcu.Pin2=PH0-OSC_IN (PH0)
Mcu.Pin20=PD14
Mcu.Pin21=PD15
Mcu.Pin22=PC6
Mcu.Pin23=PC7
Mcu.Pin24=PC8
Mcu.Pin25=PC9
Mcu.Pin26=PA9
Mcu.Pin27=PA10
Mcu.Pin28=PA11
Mcu.Pin29=PA12
Mcu.Pin3=PH1-OSC_OUT (PH1)
Mcu.Pin30=PA13 (JTMS/SWDIO)
Mcu.Pin31=PA14 (JTCK/SWCLK)
Mcu.Pin32=PA15 (JTDI)
Mcu.Pin33=PB3 (JTDO/TRACESWO)
Mcu.Pin34=PB4 (NJTRST)
Mcu.Pin35=PB5
Mcu.Pin36=PB6
Mcu.Pin37=PB7
Mcu.Pin38=PB8
Mcu.Pin39=PB9
Mcu.Pin4=PA0
Mcu.Pin40=VP_SYS_VS_Systick
Mcu.Pin41=VP_TIM13_VS_ClockSourceINT
Mcu.Pin42=VP_TIM14_VS_ClockSourceINT
Mcu.Pin43=VP_TIM16_VS_ClockSourceINT
Mcu.Pin44=VP_TIM17_VS_ClockSourceINT
Mcu.Pin45=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
Mcu.Pin46=VP_MEMORYMAP_VS_MEMORYMAP
Mcu.Pin5=PA1
Mcu.Pin6=PA2
Mcu.Pin7=PA3
Mcu.Pin8=PA6
Mcu.Pin9=PA7
Mcu.PinsNb=47
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32H750XBHx
Mcu.UserName=STM32H743VITx
MxCube.Version=6.16.0
MxDb.Version=DB.6.0.160
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
@ -61,62 +95,70 @@ NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.OTG_FS_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:true
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0.Signal=S_TIM5_CH1
PA1.Signal=S_TIM5_CH2
PA10.Locked=true
PA10.Mode=Asynchronous
PA10.Signal=USART1_RX
PA11.Mode=Device_Only
PA11.Signal=USB_OTG_FS_DM
PA12.Mode=Device_Only
PA12.Signal=USB_OTG_FS_DP
PA13\ (JTMS/SWDIO).Mode=Serial_Wire
PA13\ (JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO
PA14\ (JTCK/SWCLK).Mode=Serial_Wire
PA14\ (JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK
PA15\ (JTDI).Locked=true
PA15\ (JTDI).Signal=S_TIM2_CH1_ETR
PA2.Signal=S_TIM5_CH3
PA3.Signal=S_TIM5_CH4
PA6.Signal=S_TIM13_CH1
PA7.Signal=S_TIM14_CH1
PA9.Locked=true
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
PC14-OSC32_IN\ (OSC32_IN).Mode=LSE-External-Oscillator
PC14-OSC32_IN\ (OSC32_IN).Signal=RCC_OSC32_IN
PC15-OSC32_OUT\ (OSC32_OUT).Mode=LSE-External-Oscillator
PC15-OSC32_OUT\ (OSC32_OUT).Signal=RCC_OSC32_OUT
PD5.Mode=Asynchronous
PD5.Signal=USART2_TX
PD6.Mode=Asynchronous
PD6.Signal=USART2_RX
PD8.Locked=true
PD8.Mode=Asynchronous
PD8.Signal=USART3_TX
PD9.Locked=true
PD9.Mode=Asynchronous
PD9.Signal=USART3_RX
PE9.Locked=true
PB0.Signal=S_TIM3_CH3
PB1.Signal=S_TIM3_CH4
PB10.Locked=true
PB10.Signal=S_TIM2_CH3
PB11.Locked=true
PB11.Signal=S_TIM2_CH4
PB14.Signal=S_TIM12_CH1
PB15.Signal=S_TIM12_CH2
PB3\ (JTDO/TRACESWO).Locked=true
PB3\ (JTDO/TRACESWO).Signal=S_TIM2_CH2
PB4\ (NJTRST).Locked=true
PB4\ (NJTRST).Signal=S_TIM3_CH1
PB5.Locked=true
PB5.Signal=S_TIM3_CH2
PB6.Locked=true
PB6.Signal=S_TIM4_CH1
PB7.Locked=true
PB7.Signal=S_TIM4_CH2
PB8.Signal=S_TIM16_CH1
PB9.Signal=S_TIM17_CH1
PC6.Signal=S_TIM8_CH1
PC7.Signal=S_TIM8_CH2
PC8.Signal=S_TIM8_CH3
PC9.Signal=S_TIM8_CH4
PD14.Signal=S_TIM4_CH3
PD15.Signal=S_TIM4_CH4
PE11.Signal=S_TIM1_CH2
PE13.Signal=S_TIM1_CH3
PE14.Signal=S_TIM1_CH4
PE5.Signal=S_TIM15_CH1
PE6.Signal=S_TIM15_CH2
PE9.Signal=S_TIM1_CH1
PF10.Mode=Single Bank 1
PF10.Signal=QUADSPI_CLK
PF6.Mode=Single Bank 1
PF6.Signal=QUADSPI_BK1_IO3
PF7.Locked=true
PF7.Mode=Single Bank 1
PF7.Signal=QUADSPI_BK1_IO2
PF8.Locked=true
PF8.Mode=Single Bank 1
PF8.Signal=QUADSPI_BK1_IO0
PF9.Locked=true
PF9.Mode=Single Bank 1
PF9.Signal=QUADSPI_BK1_IO1
PG6.Locked=true
PG6.Mode=Single Bank 1
PG6.Signal=QUADSPI_BK1_NCS
PH0-OSC_IN\ (PH0).Mode=HSE-External-Oscillator
PH0-OSC_IN\ (PH0).Signal=RCC_OSC_IN
PH1-OSC_OUT\ (PH1).Mode=HSE-External-Oscillator
PH1-OSC_OUT\ (PH1).Signal=RCC_OSC_OUT
PJ10.Mode=TX_Only_Simplex_Unidirect_Master
PJ10.Signal=SPI5_MOSI
PK0.Mode=TX_Only_Simplex_Unidirect_Master
PK0.Signal=SPI5_SCK
PinOutPanel.CurrentBGAView=Top
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
@ -127,7 +169,7 @@ ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32H750XBHx
ProjectManager.DeviceId=STM32H743VITx
ProjectManager.FirmwarePackage=STM32Cube FW_H7 V1.12.1
ProjectManager.FreePins=false
ProjectManager.FreePinsContext=
@ -150,105 +192,209 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_QUADSPI_Init-QUADSPI-false-HAL-true,5-MX_SPI5_Init-SPI5-false-HAL-true,6-MX_USART2_UART_Init-USART2-false-HAL-true,7-MX_USART3_UART_Init-USART3-false-HAL-true,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
QUADSPI.ChipSelectHighTime=QSPI_CS_HIGH_TIME_5_CYCLE
QUADSPI.ClockPrescaler=5
QUADSPI.FifoThreshold=4
QUADSPI.FlashSize=22
QUADSPI.IPParameters=ClockPrescaler,FifoThreshold,SampleShifting,FlashSize,ChipSelectHighTime
QUADSPI.SampleShifting=QSPI_SAMPLE_SHIFTING_HALFCYCLE
RCC.ADCFreq_Value=129000000
RCC.AHB12Freq_Value=240000000
RCC.AHB4Freq_Value=240000000
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_TIM1_Init-TIM1-false-HAL-true,4-MX_TIM2_Init-TIM2-false-HAL-true,5-MX_TIM3_Init-TIM3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_TIM5_Init-TIM5-false-HAL-true,8-MX_TIM8_Init-TIM8-false-HAL-true,9-MX_TIM12_Init-TIM12-false-HAL-true,10-MX_TIM13_Init-TIM13-false-HAL-true,11-MX_TIM14_Init-TIM14-false-HAL-true,12-MX_TIM15_Init-TIM15-false-HAL-true,13-MX_TIM16_Init-TIM16-false-HAL-true,14-MX_TIM17_Init-TIM17-false-HAL-true,15-MX_USART1_UART_Init-USART1-false-HAL-true,16-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,0-MX_CORTEX_M7_Init-CORTEX_M7-false-HAL-true
RCC.ADCFreq_Value=50390625
RCC.AHB12Freq_Value=120000000
RCC.AHB4Freq_Value=120000000
RCC.APB1Freq_Value=120000000
RCC.APB2Freq_Value=120000000
RCC.APB2Freq_Value=30000000
RCC.APB3Freq_Value=120000000
RCC.APB4Freq_Value=120000000
RCC.AXIClockFreq_Value=240000000
RCC.AXIClockFreq_Value=120000000
RCC.CECFreq_Value=32000
RCC.CKPERFreq_Value=64000000
RCC.CortexFreq_Value=480000000
RCC.CpuClockFreq_Value=480000000
RCC.D1CPREFreq_Value=480000000
RCC.D1PPRE=RCC_APB3_DIV2
RCC.D2PPRE1=RCC_APB1_DIV2
RCC.D2PPRE2=RCC_APB2_DIV2
RCC.D3PPRE=RCC_APB4_DIV2
RCC.DFSDMACLkFreq_Value=480000000
RCC.DFSDMFreq_Value=120000000
RCC.DIVM1=4
RCC.DIVN1=60
RCC.DIVP1Freq_Value=480000000
RCC.DIVP2Freq_Value=129000000
RCC.DIVP3Freq_Value=129000000
RCC.DIVQ1Freq_Value=480000000
RCC.DIVQ2Freq_Value=129000000
RCC.DIVQ3Freq_Value=129000000
RCC.DIVR1Freq_Value=480000000
RCC.DIVR2Freq_Value=129000000
RCC.DIVR3Freq_Value=129000000
RCC.FDCANFreq_Value=480000000
RCC.FMCFreq_Value=240000000
RCC.CortexFreq_Value=120000000
RCC.CpuClockFreq_Value=120000000
RCC.D1CPREFreq_Value=120000000
RCC.D2PPRE2=RCC_APB2_DIV4
RCC.DFSDMACLkFreq_Value=48000000
RCC.DFSDMFreq_Value=30000000
RCC.DIVM1=5
RCC.DIVN1=48
RCC.DIVP1Freq_Value=120000000
RCC.DIVP2Freq_Value=50390625
RCC.DIVP3Freq_Value=50390625
RCC.DIVQ1=5
RCC.DIVQ1Freq_Value=48000000
RCC.DIVQ2Freq_Value=50390625
RCC.DIVQ3Freq_Value=50390625
RCC.DIVR1Freq_Value=120000000
RCC.DIVR2Freq_Value=50390625
RCC.DIVR3Freq_Value=50390625
RCC.FDCANFreq_Value=48000000
RCC.FMCFreq_Value=120000000
RCC.FamilyName=M
RCC.HCLK3ClockFreq_Value=240000000
RCC.HCLKFreq_Value=240000000
RCC.HPRE=RCC_HCLK_DIV2
RCC.HRTIMFreq_Value=240000000
RCC.HCLK3ClockFreq_Value=120000000
RCC.HCLKFreq_Value=120000000
RCC.HRTIMFreq_Value=60000000
RCC.I2C123Freq_Value=120000000
RCC.I2C4Freq_Value=120000000
RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D1PPRE,D2PPRE1,D2PPRE2,D3PPRE,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVN1,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HPRE,HRTIMFreq_Value,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value
RCC.IPParameters=ADCFreq_Value,AHB12Freq_Value,AHB4Freq_Value,APB1Freq_Value,APB2Freq_Value,APB3Freq_Value,APB4Freq_Value,AXIClockFreq_Value,CECFreq_Value,CKPERFreq_Value,CortexFreq_Value,CpuClockFreq_Value,D1CPREFreq_Value,D2PPRE2,DFSDMACLkFreq_Value,DFSDMFreq_Value,DIVM1,DIVN1,DIVP1Freq_Value,DIVP2Freq_Value,DIVP3Freq_Value,DIVQ1,DIVQ1Freq_Value,DIVQ2Freq_Value,DIVQ3Freq_Value,DIVR1Freq_Value,DIVR2Freq_Value,DIVR3Freq_Value,FDCANFreq_Value,FMCFreq_Value,FamilyName,HCLK3ClockFreq_Value,HCLKFreq_Value,HRTIMFreq_Value,I2C123Freq_Value,I2C4Freq_Value,LPTIM1Freq_Value,LPTIM2Freq_Value,LPTIM345Freq_Value,LPUART1Freq_Value,LTDCFreq_Value,MCO1PinFreq_Value,MCO2PinFreq_Value,PLL2FRACN,PLL3FRACN,PLLFRACN,QSPIFreq_Value,RNGFreq_Value,RTCFreq_Value,SAI1Freq_Value,SAI23Freq_Value,SAI4AFreq_Value,SAI4BFreq_Value,SDMMCFreq_Value,SPDIFRXFreq_Value,SPI123Freq_Value,SPI45Freq_Value,SPI6Freq_Value,SWPMI1Freq_Value,SYSCLKFreq_VALUE,SYSCLKSource,Tim1OutputFreq_Value,Tim2OutputFreq_Value,TraceFreq_Value,USART16Freq_Value,USART234578Freq_Value,USBFreq_Value,VCO1OutputFreq_Value,VCO2OutputFreq_Value,VCO3OutputFreq_Value,VCOInput1Freq_Value,VCOInput2Freq_Value,VCOInput3Freq_Value
RCC.LPTIM1Freq_Value=120000000
RCC.LPTIM2Freq_Value=120000000
RCC.LPTIM345Freq_Value=120000000
RCC.LPUART1Freq_Value=120000000
RCC.LTDCFreq_Value=129000000
RCC.LTDCFreq_Value=50390625
RCC.MCO1PinFreq_Value=64000000
RCC.MCO2PinFreq_Value=480000000
RCC.MCO2PinFreq_Value=120000000
RCC.PLL2FRACN=0
RCC.PLL3FRACN=0
RCC.PLLFRACN=0
RCC.QSPIFreq_Value=240000000
RCC.QSPIFreq_Value=120000000
RCC.RNGFreq_Value=48000000
RCC.RTCFreq_Value=32000
RCC.SAI1Freq_Value=480000000
RCC.SAI23Freq_Value=480000000
RCC.SAI4AFreq_Value=480000000
RCC.SAI4BFreq_Value=480000000
RCC.SDMMCFreq_Value=480000000
RCC.SPDIFRXFreq_Value=480000000
RCC.SPI123Freq_Value=480000000
RCC.SPI45Freq_Value=120000000
RCC.SAI1Freq_Value=48000000
RCC.SAI23Freq_Value=48000000
RCC.SAI4AFreq_Value=48000000
RCC.SAI4BFreq_Value=48000000
RCC.SDMMCFreq_Value=48000000
RCC.SPDIFRXFreq_Value=48000000
RCC.SPI123Freq_Value=48000000
RCC.SPI45Freq_Value=30000000
RCC.SPI6Freq_Value=120000000
RCC.SWPMI1Freq_Value=120000000
RCC.SYSCLKFreq_VALUE=480000000
RCC.SYSCLKFreq_VALUE=120000000
RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.Tim1OutputFreq_Value=240000000
RCC.Tim2OutputFreq_Value=240000000
RCC.TraceFreq_Value=480000000
RCC.USART16Freq_Value=120000000
RCC.Tim1OutputFreq_Value=120000000
RCC.Tim2OutputFreq_Value=60000000
RCC.TraceFreq_Value=120000000
RCC.USART16Freq_Value=30000000
RCC.USART234578Freq_Value=120000000
RCC.USBFreq_Value=480000000
RCC.VCO1OutputFreq_Value=960000000
RCC.VCO2OutputFreq_Value=258000000
RCC.VCO3OutputFreq_Value=258000000
RCC.VCOInput1Freq_Value=16000000
RCC.VCOInput2Freq_Value=2000000
RCC.VCOInput3Freq_Value=2000000
SH.S_TIM1_CH1.0=TIM1_CH1
RCC.USBFreq_Value=48000000
RCC.VCO1OutputFreq_Value=240000000
RCC.VCO2OutputFreq_Value=100781250
RCC.VCO3OutputFreq_Value=100781250
RCC.VCOInput1Freq_Value=5000000
RCC.VCOInput2Freq_Value=781250
RCC.VCOInput3Freq_Value=781250
SH.S_TIM12_CH1.0=TIM12_CH1,PWM Generation1 CH1
SH.S_TIM12_CH1.ConfNb=1
SH.S_TIM12_CH2.0=TIM12_CH2,PWM Generation2 CH2
SH.S_TIM12_CH2.ConfNb=1
SH.S_TIM13_CH1.0=TIM13_CH1,PWM Generation1 CH1
SH.S_TIM13_CH1.ConfNb=1
SH.S_TIM14_CH1.0=TIM14_CH1,PWM Generation1 CH1
SH.S_TIM14_CH1.ConfNb=1
SH.S_TIM15_CH1.0=TIM15_CH1,PWM Generation1 CH1
SH.S_TIM15_CH1.ConfNb=1
SH.S_TIM15_CH2.0=TIM15_CH2,PWM Generation2 CH2
SH.S_TIM15_CH2.ConfNb=1
SH.S_TIM16_CH1.0=TIM16_CH1,PWM Generation1 CH1
SH.S_TIM16_CH1.ConfNb=1
SH.S_TIM17_CH1.0=TIM17_CH1,PWM Generation1 CH1
SH.S_TIM17_CH1.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
SH.S_TIM1_CH1.ConfNb=1
SPI5.CalculateBaudRate=60.0 MBits/s
SPI5.Direction=SPI_DIRECTION_2LINES_TXONLY
SPI5.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate
SPI5.Mode=SPI_MODE_MASTER
SPI5.VirtualType=VM_MASTER
SH.S_TIM1_CH2.0=TIM1_CH2,PWM Generation2 CH2
SH.S_TIM1_CH2.ConfNb=1
SH.S_TIM1_CH3.0=TIM1_CH3,PWM Generation3 CH3
SH.S_TIM1_CH3.ConfNb=1
SH.S_TIM1_CH4.0=TIM1_CH4,PWM Generation4 CH4
SH.S_TIM1_CH4.ConfNb=1
SH.S_TIM2_CH1_ETR.0=TIM2_CH1,PWM Generation1 CH1
SH.S_TIM2_CH1_ETR.ConfNb=1
SH.S_TIM2_CH2.0=TIM2_CH2,PWM Generation2 CH2
SH.S_TIM2_CH2.ConfNb=1
SH.S_TIM2_CH3.0=TIM2_CH3,PWM Generation3 CH3
SH.S_TIM2_CH3.ConfNb=1
SH.S_TIM2_CH4.0=TIM2_CH4,PWM Generation4 CH4
SH.S_TIM2_CH4.ConfNb=1
SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
SH.S_TIM3_CH1.ConfNb=1
SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
SH.S_TIM3_CH2.ConfNb=1
SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3
SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
SH.S_TIM3_CH4.ConfNb=1
SH.S_TIM4_CH1.0=TIM4_CH1,PWM Generation1 CH1
SH.S_TIM4_CH1.ConfNb=1
SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2
SH.S_TIM4_CH2.ConfNb=1
SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3
SH.S_TIM4_CH3.ConfNb=1
SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4
SH.S_TIM4_CH4.ConfNb=1
SH.S_TIM5_CH1.0=TIM5_CH1,PWM Generation1 CH1
SH.S_TIM5_CH1.ConfNb=1
SH.S_TIM5_CH2.0=TIM5_CH2,PWM Generation2 CH2
SH.S_TIM5_CH2.ConfNb=1
SH.S_TIM5_CH3.0=TIM5_CH3,PWM Generation3 CH3
SH.S_TIM5_CH3.ConfNb=1
SH.S_TIM5_CH4.0=TIM5_CH4,PWM Generation4 CH4
SH.S_TIM5_CH4.ConfNb=1
SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1
SH.S_TIM8_CH1.ConfNb=1
SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2
SH.S_TIM8_CH2.ConfNb=1
SH.S_TIM8_CH3.0=TIM8_CH3,PWM Generation3 CH3
SH.S_TIM8_CH3.ConfNb=1
SH.S_TIM8_CH4.0=TIM8_CH4,PWM Generation4 CH4
SH.S_TIM8_CH4.ConfNb=1
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM1.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM1.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM1.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM1.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM12.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM12.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM12.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2
TIM13.Channel=TIM_CHANNEL_1
TIM13.IPParameters=Channel
TIM14.Channel=TIM_CHANNEL_1
TIM14.IPParameters=Channel
TIM15.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM15.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM15.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2
TIM16.Channel=TIM_CHANNEL_1
TIM16.IPParameters=Channel
TIM17.Channel=TIM_CHANNEL_1
TIM17.IPParameters=Channel
TIM2.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM2.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM2.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM2.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM3.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM3.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM4.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM4.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM5.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM5.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM5.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM5.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM5.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM8.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM8.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM8.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
USART1.IPParameters=VirtualMode-Asynchronous
USART1.VirtualMode-Asynchronous=VM_ASYNC
USART2.IPParameters=VirtualMode-Asynchronous
USART2.VirtualMode-Asynchronous=VM_ASYNC
USART3.IPParameters=VirtualMode-Asynchronous
USART3.VirtualMode-Asynchronous=VM_ASYNC
USB_DEVICE.CLASS_NAME_FS=CDC
USB_DEVICE.IPParameters=VirtualMode-CDC_FS,VirtualModeFS,CLASS_NAME_FS
USB_DEVICE.VirtualMode-CDC_FS=Cdc
USB_DEVICE.VirtualModeFS=Cdc_FS
USB_OTG_FS.IPParameters=VirtualMode
USB_OTG_FS.VirtualMode=Device_Only
VP_MEMORYMAP_VS_MEMORYMAP.Mode=CurAppReg
VP_MEMORYMAP_VS_MEMORYMAP.Signal=MEMORYMAP_VS_MEMORYMAP
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
VP_TIM13_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM13_VS_ClockSourceINT.Signal=TIM13_VS_ClockSourceINT
VP_TIM14_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM14_VS_ClockSourceINT.Signal=TIM14_VS_ClockSourceINT
VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT
VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT
VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS
VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS
board=custom

View File

@ -1,894 +0,0 @@
/**************************************************************************//**
* @file cmsis_armcc.h
* @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
* @version V5.1.0
* @date 08. May 2019
******************************************************************************/
/*
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CMSIS_ARMCC_H
#define __CMSIS_ARMCC_H
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
#error "Please use Arm Compiler Toolchain V4.0.677 or later!"
#endif
/* CMSIS compiler control architecture macros */
#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
(defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
#define __ARM_ARCH_6M__ 1
#endif
#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
#define __ARM_ARCH_7M__ 1
#endif
#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
#define __ARM_ARCH_7EM__ 1
#endif
/* __ARM_ARCH_8M_BASE__ not applicable */
/* __ARM_ARCH_8M_MAIN__ not applicable */
/* CMSIS compiler control DSP macros */
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
#define __ARM_FEATURE_DSP 1
#endif
/* CMSIS compiler specific defines */
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE __inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static __inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE static __forceinline
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __declspec(noreturn)
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __attribute__((packed))
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT __packed struct
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION __packed union
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
#define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
#endif
#ifndef __UNALIGNED_UINT16_WRITE
#define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
#define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
#endif
#ifndef __UNALIGNED_UINT32_WRITE
#define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __attribute__((aligned(x)))
#endif
#ifndef __RESTRICT
#define __RESTRICT __restrict
#endif
#ifndef __COMPILER_BARRIER
#define __COMPILER_BARRIER() __memory_changed()
#endif
/* ######################### Startup and Lowlevel Init ######################## */
#ifndef __PROGRAM_START
#define __PROGRAM_START __main
#endif
#ifndef __INITIAL_SP
#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit
#endif
#ifndef __STACK_LIMIT
#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base
#endif
#ifndef __VECTOR_TABLE
#define __VECTOR_TABLE __Vectors
#endif
#ifndef __VECTOR_TABLE_ATTRIBUTE
#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section("RESET")))
#endif
/* ########################### Core Function Access ########################### */
/** \ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
@{
*/
/**
\brief Enable IRQ Interrupts
\details Enables IRQ interrupts by clearing the I-bit in the CPSR.
Can only be executed in Privileged modes.
*/
/* intrinsic void __enable_irq(); */
/**
\brief Disable IRQ Interrupts
\details Disables IRQ interrupts by setting the I-bit in the CPSR.
Can only be executed in Privileged modes.
*/
/* intrinsic void __disable_irq(); */
/**
\brief Get Control Register
\details Returns the content of the Control Register.
\return Control Register value
*/
__STATIC_INLINE uint32_t __get_CONTROL(void)
{
register uint32_t __regControl __ASM("control");
return(__regControl);
}
/**
\brief Set Control Register
\details Writes the given value to the Control Register.
\param [in] control Control Register value to set
*/
__STATIC_INLINE void __set_CONTROL(uint32_t control)
{
register uint32_t __regControl __ASM("control");
__regControl = control;
}
/**
\brief Get IPSR Register
\details Returns the content of the IPSR Register.
\return IPSR Register value
*/
__STATIC_INLINE uint32_t __get_IPSR(void)
{
register uint32_t __regIPSR __ASM("ipsr");
return(__regIPSR);
}
/**
\brief Get APSR Register
\details Returns the content of the APSR Register.
\return APSR Register value
*/
__STATIC_INLINE uint32_t __get_APSR(void)
{
register uint32_t __regAPSR __ASM("apsr");
return(__regAPSR);
}
/**
\brief Get xPSR Register
\details Returns the content of the xPSR Register.
\return xPSR Register value
*/
__STATIC_INLINE uint32_t __get_xPSR(void)
{
register uint32_t __regXPSR __ASM("xpsr");
return(__regXPSR);
}
/**
\brief Get Process Stack Pointer
\details Returns the current value of the Process Stack Pointer (PSP).
\return PSP Register value
*/
__STATIC_INLINE uint32_t __get_PSP(void)
{
register uint32_t __regProcessStackPointer __ASM("psp");
return(__regProcessStackPointer);
}
/**
\brief Set Process Stack Pointer
\details Assigns the given value to the Process Stack Pointer (PSP).
\param [in] topOfProcStack Process Stack Pointer value to set
*/
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
{
register uint32_t __regProcessStackPointer __ASM("psp");
__regProcessStackPointer = topOfProcStack;
}
/**
\brief Get Main Stack Pointer
\details Returns the current value of the Main Stack Pointer (MSP).
\return MSP Register value
*/
__STATIC_INLINE uint32_t __get_MSP(void)
{
register uint32_t __regMainStackPointer __ASM("msp");
return(__regMainStackPointer);
}
/**
\brief Set Main Stack Pointer
\details Assigns the given value to the Main Stack Pointer (MSP).
\param [in] topOfMainStack Main Stack Pointer value to set
*/
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
register uint32_t __regMainStackPointer __ASM("msp");
__regMainStackPointer = topOfMainStack;
}
/**
\brief Get Priority Mask
\details Returns the current state of the priority mask bit from the Priority Mask Register.
\return Priority Mask value
*/
__STATIC_INLINE uint32_t __get_PRIMASK(void)
{
register uint32_t __regPriMask __ASM("primask");
return(__regPriMask);
}
/**
\brief Set Priority Mask
\details Assigns the given value to the Priority Mask Register.
\param [in] priMask Priority Mask
*/
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
{
register uint32_t __regPriMask __ASM("primask");
__regPriMask = (priMask);
}
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
/**
\brief Enable FIQ
\details Enables FIQ interrupts by clearing the F-bit in the CPSR.
Can only be executed in Privileged modes.
*/
#define __enable_fault_irq __enable_fiq
/**
\brief Disable FIQ
\details Disables FIQ interrupts by setting the F-bit in the CPSR.
Can only be executed in Privileged modes.
*/
#define __disable_fault_irq __disable_fiq
/**
\brief Get Base Priority
\details Returns the current value of the Base Priority register.
\return Base Priority register value
*/
__STATIC_INLINE uint32_t __get_BASEPRI(void)
{
register uint32_t __regBasePri __ASM("basepri");
return(__regBasePri);
}
/**
\brief Set Base Priority
\details Assigns the given value to the Base Priority register.
\param [in] basePri Base Priority value to set
*/
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
{
register uint32_t __regBasePri __ASM("basepri");
__regBasePri = (basePri & 0xFFU);
}
/**
\brief Set Base Priority with condition
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
or the new value increases the BASEPRI priority level.
\param [in] basePri Base Priority value to set
*/
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
{
register uint32_t __regBasePriMax __ASM("basepri_max");
__regBasePriMax = (basePri & 0xFFU);
}
/**
\brief Get Fault Mask
\details Returns the current value of the Fault Mask register.
\return Fault Mask register value
*/
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
{
register uint32_t __regFaultMask __ASM("faultmask");
return(__regFaultMask);
}
/**
\brief Set Fault Mask
\details Assigns the given value to the Fault Mask register.
\param [in] faultMask Fault Mask value to set
*/
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
{
register uint32_t __regFaultMask __ASM("faultmask");
__regFaultMask = (faultMask & (uint32_t)1U);
}
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/**
\brief Get FPSCR
\details Returns the current value of the Floating Point Status/Control register.
\return Floating Point Status/Control register value
*/
__STATIC_INLINE uint32_t __get_FPSCR(void)
{
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
register uint32_t __regfpscr __ASM("fpscr");
return(__regfpscr);
#else
return(0U);
#endif
}
/**
\brief Set FPSCR
\details Assigns the given value to the Floating Point Status/Control register.
\param [in] fpscr Floating Point Status/Control value to set
*/
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
{
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
register uint32_t __regfpscr __ASM("fpscr");
__regfpscr = (fpscr);
#else
(void)fpscr;
#endif
}
/*@} end of CMSIS_Core_RegAccFunctions */
/* ########################## Core Instruction Access ######################### */
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
Access to dedicated instructions
@{
*/
/**
\brief No Operation
\details No Operation does nothing. This instruction can be used for code alignment purposes.
*/
#define __NOP __nop
/**
\brief Wait For Interrupt
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
*/
#define __WFI __wfi
/**
\brief Wait For Event
\details Wait For Event is a hint instruction that permits the processor to enter
a low-power state until one of a number of events occurs.
*/
#define __WFE __wfe
/**
\brief Send Event
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
*/
#define __SEV __sev
/**
\brief Instruction Synchronization Barrier
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
so that all instructions following the ISB are fetched from cache or memory,
after the instruction has been completed.
*/
#define __ISB() do {\
__schedule_barrier();\
__isb(0xF);\
__schedule_barrier();\
} while (0U)
/**
\brief Data Synchronization Barrier
\details Acts as a special kind of Data Memory Barrier.
It completes when all explicit memory accesses before this instruction complete.
*/
#define __DSB() do {\
__schedule_barrier();\
__dsb(0xF);\
__schedule_barrier();\
} while (0U)
/**
\brief Data Memory Barrier
\details Ensures the apparent order of the explicit memory operations before
and after the instruction, without ensuring their completion.
*/
#define __DMB() do {\
__schedule_barrier();\
__dmb(0xF);\
__schedule_barrier();\
} while (0U)
/**
\brief Reverse byte order (32 bit)
\details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
\param [in] value Value to reverse
\return Reversed value
*/
#define __REV __rev
/**
\brief Reverse byte order (16 bit)
\details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
\param [in] value Value to reverse
\return Reversed value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
{
rev16 r0, r0
bx lr
}
#endif
/**
\brief Reverse byte order (16 bit)
\details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
\param [in] value Value to reverse
\return Reversed value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
{
revsh r0, r0
bx lr
}
#endif
/**
\brief Rotate Right in unsigned value (32 bit)
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
\param [in] op1 Value to rotate
\param [in] op2 Number of Bits to rotate
\return Rotated value
*/
#define __ROR __ror
/**
\brief Breakpoint
\details Causes the processor to enter Debug state.
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
\param [in] value is ignored by the processor.
If required, a debugger can use it to store additional information about the breakpoint.
*/
#define __BKPT(value) __breakpoint(value)
/**
\brief Reverse bit order of value
\details Reverses the bit order of the given value.
\param [in] value Value to reverse
\return Reversed value
*/
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
#define __RBIT __rbit
#else
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
{
uint32_t result;
uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
result = value; /* r will be reversed bits of v; first get LSB of v */
for (value >>= 1U; value != 0U; value >>= 1U)
{
result <<= 1U;
result |= value & 1U;
s--;
}
result <<= s; /* shift when v's highest bits are zero */
return result;
}
#endif
/**
\brief Count leading zeros
\details Counts the number of leading zeros of a data value.
\param [in] value Value to count the leading zeros
\return number of leading zeros in value
*/
#define __CLZ __clz
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
/**
\brief LDR Exclusive (8 bit)
\details Executes a exclusive LDR instruction for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
#else
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief LDR Exclusive (16 bit)
\details Executes a exclusive LDR instruction for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
#else
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief LDR Exclusive (32 bit)
\details Executes a exclusive LDR instruction for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
#else
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
#endif
/**
\brief STR Exclusive (8 bit)
\details Executes a exclusive STR instruction for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXB(value, ptr) __strex(value, ptr)
#else
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief STR Exclusive (16 bit)
\details Executes a exclusive STR instruction for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXH(value, ptr) __strex(value, ptr)
#else
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief STR Exclusive (32 bit)
\details Executes a exclusive STR instruction for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
\return 0 Function succeeded
\return 1 Function failed
*/
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
#define __STREXW(value, ptr) __strex(value, ptr)
#else
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
#endif
/**
\brief Remove the exclusive lock
\details Removes the exclusive lock which is created by LDREX.
*/
#define __CLREX __clrex
/**
\brief Signed Saturate
\details Saturates a signed value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (1..32)
\return Saturated value
*/
#define __SSAT __ssat
/**
\brief Unsigned Saturate
\details Saturates an unsigned value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (0..31)
\return Saturated value
*/
#define __USAT __usat
/**
\brief Rotate Right with Extend (32 bit)
\details Moves each bit of a bitstring right by one bit.
The carry input is shifted in at the left end of the bitstring.
\param [in] value Value to rotate
\return Rotated value
*/
#ifndef __NO_EMBEDDED_ASM
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
{
rrx r0, r0
bx lr
}
#endif
/**
\brief LDRT Unprivileged (8 bit)
\details Executes a Unprivileged LDRT instruction for 8 bit value.
\param [in] ptr Pointer to data
\return value of type uint8_t at (*ptr)
*/
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
/**
\brief LDRT Unprivileged (16 bit)
\details Executes a Unprivileged LDRT instruction for 16 bit values.
\param [in] ptr Pointer to data
\return value of type uint16_t at (*ptr)
*/
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
/**
\brief LDRT Unprivileged (32 bit)
\details Executes a Unprivileged LDRT instruction for 32 bit values.
\param [in] ptr Pointer to data
\return value of type uint32_t at (*ptr)
*/
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
/**
\brief STRT Unprivileged (8 bit)
\details Executes a Unprivileged STRT instruction for 8 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRBT(value, ptr) __strt(value, ptr)
/**
\brief STRT Unprivileged (16 bit)
\details Executes a Unprivileged STRT instruction for 16 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRHT(value, ptr) __strt(value, ptr)
/**
\brief STRT Unprivileged (32 bit)
\details Executes a Unprivileged STRT instruction for 32 bit values.
\param [in] value Value to store
\param [in] ptr Pointer to location
*/
#define __STRT(value, ptr) __strt(value, ptr)
#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/**
\brief Signed Saturate
\details Saturates a signed value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (1..32)
\return Saturated value
*/
__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
{
if ((sat >= 1U) && (sat <= 32U))
{
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
const int32_t min = -1 - max ;
if (val > max)
{
return max;
}
else if (val < min)
{
return min;
}
}
return val;
}
/**
\brief Unsigned Saturate
\details Saturates an unsigned value.
\param [in] value Value to be saturated
\param [in] sat Bit position to saturate to (0..31)
\return Saturated value
*/
__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
{
if (sat <= 31U)
{
const uint32_t max = ((1U << sat) - 1U);
if (val > (int32_t)max)
{
return max;
}
else if (val < 0)
{
return 0U;
}
}
return (uint32_t)val;
}
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
/* ################### Compiler specific Intrinsics ########################### */
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
Access to dedicated SIMD instructions
@{
*/
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
#define __SADD8 __sadd8
#define __QADD8 __qadd8
#define __SHADD8 __shadd8
#define __UADD8 __uadd8
#define __UQADD8 __uqadd8
#define __UHADD8 __uhadd8
#define __SSUB8 __ssub8
#define __QSUB8 __qsub8
#define __SHSUB8 __shsub8
#define __USUB8 __usub8
#define __UQSUB8 __uqsub8
#define __UHSUB8 __uhsub8
#define __SADD16 __sadd16
#define __QADD16 __qadd16
#define __SHADD16 __shadd16
#define __UADD16 __uadd16
#define __UQADD16 __uqadd16
#define __UHADD16 __uhadd16
#define __SSUB16 __ssub16
#define __QSUB16 __qsub16
#define __SHSUB16 __shsub16
#define __USUB16 __usub16
#define __UQSUB16 __uqsub16
#define __UHSUB16 __uhsub16
#define __SASX __sasx
#define __QASX __qasx
#define __SHASX __shasx
#define __UASX __uasx
#define __UQASX __uqasx
#define __UHASX __uhasx
#define __SSAX __ssax
#define __QSAX __qsax
#define __SHSAX __shsax
#define __USAX __usax
#define __UQSAX __uqsax
#define __UHSAX __uhsax
#define __USAD8 __usad8
#define __USADA8 __usada8
#define __SSAT16 __ssat16
#define __USAT16 __usat16
#define __UXTB16 __uxtb16
#define __UXTAB16 __uxtab16
#define __SXTB16 __sxtb16
#define __SXTAB16 __sxtab16
#define __SMUAD __smuad
#define __SMUADX __smuadx
#define __SMLAD __smlad
#define __SMLADX __smladx
#define __SMLALD __smlald
#define __SMLALDX __smlaldx
#define __SMUSD __smusd
#define __SMUSDX __smusdx
#define __SMLSD __smlsd
#define __SMLSDX __smlsdx
#define __SMLSLD __smlsld
#define __SMLSLDX __smlsldx
#define __SEL __sel
#define __QADD __qadd
#define __QSUB __qsub
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
((int64_t)(ARG3) << 32U) ) >> 32U))
#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
/*@} end of group CMSIS_SIMD_intrinsics */
#endif /* __CMSIS_ARMCC_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,283 +0,0 @@
/**************************************************************************//**
* @file cmsis_compiler.h
* @brief CMSIS compiler generic header file
* @version V5.1.0
* @date 09. October 2018
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __CMSIS_COMPILER_H
#define __CMSIS_COMPILER_H
#include <stdint.h>
/*
* Arm Compiler 4/5
*/
#if defined ( __CC_ARM )
#include "cmsis_armcc.h"
/*
* Arm Compiler 6.6 LTM (armclang)
*/
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) && (__ARMCC_VERSION < 6100100)
#include "cmsis_armclang_ltm.h"
/*
* Arm Compiler above 6.10.1 (armclang)
*/
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6100100)
#include "cmsis_armclang.h"
/*
* GNU Compiler
*/
#elif defined ( __GNUC__ )
#include "cmsis_gcc.h"
/*
* IAR Compiler
*/
#elif defined ( __ICCARM__ )
#include <cmsis_iccarm.h>
/*
* TI Arm Compiler
*/
#elif defined ( __TI_ARM__ )
#include <cmsis_ccs.h>
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((noreturn))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __attribute__((packed))
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __attribute__((packed))
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __attribute__((packed))
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __attribute__((aligned(x)))
#endif
#ifndef __RESTRICT
#define __RESTRICT __restrict
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
/*
* TASKING Compiler
*/
#elif defined ( __TASKING__ )
/*
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all intrinsics,
* Including the CMSIS ones.
*/
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
#define __NO_RETURN __attribute__((noreturn))
#endif
#ifndef __USED
#define __USED __attribute__((used))
#endif
#ifndef __WEAK
#define __WEAK __attribute__((weak))
#endif
#ifndef __PACKED
#define __PACKED __packed__
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT struct __packed__
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION union __packed__
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
struct __packed__ T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#define __ALIGNED(x) __align(x)
#endif
#ifndef __RESTRICT
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
#define __RESTRICT
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
/*
* COSMIC Compiler
*/
#elif defined ( __CSMC__ )
#include <cmsis_csm.h>
#ifndef __ASM
#define __ASM _asm
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __STATIC_INLINE
#endif
#ifndef __NO_RETURN
// NO RETURN is automatically detected hence no warning here
#define __NO_RETURN
#endif
#ifndef __USED
#warning No compiler specific solution for __USED. __USED is ignored.
#define __USED
#endif
#ifndef __WEAK
#define __WEAK __weak
#endif
#ifndef __PACKED
#define __PACKED @packed
#endif
#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT @packed struct
#endif
#ifndef __PACKED_UNION
#define __PACKED_UNION @packed union
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
@packed struct T_UINT32 { uint32_t v; };
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT16_READ
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#endif
#ifndef __UNALIGNED_UINT32_READ
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#endif
#ifndef __ALIGNED
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
#define __ALIGNED(x)
#endif
#ifndef __RESTRICT
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
#define __RESTRICT
#endif
#ifndef __COMPILER_BARRIER
#warning No compiler specific solution for __COMPILER_BARRIER. __COMPILER_BARRIER is ignored.
#define __COMPILER_BARRIER() (void)0
#endif
#else
#error Unknown compiler.
#endif
#endif /* __CMSIS_COMPILER_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,964 +0,0 @@
/**************************************************************************//**
* @file cmsis_iccarm.h
* @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file
* @version V5.1.0
* @date 08. May 2019
******************************************************************************/
//------------------------------------------------------------------------------
//
// Copyright (c) 2017-2019 IAR Systems
// Copyright (c) 2017-2019 Arm Limited. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License")
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//------------------------------------------------------------------------------
#ifndef __CMSIS_ICCARM_H__
#define __CMSIS_ICCARM_H__
#ifndef __ICCARM__
#error This file should only be compiled by ICCARM
#endif
#pragma system_include
#define __IAR_FT _Pragma("inline=forced") __intrinsic
#if (__VER__ >= 8000000)
#define __ICCARM_V8 1
#else
#define __ICCARM_V8 0
#endif
#ifndef __ALIGNED
#if __ICCARM_V8
#define __ALIGNED(x) __attribute__((aligned(x)))
#elif (__VER__ >= 7080000)
/* Needs IAR language extensions */
#define __ALIGNED(x) __attribute__((aligned(x)))
#else
#warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored.
#define __ALIGNED(x)
#endif
#endif
/* Define compiler macros for CPU architecture, used in CMSIS 5.
*/
#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__
/* Macros already defined */
#else
#if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__)
#define __ARM_ARCH_8M_MAIN__ 1
#elif defined(__ARM8M_BASELINE__)
#define __ARM_ARCH_8M_BASE__ 1
#elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M'
#if __ARM_ARCH == 6
#define __ARM_ARCH_6M__ 1
#elif __ARM_ARCH == 7
#if __ARM_FEATURE_DSP
#define __ARM_ARCH_7EM__ 1
#else
#define __ARM_ARCH_7M__ 1
#endif
#endif /* __ARM_ARCH */
#endif /* __ARM_ARCH_PROFILE == 'M' */
#endif
/* Alternativ core deduction for older ICCARM's */
#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \
!defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__)
#if defined(__ARM6M__) && (__CORE__ == __ARM6M__)
#define __ARM_ARCH_6M__ 1
#elif defined(__ARM7M__) && (__CORE__ == __ARM7M__)
#define __ARM_ARCH_7M__ 1
#elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__)
#define __ARM_ARCH_7EM__ 1
#elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__)
#define __ARM_ARCH_8M_BASE__ 1
#elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__)
#define __ARM_ARCH_8M_MAIN__ 1
#elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__)
#define __ARM_ARCH_8M_MAIN__ 1
#else
#error "Unknown target."
#endif
#endif
#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1
#define __IAR_M0_FAMILY 1
#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1
#define __IAR_M0_FAMILY 1
#else
#define __IAR_M0_FAMILY 0
#endif
#ifndef __ASM
#define __ASM __asm
#endif
#ifndef __COMPILER_BARRIER
#define __COMPILER_BARRIER() __ASM volatile("":::"memory")
#endif
#ifndef __INLINE
#define __INLINE inline
#endif
#ifndef __NO_RETURN
#if __ICCARM_V8
#define __NO_RETURN __attribute__((__noreturn__))
#else
#define __NO_RETURN _Pragma("object_attribute=__noreturn")
#endif
#endif
#ifndef __PACKED
#if __ICCARM_V8
#define __PACKED __attribute__((packed, aligned(1)))
#else
/* Needs IAR language extensions */
#define __PACKED __packed
#endif
#endif
#ifndef __PACKED_STRUCT
#if __ICCARM_V8
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
#else
/* Needs IAR language extensions */
#define __PACKED_STRUCT __packed struct
#endif
#endif
#ifndef __PACKED_UNION
#if __ICCARM_V8
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
#else
/* Needs IAR language extensions */
#define __PACKED_UNION __packed union
#endif
#endif
#ifndef __RESTRICT
#if __ICCARM_V8
#define __RESTRICT __restrict
#else
/* Needs IAR language extensions */
#define __RESTRICT restrict
#endif
#endif
#ifndef __STATIC_INLINE
#define __STATIC_INLINE static inline
#endif
#ifndef __FORCEINLINE
#define __FORCEINLINE _Pragma("inline=forced")
#endif
#ifndef __STATIC_FORCEINLINE
#define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE
#endif
#ifndef __UNALIGNED_UINT16_READ
#pragma language=save
#pragma language=extended
__IAR_FT uint16_t __iar_uint16_read(void const *ptr)
{
return *(__packed uint16_t*)(ptr);
}
#pragma language=restore
#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR)
#endif
#ifndef __UNALIGNED_UINT16_WRITE
#pragma language=save
#pragma language=extended
__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
{
*(__packed uint16_t*)(ptr) = val;;
}
#pragma language=restore
#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
#endif
#ifndef __UNALIGNED_UINT32_READ
#pragma language=save
#pragma language=extended
__IAR_FT uint32_t __iar_uint32_read(void const *ptr)
{
return *(__packed uint32_t*)(ptr);
}
#pragma language=restore
#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR)
#endif
#ifndef __UNALIGNED_UINT32_WRITE
#pragma language=save
#pragma language=extended
__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
{
*(__packed uint32_t*)(ptr) = val;;
}
#pragma language=restore
#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
#endif
#ifndef __UNALIGNED_UINT32 /* deprecated */
#pragma language=save
#pragma language=extended
__packed struct __iar_u32 { uint32_t v; };
#pragma language=restore
#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
#endif
#ifndef __USED
#if __ICCARM_V8
#define __USED __attribute__((used))
#else
#define __USED _Pragma("__root")
#endif
#endif
#ifndef __WEAK
#if __ICCARM_V8
#define __WEAK __attribute__((weak))
#else
#define __WEAK _Pragma("__weak")
#endif
#endif
#ifndef __PROGRAM_START
#define __PROGRAM_START __iar_program_start
#endif
#ifndef __INITIAL_SP
#define __INITIAL_SP CSTACK$$Limit
#endif
#ifndef __STACK_LIMIT
#define __STACK_LIMIT CSTACK$$Base
#endif
#ifndef __VECTOR_TABLE
#define __VECTOR_TABLE __vector_table
#endif
#ifndef __VECTOR_TABLE_ATTRIBUTE
#define __VECTOR_TABLE_ATTRIBUTE @".intvec"
#endif
#ifndef __ICCARM_INTRINSICS_VERSION__
#define __ICCARM_INTRINSICS_VERSION__ 0
#endif
#if __ICCARM_INTRINSICS_VERSION__ == 2
#if defined(__CLZ)
#undef __CLZ
#endif
#if defined(__REVSH)
#undef __REVSH
#endif
#if defined(__RBIT)
#undef __RBIT
#endif
#if defined(__SSAT)
#undef __SSAT
#endif
#if defined(__USAT)
#undef __USAT
#endif
#include "iccarm_builtin.h"
#define __disable_fault_irq __iar_builtin_disable_fiq
#define __disable_irq __iar_builtin_disable_interrupt
#define __enable_fault_irq __iar_builtin_enable_fiq
#define __enable_irq __iar_builtin_enable_interrupt
#define __arm_rsr __iar_builtin_rsr
#define __arm_wsr __iar_builtin_wsr
#define __get_APSR() (__arm_rsr("APSR"))
#define __get_BASEPRI() (__arm_rsr("BASEPRI"))
#define __get_CONTROL() (__arm_rsr("CONTROL"))
#define __get_FAULTMASK() (__arm_rsr("FAULTMASK"))
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
#define __get_FPSCR() (__arm_rsr("FPSCR"))
#define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE)))
#else
#define __get_FPSCR() ( 0 )
#define __set_FPSCR(VALUE) ((void)VALUE)
#endif
#define __get_IPSR() (__arm_rsr("IPSR"))
#define __get_MSP() (__arm_rsr("MSP"))
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure MSPLIM is RAZ/WI
#define __get_MSPLIM() (0U)
#else
#define __get_MSPLIM() (__arm_rsr("MSPLIM"))
#endif
#define __get_PRIMASK() (__arm_rsr("PRIMASK"))
#define __get_PSP() (__arm_rsr("PSP"))
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
#define __get_PSPLIM() (0U)
#else
#define __get_PSPLIM() (__arm_rsr("PSPLIM"))
#endif
#define __get_xPSR() (__arm_rsr("xPSR"))
#define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE)))
#define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE)))
#define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE)))
#define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE)))
#define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE)))
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure MSPLIM is RAZ/WI
#define __set_MSPLIM(VALUE) ((void)(VALUE))
#else
#define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE)))
#endif
#define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE)))
#define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE)))
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
#define __set_PSPLIM(VALUE) ((void)(VALUE))
#else
#define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE)))
#endif
#define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS"))
#define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE)))
#define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS"))
#define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE)))
#define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS"))
#define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE)))
#define __TZ_get_SP_NS() (__arm_rsr("SP_NS"))
#define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE)))
#define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS"))
#define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE)))
#define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS"))
#define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE)))
#define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS"))
#define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE)))
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
#define __TZ_get_PSPLIM_NS() (0U)
#define __TZ_set_PSPLIM_NS(VALUE) ((void)(VALUE))
#else
#define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS"))
#define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE)))
#endif
#define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS"))
#define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE)))
#define __NOP __iar_builtin_no_operation
#define __CLZ __iar_builtin_CLZ
#define __CLREX __iar_builtin_CLREX
#define __DMB __iar_builtin_DMB
#define __DSB __iar_builtin_DSB
#define __ISB __iar_builtin_ISB
#define __LDREXB __iar_builtin_LDREXB
#define __LDREXH __iar_builtin_LDREXH
#define __LDREXW __iar_builtin_LDREX
#define __RBIT __iar_builtin_RBIT
#define __REV __iar_builtin_REV
#define __REV16 __iar_builtin_REV16
__IAR_FT int16_t __REVSH(int16_t val)
{
return (int16_t) __iar_builtin_REVSH(val);
}
#define __ROR __iar_builtin_ROR
#define __RRX __iar_builtin_RRX
#define __SEV __iar_builtin_SEV
#if !__IAR_M0_FAMILY
#define __SSAT __iar_builtin_SSAT
#endif
#define __STREXB __iar_builtin_STREXB
#define __STREXH __iar_builtin_STREXH
#define __STREXW __iar_builtin_STREX
#if !__IAR_M0_FAMILY
#define __USAT __iar_builtin_USAT
#endif
#define __WFE __iar_builtin_WFE
#define __WFI __iar_builtin_WFI
#if __ARM_MEDIA__
#define __SADD8 __iar_builtin_SADD8
#define __QADD8 __iar_builtin_QADD8
#define __SHADD8 __iar_builtin_SHADD8
#define __UADD8 __iar_builtin_UADD8
#define __UQADD8 __iar_builtin_UQADD8
#define __UHADD8 __iar_builtin_UHADD8
#define __SSUB8 __iar_builtin_SSUB8
#define __QSUB8 __iar_builtin_QSUB8
#define __SHSUB8 __iar_builtin_SHSUB8
#define __USUB8 __iar_builtin_USUB8
#define __UQSUB8 __iar_builtin_UQSUB8
#define __UHSUB8 __iar_builtin_UHSUB8
#define __SADD16 __iar_builtin_SADD16
#define __QADD16 __iar_builtin_QADD16
#define __SHADD16 __iar_builtin_SHADD16
#define __UADD16 __iar_builtin_UADD16
#define __UQADD16 __iar_builtin_UQADD16
#define __UHADD16 __iar_builtin_UHADD16
#define __SSUB16 __iar_builtin_SSUB16
#define __QSUB16 __iar_builtin_QSUB16
#define __SHSUB16 __iar_builtin_SHSUB16
#define __USUB16 __iar_builtin_USUB16
#define __UQSUB16 __iar_builtin_UQSUB16
#define __UHSUB16 __iar_builtin_UHSUB16
#define __SASX __iar_builtin_SASX
#define __QASX __iar_builtin_QASX
#define __SHASX __iar_builtin_SHASX
#define __UASX __iar_builtin_UASX
#define __UQASX __iar_builtin_UQASX
#define __UHASX __iar_builtin_UHASX
#define __SSAX __iar_builtin_SSAX
#define __QSAX __iar_builtin_QSAX
#define __SHSAX __iar_builtin_SHSAX
#define __USAX __iar_builtin_USAX
#define __UQSAX __iar_builtin_UQSAX
#define __UHSAX __iar_builtin_UHSAX
#define __USAD8 __iar_builtin_USAD8
#define __USADA8 __iar_builtin_USADA8
#define __SSAT16 __iar_builtin_SSAT16
#define __USAT16 __iar_builtin_USAT16
#define __UXTB16 __iar_builtin_UXTB16
#define __UXTAB16 __iar_builtin_UXTAB16
#define __SXTB16 __iar_builtin_SXTB16
#define __SXTAB16 __iar_builtin_SXTAB16
#define __SMUAD __iar_builtin_SMUAD
#define __SMUADX __iar_builtin_SMUADX
#define __SMMLA __iar_builtin_SMMLA
#define __SMLAD __iar_builtin_SMLAD
#define __SMLADX __iar_builtin_SMLADX
#define __SMLALD __iar_builtin_SMLALD
#define __SMLALDX __iar_builtin_SMLALDX
#define __SMUSD __iar_builtin_SMUSD
#define __SMUSDX __iar_builtin_SMUSDX
#define __SMLSD __iar_builtin_SMLSD
#define __SMLSDX __iar_builtin_SMLSDX
#define __SMLSLD __iar_builtin_SMLSLD
#define __SMLSLDX __iar_builtin_SMLSLDX
#define __SEL __iar_builtin_SEL
#define __QADD __iar_builtin_QADD
#define __QSUB __iar_builtin_QSUB
#define __PKHBT __iar_builtin_PKHBT
#define __PKHTB __iar_builtin_PKHTB
#endif
#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */
#if __IAR_M0_FAMILY
/* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
#define __CLZ __cmsis_iar_clz_not_active
#define __SSAT __cmsis_iar_ssat_not_active
#define __USAT __cmsis_iar_usat_not_active
#define __RBIT __cmsis_iar_rbit_not_active
#define __get_APSR __cmsis_iar_get_APSR_not_active
#endif
#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
#define __get_FPSCR __cmsis_iar_get_FPSR_not_active
#define __set_FPSCR __cmsis_iar_set_FPSR_not_active
#endif
#ifdef __INTRINSICS_INCLUDED
#error intrinsics.h is already included previously!
#endif
#include <intrinsics.h>
#if __IAR_M0_FAMILY
/* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
#undef __CLZ
#undef __SSAT
#undef __USAT
#undef __RBIT
#undef __get_APSR
__STATIC_INLINE uint8_t __CLZ(uint32_t data)
{
if (data == 0U) { return 32U; }
uint32_t count = 0U;
uint32_t mask = 0x80000000U;
while ((data & mask) == 0U)
{
count += 1U;
mask = mask >> 1U;
}
return count;
}
__STATIC_INLINE uint32_t __RBIT(uint32_t v)
{
uint8_t sc = 31U;
uint32_t r = v;
for (v >>= 1U; v; v >>= 1U)
{
r <<= 1U;
r |= v & 1U;
sc--;
}
return (r << sc);
}
__STATIC_INLINE uint32_t __get_APSR(void)
{
uint32_t res;
__asm("MRS %0,APSR" : "=r" (res));
return res;
}
#endif
#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
#undef __get_FPSCR
#undef __set_FPSCR
#define __get_FPSCR() (0)
#define __set_FPSCR(VALUE) ((void)VALUE)
#endif
#pragma diag_suppress=Pe940
#pragma diag_suppress=Pe177
#define __enable_irq __enable_interrupt
#define __disable_irq __disable_interrupt
#define __NOP __no_operation
#define __get_xPSR __get_PSR
#if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0)
__IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr)
{
return __LDREX((unsigned long *)ptr);
}
__IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr)
{
return __STREX(value, (unsigned long *)ptr);
}
#endif
/* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
#if (__CORTEX_M >= 0x03)
__IAR_FT uint32_t __RRX(uint32_t value)
{
uint32_t result;
__ASM("RRX %0, %1" : "=r"(result) : "r" (value) : "cc");
return(result);
}
__IAR_FT void __set_BASEPRI_MAX(uint32_t value)
{
__asm volatile("MSR BASEPRI_MAX,%0"::"r" (value));
}
#define __enable_fault_irq __enable_fiq
#define __disable_fault_irq __disable_fiq
#endif /* (__CORTEX_M >= 0x03) */
__IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2)
{
return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2));
}
#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
(defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
__IAR_FT uint32_t __get_MSPLIM(void)
{
uint32_t res;
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure MSPLIM is RAZ/WI
res = 0U;
#else
__asm volatile("MRS %0,MSPLIM" : "=r" (res));
#endif
return res;
}
__IAR_FT void __set_MSPLIM(uint32_t value)
{
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure MSPLIM is RAZ/WI
(void)value;
#else
__asm volatile("MSR MSPLIM,%0" :: "r" (value));
#endif
}
__IAR_FT uint32_t __get_PSPLIM(void)
{
uint32_t res;
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
res = 0U;
#else
__asm volatile("MRS %0,PSPLIM" : "=r" (res));
#endif
return res;
}
__IAR_FT void __set_PSPLIM(uint32_t value)
{
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
(void)value;
#else
__asm volatile("MSR PSPLIM,%0" :: "r" (value));
#endif
}
__IAR_FT uint32_t __TZ_get_CONTROL_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,CONTROL_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_CONTROL_NS(uint32_t value)
{
__asm volatile("MSR CONTROL_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_PSP_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,PSP_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_PSP_NS(uint32_t value)
{
__asm volatile("MSR PSP_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_MSP_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,MSP_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_MSP_NS(uint32_t value)
{
__asm volatile("MSR MSP_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_SP_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,SP_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_SP_NS(uint32_t value)
{
__asm volatile("MSR SP_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_PRIMASK_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,PRIMASK_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value)
{
__asm volatile("MSR PRIMASK_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_BASEPRI_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,BASEPRI_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value)
{
__asm volatile("MSR BASEPRI_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value)
{
__asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value));
}
__IAR_FT uint32_t __TZ_get_PSPLIM_NS(void)
{
uint32_t res;
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
res = 0U;
#else
__asm volatile("MRS %0,PSPLIM_NS" : "=r" (res));
#endif
return res;
}
__IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value)
{
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
// without main extensions, the non-secure PSPLIM is RAZ/WI
(void)value;
#else
__asm volatile("MSR PSPLIM_NS,%0" :: "r" (value));
#endif
}
__IAR_FT uint32_t __TZ_get_MSPLIM_NS(void)
{
uint32_t res;
__asm volatile("MRS %0,MSPLIM_NS" : "=r" (res));
return res;
}
__IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value)
{
__asm volatile("MSR MSPLIM_NS,%0" :: "r" (value));
}
#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */
#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value))
#if __IAR_M0_FAMILY
__STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
{
if ((sat >= 1U) && (sat <= 32U))
{
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
const int32_t min = -1 - max ;
if (val > max)
{
return max;
}
else if (val < min)
{
return min;
}
}
return val;
}
__STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
{
if (sat <= 31U)
{
const uint32_t max = ((1U << sat) - 1U);
if (val > (int32_t)max)
{
return max;
}
else if (val < 0)
{
return 0U;
}
}
return (uint32_t)val;
}
#endif
#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
__IAR_FT uint8_t __LDRBT(volatile uint8_t *addr)
{
uint32_t res;
__ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
return ((uint8_t)res);
}
__IAR_FT uint16_t __LDRHT(volatile uint16_t *addr)
{
uint32_t res;
__ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
return ((uint16_t)res);
}
__IAR_FT uint32_t __LDRT(volatile uint32_t *addr)
{
uint32_t res;
__ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
return res;
}
__IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr)
{
__ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
}
__IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr)
{
__ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
}
__IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr)
{
__ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory");
}
#endif /* (__CORTEX_M >= 0x03) */
#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
(defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
__IAR_FT uint8_t __LDAB(volatile uint8_t *ptr)
{
uint32_t res;
__ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
return ((uint8_t)res);
}
__IAR_FT uint16_t __LDAH(volatile uint16_t *ptr)
{
uint32_t res;
__ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
return ((uint16_t)res);
}
__IAR_FT uint32_t __LDA(volatile uint32_t *ptr)
{
uint32_t res;
__ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
return res;
}
__IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr)
{
__ASM volatile ("STLB %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
}
__IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr)
{
__ASM volatile ("STLH %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
}
__IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr)
{
__ASM volatile ("STL %1, [%0]" :: "r" (ptr), "r" (value) : "memory");
}
__IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr)
{
uint32_t res;
__ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
return ((uint8_t)res);
}
__IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr)
{
uint32_t res;
__ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
return ((uint16_t)res);
}
__IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr)
{
uint32_t res;
__ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (ptr) : "memory");
return res;
}
__IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
{
uint32_t res;
__ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
return res;
}
__IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
{
uint32_t res;
__ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
return res;
}
__IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
{
uint32_t res;
__ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (ptr), "r" (value) : "memory");
return res;
}
#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
#undef __IAR_FT
#undef __IAR_M0_FAMILY
#undef __ICCARM_V8
#pragma diag_default=Pe940
#pragma diag_default=Pe177
#endif /* __CMSIS_ICCARM_H__ */

View File

@ -1,39 +0,0 @@
/**************************************************************************//**
* @file cmsis_version.h
* @brief CMSIS Core(M) Version definitions
* @version V5.0.3
* @date 24. June 2019
******************************************************************************/
/*
* Copyright (c) 2009-2019 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CMSIS_VERSION_H
#define __CMSIS_VERSION_H
/* CMSIS Version definitions */
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
#define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,952 +0,0 @@
/**************************************************************************//**
* @file core_cm0.h
* @brief CMSIS Cortex-M0 Core Peripheral Access Layer Header File
* @version V5.0.6
* @date 13. March 2019
******************************************************************************/
/*
* Copyright (c) 2009-2019 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CORE_CM0_H_GENERIC
#define __CORE_CM0_H_GENERIC
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
\page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
CMSIS violates the following MISRA-C:2004 rules:
\li Required Rule 8.5, object/function definition in header file.<br>
Function definitions in header files are used to allow 'inlining'.
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
Unions are used for effective representation of core registers.
\li Advisory Rule 19.7, Function-like macro defined.<br>
Function-like macros are used to allow more efficient code.
*/
/*******************************************************************************
* CMSIS definitions
******************************************************************************/
/**
\ingroup Cortex_M0
@{
*/
#include "cmsis_version.h"
/* CMSIS CM0 definitions */
#define __CM0_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */
#define __CM0_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */
#define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
__CM0_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */
#define __CORTEX_M (0U) /*!< Cortex-M Core */
/** __FPU_USED indicates whether an FPU is used or not.
This core does not support an FPU at all
*/
#define __FPU_USED 0U
#if defined ( __CC_ARM )
#if defined __TARGET_FPU_VFP
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#if defined __ARM_FP
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __GNUC__ )
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __ICCARM__ )
#if defined __ARMVFP__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __TI_ARM__ )
#if defined __TI_VFP_SUPPORT__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __TASKING__ )
#if defined __FPU_VFP__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __CSMC__ )
#if ( __CSMC__ & 0x400U)
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#endif
#include "cmsis_compiler.h" /* CMSIS compiler specific defines */
#ifdef __cplusplus
}
#endif
#endif /* __CORE_CM0_H_GENERIC */
#ifndef __CMSIS_GENERIC
#ifndef __CORE_CM0_H_DEPENDANT
#define __CORE_CM0_H_DEPENDANT
#ifdef __cplusplus
extern "C" {
#endif
/* check device defines and use defaults */
#if defined __CHECK_DEVICE_DEFINES
#ifndef __CM0_REV
#define __CM0_REV 0x0000U
#warning "__CM0_REV not defined in device header file; using default!"
#endif
#ifndef __NVIC_PRIO_BITS
#define __NVIC_PRIO_BITS 2U
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
#endif
#ifndef __Vendor_SysTickConfig
#define __Vendor_SysTickConfig 0U
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
#endif
#endif
/* IO definitions (access restrictions to peripheral registers) */
/**
\defgroup CMSIS_glob_defs CMSIS Global Defines
<strong>IO Type Qualifiers</strong> are used
\li to specify the access to peripheral variables.
\li for automatic generation of peripheral register debug information.
*/
#ifdef __cplusplus
#define __I volatile /*!< Defines 'read only' permissions */
#else
#define __I volatile const /*!< Defines 'read only' permissions */
#endif
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */
/* following defines should be used for structure members */
#define __IM volatile const /*! Defines 'read only' structure member permissions */
#define __OM volatile /*! Defines 'write only' structure member permissions */
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
/*@} end of group Cortex_M0 */
/*******************************************************************************
* Register Abstraction
Core Register contain:
- Core Register
- Core NVIC Register
- Core SCB Register
- Core SysTick Register
******************************************************************************/
/**
\defgroup CMSIS_core_register Defines and Type Definitions
\brief Type definitions and defines for Cortex-M processor based devices.
*/
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_CORE Status and Control Registers
\brief Core Register type definitions.
@{
*/
/**
\brief Union type to access the Application Program Status Register (APSR).
*/
typedef union
{
struct
{
uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} APSR_Type;
/* APSR Register Definitions */
#define APSR_N_Pos 31U /*!< APSR: N Position */
#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
#define APSR_Z_Pos 30U /*!< APSR: Z Position */
#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
#define APSR_C_Pos 29U /*!< APSR: C Position */
#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
#define APSR_V_Pos 28U /*!< APSR: V Position */
#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
/**
\brief Union type to access the Interrupt Program Status Register (IPSR).
*/
typedef union
{
struct
{
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} IPSR_Type;
/* IPSR Register Definitions */
#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
/**
\brief Union type to access the Special-Purpose Program Status Registers (xPSR).
*/
typedef union
{
struct
{
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} xPSR_Type;
/* xPSR Register Definitions */
#define xPSR_N_Pos 31U /*!< xPSR: N Position */
#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
#define xPSR_C_Pos 29U /*!< xPSR: C Position */
#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
#define xPSR_V_Pos 28U /*!< xPSR: V Position */
#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
#define xPSR_T_Pos 24U /*!< xPSR: T Position */
#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
/**
\brief Union type to access the Control Registers (CONTROL).
*/
typedef union
{
struct
{
uint32_t _reserved0:1; /*!< bit: 0 Reserved */
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} CONTROL_Type;
/* CONTROL Register Definitions */
#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
/*@} end of group CMSIS_CORE */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
\brief Type definitions for the NVIC Registers
@{
*/
/**
\brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
*/
typedef struct
{
__IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
uint32_t RESERVED0[31U];
__IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
uint32_t RESERVED1[31U];
__IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
uint32_t RESERVED2[31U];
__IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
uint32_t RESERVED3[31U];
uint32_t RESERVED4[64U];
__IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
} NVIC_Type;
/*@} end of group CMSIS_NVIC */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_SCB System Control Block (SCB)
\brief Type definitions for the System Control Block Registers
@{
*/
/**
\brief Structure type to access the System Control Block (SCB).
*/
typedef struct
{
__IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
__IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
uint32_t RESERVED0;
__IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
__IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
__IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
uint32_t RESERVED1;
__IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
__IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
} SCB_Type;
/* SCB CPUID Register Definitions */
#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
/* SCB Interrupt Control State Register Definitions */
#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
/* SCB Application Interrupt and Reset Control Register Definitions */
#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
/* SCB System Control Register Definitions */
#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
/* SCB Configuration Control Register Definitions */
#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
/* SCB System Handler Control and State Register Definitions */
#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
/*@} end of group CMSIS_SCB */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
\brief Type definitions for the System Timer Registers.
@{
*/
/**
\brief Structure type to access the System Timer (SysTick).
*/
typedef struct
{
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
} SysTick_Type;
/* SysTick Control / Status Register Definitions */
#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
/* SysTick Reload Register Definitions */
#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
/* SysTick Current Register Definitions */
#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
/* SysTick Calibration Register Definitions */
#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
/*@} end of group CMSIS_SysTick */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
\brief Cortex-M0 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
Therefore they are not covered by the Cortex-M0 header file.
@{
*/
/*@} end of group CMSIS_CoreDebug */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_core_bitfield Core register bit field macros
\brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
@{
*/
/**
\brief Mask and shift a bit field value for use in a register bit range.
\param[in] field Name of the register bit field.
\param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
\return Masked and shifted value.
*/
#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
/**
\brief Mask and shift a register value to extract a bit filed value.
\param[in] field Name of the register bit field.
\param[in] value Value of register. This parameter is interpreted as an uint32_t type.
\return Masked and shifted bit field value.
*/
#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
/*@} end of group CMSIS_core_bitfield */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_core_base Core Definitions
\brief Definitions for base addresses, unions, and structures.
@{
*/
/* Memory mapping of Core Hardware */
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
/*@} */
/*******************************************************************************
* Hardware Abstraction Layer
Core Function Interface contains:
- Core NVIC Functions
- Core SysTick Functions
- Core Register Access Functions
******************************************************************************/
/**
\defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
*/
/* ########################## NVIC functions #################################### */
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
\brief Functions that manage interrupts and exceptions via the NVIC.
@{
*/
#ifdef CMSIS_NVIC_VIRTUAL
#ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
#define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
#endif
#include CMSIS_NVIC_VIRTUAL_HEADER_FILE
#else
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
#define NVIC_EnableIRQ __NVIC_EnableIRQ
#define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ
#define NVIC_DisableIRQ __NVIC_DisableIRQ
#define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
#define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
#define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M0 */
#define NVIC_SetPriority __NVIC_SetPriority
#define NVIC_GetPriority __NVIC_GetPriority
#define NVIC_SystemReset __NVIC_SystemReset
#endif /* CMSIS_NVIC_VIRTUAL */
#ifdef CMSIS_VECTAB_VIRTUAL
#ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
#define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
#endif
#include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
#else
#define NVIC_SetVector __NVIC_SetVector
#define NVIC_GetVector __NVIC_GetVector
#endif /* (CMSIS_VECTAB_VIRTUAL) */
#define NVIC_USER_IRQ_OFFSET 16
/* The following EXC_RETURN values are saved the LR on exception entry */
#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */
#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */
#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */
/* Interrupt Priorities are WORD accessible only under Armv6-M */
/* The following MACROS handle generation of the register offset and byte masks */
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
#define __NVIC_SetPriorityGrouping(X) (void)(X)
#define __NVIC_GetPriorityGrouping() (0U)
/**
\brief Enable Interrupt
\details Enables a device specific interrupt in the NVIC interrupt controller.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
__COMPILER_BARRIER();
NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
__COMPILER_BARRIER();
}
}
/**
\brief Get Interrupt Enable status
\details Returns a device specific interrupt enable status from the NVIC interrupt controller.
\param [in] IRQn Device specific interrupt number.
\return 0 Interrupt is not enabled.
\return 1 Interrupt is enabled.
\note IRQn must not be negative.
*/
__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
}
else
{
return(0U);
}
}
/**
\brief Disable Interrupt
\details Disables a device specific interrupt in the NVIC interrupt controller.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
__DSB();
__ISB();
}
}
/**
\brief Get Pending Interrupt
\details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
\param [in] IRQn Device specific interrupt number.
\return 0 Interrupt status is not pending.
\return 1 Interrupt status is pending.
\note IRQn must not be negative.
*/
__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
}
else
{
return(0U);
}
}
/**
\brief Set Pending Interrupt
\details Sets the pending bit of a device specific interrupt in the NVIC pending register.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
}
}
/**
\brief Clear Pending Interrupt
\details Clears the pending bit of a device specific interrupt in the NVIC pending register.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
}
}
/**
\brief Set Interrupt Priority
\details Sets the priority of a device specific interrupt or a processor exception.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\param [in] priority Priority to set.
\note The priority cannot be set for every processor exception.
*/
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
}
else
{
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
}
}
/**
\brief Get Interrupt Priority
\details Reads the priority of a device specific interrupt or a processor exception.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\return Interrupt Priority.
Value is aligned automatically to the implemented priority bits of the microcontroller.
*/
__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
}
else
{
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
}
}
/**
\brief Encode Priority
\details Encodes the priority for an interrupt with the given priority group,
preemptive priority value, and subpriority value.
In case of a conflict between priority grouping and available
priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
\param [in] PriorityGroup Used priority group.
\param [in] PreemptPriority Preemptive priority value (starting from 0).
\param [in] SubPriority Subpriority value (starting from 0).
\return Encoded priority. Value can be used in the function \ref NVIC_SetPriority().
*/
__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
{
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
uint32_t PreemptPriorityBits;
uint32_t SubPriorityBits;
PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
return (
((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) |
((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL)))
);
}
/**
\brief Decode Priority
\details Decodes an interrupt priority value with a given priority group to
preemptive priority value and subpriority value.
In case of a conflict between priority grouping and available
priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
\param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority().
\param [in] PriorityGroup Used priority group.
\param [out] pPreemptPriority Preemptive priority value (starting from 0).
\param [out] pSubPriority Subpriority value (starting from 0).
*/
__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
{
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
uint32_t PreemptPriorityBits;
uint32_t SubPriorityBits;
PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
*pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL);
*pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL);
}
/**
\brief Set Interrupt Vector
\details Sets an interrupt vector in SRAM based interrupt vector table.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
Address 0 must be mapped to SRAM.
\param [in] IRQn Interrupt number
\param [in] vector Address of interrupt handler function
*/
__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
{
uint32_t vectors = 0x0U;
(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4)) = vector;
/* ARM Application Note 321 states that the M0 does not require the architectural barrier */
}
/**
\brief Get Interrupt Vector
\details Reads an interrupt vector from interrupt vector table.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\return Address of interrupt handler function
*/
__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn)
{
uint32_t vectors = 0x0U;
return (uint32_t)(* (int *) (vectors + ((int32_t)IRQn + NVIC_USER_IRQ_OFFSET) * 4));
}
/**
\brief System Reset
\details Initiates a system reset request to reset the MCU.
*/
__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void)
{
__DSB(); /* Ensure all outstanding memory accesses included
buffered write are completed before reset */
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
SCB_AIRCR_SYSRESETREQ_Msk);
__DSB(); /* Ensure completion of memory access */
for(;;) /* wait until reset */
{
__NOP();
}
}
/*@} end of CMSIS_Core_NVICFunctions */
/* ########################## FPU functions #################################### */
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_FpuFunctions FPU Functions
\brief Function that provides FPU type.
@{
*/
/**
\brief get FPU type
\details returns the FPU type
\returns
- \b 0: No FPU
- \b 1: Single precision FPU
- \b 2: Double + Single precision FPU
*/
__STATIC_INLINE uint32_t SCB_GetFPUType(void)
{
return 0U; /* No FPU */
}
/*@} end of CMSIS_Core_FpuFunctions */
/* ################################## SysTick function ############################################ */
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
\brief Functions that configure the System.
@{
*/
#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
/**
\brief System Tick Configuration
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
Counter is in free running mode to generate periodic interrupts.
\param [in] ticks Number of ticks between two interrupts.
\return 0 Function succeeded.
\return 1 Function failed.
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
must contain a vendor-specific implementation of this function.
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
{
return (1UL); /* Reload value impossible */
}
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0UL); /* Function successful */
}
#endif
/*@} end of CMSIS_Core_SysTickFunctions */
#ifdef __cplusplus
}
#endif
#endif /* __CORE_CM0_H_DEPENDANT */
#endif /* __CMSIS_GENERIC */

File diff suppressed because it is too large Load Diff

View File

@ -1,979 +0,0 @@
/**************************************************************************//**
* @file core_cm1.h
* @brief CMSIS Cortex-M1 Core Peripheral Access Layer Header File
* @version V1.0.1
* @date 12. November 2018
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif
#ifndef __CORE_CM1_H_GENERIC
#define __CORE_CM1_H_GENERIC
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
\page CMSIS_MISRA_Exceptions MISRA-C:2004 Compliance Exceptions
CMSIS violates the following MISRA-C:2004 rules:
\li Required Rule 8.5, object/function definition in header file.<br>
Function definitions in header files are used to allow 'inlining'.
\li Required Rule 18.4, declaration of union type or object of union type: '{...}'.<br>
Unions are used for effective representation of core registers.
\li Advisory Rule 19.7, Function-like macro defined.<br>
Function-like macros are used to allow more efficient code.
*/
/*******************************************************************************
* CMSIS definitions
******************************************************************************/
/**
\ingroup Cortex_M1
@{
*/
#include "cmsis_version.h"
/* CMSIS CM1 definitions */
#define __CM1_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */
#define __CM1_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */
#define __CM1_CMSIS_VERSION ((__CM1_CMSIS_VERSION_MAIN << 16U) | \
__CM1_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */
#define __CORTEX_M (1U) /*!< Cortex-M Core */
/** __FPU_USED indicates whether an FPU is used or not.
This core does not support an FPU at all
*/
#define __FPU_USED 0U
#if defined ( __CC_ARM )
#if defined __TARGET_FPU_VFP
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
#if defined __ARM_FP
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __GNUC__ )
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __ICCARM__ )
#if defined __ARMVFP__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __TI_ARM__ )
#if defined __TI_VFP_SUPPORT__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __TASKING__ )
#if defined __FPU_VFP__
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#elif defined ( __CSMC__ )
#if ( __CSMC__ & 0x400U)
#error "Compiler generates FPU instructions for a device without an FPU (check __FPU_PRESENT)"
#endif
#endif
#include "cmsis_compiler.h" /* CMSIS compiler specific defines */
#ifdef __cplusplus
}
#endif
#endif /* __CORE_CM1_H_GENERIC */
#ifndef __CMSIS_GENERIC
#ifndef __CORE_CM1_H_DEPENDANT
#define __CORE_CM1_H_DEPENDANT
#ifdef __cplusplus
extern "C" {
#endif
/* check device defines and use defaults */
#if defined __CHECK_DEVICE_DEFINES
#ifndef __CM1_REV
#define __CM1_REV 0x0100U
#warning "__CM1_REV not defined in device header file; using default!"
#endif
#ifndef __NVIC_PRIO_BITS
#define __NVIC_PRIO_BITS 2U
#warning "__NVIC_PRIO_BITS not defined in device header file; using default!"
#endif
#ifndef __Vendor_SysTickConfig
#define __Vendor_SysTickConfig 0U
#warning "__Vendor_SysTickConfig not defined in device header file; using default!"
#endif
#endif
/* IO definitions (access restrictions to peripheral registers) */
/**
\defgroup CMSIS_glob_defs CMSIS Global Defines
<strong>IO Type Qualifiers</strong> are used
\li to specify the access to peripheral variables.
\li for automatic generation of peripheral register debug information.
*/
#ifdef __cplusplus
#define __I volatile /*!< Defines 'read only' permissions */
#else
#define __I volatile const /*!< Defines 'read only' permissions */
#endif
#define __O volatile /*!< Defines 'write only' permissions */
#define __IO volatile /*!< Defines 'read / write' permissions */
/* following defines should be used for structure members */
#define __IM volatile const /*! Defines 'read only' structure member permissions */
#define __OM volatile /*! Defines 'write only' structure member permissions */
#define __IOM volatile /*! Defines 'read / write' structure member permissions */
/*@} end of group Cortex_M1 */
/*******************************************************************************
* Register Abstraction
Core Register contain:
- Core Register
- Core NVIC Register
- Core SCB Register
- Core SysTick Register
******************************************************************************/
/**
\defgroup CMSIS_core_register Defines and Type Definitions
\brief Type definitions and defines for Cortex-M processor based devices.
*/
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_CORE Status and Control Registers
\brief Core Register type definitions.
@{
*/
/**
\brief Union type to access the Application Program Status Register (APSR).
*/
typedef union
{
struct
{
uint32_t _reserved0:28; /*!< bit: 0..27 Reserved */
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} APSR_Type;
/* APSR Register Definitions */
#define APSR_N_Pos 31U /*!< APSR: N Position */
#define APSR_N_Msk (1UL << APSR_N_Pos) /*!< APSR: N Mask */
#define APSR_Z_Pos 30U /*!< APSR: Z Position */
#define APSR_Z_Msk (1UL << APSR_Z_Pos) /*!< APSR: Z Mask */
#define APSR_C_Pos 29U /*!< APSR: C Position */
#define APSR_C_Msk (1UL << APSR_C_Pos) /*!< APSR: C Mask */
#define APSR_V_Pos 28U /*!< APSR: V Position */
#define APSR_V_Msk (1UL << APSR_V_Pos) /*!< APSR: V Mask */
/**
\brief Union type to access the Interrupt Program Status Register (IPSR).
*/
typedef union
{
struct
{
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
uint32_t _reserved0:23; /*!< bit: 9..31 Reserved */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} IPSR_Type;
/* IPSR Register Definitions */
#define IPSR_ISR_Pos 0U /*!< IPSR: ISR Position */
#define IPSR_ISR_Msk (0x1FFUL /*<< IPSR_ISR_Pos*/) /*!< IPSR: ISR Mask */
/**
\brief Union type to access the Special-Purpose Program Status Registers (xPSR).
*/
typedef union
{
struct
{
uint32_t ISR:9; /*!< bit: 0.. 8 Exception number */
uint32_t _reserved0:15; /*!< bit: 9..23 Reserved */
uint32_t T:1; /*!< bit: 24 Thumb bit (read 0) */
uint32_t _reserved1:3; /*!< bit: 25..27 Reserved */
uint32_t V:1; /*!< bit: 28 Overflow condition code flag */
uint32_t C:1; /*!< bit: 29 Carry condition code flag */
uint32_t Z:1; /*!< bit: 30 Zero condition code flag */
uint32_t N:1; /*!< bit: 31 Negative condition code flag */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} xPSR_Type;
/* xPSR Register Definitions */
#define xPSR_N_Pos 31U /*!< xPSR: N Position */
#define xPSR_N_Msk (1UL << xPSR_N_Pos) /*!< xPSR: N Mask */
#define xPSR_Z_Pos 30U /*!< xPSR: Z Position */
#define xPSR_Z_Msk (1UL << xPSR_Z_Pos) /*!< xPSR: Z Mask */
#define xPSR_C_Pos 29U /*!< xPSR: C Position */
#define xPSR_C_Msk (1UL << xPSR_C_Pos) /*!< xPSR: C Mask */
#define xPSR_V_Pos 28U /*!< xPSR: V Position */
#define xPSR_V_Msk (1UL << xPSR_V_Pos) /*!< xPSR: V Mask */
#define xPSR_T_Pos 24U /*!< xPSR: T Position */
#define xPSR_T_Msk (1UL << xPSR_T_Pos) /*!< xPSR: T Mask */
#define xPSR_ISR_Pos 0U /*!< xPSR: ISR Position */
#define xPSR_ISR_Msk (0x1FFUL /*<< xPSR_ISR_Pos*/) /*!< xPSR: ISR Mask */
/**
\brief Union type to access the Control Registers (CONTROL).
*/
typedef union
{
struct
{
uint32_t _reserved0:1; /*!< bit: 0 Reserved */
uint32_t SPSEL:1; /*!< bit: 1 Stack to be used */
uint32_t _reserved1:30; /*!< bit: 2..31 Reserved */
} b; /*!< Structure used for bit access */
uint32_t w; /*!< Type used for word access */
} CONTROL_Type;
/* CONTROL Register Definitions */
#define CONTROL_SPSEL_Pos 1U /*!< CONTROL: SPSEL Position */
#define CONTROL_SPSEL_Msk (1UL << CONTROL_SPSEL_Pos) /*!< CONTROL: SPSEL Mask */
/*@} end of group CMSIS_CORE */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_NVIC Nested Vectored Interrupt Controller (NVIC)
\brief Type definitions for the NVIC Registers
@{
*/
/**
\brief Structure type to access the Nested Vectored Interrupt Controller (NVIC).
*/
typedef struct
{
__IOM uint32_t ISER[1U]; /*!< Offset: 0x000 (R/W) Interrupt Set Enable Register */
uint32_t RESERVED0[31U];
__IOM uint32_t ICER[1U]; /*!< Offset: 0x080 (R/W) Interrupt Clear Enable Register */
uint32_t RSERVED1[31U];
__IOM uint32_t ISPR[1U]; /*!< Offset: 0x100 (R/W) Interrupt Set Pending Register */
uint32_t RESERVED2[31U];
__IOM uint32_t ICPR[1U]; /*!< Offset: 0x180 (R/W) Interrupt Clear Pending Register */
uint32_t RESERVED3[31U];
uint32_t RESERVED4[64U];
__IOM uint32_t IP[8U]; /*!< Offset: 0x300 (R/W) Interrupt Priority Register */
} NVIC_Type;
/*@} end of group CMSIS_NVIC */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_SCB System Control Block (SCB)
\brief Type definitions for the System Control Block Registers
@{
*/
/**
\brief Structure type to access the System Control Block (SCB).
*/
typedef struct
{
__IM uint32_t CPUID; /*!< Offset: 0x000 (R/ ) CPUID Base Register */
__IOM uint32_t ICSR; /*!< Offset: 0x004 (R/W) Interrupt Control and State Register */
uint32_t RESERVED0;
__IOM uint32_t AIRCR; /*!< Offset: 0x00C (R/W) Application Interrupt and Reset Control Register */
__IOM uint32_t SCR; /*!< Offset: 0x010 (R/W) System Control Register */
__IOM uint32_t CCR; /*!< Offset: 0x014 (R/W) Configuration Control Register */
uint32_t RESERVED1;
__IOM uint32_t SHP[2U]; /*!< Offset: 0x01C (R/W) System Handlers Priority Registers. [0] is RESERVED */
__IOM uint32_t SHCSR; /*!< Offset: 0x024 (R/W) System Handler Control and State Register */
} SCB_Type;
/* SCB CPUID Register Definitions */
#define SCB_CPUID_IMPLEMENTER_Pos 24U /*!< SCB CPUID: IMPLEMENTER Position */
#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL << SCB_CPUID_IMPLEMENTER_Pos) /*!< SCB CPUID: IMPLEMENTER Mask */
#define SCB_CPUID_VARIANT_Pos 20U /*!< SCB CPUID: VARIANT Position */
#define SCB_CPUID_VARIANT_Msk (0xFUL << SCB_CPUID_VARIANT_Pos) /*!< SCB CPUID: VARIANT Mask */
#define SCB_CPUID_ARCHITECTURE_Pos 16U /*!< SCB CPUID: ARCHITECTURE Position */
#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL << SCB_CPUID_ARCHITECTURE_Pos) /*!< SCB CPUID: ARCHITECTURE Mask */
#define SCB_CPUID_PARTNO_Pos 4U /*!< SCB CPUID: PARTNO Position */
#define SCB_CPUID_PARTNO_Msk (0xFFFUL << SCB_CPUID_PARTNO_Pos) /*!< SCB CPUID: PARTNO Mask */
#define SCB_CPUID_REVISION_Pos 0U /*!< SCB CPUID: REVISION Position */
#define SCB_CPUID_REVISION_Msk (0xFUL /*<< SCB_CPUID_REVISION_Pos*/) /*!< SCB CPUID: REVISION Mask */
/* SCB Interrupt Control State Register Definitions */
#define SCB_ICSR_NMIPENDSET_Pos 31U /*!< SCB ICSR: NMIPENDSET Position */
#define SCB_ICSR_NMIPENDSET_Msk (1UL << SCB_ICSR_NMIPENDSET_Pos) /*!< SCB ICSR: NMIPENDSET Mask */
#define SCB_ICSR_PENDSVSET_Pos 28U /*!< SCB ICSR: PENDSVSET Position */
#define SCB_ICSR_PENDSVSET_Msk (1UL << SCB_ICSR_PENDSVSET_Pos) /*!< SCB ICSR: PENDSVSET Mask */
#define SCB_ICSR_PENDSVCLR_Pos 27U /*!< SCB ICSR: PENDSVCLR Position */
#define SCB_ICSR_PENDSVCLR_Msk (1UL << SCB_ICSR_PENDSVCLR_Pos) /*!< SCB ICSR: PENDSVCLR Mask */
#define SCB_ICSR_PENDSTSET_Pos 26U /*!< SCB ICSR: PENDSTSET Position */
#define SCB_ICSR_PENDSTSET_Msk (1UL << SCB_ICSR_PENDSTSET_Pos) /*!< SCB ICSR: PENDSTSET Mask */
#define SCB_ICSR_PENDSTCLR_Pos 25U /*!< SCB ICSR: PENDSTCLR Position */
#define SCB_ICSR_PENDSTCLR_Msk (1UL << SCB_ICSR_PENDSTCLR_Pos) /*!< SCB ICSR: PENDSTCLR Mask */
#define SCB_ICSR_ISRPREEMPT_Pos 23U /*!< SCB ICSR: ISRPREEMPT Position */
#define SCB_ICSR_ISRPREEMPT_Msk (1UL << SCB_ICSR_ISRPREEMPT_Pos) /*!< SCB ICSR: ISRPREEMPT Mask */
#define SCB_ICSR_ISRPENDING_Pos 22U /*!< SCB ICSR: ISRPENDING Position */
#define SCB_ICSR_ISRPENDING_Msk (1UL << SCB_ICSR_ISRPENDING_Pos) /*!< SCB ICSR: ISRPENDING Mask */
#define SCB_ICSR_VECTPENDING_Pos 12U /*!< SCB ICSR: VECTPENDING Position */
#define SCB_ICSR_VECTPENDING_Msk (0x1FFUL << SCB_ICSR_VECTPENDING_Pos) /*!< SCB ICSR: VECTPENDING Mask */
#define SCB_ICSR_VECTACTIVE_Pos 0U /*!< SCB ICSR: VECTACTIVE Position */
#define SCB_ICSR_VECTACTIVE_Msk (0x1FFUL /*<< SCB_ICSR_VECTACTIVE_Pos*/) /*!< SCB ICSR: VECTACTIVE Mask */
/* SCB Application Interrupt and Reset Control Register Definitions */
#define SCB_AIRCR_VECTKEY_Pos 16U /*!< SCB AIRCR: VECTKEY Position */
#define SCB_AIRCR_VECTKEY_Msk (0xFFFFUL << SCB_AIRCR_VECTKEY_Pos) /*!< SCB AIRCR: VECTKEY Mask */
#define SCB_AIRCR_VECTKEYSTAT_Pos 16U /*!< SCB AIRCR: VECTKEYSTAT Position */
#define SCB_AIRCR_VECTKEYSTAT_Msk (0xFFFFUL << SCB_AIRCR_VECTKEYSTAT_Pos) /*!< SCB AIRCR: VECTKEYSTAT Mask */
#define SCB_AIRCR_ENDIANESS_Pos 15U /*!< SCB AIRCR: ENDIANESS Position */
#define SCB_AIRCR_ENDIANESS_Msk (1UL << SCB_AIRCR_ENDIANESS_Pos) /*!< SCB AIRCR: ENDIANESS Mask */
#define SCB_AIRCR_SYSRESETREQ_Pos 2U /*!< SCB AIRCR: SYSRESETREQ Position */
#define SCB_AIRCR_SYSRESETREQ_Msk (1UL << SCB_AIRCR_SYSRESETREQ_Pos) /*!< SCB AIRCR: SYSRESETREQ Mask */
#define SCB_AIRCR_VECTCLRACTIVE_Pos 1U /*!< SCB AIRCR: VECTCLRACTIVE Position */
#define SCB_AIRCR_VECTCLRACTIVE_Msk (1UL << SCB_AIRCR_VECTCLRACTIVE_Pos) /*!< SCB AIRCR: VECTCLRACTIVE Mask */
/* SCB System Control Register Definitions */
#define SCB_SCR_SEVONPEND_Pos 4U /*!< SCB SCR: SEVONPEND Position */
#define SCB_SCR_SEVONPEND_Msk (1UL << SCB_SCR_SEVONPEND_Pos) /*!< SCB SCR: SEVONPEND Mask */
#define SCB_SCR_SLEEPDEEP_Pos 2U /*!< SCB SCR: SLEEPDEEP Position */
#define SCB_SCR_SLEEPDEEP_Msk (1UL << SCB_SCR_SLEEPDEEP_Pos) /*!< SCB SCR: SLEEPDEEP Mask */
#define SCB_SCR_SLEEPONEXIT_Pos 1U /*!< SCB SCR: SLEEPONEXIT Position */
#define SCB_SCR_SLEEPONEXIT_Msk (1UL << SCB_SCR_SLEEPONEXIT_Pos) /*!< SCB SCR: SLEEPONEXIT Mask */
/* SCB Configuration Control Register Definitions */
#define SCB_CCR_STKALIGN_Pos 9U /*!< SCB CCR: STKALIGN Position */
#define SCB_CCR_STKALIGN_Msk (1UL << SCB_CCR_STKALIGN_Pos) /*!< SCB CCR: STKALIGN Mask */
#define SCB_CCR_UNALIGN_TRP_Pos 3U /*!< SCB CCR: UNALIGN_TRP Position */
#define SCB_CCR_UNALIGN_TRP_Msk (1UL << SCB_CCR_UNALIGN_TRP_Pos) /*!< SCB CCR: UNALIGN_TRP Mask */
/* SCB System Handler Control and State Register Definitions */
#define SCB_SHCSR_SVCALLPENDED_Pos 15U /*!< SCB SHCSR: SVCALLPENDED Position */
#define SCB_SHCSR_SVCALLPENDED_Msk (1UL << SCB_SHCSR_SVCALLPENDED_Pos) /*!< SCB SHCSR: SVCALLPENDED Mask */
/*@} end of group CMSIS_SCB */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_SCnSCB System Controls not in SCB (SCnSCB)
\brief Type definitions for the System Control and ID Register not in the SCB
@{
*/
/**
\brief Structure type to access the System Control and ID Register not in the SCB.
*/
typedef struct
{
uint32_t RESERVED0[2U];
__IOM uint32_t ACTLR; /*!< Offset: 0x008 (R/W) Auxiliary Control Register */
} SCnSCB_Type;
/* Auxiliary Control Register Definitions */
#define SCnSCB_ACTLR_ITCMUAEN_Pos 4U /*!< ACTLR: Instruction TCM Upper Alias Enable Position */
#define SCnSCB_ACTLR_ITCMUAEN_Msk (1UL << SCnSCB_ACTLR_ITCMUAEN_Pos) /*!< ACTLR: Instruction TCM Upper Alias Enable Mask */
#define SCnSCB_ACTLR_ITCMLAEN_Pos 3U /*!< ACTLR: Instruction TCM Lower Alias Enable Position */
#define SCnSCB_ACTLR_ITCMLAEN_Msk (1UL << SCnSCB_ACTLR_ITCMLAEN_Pos) /*!< ACTLR: Instruction TCM Lower Alias Enable Mask */
/*@} end of group CMSIS_SCnotSCB */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_SysTick System Tick Timer (SysTick)
\brief Type definitions for the System Timer Registers.
@{
*/
/**
\brief Structure type to access the System Timer (SysTick).
*/
typedef struct
{
__IOM uint32_t CTRL; /*!< Offset: 0x000 (R/W) SysTick Control and Status Register */
__IOM uint32_t LOAD; /*!< Offset: 0x004 (R/W) SysTick Reload Value Register */
__IOM uint32_t VAL; /*!< Offset: 0x008 (R/W) SysTick Current Value Register */
__IM uint32_t CALIB; /*!< Offset: 0x00C (R/ ) SysTick Calibration Register */
} SysTick_Type;
/* SysTick Control / Status Register Definitions */
#define SysTick_CTRL_COUNTFLAG_Pos 16U /*!< SysTick CTRL: COUNTFLAG Position */
#define SysTick_CTRL_COUNTFLAG_Msk (1UL << SysTick_CTRL_COUNTFLAG_Pos) /*!< SysTick CTRL: COUNTFLAG Mask */
#define SysTick_CTRL_CLKSOURCE_Pos 2U /*!< SysTick CTRL: CLKSOURCE Position */
#define SysTick_CTRL_CLKSOURCE_Msk (1UL << SysTick_CTRL_CLKSOURCE_Pos) /*!< SysTick CTRL: CLKSOURCE Mask */
#define SysTick_CTRL_TICKINT_Pos 1U /*!< SysTick CTRL: TICKINT Position */
#define SysTick_CTRL_TICKINT_Msk (1UL << SysTick_CTRL_TICKINT_Pos) /*!< SysTick CTRL: TICKINT Mask */
#define SysTick_CTRL_ENABLE_Pos 0U /*!< SysTick CTRL: ENABLE Position */
#define SysTick_CTRL_ENABLE_Msk (1UL /*<< SysTick_CTRL_ENABLE_Pos*/) /*!< SysTick CTRL: ENABLE Mask */
/* SysTick Reload Register Definitions */
#define SysTick_LOAD_RELOAD_Pos 0U /*!< SysTick LOAD: RELOAD Position */
#define SysTick_LOAD_RELOAD_Msk (0xFFFFFFUL /*<< SysTick_LOAD_RELOAD_Pos*/) /*!< SysTick LOAD: RELOAD Mask */
/* SysTick Current Register Definitions */
#define SysTick_VAL_CURRENT_Pos 0U /*!< SysTick VAL: CURRENT Position */
#define SysTick_VAL_CURRENT_Msk (0xFFFFFFUL /*<< SysTick_VAL_CURRENT_Pos*/) /*!< SysTick VAL: CURRENT Mask */
/* SysTick Calibration Register Definitions */
#define SysTick_CALIB_NOREF_Pos 31U /*!< SysTick CALIB: NOREF Position */
#define SysTick_CALIB_NOREF_Msk (1UL << SysTick_CALIB_NOREF_Pos) /*!< SysTick CALIB: NOREF Mask */
#define SysTick_CALIB_SKEW_Pos 30U /*!< SysTick CALIB: SKEW Position */
#define SysTick_CALIB_SKEW_Msk (1UL << SysTick_CALIB_SKEW_Pos) /*!< SysTick CALIB: SKEW Mask */
#define SysTick_CALIB_TENMS_Pos 0U /*!< SysTick CALIB: TENMS Position */
#define SysTick_CALIB_TENMS_Msk (0xFFFFFFUL /*<< SysTick_CALIB_TENMS_Pos*/) /*!< SysTick CALIB: TENMS Mask */
/*@} end of group CMSIS_SysTick */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_CoreDebug Core Debug Registers (CoreDebug)
\brief Cortex-M1 Core Debug Registers (DCB registers, SHCSR, and DFSR) are only accessible over DAP and not via processor.
Therefore they are not covered by the Cortex-M1 header file.
@{
*/
/*@} end of group CMSIS_CoreDebug */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_core_bitfield Core register bit field macros
\brief Macros for use with bit field definitions (xxx_Pos, xxx_Msk).
@{
*/
/**
\brief Mask and shift a bit field value for use in a register bit range.
\param[in] field Name of the register bit field.
\param[in] value Value of the bit field. This parameter is interpreted as an uint32_t type.
\return Masked and shifted value.
*/
#define _VAL2FLD(field, value) (((uint32_t)(value) << field ## _Pos) & field ## _Msk)
/**
\brief Mask and shift a register value to extract a bit filed value.
\param[in] field Name of the register bit field.
\param[in] value Value of register. This parameter is interpreted as an uint32_t type.
\return Masked and shifted bit field value.
*/
#define _FLD2VAL(field, value) (((uint32_t)(value) & field ## _Msk) >> field ## _Pos)
/*@} end of group CMSIS_core_bitfield */
/**
\ingroup CMSIS_core_register
\defgroup CMSIS_core_base Core Definitions
\brief Definitions for base addresses, unions, and structures.
@{
*/
/* Memory mapping of Core Hardware */
#define SCS_BASE (0xE000E000UL) /*!< System Control Space Base Address */
#define SysTick_BASE (SCS_BASE + 0x0010UL) /*!< SysTick Base Address */
#define NVIC_BASE (SCS_BASE + 0x0100UL) /*!< NVIC Base Address */
#define SCB_BASE (SCS_BASE + 0x0D00UL) /*!< System Control Block Base Address */
#define SCnSCB ((SCnSCB_Type *) SCS_BASE ) /*!< System control Register not in SCB */
#define SCB ((SCB_Type *) SCB_BASE ) /*!< SCB configuration struct */
#define SysTick ((SysTick_Type *) SysTick_BASE ) /*!< SysTick configuration struct */
#define NVIC ((NVIC_Type *) NVIC_BASE ) /*!< NVIC configuration struct */
/*@} */
/*******************************************************************************
* Hardware Abstraction Layer
Core Function Interface contains:
- Core NVIC Functions
- Core SysTick Functions
- Core Register Access Functions
******************************************************************************/
/**
\defgroup CMSIS_Core_FunctionInterface Functions and Instructions Reference
*/
/* ########################## NVIC functions #################################### */
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_NVICFunctions NVIC Functions
\brief Functions that manage interrupts and exceptions via the NVIC.
@{
*/
#ifdef CMSIS_NVIC_VIRTUAL
#ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
#define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
#endif
#include CMSIS_NVIC_VIRTUAL_HEADER_FILE
#else
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
#define NVIC_EnableIRQ __NVIC_EnableIRQ
#define NVIC_GetEnableIRQ __NVIC_GetEnableIRQ
#define NVIC_DisableIRQ __NVIC_DisableIRQ
#define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
#define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
#define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
/*#define NVIC_GetActive __NVIC_GetActive not available for Cortex-M1 */
#define NVIC_SetPriority __NVIC_SetPriority
#define NVIC_GetPriority __NVIC_GetPriority
#define NVIC_SystemReset __NVIC_SystemReset
#endif /* CMSIS_NVIC_VIRTUAL */
#ifdef CMSIS_VECTAB_VIRTUAL
#ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
#define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
#endif
#include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
#else
#define NVIC_SetVector __NVIC_SetVector
#define NVIC_GetVector __NVIC_GetVector
#endif /* (CMSIS_VECTAB_VIRTUAL) */
#define NVIC_USER_IRQ_OFFSET 16
/* The following EXC_RETURN values are saved the LR on exception entry */
#define EXC_RETURN_HANDLER (0xFFFFFFF1UL) /* return to Handler mode, uses MSP after return */
#define EXC_RETURN_THREAD_MSP (0xFFFFFFF9UL) /* return to Thread mode, uses MSP after return */
#define EXC_RETURN_THREAD_PSP (0xFFFFFFFDUL) /* return to Thread mode, uses PSP after return */
/* Interrupt Priorities are WORD accessible only under Armv6-M */
/* The following MACROS handle generation of the register offset and byte masks */
#define _BIT_SHIFT(IRQn) ( ((((uint32_t)(int32_t)(IRQn)) ) & 0x03UL) * 8UL)
#define _SHP_IDX(IRQn) ( (((((uint32_t)(int32_t)(IRQn)) & 0x0FUL)-8UL) >> 2UL) )
#define _IP_IDX(IRQn) ( (((uint32_t)(int32_t)(IRQn)) >> 2UL) )
#define __NVIC_SetPriorityGrouping(X) (void)(X)
#define __NVIC_GetPriorityGrouping() (0U)
/**
\brief Enable Interrupt
\details Enables a device specific interrupt in the NVIC interrupt controller.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
__COMPILER_BARRIER();
NVIC->ISER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
__COMPILER_BARRIER();
}
}
/**
\brief Get Interrupt Enable status
\details Returns a device specific interrupt enable status from the NVIC interrupt controller.
\param [in] IRQn Device specific interrupt number.
\return 0 Interrupt is not enabled.
\return 1 Interrupt is enabled.
\note IRQn must not be negative.
*/
__STATIC_INLINE uint32_t __NVIC_GetEnableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
return((uint32_t)(((NVIC->ISER[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
}
else
{
return(0U);
}
}
/**
\brief Disable Interrupt
\details Disables a device specific interrupt in the NVIC interrupt controller.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICER[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
__DSB();
__ISB();
}
}
/**
\brief Get Pending Interrupt
\details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
\param [in] IRQn Device specific interrupt number.
\return 0 Interrupt status is not pending.
\return 1 Interrupt status is pending.
\note IRQn must not be negative.
*/
__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
return((uint32_t)(((NVIC->ISPR[0U] & (1UL << (((uint32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
}
else
{
return(0U);
}
}
/**
\brief Set Pending Interrupt
\details Sets the pending bit of a device specific interrupt in the NVIC pending register.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ISPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
}
}
/**
\brief Clear Pending Interrupt
\details Clears the pending bit of a device specific interrupt in the NVIC pending register.
\param [in] IRQn Device specific interrupt number.
\note IRQn must not be negative.
*/
__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->ICPR[0U] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
}
}
/**
\brief Set Interrupt Priority
\details Sets the priority of a device specific interrupt or a processor exception.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\param [in] priority Priority to set.
\note The priority cannot be set for every processor exception.
*/
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
{
if ((int32_t)(IRQn) >= 0)
{
NVIC->IP[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IP[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
}
else
{
SCB->SHP[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHP[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
}
}
/**
\brief Get Interrupt Priority
\details Reads the priority of a device specific interrupt or a processor exception.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\return Interrupt Priority.
Value is aligned automatically to the implemented priority bits of the microcontroller.
*/
__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
{
if ((int32_t)(IRQn) >= 0)
{
return((uint32_t)(((NVIC->IP[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
}
else
{
return((uint32_t)(((SCB->SHP[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
}
}
/**
\brief Encode Priority
\details Encodes the priority for an interrupt with the given priority group,
preemptive priority value, and subpriority value.
In case of a conflict between priority grouping and available
priority bits (__NVIC_PRIO_BITS), the smallest possible priority group is set.
\param [in] PriorityGroup Used priority group.
\param [in] PreemptPriority Preemptive priority value (starting from 0).
\param [in] SubPriority Subpriority value (starting from 0).
\return Encoded priority. Value can be used in the function \ref NVIC_SetPriority().
*/
__STATIC_INLINE uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority)
{
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
uint32_t PreemptPriorityBits;
uint32_t SubPriorityBits;
PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
return (
((PreemptPriority & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL)) << SubPriorityBits) |
((SubPriority & (uint32_t)((1UL << (SubPriorityBits )) - 1UL)))
);
}
/**
\brief Decode Priority
\details Decodes an interrupt priority value with a given priority group to
preemptive priority value and subpriority value.
In case of a conflict between priority grouping and available
priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
\param [in] Priority Priority value, which can be retrieved with the function \ref NVIC_GetPriority().
\param [in] PriorityGroup Used priority group.
\param [out] pPreemptPriority Preemptive priority value (starting from 0).
\param [out] pSubPriority Subpriority value (starting from 0).
*/
__STATIC_INLINE void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* const pPreemptPriority, uint32_t* const pSubPriority)
{
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
uint32_t PreemptPriorityBits;
uint32_t SubPriorityBits;
PreemptPriorityBits = ((7UL - PriorityGroupTmp) > (uint32_t)(__NVIC_PRIO_BITS)) ? (uint32_t)(__NVIC_PRIO_BITS) : (uint32_t)(7UL - PriorityGroupTmp);
SubPriorityBits = ((PriorityGroupTmp + (uint32_t)(__NVIC_PRIO_BITS)) < (uint32_t)7UL) ? (uint32_t)0UL : (uint32_t)((PriorityGroupTmp - 7UL) + (uint32_t)(__NVIC_PRIO_BITS));
*pPreemptPriority = (Priority >> SubPriorityBits) & (uint32_t)((1UL << (PreemptPriorityBits)) - 1UL);
*pSubPriority = (Priority ) & (uint32_t)((1UL << (SubPriorityBits )) - 1UL);
}
/**
\brief Set Interrupt Vector
\details Sets an interrupt vector in SRAM based interrupt vector table.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
Address 0 must be mapped to SRAM.
\param [in] IRQn Interrupt number
\param [in] vector Address of interrupt handler function
*/
__STATIC_INLINE void __NVIC_SetVector(IRQn_Type IRQn, uint32_t vector)
{
uint32_t *vectors = (uint32_t *)0x0U;
vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET] = vector;
/* ARM Application Note 321 states that the M1 does not require the architectural barrier */
}
/**
\brief Get Interrupt Vector
\details Reads an interrupt vector from interrupt vector table.
The interrupt number can be positive to specify a device specific interrupt,
or negative to specify a processor exception.
\param [in] IRQn Interrupt number.
\return Address of interrupt handler function
*/
__STATIC_INLINE uint32_t __NVIC_GetVector(IRQn_Type IRQn)
{
uint32_t *vectors = (uint32_t *)0x0U;
return vectors[(int32_t)IRQn + NVIC_USER_IRQ_OFFSET];
}
/**
\brief System Reset
\details Initiates a system reset request to reset the MCU.
*/
__NO_RETURN __STATIC_INLINE void __NVIC_SystemReset(void)
{
__DSB(); /* Ensure all outstanding memory accesses included
buffered write are completed before reset */
SCB->AIRCR = ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
SCB_AIRCR_SYSRESETREQ_Msk);
__DSB(); /* Ensure completion of memory access */
for(;;) /* wait until reset */
{
__NOP();
}
}
/*@} end of CMSIS_Core_NVICFunctions */
/* ########################## FPU functions #################################### */
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_FpuFunctions FPU Functions
\brief Function that provides FPU type.
@{
*/
/**
\brief get FPU type
\details returns the FPU type
\returns
- \b 0: No FPU
- \b 1: Single precision FPU
- \b 2: Double + Single precision FPU
*/
__STATIC_INLINE uint32_t SCB_GetFPUType(void)
{
return 0U; /* No FPU */
}
/*@} end of CMSIS_Core_FpuFunctions */
/* ################################## SysTick function ############################################ */
/**
\ingroup CMSIS_Core_FunctionInterface
\defgroup CMSIS_Core_SysTickFunctions SysTick Functions
\brief Functions that configure the System.
@{
*/
#if defined (__Vendor_SysTickConfig) && (__Vendor_SysTickConfig == 0U)
/**
\brief System Tick Configuration
\details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
Counter is in free running mode to generate periodic interrupts.
\param [in] ticks Number of ticks between two interrupts.
\return 0 Function succeeded.
\return 1 Function failed.
\note When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
must contain a vendor-specific implementation of this function.
*/
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
{
return (1UL); /* Reload value impossible */
}
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0UL); /* Function successful */
}
#endif
/*@} end of CMSIS_Core_SysTickFunctions */
#ifdef __cplusplus
}
#endif
#endif /* __CORE_CM1_H_DEPENDANT */
#endif /* __CMSIS_GENERIC */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More