├── .gitmodules
├── README.md
├── hardware
├── mount_3d_data
│ └── robomaster_s1_plate.step
└── robomasters1_bom.xlsx
├── robomasters1_reference_design.pdf
└── software
└── opencr_firmware
└── RoboMaster_S1_Reference_Design
├── .cproject
├── .mxproject
├── .project
├── .settings
└── language.settings.xml
├── Core
├── Inc
│ ├── command_list.csv
│ ├── main.h
│ ├── robomaster_s1.h
│ ├── robomaster_s1_crc.h
│ ├── stm32f7xx_hal_conf.h
│ └── stm32f7xx_it.h
├── Src
│ ├── main.c
│ ├── robomaster_s1_parser.c
│ ├── stm32f7xx_hal_msp.c
│ ├── stm32f7xx_hal_timebase_tim.c
│ ├── stm32f7xx_it.c
│ ├── syscalls.c
│ ├── sysmem.c
│ └── system_stm32f7xx.c
└── Startup
│ └── startup_stm32f746zgtx.s
├── Drivers
├── CMSIS
│ ├── Device
│ │ └── ST
│ │ │ └── STM32F7xx
│ │ │ └── Include
│ │ │ ├── stm32f746xx.h
│ │ │ ├── stm32f7xx.h
│ │ │ └── system_stm32f7xx.h
│ └── Include
│ │ ├── cmsis_armcc.h
│ │ ├── cmsis_armclang.h
│ │ ├── cmsis_compiler.h
│ │ ├── cmsis_gcc.h
│ │ ├── cmsis_iccarm.h
│ │ ├── cmsis_version.h
│ │ ├── core_armv8mbl.h
│ │ ├── core_armv8mml.h
│ │ ├── core_cm0.h
│ │ ├── core_cm0plus.h
│ │ ├── core_cm1.h
│ │ ├── core_cm23.h
│ │ ├── core_cm3.h
│ │ ├── core_cm33.h
│ │ ├── core_cm4.h
│ │ ├── core_cm7.h
│ │ ├── core_sc000.h
│ │ ├── core_sc300.h
│ │ ├── mpu_armv7.h
│ │ ├── mpu_armv8.h
│ │ └── tz_context.h
└── STM32F7xx_HAL_Driver
│ ├── Inc
│ ├── Legacy
│ │ └── stm32_hal_legacy.h
│ ├── stm32f7xx_hal.h
│ ├── stm32f7xx_hal_can.h
│ ├── stm32f7xx_hal_cortex.h
│ ├── stm32f7xx_hal_def.h
│ ├── stm32f7xx_hal_dma.h
│ ├── stm32f7xx_hal_dma_ex.h
│ ├── stm32f7xx_hal_exti.h
│ ├── stm32f7xx_hal_flash.h
│ ├── stm32f7xx_hal_flash_ex.h
│ ├── stm32f7xx_hal_gpio.h
│ ├── stm32f7xx_hal_gpio_ex.h
│ ├── stm32f7xx_hal_i2c.h
│ ├── stm32f7xx_hal_i2c_ex.h
│ ├── stm32f7xx_hal_pcd.h
│ ├── stm32f7xx_hal_pcd_ex.h
│ ├── stm32f7xx_hal_pwr.h
│ ├── stm32f7xx_hal_pwr_ex.h
│ ├── stm32f7xx_hal_rcc.h
│ ├── stm32f7xx_hal_rcc_ex.h
│ ├── stm32f7xx_hal_spi.h
│ ├── stm32f7xx_hal_spi_ex.h
│ ├── stm32f7xx_hal_tim.h
│ ├── stm32f7xx_hal_tim_ex.h
│ └── stm32f7xx_ll_usb.h
│ └── Src
│ ├── stm32f7xx_hal.c
│ ├── stm32f7xx_hal_can.c
│ ├── stm32f7xx_hal_cortex.c
│ ├── stm32f7xx_hal_dma.c
│ ├── stm32f7xx_hal_dma_ex.c
│ ├── stm32f7xx_hal_exti.c
│ ├── stm32f7xx_hal_flash.c
│ ├── stm32f7xx_hal_flash_ex.c
│ ├── stm32f7xx_hal_gpio.c
│ ├── stm32f7xx_hal_i2c.c
│ ├── stm32f7xx_hal_i2c_ex.c
│ ├── stm32f7xx_hal_pcd.c
│ ├── stm32f7xx_hal_pcd_ex.c
│ ├── stm32f7xx_hal_pwr.c
│ ├── stm32f7xx_hal_pwr_ex.c
│ ├── stm32f7xx_hal_rcc.c
│ ├── stm32f7xx_hal_rcc_ex.c
│ ├── stm32f7xx_hal_spi.c
│ ├── stm32f7xx_hal_spi_ex.c
│ ├── stm32f7xx_hal_tim.c
│ ├── stm32f7xx_hal_tim_ex.c
│ └── stm32f7xx_ll_usb.c
├── IMU
├── MPU9250.c
├── MPU9250.h
└── SPI.h
├── Middlewares
└── ST
│ └── STM32_USB_Device_Library
│ ├── Class
│ └── CDC
│ │ └── Inc
│ │ └── usbd_cdc.h
│ └── Core
│ ├── Inc
│ ├── usbd_core.h
│ ├── usbd_ctlreq.h
│ └── usbd_def.h
│ └── Src
│ ├── usbd_core.c
│ ├── usbd_ctlreq.c
│ └── usbd_ioreq.c
├── PROTOBUF
├── command.pb.c
├── command.pb.h
├── command.proto
├── pb.h
├── pb_common.c
├── pb_common.h
├── pb_decode.c
├── pb_decode.h
├── pb_encode.c
└── pb_encode.h
├── RoboMaster_S1_Reference_Design Debug.cfg
├── RoboMaster_S1_Reference_Design Debug.launch
├── RoboMaster_S1_Reference_Design.ioc
├── STM32F746ZGTX_FLASH.ld
├── STM32F746ZGTX_RAM.ld
└── USB_DEVICE
├── App
├── usb_device.c
├── usb_device.h
├── usbd_cdc_if.c
├── usbd_cdc_if.h
├── usbd_desc.c
└── usbd_desc.h
└── Target
├── usbd_conf.c
└── usbd_conf.h
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "software/opencr_firmware/RoboMaster_S1_Reference_Design/nanopb"]
2 | path = software/opencr_firmware/RoboMaster_S1_Reference_Design/nanopb
3 | url = https://github.com/nanopb/nanopb.git
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RoboMaster S1 ROS Platform
2 | Hardware and software reference design for RoboMaster S1 Challenge
3 |
--------------------------------------------------------------------------------
/hardware/robomasters1_bom.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoboMasterS1Challenge/robomaster_s1_ros_reference_design/7c646c677f02b34e6e1b435621a257e1364ce32b/hardware/robomasters1_bom.xlsx
--------------------------------------------------------------------------------
/robomasters1_reference_design.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoboMasterS1Challenge/robomaster_s1_ros_reference_design/7c646c677f02b34e6e1b435621a257e1364ce32b/robomasters1_reference_design.pdf
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/.mxproject:
--------------------------------------------------------------------------------
1 | [PreviousGenFiles]
2 | AdvancedFolderStructure=true
3 | HeaderFileListSize=3
4 | HeaderFiles#0=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc/stm32f7xx_it.h
5 | HeaderFiles#1=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc/stm32f7xx_hal_conf.h
6 | HeaderFiles#2=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc/main.h
7 | HeaderFolderListSize=1
8 | HeaderPath#0=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc
9 | SourceFileListSize=4
10 | SourceFiles#0=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_it.c
11 | SourceFiles#1=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_hal_msp.c
12 | SourceFiles#2=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_hal_timebase_tim.c
13 | SourceFolderListSize=1
14 | SourcePath#0=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src
15 | HeaderFiles#3=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/USB_DEVICE/App/usbd_cdc_if.h
16 | HeaderFiles#4=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc/stm32f7xx_it.h
17 | HeaderFiles#5=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc/stm32f7xx_hal_conf.h
18 | HeaderFiles#6=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc/main.h
19 | HeaderPath#1=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/USB_DEVICE/Target
20 | HeaderPath#2=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Inc
21 | SourceFiles#3=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/main.c
22 | SourceFiles#4=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_it.c
23 | SourceFiles#5=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_hal_msp.c
24 | SourceFiles#6=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_hal_timebase_tim.c
25 | SourcePath#1=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/USB_DEVICE/Target
26 | SourcePath#2=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src
27 | SourceFiles#7=/home/tatsuyai/STM32CubeIDE/workspace_1.1.0/RoboMaster_S1_Reference_Design/Core/Src/main.c
28 |
29 | [PreviousLibFiles]
30 | LibFiles=Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_can.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_rcc.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_rcc_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_flash.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_flash_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_gpio.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_gpio_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pwr.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pwr_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_cortex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_def.h;Drivers/STM32F7xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_exti.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_spi.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_spi_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_tim.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_tim_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pcd.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pcd_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_usb.h;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_can.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_exti.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_can.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_rcc.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_rcc_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_flash.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_flash_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_gpio.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_gpio_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pwr.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pwr_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_cortex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_def.h;Drivers/STM32F7xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_i2c_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_exti.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_spi.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_spi_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_tim.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_tim_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pcd.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pcd_ex.h;Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_usb.h;Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f746xx.h;Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h;Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h;Drivers/CMSIS/Device/ST/STM32F7xx/Source/Templates/system_stm32f7xx.c;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm0plus.h;
31 |
32 | [PreviousUsedCubeIDEFiles]
33 | SourceFiles=Core/Src/main.c;Core/Src/stm32f7xx_it.c;Core/Src/stm32f7xx_hal_msp.c;Core/Src/stm32f7xx_hal_timebase_tim.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_can.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_exti.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c;Core/Src/system_stm32f7xx.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_can.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_rcc_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_flash_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_gpio.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_dma_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pwr_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_cortex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_exti.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_tim_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c;Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c;Core/Src/system_stm32f7xx.c;Drivers/CMSIS/Device/ST/STM32F7xx/Source/Templates/system_stm32f7xx.c;;
34 | HeaderPath=Drivers/STM32F7xx_HAL_Driver/Inc;Drivers/STM32F7xx_HAL_Driver/Inc/Legacy;Drivers/CMSIS/Device/ST/STM32F7xx/Include;Drivers/CMSIS/Include;Core/Inc;
35 | CDefines=USE_HAL_DRIVER;STM32F746xx;USE_HAL_DRIVER;USE_HAL_DRIVER;
36 |
37 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | RoboMaster_S1_Reference_Design
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder
10 | clean,full,incremental,
11 |
12 |
13 |
14 |
15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
16 | full,incremental,
17 |
18 |
19 |
20 |
21 |
22 | com.st.stm32cube.ide.mcu.MCUProjectNature
23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature
24 | org.eclipse.cdt.core.cnature
25 | org.eclipse.cdt.core.ccnature
26 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAProjectNature
27 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature
28 | com.st.stm32cube.ide.mcu.MCUEndUserDisabledTrustZoneProjectNature
29 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature
30 | com.st.stm32cube.ide.mcu.MCURootProjectNature
31 | org.eclipse.cdt.managedbuilder.core.managedBuildNature
32 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
33 |
34 |
35 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/.settings/language.settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Inc/command_list.csv:
--------------------------------------------------------------------------------
1 | {1,10,0x55,0x0D,0x04,0xFF,0x0A,0xFF,0xFF,0xFF,0x40,0x00,0x01,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
2 | {2/*ACK*/,0xFF,0x55,0x0E,0x04,0xFF,0x09,0x03,0xFF,0xFF,0xA0,0x48,0x08,0x01,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
3 | {3,10,0x55,0x0F,0x04,0xFF,0xF1,0xC3,0xFF,0xFF,0x00,0x0A,0x53,0x32,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
4 | {4,100,0x55,0x12,0x04,0xFF,0xF1,0xC3,0xFF,0xFF,0x40,0x00,0x58,0x03,0x92,0x06,0x02,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
5 | {5,1,0x55,0x14,0x04,0xFF,0x09,0x04,0xFF,0xFF,0x00,0x04,0x69,0x08,0x05,0x00,0x00,0x00,0x00,0x6D,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
6 | {6/*Move Command*/,1,0x55,0x1B,0x04,0xFF,0x09,0xC3,0xFF,0xFF,0x00,0x3F,0x60,0x00,0x04,0x20,0x00,0x01,0x08,0x40,0x00,0x02,0x10,0x04,0x03,0x00,0x04,0xA3,0x88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
7 | {7,100,0x55,0x49,0x04,0xFF,0x49,0x03,0xFF,0xFF,0x00,0x3F,0x70,0xB4,0x11,0x34,0x03,0x00,0x00,0xF7,0x05,0x42,0x08,0x10,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x0E,0xF3,0x0B,0xD9,0x07,0x0E,0x07,0x3D,0x07,0x6A,0x08,0x62,0x0A,0x05,0x0B,0xD6,0x0B,0xFF,0xFF},
8 | {8/*Blaster*/,0xFF,0x55,0x0E,0x04,0xFF,0x09,0x17,0xFF,0xFF,0x00,0x3F,0x51,0x11,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
9 | {9/*Blaster*/,0xFF,0x55,0x16,0x04,0xFF,0x09,0x17,0xFF,0xFF,0x00,0x3F,0x55,0x73,0x00,0xFF,0x00,0x01,0x28,0x00,0x00,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
10 | {10/*Blaster LED*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x05,0xFF,0x00,0x00,0x7F,0x46,0x00,0x64,0x00,0x64,0x00,0x30,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
11 | {11/*Blaster LED*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x01,0xFF,0x00,0x00,0x7F,0x46,0x00,0xC8,0x00,0xC8,0x00,0x0F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
12 | {12/*LED ON*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x01,0xFF,0x00,0x00,0x7F,0x46,0x00,0x00,0x00,0x00,0x00,0x3F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
13 | {13/*LED FLASH*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x02,0xFF,0x00,0xFF,0xFF,0xFF,0x00,0xF4,0x01,0xF4,0x01,0x3F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
14 | {14/*LED Damage*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x73,0xFF,0x00,0xFF,0x00,0x00,0x01,0x64,0x00,0x0A,0x00,0x3F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
15 | {15/*LED RED1*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x05,0xF0,0x00,0xC8,0x00,0x00,0x00,0x64,0x00,0x64,0x00,0x30,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
16 | {16/*LED RED2*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x01,0xFF,0x00,0xC8,0x00,0x00,0x00,0xC8,0x00,0xC8,0x00,0x0F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
17 | {17/*LED BLUE1*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x05,0xF0,0x00,0x00,0x00,0xFF,0x00,0x64,0x00,0x64,0x00,0x30,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
18 | {18/*LED BLUE2*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x01,0xFF,0x00,0x00,0x00,0xFF,0x00,0xC8,0x00,0xC8,0x00,0x0F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
19 | {19/*LED GREEN1*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x05,0xF0,0x00,0x00,0xFF,0x00,0x00,0x64,0x00,0x64,0x00,0x30,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
20 | {20/*LED GREEN2*/,0xFF,0x55,0x1A,0x04,0xFF,0x09,0x18,0xFF,0xFF,0x00,0x3F,0x32,0x01,0xFF,0x00,0x00,0xFF,0x00,0x00,0xC8,0x00,0xC8,0x00,0x0F,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
21 | {21/*Touch Event*/,100,0x55,0x0F,0x04,0xFF,0x09,0x04,0xFF,0xFF,0x40,0x04,0x4C,0x00,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
22 | {22/*No Touch Event*/,0xFF,0x55,0x0F,0x04,0xFF,0x09,0x04,0xFF,0xFF,0x40,0x04,0x4C,0x02,0x00,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
23 | {23/*FAST MODE*/,0xFF,0x55,0x0E,0x04,0xFF,0x09,0xC3,0xFF,0xFF,0x40,0x3F,0x3F,0x01,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
24 | {24/*NORRMAL MODE*/,0xFF,0x55,0x0E,0x04,0xFF,0x09,0xC3,0xFF,0xFF,0x40,0x3F,0x3F,0x02,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
25 | {25/*SLOW MODE*/,0xFF,0x55,0x0E,0x04,0xFF,0x09,0xC3,0xFF,0xFF,0x40,0x3F,0x3F,0x03,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
26 | {26/*MANUAL MODE*/,0xFF,0x55,0x0E,0x04,0xFF,0x09,0xC3,0xFF,0xFF,0x40,0x3F,0x3F,0x04,0xFF,0xFF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
27 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Inc/main.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.h
5 | * @brief : Header for main.c file.
6 | * This file contains the common defines of the application.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | *
© Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MAIN_H
24 | #define __MAIN_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f7xx_hal.h"
32 |
33 | /* Private includes ----------------------------------------------------------*/
34 | /* USER CODE BEGIN Includes */
35 |
36 | /* USER CODE END Includes */
37 |
38 | /* Exported types ------------------------------------------------------------*/
39 | /* USER CODE BEGIN ET */
40 |
41 | /* USER CODE END ET */
42 |
43 | /* Exported constants --------------------------------------------------------*/
44 | /* USER CODE BEGIN EC */
45 |
46 | /* USER CODE END EC */
47 |
48 | /* Exported macro ------------------------------------------------------------*/
49 | /* USER CODE BEGIN EM */
50 |
51 | /* USER CODE END EM */
52 |
53 | /* Exported functions prototypes ---------------------------------------------*/
54 | void Error_Handler(void);
55 |
56 | /* USER CODE BEGIN EFP */
57 |
58 | /* USER CODE END EFP */
59 |
60 | /* Private defines -----------------------------------------------------------*/
61 | #define SYS_USER_LED3_Pin GPIO_PIN_4
62 | #define SYS_USER_LED3_GPIO_Port GPIOE
63 | #define SYS_USER_LED2_Pin GPIO_PIN_5
64 | #define SYS_USER_LED2_GPIO_Port GPIOE
65 | #define SW_USER2_Pin GPIO_PIN_6
66 | #define SW_USER2_GPIO_Port GPIOE
67 | #define SPI1_INT_Pin GPIO_PIN_1
68 | #define SPI1_INT_GPIO_Port GPIOA
69 | #define SPI1_NSS_Pin GPIO_PIN_4
70 | #define SPI1_NSS_GPIO_Port GPIOA
71 | #define BUZZER_SIG_Pin GPIO_PIN_14
72 | #define BUZZER_SIG_GPIO_Port GPIOF
73 | #define BUT_USER2_Pin GPIO_PIN_3
74 | #define BUT_USER2_GPIO_Port GPIOG
75 | #define BUT_USER1_Pin GPIO_PIN_12
76 | #define BUT_USER1_GPIO_Port GPIOC
77 | #define OTG_FS_VBUS_Pin GPIO_PIN_3
78 | #define OTG_FS_VBUS_GPIO_Port GPIOD
79 | #define OTG_FS_OC_Pin GPIO_PIN_4
80 | #define OTG_FS_OC_GPIO_Port GPIOD
81 | #define OTG_FS_PWR_Pin GPIO_PIN_7
82 | #define OTG_FS_PWR_GPIO_Port GPIOD
83 | #define SYS_STS_LED_Pin GPIO_PIN_9
84 | #define SYS_STS_LED_GPIO_Port GPIOG
85 | #define SYS_USER_LED4_Pin GPIO_PIN_10
86 | #define SYS_USER_LED4_GPIO_Port GPIOG
87 | #define SW_USER1_Pin GPIO_PIN_11
88 | #define SW_USER1_GPIO_Port GPIOG
89 | #define SYS_USER_LED1_Pin GPIO_PIN_12
90 | #define SYS_USER_LED1_GPIO_Port GPIOG
91 | /* USER CODE BEGIN Private defines */
92 |
93 | /* USER CODE END Private defines */
94 |
95 | #ifdef __cplusplus
96 | }
97 | #endif
98 |
99 | #endif /* __MAIN_H */
100 |
101 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
102 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Inc/robomaster_s1.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #ifndef __ROBOMASTER_S1_H__
5 | #define __ROBOMASTER_S1_H__
6 |
7 |
8 | #define CAN_ID_NUM 10
9 |
10 | #define BUFFER_SIZE 512
11 |
12 | #define PI 3.14159265
13 |
14 | #define TWIST_COMMAND_SIZE 19
15 | #define BLASTER_COMMAND_SIZE 8
16 |
17 | typedef enum can_ids
18 | {
19 | ID_0x201 = 0,
20 | ID_0x202 = 1,
21 | ID_0x203 = 2,
22 | ID_0x204 = 3,
23 | ID_0x211 = 4,
24 | ID_0x212 = 5,
25 | ID_0x213 = 6,
26 | ID_0x214 = 7,
27 | ID_0x215 = 8,
28 | ID_0x216 = 9
29 | } can_ids;
30 |
31 |
32 | typedef struct CANRxMsg
33 | {
34 | can_ids can_id;
35 | uint8_t dlc;
36 | uint8_t data[8];
37 | } CANRxMsg;
38 |
39 | typedef struct linear {
40 | double x;
41 | double y;
42 | double z;
43 | } linear;
44 | typedef struct angular {
45 | double x;
46 | double y;
47 | double z;
48 | } angular;
49 | typedef struct twist {
50 | uint8_t enable;
51 | linear linear;
52 | angular angular;
53 | } twist;
54 |
55 | #endif
56 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Inc/robomaster_s1_crc.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #ifndef __ROBOMASTER_S1_CRC_H__
5 | #define __ROBOMASTER_S1_CRC_H__
6 |
7 | #define CRC8_INIT 119
8 | const uint8_t CRC8_TABLE[256] =
9 | {
10 | 0x00, 0x5e, 0xbc, 0xe2, 0x61, 0x3f, 0xdd, 0x83, 0xc2, 0x9c, 0x7e, 0x20, 0xa3, 0xfd, 0x1f, 0x41,
11 | 0x9d, 0xc3, 0x21, 0x7f, 0xfc, 0xa2, 0x40, 0x1e, 0x5f, 0x01, 0xe3, 0xbd, 0x3e, 0x60, 0x82, 0xdc,
12 | 0x23, 0x7d, 0x9f, 0xc1, 0x42, 0x1c, 0xfe, 0xa0, 0xe1, 0xbf, 0x5d, 0x03, 0x80, 0xde, 0x3c, 0x62,
13 | 0xbe, 0xe0, 0x02, 0x5c, 0xdf, 0x81, 0x63, 0x3d, 0x7c, 0x22, 0xc0, 0x9e, 0x1d, 0x43, 0xa1, 0xff,
14 | 0x46, 0x18, 0xfa, 0xa4, 0x27, 0x79, 0x9b, 0xc5, 0x84, 0xda, 0x38, 0x66, 0xe5, 0xbb, 0x59, 0x07,
15 | 0xdb, 0x85, 0x67, 0x39, 0xba, 0xe4, 0x06, 0x58, 0x19, 0x47, 0xa5, 0xfb, 0x78, 0x26, 0xc4, 0x9a,
16 | 0x65, 0x3b, 0xd9, 0x87, 0x04, 0x5a, 0xb8, 0xe6, 0xa7, 0xf9, 0x1b, 0x45, 0xc6, 0x98, 0x7a, 0x24,
17 | 0xf8, 0xa6, 0x44, 0x1a, 0x99, 0xc7, 0x25, 0x7b, 0x3a, 0x64, 0x86, 0xd8, 0x5b, 0x05, 0xe7, 0xb9,
18 | 0x8c, 0xd2, 0x30, 0x6e, 0xed, 0xb3, 0x51, 0x0f, 0x4e, 0x10, 0xf2, 0xac, 0x2f, 0x71, 0x93, 0xcd,
19 | 0x11, 0x4f, 0xad, 0xf3, 0x70, 0x2e, 0xcc, 0x92, 0xd3, 0x8d, 0x6f, 0x31, 0xb2, 0xec, 0x0e, 0x50,
20 | 0xaf, 0xf1, 0x13, 0x4d, 0xce, 0x90, 0x72, 0x2c, 0x6d, 0x33, 0xd1, 0x8f, 0x0c, 0x52, 0xb0, 0xee,
21 | 0x32, 0x6c, 0x8e, 0xd0, 0x53, 0x0d, 0xef, 0xb1, 0xf0, 0xae, 0x4c, 0x12, 0x91, 0xcf, 0x2d, 0x73,
22 | 0xca, 0x94, 0x76, 0x28, 0xab, 0xf5, 0x17, 0x49, 0x08, 0x56, 0xb4, 0xea, 0x69, 0x37, 0xd5, 0x8b,
23 | 0x57, 0x09, 0xeb, 0xb5, 0x36, 0x68, 0x8a, 0xd4, 0x95, 0xcb, 0x29, 0x77, 0xf4, 0xaa, 0x48, 0x16,
24 | 0xe9, 0xb7, 0x55, 0x0b, 0x88, 0xd6, 0x34, 0x6a, 0x2b, 0x75, 0x97, 0xc9, 0x4a, 0x14, 0xf6, 0xa8,
25 | 0x74, 0x2a, 0xc8, 0x96, 0x15, 0x4b, 0xa9, 0xf7, 0xb6, 0xe8, 0x0a, 0x54, 0xd7, 0x89, 0x6b, 0x35};
26 |
27 | uint8_t getCRC8CheckSum(uint8_t *pchMessage, uint32_t dwLength, uint8_t ucCRC8)
28 | {
29 | uint8_t ucIndex;
30 | while (dwLength--)
31 | {
32 | ucIndex = ucCRC8 ^ (*pchMessage++);
33 | ucCRC8 = CRC8_TABLE[ucIndex];
34 | }
35 | return (ucCRC8);
36 | }
37 |
38 | uint32_t verifyCRC8CheckSum(uint8_t *pchMessage, uint32_t dwLength)
39 | {
40 | uint8_t ucExpected = 0;
41 | if ((pchMessage == 0) || (dwLength <= 2)){
42 | return 0;
43 | }
44 | ucExpected = getCRC8CheckSum(pchMessage, dwLength - 1, CRC8_INIT);
45 | return (ucExpected == pchMessage[dwLength - 1]);
46 | }
47 |
48 | void appendCRC8CheckSum(uint8_t *pchMessage, uint32_t dwLength)
49 | {
50 | uint8_t ucCRC = 0;
51 | if ((pchMessage == 0) || (dwLength <= 2))
52 | return;
53 | ucCRC = getCRC8CheckSum((uint8_t *)pchMessage, dwLength - 1, CRC8_INIT);
54 | pchMessage[dwLength - 1] = ucCRC;
55 | }
56 |
57 | uint16_t CRC_INIT = 13970;
58 | const uint16_t CRC16_TABLE[256] =
59 | {
60 | 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
61 | 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
62 | 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
63 | 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
64 | 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
65 | 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
66 | 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
67 | 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
68 | 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
69 | 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
70 | 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
71 | 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
72 | 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
73 | 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
74 | 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
75 | 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
76 | 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
77 | 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
78 | 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
79 | 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
80 | 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
81 | 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
82 | 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
83 | 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
84 | 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
85 | 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
86 | 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
87 | 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
88 | 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
89 | 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
90 | 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
91 | 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78};
92 |
93 | uint16_t getCRC16CheckSum(uint8_t *pchMessage, uint32_t dwLength, uint16_t wCRC)
94 | {
95 | uint8_t chData;
96 | if (pchMessage == NULL)
97 | {
98 | return 0xFFFF;
99 | }
100 | while (dwLength--)
101 | {
102 | chData = *pchMessage++;
103 | (wCRC) = ((uint16_t)(wCRC) >> 8) ^ CRC16_TABLE[((uint16_t)(wCRC) ^ (uint16_t)(chData)) & 0x00ff];
104 | }
105 | return wCRC;
106 | }
107 |
108 | uint32_t verifyCRC16CheckSum(uint8_t *pchMessage, uint32_t dwLength)
109 | {
110 | uint16_t wExpected = 0;
111 | if ((pchMessage == NULL) || (dwLength <= 2))
112 | {
113 | return 0;
114 | }
115 | wExpected = getCRC16CheckSum(pchMessage, dwLength - 2, CRC_INIT);
116 | return ((wExpected & 0xff) == pchMessage[dwLength - 2] && ((wExpected >> 8) & 0xff) == pchMessage[dwLength - 1]);
117 | }
118 |
119 | void appendCRC16CheckSum(uint8_t *pchMessage, uint32_t dwLength)
120 | {
121 | uint16_t wCRC = 0;
122 | if ((pchMessage == NULL) || (dwLength <= 2))
123 | {
124 | return;
125 | }
126 | wCRC = getCRC16CheckSum((uint8_t *)pchMessage, dwLength - 2, CRC_INIT);
127 | pchMessage[dwLength - 2] = (uint8_t)(wCRC & 0x00ff);
128 | pchMessage[dwLength - 1] = (uint8_t)((wCRC >> 8) & 0x00ff);
129 | }
130 |
131 | #endif
132 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Inc/stm32f7xx_it.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f7xx_it.h
5 | * @brief This file contains the headers of the interrupt handlers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F7xx_IT_H
23 | #define __STM32F7xx_IT_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 | /* USER CODE BEGIN ET */
36 |
37 | /* USER CODE END ET */
38 |
39 | /* Exported constants --------------------------------------------------------*/
40 | /* USER CODE BEGIN EC */
41 |
42 | /* USER CODE END EC */
43 |
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* USER CODE BEGIN EM */
46 |
47 | /* USER CODE END EM */
48 |
49 | /* Exported functions prototypes ---------------------------------------------*/
50 | void NMI_Handler(void);
51 | void HardFault_Handler(void);
52 | void MemManage_Handler(void);
53 | void BusFault_Handler(void);
54 | void UsageFault_Handler(void);
55 | void SVC_Handler(void);
56 | void DebugMon_Handler(void);
57 | void PendSV_Handler(void);
58 | void SysTick_Handler(void);
59 | void TIM1_UP_TIM10_IRQHandler(void);
60 | void TIM2_IRQHandler(void);
61 | void DMA2_Stream0_IRQHandler(void);
62 | void DMA2_Stream3_IRQHandler(void);
63 | void OTG_FS_IRQHandler(void);
64 | /* USER CODE BEGIN EFP */
65 |
66 | /* USER CODE END EFP */
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif /* __STM32F7xx_IT_H */
73 |
74 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
75 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Src/robomaster_s1_parser.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include // CHAR_BIT
4 | #include
5 | #include
6 |
7 | #include "robomaster_s1.h"
8 | #include "robomaster_s1_crc.h"
9 |
10 | volatile uint8_t robomas_buffer[CAN_ID_NUM][BUFFER_SIZE];
11 | volatile int robomas_buffer_rp[CAN_ID_NUM];
12 | volatile int robomas_buffer_wp[CAN_ID_NUM];
13 |
14 |
15 | int parseCanData(uint16_t id, uint8_t* in_data, uint8_t in_data_size, uint8_t out_data[], uint8_t* out_data_size)
16 | {
17 | int i;
18 |
19 | for(int i=0;i can_in_buffer_size)
51 | {
52 | // Not enough data
53 | return 0;
54 | }
55 |
56 | // Prepare send data
57 | uint8_t* send_data;
58 | send_data = (uint8_t*)malloc(sizeof(uint8_t) * send_data_size);
59 |
60 |
61 | for(i = 0; i < send_data_size; i++){
62 | int buffer_p = (robomas_buffer_rp[id] + i) % BUFFER_SIZE;
63 | send_data[i] = robomas_buffer[id][buffer_p];
64 | }
65 |
66 | // Check header crc8
67 | if(!verifyCRC8CheckSum(send_data, 4))
68 | {
69 | // checksum error
70 | // skip header
71 | robomas_buffer_rp[id]++;
72 | robomas_buffer_rp[id] %= BUFFER_SIZE;
73 | free(send_data);
74 | return 0;
75 | }
76 |
77 | // Check crc16
78 | if(!verifyCRC16CheckSum(send_data, send_data_size))
79 | {
80 | // checksum error
81 | // skip header
82 | robomas_buffer_rp[id]++;
83 | robomas_buffer_rp[id] %= BUFFER_SIZE;
84 | free(send_data);
85 | return 0;
86 | }
87 |
88 | memcpy(out_data, send_data, send_data_size);
89 | *out_data_size = send_data_size;
90 |
91 | free(send_data);
92 | robomas_buffer_rp[id] += send_data_size;
93 | robomas_buffer_rp[id] %= BUFFER_SIZE;
94 | return 1;
95 | }
96 |
97 | twist parseTwistCommandData(uint8_t* in_data, uint8_t in_data_size)
98 | {
99 | twist command_twist;
100 | command_twist.enable = 0;
101 | command_twist.linear.x = 0;
102 | command_twist.linear.y = 0;
103 | command_twist.linear.z = 0;
104 | command_twist.angular.x = 0;
105 | command_twist.angular.y = 0;
106 | command_twist.angular.z = 0;
107 |
108 | // Check data length
109 | if(in_data_size != TWIST_COMMAND_SIZE)
110 | {
111 | // Not enough data
112 | return command_twist;
113 | }
114 |
115 | if(in_data[0] == 0x55 &&
116 | in_data[1] == TWIST_COMMAND_SIZE &&
117 | in_data[2] == 0x04 &&
118 | verifyCRC8CheckSum(in_data, 4) == 1 &&
119 | verifyCRC16CheckSum(in_data, TWIST_COMMAND_SIZE) == 1 &&
120 | in_data[4] == 0x01
121 | ){
122 |
123 | // make twist command
124 | command_twist.enable = 1;
125 | command_twist.linear.x = 0.01 * (int16_t)((((uint16_t)in_data[5])<<8)|(in_data[6]));
126 | command_twist.linear.y = 0.01 * (int16_t)((((uint16_t)in_data[7])<<8)|(in_data[8]));
127 | command_twist.linear.z = 0.01 * (int16_t)((((uint16_t)in_data[9])<<8)|(in_data[10]));
128 | command_twist.angular.x = 0.01 * (int16_t)((((uint16_t)in_data[11])<<8)|(in_data[12]));
129 | command_twist.angular.y = 0.01 * (int16_t)((((uint16_t)in_data[13])<<8)|(in_data[14]));
130 | command_twist.angular.z = 0.01 * (int16_t)((((uint16_t)in_data[15])<<8)|(in_data[16]));
131 | }
132 |
133 | return command_twist;
134 | }
135 |
136 | int parseBlasterCommandData(uint8_t* in_data, uint8_t in_data_size)
137 | {
138 | int blaster = 0;
139 |
140 | // Check data length
141 | if(in_data_size != BLASTER_COMMAND_SIZE)
142 | {
143 | // Not enough data
144 | return blaster;
145 | }
146 |
147 | if(in_data[0] == 0x55 &&
148 | in_data[1] == BLASTER_COMMAND_SIZE &&
149 | in_data[2] == 0x04 &&
150 | verifyCRC8CheckSum(in_data, 4) == 1 &&
151 | verifyCRC16CheckSum(in_data, BLASTER_COMMAND_SIZE) == 1 &&
152 | in_data[4] == 0x02
153 | ){
154 |
155 | // make blaster command
156 | blaster = in_data[5];
157 | }
158 |
159 | return blaster;
160 | }
161 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_hal_timebase_tim.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f7xx_hal_timebase_TIM.c
5 | * @brief HAL time base based on the hardware TIM.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "stm32f7xx_hal.h"
23 | #include "stm32f7xx_hal_tim.h"
24 |
25 | /* Private typedef -----------------------------------------------------------*/
26 | /* Private define ------------------------------------------------------------*/
27 | /* Private macro -------------------------------------------------------------*/
28 | /* Private variables ---------------------------------------------------------*/
29 | TIM_HandleTypeDef htim10;
30 | /* Private function prototypes -----------------------------------------------*/
31 | /* Private functions ---------------------------------------------------------*/
32 |
33 | /**
34 | * @brief This function configures the TIM10 as a time base source.
35 | * The time source is configured to have 1ms time base with a dedicated
36 | * Tick interrupt priority.
37 | * @note This function is called automatically at the beginning of program after
38 | * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
39 | * @param TickPriority: Tick interrupt priority.
40 | * @retval HAL status
41 | */
42 | HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
43 | {
44 | RCC_ClkInitTypeDef clkconfig;
45 | uint32_t uwTimclock = 0;
46 | uint32_t uwPrescalerValue = 0;
47 | uint32_t pFLatency;
48 |
49 | /*Configure the TIM10 IRQ priority */
50 | HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, TickPriority ,0);
51 |
52 | /* Enable the TIM10 global Interrupt */
53 | HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
54 |
55 | /* Enable TIM10 clock */
56 | __HAL_RCC_TIM10_CLK_ENABLE();
57 |
58 | /* Get clock configuration */
59 | HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
60 |
61 | /* Compute TIM10 clock */
62 | uwTimclock = 2*HAL_RCC_GetPCLK2Freq();
63 |
64 | /* Compute the prescaler value to have TIM10 counter clock equal to 1MHz */
65 | uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000) - 1);
66 |
67 | /* Initialize TIM10 */
68 | htim10.Instance = TIM10;
69 |
70 | /* Initialize TIMx peripheral as follow:
71 | + Period = [(TIM10CLK/1000) - 1]. to have a (1/1000) s time base.
72 | + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
73 | + ClockDivision = 0
74 | + Counter direction = Up
75 | */
76 | htim10.Init.Period = (1000000 / 1000) - 1;
77 | htim10.Init.Prescaler = uwPrescalerValue;
78 | htim10.Init.ClockDivision = 0;
79 | htim10.Init.CounterMode = TIM_COUNTERMODE_UP;
80 | if(HAL_TIM_Base_Init(&htim10) == HAL_OK)
81 | {
82 | /* Start the TIM time Base generation in interrupt mode */
83 | return HAL_TIM_Base_Start_IT(&htim10);
84 | }
85 |
86 | /* Return function status */
87 | return HAL_ERROR;
88 | }
89 |
90 | /**
91 | * @brief Suspend Tick increment.
92 | * @note Disable the tick increment by disabling TIM10 update interrupt.
93 | * @param None
94 | * @retval None
95 | */
96 | void HAL_SuspendTick(void)
97 | {
98 | /* Disable TIM10 update Interrupt */
99 | __HAL_TIM_DISABLE_IT(&htim10, TIM_IT_UPDATE);
100 | }
101 |
102 | /**
103 | * @brief Resume Tick increment.
104 | * @note Enable the tick increment by Enabling TIM10 update interrupt.
105 | * @param None
106 | * @retval None
107 | */
108 | void HAL_ResumeTick(void)
109 | {
110 | /* Enable TIM10 Update interrupt */
111 | __HAL_TIM_ENABLE_IT(&htim10, TIM_IT_UPDATE);
112 | }
113 |
114 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
115 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Src/stm32f7xx_it.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f7xx_it.c
5 | * @brief Interrupt Service Routines.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "main.h"
23 | #include "stm32f7xx_it.h"
24 | /* Private includes ----------------------------------------------------------*/
25 | /* USER CODE BEGIN Includes */
26 | /* USER CODE END Includes */
27 |
28 | /* Private typedef -----------------------------------------------------------*/
29 | /* USER CODE BEGIN TD */
30 |
31 | /* USER CODE END TD */
32 |
33 | /* Private define ------------------------------------------------------------*/
34 | /* USER CODE BEGIN PD */
35 |
36 | /* USER CODE END PD */
37 |
38 | /* Private macro -------------------------------------------------------------*/
39 | /* USER CODE BEGIN PM */
40 |
41 | /* USER CODE END PM */
42 |
43 | /* Private variables ---------------------------------------------------------*/
44 | /* USER CODE BEGIN PV */
45 |
46 | /* USER CODE END PV */
47 |
48 | /* Private function prototypes -----------------------------------------------*/
49 | /* USER CODE BEGIN PFP */
50 |
51 | /* USER CODE END PFP */
52 |
53 | /* Private user code ---------------------------------------------------------*/
54 | /* USER CODE BEGIN 0 */
55 |
56 | /* USER CODE END 0 */
57 |
58 | /* External variables --------------------------------------------------------*/
59 | extern PCD_HandleTypeDef hpcd_USB_OTG_FS;
60 | extern DMA_HandleTypeDef hdma_spi1_rx;
61 | extern DMA_HandleTypeDef hdma_spi1_tx;
62 | extern TIM_HandleTypeDef htim2;
63 | extern TIM_HandleTypeDef htim10;
64 |
65 | /* USER CODE BEGIN EV */
66 |
67 | /* USER CODE END EV */
68 |
69 | /******************************************************************************/
70 | /* Cortex-M7 Processor Interruption and Exception Handlers */
71 | /******************************************************************************/
72 | /**
73 | * @brief This function handles Non maskable interrupt.
74 | */
75 | void NMI_Handler(void)
76 | {
77 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
78 |
79 | /* USER CODE END NonMaskableInt_IRQn 0 */
80 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
81 |
82 | /* USER CODE END NonMaskableInt_IRQn 1 */
83 | }
84 |
85 | /**
86 | * @brief This function handles Hard fault interrupt.
87 | */
88 | void HardFault_Handler(void)
89 | {
90 | /* USER CODE BEGIN HardFault_IRQn 0 */
91 |
92 | /* USER CODE END HardFault_IRQn 0 */
93 | while (1)
94 | {
95 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */
96 | /* USER CODE END W1_HardFault_IRQn 0 */
97 | }
98 | }
99 |
100 | /**
101 | * @brief This function handles Memory management fault.
102 | */
103 | void MemManage_Handler(void)
104 | {
105 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */
106 |
107 | /* USER CODE END MemoryManagement_IRQn 0 */
108 | while (1)
109 | {
110 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
111 | /* USER CODE END W1_MemoryManagement_IRQn 0 */
112 | }
113 | }
114 |
115 | /**
116 | * @brief This function handles Pre-fetch fault, memory access fault.
117 | */
118 | void BusFault_Handler(void)
119 | {
120 | /* USER CODE BEGIN BusFault_IRQn 0 */
121 |
122 | /* USER CODE END BusFault_IRQn 0 */
123 | while (1)
124 | {
125 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */
126 | /* USER CODE END W1_BusFault_IRQn 0 */
127 | }
128 | }
129 |
130 | /**
131 | * @brief This function handles Undefined instruction or illegal state.
132 | */
133 | void UsageFault_Handler(void)
134 | {
135 | /* USER CODE BEGIN UsageFault_IRQn 0 */
136 |
137 | /* USER CODE END UsageFault_IRQn 0 */
138 | while (1)
139 | {
140 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
141 | /* USER CODE END W1_UsageFault_IRQn 0 */
142 | }
143 | }
144 |
145 | /**
146 | * @brief This function handles System service call via SWI instruction.
147 | */
148 | void SVC_Handler(void)
149 | {
150 | /* USER CODE BEGIN SVCall_IRQn 0 */
151 |
152 | /* USER CODE END SVCall_IRQn 0 */
153 | /* USER CODE BEGIN SVCall_IRQn 1 */
154 |
155 | /* USER CODE END SVCall_IRQn 1 */
156 | }
157 |
158 | /**
159 | * @brief This function handles Debug monitor.
160 | */
161 | void DebugMon_Handler(void)
162 | {
163 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */
164 |
165 | /* USER CODE END DebugMonitor_IRQn 0 */
166 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */
167 |
168 | /* USER CODE END DebugMonitor_IRQn 1 */
169 | }
170 |
171 | /**
172 | * @brief This function handles Pendable request for system service.
173 | */
174 | void PendSV_Handler(void)
175 | {
176 | /* USER CODE BEGIN PendSV_IRQn 0 */
177 |
178 | /* USER CODE END PendSV_IRQn 0 */
179 | /* USER CODE BEGIN PendSV_IRQn 1 */
180 |
181 | /* USER CODE END PendSV_IRQn 1 */
182 | }
183 |
184 | /**
185 | * @brief This function handles System tick timer.
186 | */
187 | void SysTick_Handler(void)
188 | {
189 | /* USER CODE BEGIN SysTick_IRQn 0 */
190 |
191 | /* USER CODE END SysTick_IRQn 0 */
192 |
193 | /* USER CODE BEGIN SysTick_IRQn 1 */
194 |
195 | /* USER CODE END SysTick_IRQn 1 */
196 | }
197 |
198 | /******************************************************************************/
199 | /* STM32F7xx Peripheral Interrupt Handlers */
200 | /* Add here the Interrupt Handlers for the used peripherals. */
201 | /* For the available peripheral interrupt handler names, */
202 | /* please refer to the startup file (startup_stm32f7xx.s). */
203 | /******************************************************************************/
204 |
205 | /**
206 | * @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
207 | */
208 | void TIM1_UP_TIM10_IRQHandler(void)
209 | {
210 | /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
211 |
212 | /* USER CODE END TIM1_UP_TIM10_IRQn 0 */
213 | HAL_TIM_IRQHandler(&htim10);
214 | /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
215 |
216 | /* USER CODE END TIM1_UP_TIM10_IRQn 1 */
217 | }
218 |
219 | /**
220 | * @brief This function handles TIM2 global interrupt.
221 | */
222 | void TIM2_IRQHandler(void)
223 | {
224 | /* USER CODE BEGIN TIM2_IRQn 0 */
225 |
226 | /* USER CODE END TIM2_IRQn 0 */
227 | HAL_TIM_IRQHandler(&htim2);
228 | /* USER CODE BEGIN TIM2_IRQn 1 */
229 |
230 | /* USER CODE END TIM2_IRQn 1 */
231 | }
232 |
233 | /**
234 | * @brief This function handles DMA2 stream0 global interrupt.
235 | */
236 | void DMA2_Stream0_IRQHandler(void)
237 | {
238 | /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */
239 |
240 | /* USER CODE END DMA2_Stream0_IRQn 0 */
241 | HAL_DMA_IRQHandler(&hdma_spi1_rx);
242 | /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */
243 |
244 | /* USER CODE END DMA2_Stream0_IRQn 1 */
245 | }
246 |
247 | /**
248 | * @brief This function handles DMA2 stream3 global interrupt.
249 | */
250 | void DMA2_Stream3_IRQHandler(void)
251 | {
252 | /* USER CODE BEGIN DMA2_Stream3_IRQn 0 */
253 |
254 | /* USER CODE END DMA2_Stream3_IRQn 0 */
255 | HAL_DMA_IRQHandler(&hdma_spi1_tx);
256 | /* USER CODE BEGIN DMA2_Stream3_IRQn 1 */
257 |
258 | /* USER CODE END DMA2_Stream3_IRQn 1 */
259 | }
260 |
261 | /**
262 | * @brief This function handles USB On The Go FS global interrupt.
263 | */
264 | void OTG_FS_IRQHandler(void)
265 | {
266 | /* USER CODE BEGIN OTG_FS_IRQn 0 */
267 |
268 | /* USER CODE END OTG_FS_IRQn 0 */
269 | HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
270 | /* USER CODE BEGIN OTG_FS_IRQn 1 */
271 |
272 | /* USER CODE END OTG_FS_IRQn 1 */
273 | }
274 |
275 | /* USER CODE BEGIN 1 */
276 |
277 | /* USER CODE END 1 */
278 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
279 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Src/syscalls.c:
--------------------------------------------------------------------------------
1 | /**
2 | *****************************************************************************
3 | **
4 | ** File : syscalls.c
5 | **
6 | ** Author : Auto-generated by STM32CubeIDE
7 | **
8 | ** Abstract : STM32CubeIDE Minimal System calls file
9 | **
10 | ** For more information about which c-functions
11 | ** need which of these lowlevel functions
12 | ** please consult the Newlib libc-manual
13 | **
14 | ** Environment : STM32CubeIDE MCU
15 | **
16 | ** Distribution: The file is distributed as is, without any warranty
17 | ** of any kind.
18 | **
19 | *****************************************************************************
20 | **
21 | ** © COPYRIGHT(c) 2018 STMicroelectronics
22 | **
23 | ** Redistribution and use in source and binary forms, with or without modification,
24 | ** are permitted provided that the following conditions are met:
25 | ** 1. Redistributions of source code must retain the above copyright notice,
26 | ** this list of conditions and the following disclaimer.
27 | ** 2. Redistributions in binary form must reproduce the above copyright notice,
28 | ** this list of conditions and the following disclaimer in the documentation
29 | ** and/or other materials provided with the distribution.
30 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors
31 | ** may be used to endorse or promote products derived from this software
32 | ** without specific prior written permission.
33 | **
34 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
38 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 | **
45 | **
46 | *****************************************************************************
47 | */
48 |
49 | /* Includes */
50 | #include
51 | #include
52 | #include
53 | #include
54 | #include
55 | #include
56 | #include
57 | #include
58 |
59 |
60 | /* Variables */
61 | //#undef errno
62 | extern int errno;
63 | extern int __io_putchar(int ch) __attribute__((weak));
64 | extern int __io_getchar(void) __attribute__((weak));
65 |
66 | register char * stack_ptr asm("sp");
67 |
68 | char *__env[1] = { 0 };
69 | char **environ = __env;
70 |
71 |
72 | /* Functions */
73 | void initialise_monitor_handles()
74 | {
75 | }
76 |
77 | int _getpid(void)
78 | {
79 | return 1;
80 | }
81 |
82 | int _kill(int pid, int sig)
83 | {
84 | errno = EINVAL;
85 | return -1;
86 | }
87 |
88 | void _exit (int status)
89 | {
90 | _kill(status, -1);
91 | while (1) {} /* Make sure we hang here */
92 | }
93 |
94 | __attribute__((weak)) int _read(int file, char *ptr, int len)
95 | {
96 | int DataIdx;
97 |
98 | for (DataIdx = 0; DataIdx < len; DataIdx++)
99 | {
100 | *ptr++ = __io_getchar();
101 | }
102 |
103 | return len;
104 | }
105 |
106 | __attribute__((weak)) int _write(int file, char *ptr, int len)
107 | {
108 | int DataIdx;
109 |
110 | for (DataIdx = 0; DataIdx < len; DataIdx++)
111 | {
112 | __io_putchar(*ptr++);
113 | }
114 | return len;
115 | }
116 |
117 | int _close(int file)
118 | {
119 | return -1;
120 | }
121 |
122 |
123 | int _fstat(int file, struct stat *st)
124 | {
125 | st->st_mode = S_IFCHR;
126 | return 0;
127 | }
128 |
129 | int _isatty(int file)
130 | {
131 | return 1;
132 | }
133 |
134 | int _lseek(int file, int ptr, int dir)
135 | {
136 | return 0;
137 | }
138 |
139 | int _open(char *path, int flags, ...)
140 | {
141 | /* Pretend like we always fail */
142 | return -1;
143 | }
144 |
145 | int _wait(int *status)
146 | {
147 | errno = ECHILD;
148 | return -1;
149 | }
150 |
151 | int _unlink(char *name)
152 | {
153 | errno = ENOENT;
154 | return -1;
155 | }
156 |
157 | int _times(struct tms *buf)
158 | {
159 | return -1;
160 | }
161 |
162 | int _stat(char *file, struct stat *st)
163 | {
164 | st->st_mode = S_IFCHR;
165 | return 0;
166 | }
167 |
168 | int _link(char *old, char *new)
169 | {
170 | errno = EMLINK;
171 | return -1;
172 | }
173 |
174 | int _fork(void)
175 | {
176 | errno = EAGAIN;
177 | return -1;
178 | }
179 |
180 | int _execve(char *name, char **argv, char **env)
181 | {
182 | errno = ENOMEM;
183 | return -1;
184 | }
185 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Core/Src/sysmem.c:
--------------------------------------------------------------------------------
1 | /**
2 | *****************************************************************************
3 | **
4 | ** File : sysmem.c
5 | **
6 | ** Author : Auto-generated by STM32CubeIDE
7 | **
8 | ** Abstract : STM32CubeIDE Minimal System Memory calls file
9 | **
10 | ** For more information about which c-functions
11 | ** need which of these lowlevel functions
12 | ** please consult the Newlib libc-manual
13 | **
14 | ** Environment : STM32CubeIDE MCU
15 | **
16 | ** Distribution: The file is distributed as is, without any warranty
17 | ** of any kind.
18 | **
19 | *****************************************************************************
20 | **
21 | ** © COPYRIGHT(c) 2018 STMicroelectronics
22 | **
23 | ** Redistribution and use in source and binary forms, with or without modification,
24 | ** are permitted provided that the following conditions are met:
25 | ** 1. Redistributions of source code must retain the above copyright notice,
26 | ** this list of conditions and the following disclaimer.
27 | ** 2. Redistributions in binary form must reproduce the above copyright notice,
28 | ** this list of conditions and the following disclaimer in the documentation
29 | ** and/or other materials provided with the distribution.
30 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors
31 | ** may be used to endorse or promote products derived from this software
32 | ** without specific prior written permission.
33 | **
34 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
35 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
38 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
40 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
41 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
42 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
43 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44 | **
45 | **
46 | *****************************************************************************
47 | */
48 |
49 | /* Includes */
50 | #include
51 | #include
52 |
53 | /* Variables */
54 | extern int errno;
55 | register char * stack_ptr asm("sp");
56 |
57 | /* Functions */
58 |
59 | /**
60 | _sbrk
61 | Increase program data space. Malloc and related functions depend on this
62 | **/
63 | caddr_t _sbrk(int incr)
64 | {
65 | extern char end asm("end");
66 | static char *heap_end;
67 | char *prev_heap_end;
68 |
69 | if (heap_end == 0)
70 | heap_end = &end;
71 |
72 | prev_heap_end = heap_end;
73 | if (heap_end + incr > stack_ptr)
74 | {
75 | errno = ENOMEM;
76 | return (caddr_t) -1;
77 | }
78 |
79 | heap_end += incr;
80 |
81 | return (caddr_t) prev_heap_end;
82 | }
83 |
84 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f746xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoboMasterS1Challenge/robomaster_s1_ros_reference_design/7c646c677f02b34e6e1b435621a257e1364ce32b/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f746xx.h
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RoboMasterS1Challenge/robomaster_s1_ros_reference_design/7c646c677f02b34e6e1b435621a257e1364ce32b/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Device/ST/STM32F7xx/Include/stm32f7xx.h
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Device/ST/STM32F7xx/Include/system_stm32f7xx.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file system_stm32f7xx.h
4 | * @author MCD Application Team
5 | * @brief CMSIS Cortex-M7 Device System Source File for STM32F7xx devices.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © COPYRIGHT(c) 2016 STMicroelectronics
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | * 1. Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 | * may be used to endorse or promote products derived from this software
20 | * without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | *
33 | ******************************************************************************
34 | */
35 |
36 | /** @addtogroup CMSIS
37 | * @{
38 | */
39 |
40 | /** @addtogroup stm32f7xx_system
41 | * @{
42 | */
43 |
44 | /**
45 | * @brief Define to prevent recursive inclusion
46 | */
47 | #ifndef __SYSTEM_STM32F7XX_H
48 | #define __SYSTEM_STM32F7XX_H
49 |
50 | #ifdef __cplusplus
51 | extern "C" {
52 | #endif
53 |
54 | /** @addtogroup STM32F7xx_System_Includes
55 | * @{
56 | */
57 |
58 | /**
59 | * @}
60 | */
61 |
62 |
63 | /** @addtogroup STM32F7xx_System_Exported_Variables
64 | * @{
65 | */
66 | /* The SystemCoreClock variable is updated in three ways:
67 | 1) by calling CMSIS function SystemCoreClockUpdate()
68 | 2) by calling HAL API function HAL_RCC_GetSysClockFreq()
69 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency
70 | Note: If you use this function to configure the system clock; then there
71 | is no need to call the 2 first functions listed above, since SystemCoreClock
72 | variable is updated automatically.
73 | */
74 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */
75 |
76 | extern const uint8_t AHBPrescTable[16]; /*!< AHB prescalers table values */
77 | extern const uint8_t APBPrescTable[8]; /*!< APB prescalers table values */
78 |
79 |
80 | /**
81 | * @}
82 | */
83 |
84 | /** @addtogroup STM32F7xx_System_Exported_Constants
85 | * @{
86 | */
87 |
88 | /**
89 | * @}
90 | */
91 |
92 | /** @addtogroup STM32F7xx_System_Exported_Macros
93 | * @{
94 | */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /** @addtogroup STM32F7xx_System_Exported_Functions
101 | * @{
102 | */
103 |
104 | extern void SystemInit(void);
105 | extern void SystemCoreClockUpdate(void);
106 | /**
107 | * @}
108 | */
109 |
110 | #ifdef __cplusplus
111 | }
112 | #endif
113 |
114 | #endif /*__SYSTEM_STM32F7XX_H */
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /**
121 | * @}
122 | */
123 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
124 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Include/cmsis_compiler.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_compiler.h
3 | * @brief CMSIS compiler generic header file
4 | * @version V5.0.4
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #ifndef __CMSIS_COMPILER_H
26 | #define __CMSIS_COMPILER_H
27 |
28 | #include
29 |
30 | /*
31 | * Arm Compiler 4/5
32 | */
33 | #if defined ( __CC_ARM )
34 | #include "cmsis_armcc.h"
35 |
36 |
37 | /*
38 | * Arm Compiler 6 (armclang)
39 | */
40 | #elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
41 | #include "cmsis_armclang.h"
42 |
43 |
44 | /*
45 | * GNU Compiler
46 | */
47 | #elif defined ( __GNUC__ )
48 | #include "cmsis_gcc.h"
49 |
50 |
51 | /*
52 | * IAR Compiler
53 | */
54 | #elif defined ( __ICCARM__ )
55 | #include
56 |
57 |
58 | /*
59 | * TI Arm Compiler
60 | */
61 | #elif defined ( __TI_ARM__ )
62 | #include
63 |
64 | #ifndef __ASM
65 | #define __ASM __asm
66 | #endif
67 | #ifndef __INLINE
68 | #define __INLINE inline
69 | #endif
70 | #ifndef __STATIC_INLINE
71 | #define __STATIC_INLINE static inline
72 | #endif
73 | #ifndef __STATIC_FORCEINLINE
74 | #define __STATIC_FORCEINLINE __STATIC_INLINE
75 | #endif
76 | #ifndef __NO_RETURN
77 | #define __NO_RETURN __attribute__((noreturn))
78 | #endif
79 | #ifndef __USED
80 | #define __USED __attribute__((used))
81 | #endif
82 | #ifndef __WEAK
83 | #define __WEAK __attribute__((weak))
84 | #endif
85 | #ifndef __PACKED
86 | #define __PACKED __attribute__((packed))
87 | #endif
88 | #ifndef __PACKED_STRUCT
89 | #define __PACKED_STRUCT struct __attribute__((packed))
90 | #endif
91 | #ifndef __PACKED_UNION
92 | #define __PACKED_UNION union __attribute__((packed))
93 | #endif
94 | #ifndef __UNALIGNED_UINT32 /* deprecated */
95 | struct __attribute__((packed)) T_UINT32 { uint32_t v; };
96 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
97 | #endif
98 | #ifndef __UNALIGNED_UINT16_WRITE
99 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
100 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
101 | #endif
102 | #ifndef __UNALIGNED_UINT16_READ
103 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
104 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
105 | #endif
106 | #ifndef __UNALIGNED_UINT32_WRITE
107 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
108 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
109 | #endif
110 | #ifndef __UNALIGNED_UINT32_READ
111 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
112 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
113 | #endif
114 | #ifndef __ALIGNED
115 | #define __ALIGNED(x) __attribute__((aligned(x)))
116 | #endif
117 | #ifndef __RESTRICT
118 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
119 | #define __RESTRICT
120 | #endif
121 |
122 |
123 | /*
124 | * TASKING Compiler
125 | */
126 | #elif defined ( __TASKING__ )
127 | /*
128 | * The CMSIS functions have been implemented as intrinsics in the compiler.
129 | * Please use "carm -?i" to get an up to date list of all intrinsics,
130 | * Including the CMSIS ones.
131 | */
132 |
133 | #ifndef __ASM
134 | #define __ASM __asm
135 | #endif
136 | #ifndef __INLINE
137 | #define __INLINE inline
138 | #endif
139 | #ifndef __STATIC_INLINE
140 | #define __STATIC_INLINE static inline
141 | #endif
142 | #ifndef __STATIC_FORCEINLINE
143 | #define __STATIC_FORCEINLINE __STATIC_INLINE
144 | #endif
145 | #ifndef __NO_RETURN
146 | #define __NO_RETURN __attribute__((noreturn))
147 | #endif
148 | #ifndef __USED
149 | #define __USED __attribute__((used))
150 | #endif
151 | #ifndef __WEAK
152 | #define __WEAK __attribute__((weak))
153 | #endif
154 | #ifndef __PACKED
155 | #define __PACKED __packed__
156 | #endif
157 | #ifndef __PACKED_STRUCT
158 | #define __PACKED_STRUCT struct __packed__
159 | #endif
160 | #ifndef __PACKED_UNION
161 | #define __PACKED_UNION union __packed__
162 | #endif
163 | #ifndef __UNALIGNED_UINT32 /* deprecated */
164 | struct __packed__ T_UINT32 { uint32_t v; };
165 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
166 | #endif
167 | #ifndef __UNALIGNED_UINT16_WRITE
168 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
169 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
170 | #endif
171 | #ifndef __UNALIGNED_UINT16_READ
172 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
173 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
174 | #endif
175 | #ifndef __UNALIGNED_UINT32_WRITE
176 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
177 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
178 | #endif
179 | #ifndef __UNALIGNED_UINT32_READ
180 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
181 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
182 | #endif
183 | #ifndef __ALIGNED
184 | #define __ALIGNED(x) __align(x)
185 | #endif
186 | #ifndef __RESTRICT
187 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
188 | #define __RESTRICT
189 | #endif
190 |
191 |
192 | /*
193 | * COSMIC Compiler
194 | */
195 | #elif defined ( __CSMC__ )
196 | #include
197 |
198 | #ifndef __ASM
199 | #define __ASM _asm
200 | #endif
201 | #ifndef __INLINE
202 | #define __INLINE inline
203 | #endif
204 | #ifndef __STATIC_INLINE
205 | #define __STATIC_INLINE static inline
206 | #endif
207 | #ifndef __STATIC_FORCEINLINE
208 | #define __STATIC_FORCEINLINE __STATIC_INLINE
209 | #endif
210 | #ifndef __NO_RETURN
211 | // NO RETURN is automatically detected hence no warning here
212 | #define __NO_RETURN
213 | #endif
214 | #ifndef __USED
215 | #warning No compiler specific solution for __USED. __USED is ignored.
216 | #define __USED
217 | #endif
218 | #ifndef __WEAK
219 | #define __WEAK __weak
220 | #endif
221 | #ifndef __PACKED
222 | #define __PACKED @packed
223 | #endif
224 | #ifndef __PACKED_STRUCT
225 | #define __PACKED_STRUCT @packed struct
226 | #endif
227 | #ifndef __PACKED_UNION
228 | #define __PACKED_UNION @packed union
229 | #endif
230 | #ifndef __UNALIGNED_UINT32 /* deprecated */
231 | @packed struct T_UINT32 { uint32_t v; };
232 | #define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
233 | #endif
234 | #ifndef __UNALIGNED_UINT16_WRITE
235 | __PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
236 | #define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
237 | #endif
238 | #ifndef __UNALIGNED_UINT16_READ
239 | __PACKED_STRUCT T_UINT16_READ { uint16_t v; };
240 | #define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
241 | #endif
242 | #ifndef __UNALIGNED_UINT32_WRITE
243 | __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
244 | #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
245 | #endif
246 | #ifndef __UNALIGNED_UINT32_READ
247 | __PACKED_STRUCT T_UINT32_READ { uint32_t v; };
248 | #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
249 | #endif
250 | #ifndef __ALIGNED
251 | #warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
252 | #define __ALIGNED(x)
253 | #endif
254 | #ifndef __RESTRICT
255 | #warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
256 | #define __RESTRICT
257 | #endif
258 |
259 |
260 | #else
261 | #error Unknown compiler.
262 | #endif
263 |
264 |
265 | #endif /* __CMSIS_COMPILER_H */
266 |
267 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Include/cmsis_version.h:
--------------------------------------------------------------------------------
1 | /**************************************************************************//**
2 | * @file cmsis_version.h
3 | * @brief CMSIS Core(M) Version definitions
4 | * @version V5.0.2
5 | * @date 19. April 2017
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2009-2017 ARM Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef __CMSIS_VERSION_H
32 | #define __CMSIS_VERSION_H
33 |
34 | /* CMSIS Version definitions */
35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
36 | #define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
39 | #endif
40 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/CMSIS/Include/tz_context.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************
2 | * @file tz_context.h
3 | * @brief Context Management for Armv8-M TrustZone
4 | * @version V1.0.1
5 | * @date 10. January 2018
6 | ******************************************************************************/
7 | /*
8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved.
9 | *
10 | * SPDX-License-Identifier: Apache-2.0
11 | *
12 | * Licensed under the Apache License, Version 2.0 (the License); you may
13 | * not use this file except in compliance with the License.
14 | * You may obtain a copy of the License at
15 | *
16 | * www.apache.org/licenses/LICENSE-2.0
17 | *
18 | * Unless required by applicable law or agreed to in writing, software
19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 | * See the License for the specific language governing permissions and
22 | * limitations under the License.
23 | */
24 |
25 | #if defined ( __ICCARM__ )
26 | #pragma system_include /* treat file as system include file for MISRA check */
27 | #elif defined (__clang__)
28 | #pragma clang system_header /* treat file as system include file */
29 | #endif
30 |
31 | #ifndef TZ_CONTEXT_H
32 | #define TZ_CONTEXT_H
33 |
34 | #include
35 |
36 | #ifndef TZ_MODULEID_T
37 | #define TZ_MODULEID_T
38 | /// \details Data type that identifies secure software modules called by a process.
39 | typedef uint32_t TZ_ModuleId_t;
40 | #endif
41 |
42 | /// \details TZ Memory ID identifies an allocated memory slot.
43 | typedef uint32_t TZ_MemoryId_t;
44 |
45 | /// Initialize secure context memory system
46 | /// \return execution status (1: success, 0: error)
47 | uint32_t TZ_InitContextSystem_S (void);
48 |
49 | /// Allocate context memory for calling secure software modules in TrustZone
50 | /// \param[in] module identifies software modules called from non-secure mode
51 | /// \return value != 0 id TrustZone memory slot identifier
52 | /// \return value 0 no memory available or internal error
53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module);
54 |
55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S
56 | /// \param[in] id TrustZone memory slot identifier
57 | /// \return execution status (1: success, 0: error)
58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id);
59 |
60 | /// Load secure context (called on RTOS thread context switch)
61 | /// \param[in] id TrustZone memory slot identifier
62 | /// \return execution status (1: success, 0: error)
63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id);
64 |
65 | /// Store secure context (called on RTOS thread context switch)
66 | /// \param[in] id TrustZone memory slot identifier
67 | /// \return execution status (1: success, 0: error)
68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id);
69 |
70 | #endif // TZ_CONTEXT_H
71 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_def.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_def.h
4 | * @author MCD Application Team
5 | * @brief This file contains HAL common defines, enumeration, macros and
6 | * structures definitions.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2017 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F7xx_HAL_DEF
23 | #define __STM32F7xx_HAL_DEF
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "stm32f7xx.h"
31 | #include "Legacy/stm32_hal_legacy.h"
32 | #include
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 |
36 | /**
37 | * @brief HAL Status structures definition
38 | */
39 | typedef enum
40 | {
41 | HAL_OK = 0x00U,
42 | HAL_ERROR = 0x01U,
43 | HAL_BUSY = 0x02U,
44 | HAL_TIMEOUT = 0x03U
45 | } HAL_StatusTypeDef;
46 |
47 | /**
48 | * @brief HAL Lock structures definition
49 | */
50 | typedef enum
51 | {
52 | HAL_UNLOCKED = 0x00U,
53 | HAL_LOCKED = 0x01U
54 | } HAL_LockTypeDef;
55 |
56 | /* Exported macro ------------------------------------------------------------*/
57 |
58 | #define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
59 |
60 | #define HAL_MAX_DELAY 0xFFFFFFFFU
61 |
62 | #define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
63 | #define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
64 |
65 | #define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD__, __DMA_HANDLE__) \
66 | do{ \
67 | (__HANDLE__)->__PPP_DMA_FIELD__ = &(__DMA_HANDLE__); \
68 | (__DMA_HANDLE__).Parent = (__HANDLE__); \
69 | } while(0)
70 |
71 | /** @brief Reset the Handle's State field.
72 | * @param __HANDLE__ specifies the Peripheral Handle.
73 | * @note This macro can be used for the following purpose:
74 | * - When the Handle is declared as local variable; before passing it as parameter
75 | * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
76 | * to set to 0 the Handle's "State" field.
77 | * Otherwise, "State" field may have any random value and the first time the function
78 | * HAL_PPP_Init() is called, the low level hardware initialization will be missed
79 | * (i.e. HAL_PPP_MspInit() will not be executed).
80 | * - When there is a need to reconfigure the low level hardware: instead of calling
81 | * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
82 | * In this later function, when the Handle's "State" field is set to 0, it will execute the function
83 | * HAL_PPP_MspInit() which will reconfigure the low level hardware.
84 | * @retval None
85 | */
86 | #define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
87 |
88 | #if (USE_RTOS == 1U)
89 | /* Reserved for future use */
90 | #error "USE_RTOS should be 0 in the current HAL release"
91 | #else
92 | #define __HAL_LOCK(__HANDLE__) \
93 | do{ \
94 | if((__HANDLE__)->Lock == HAL_LOCKED) \
95 | { \
96 | return HAL_BUSY; \
97 | } \
98 | else \
99 | { \
100 | (__HANDLE__)->Lock = HAL_LOCKED; \
101 | } \
102 | }while (0U)
103 |
104 | #define __HAL_UNLOCK(__HANDLE__) \
105 | do{ \
106 | (__HANDLE__)->Lock = HAL_UNLOCKED; \
107 | }while (0U)
108 | #endif /* USE_RTOS */
109 |
110 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
111 | #ifndef __weak
112 | #define __weak __attribute__((weak))
113 | #endif /* __weak */
114 | #ifndef __packed
115 | #define __packed __attribute__((__packed__))
116 | #endif /* __packed */
117 | #endif /* __GNUC__ */
118 |
119 |
120 | /* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
121 | #if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
122 | #ifndef __ALIGN_END
123 | #define __ALIGN_END __attribute__ ((aligned (4)))
124 | #endif /* __ALIGN_END */
125 | #ifndef __ALIGN_BEGIN
126 | #define __ALIGN_BEGIN
127 | #endif /* __ALIGN_BEGIN */
128 | #else
129 | #ifndef __ALIGN_END
130 | #define __ALIGN_END
131 | #endif /* __ALIGN_END */
132 | #ifndef __ALIGN_BEGIN
133 | #if defined (__CC_ARM) /* ARM Compiler */
134 | #define __ALIGN_BEGIN __align(4)
135 | #elif defined (__ICCARM__) /* IAR Compiler */
136 | #define __ALIGN_BEGIN
137 | #endif /* __CC_ARM */
138 | #endif /* __ALIGN_BEGIN */
139 | #endif /* __GNUC__ */
140 |
141 | /* Macro to get variable aligned on 32-bytes,needed for cache maintenance purpose */
142 | #if defined (__GNUC__) /* GNU Compiler */
143 | #define ALIGN_32BYTES(buf) buf __attribute__ ((aligned (32)))
144 | #elif defined (__ICCARM__) /* IAR Compiler */
145 | #define ALIGN_32BYTES(buf) _Pragma("data_alignment=32") buf
146 | #elif defined (__CC_ARM) /* ARM Compiler */
147 | #define ALIGN_32BYTES(buf) __align(32) buf
148 | #endif
149 |
150 | /**
151 | * @brief __RAM_FUNC definition
152 | */
153 | #if defined ( __CC_ARM )
154 | /* ARM Compiler
155 | ------------
156 | RAM functions are defined using the toolchain options.
157 | Functions that are executed in RAM should reside in a separate source module.
158 | Using the 'Options for File' dialog you can simply change the 'Code / Const'
159 | area of a module to a memory space in physical RAM.
160 | Available memory areas are declared in the 'Target' tab of the 'Options for Target'
161 | dialog.
162 | */
163 | #define __RAM_FUNC
164 |
165 | #elif defined ( __ICCARM__ )
166 | /* ICCARM Compiler
167 | ---------------
168 | RAM functions are defined using a specific toolchain keyword "__ramfunc".
169 | */
170 | #define __RAM_FUNC __ramfunc
171 |
172 | #elif defined ( __GNUC__ )
173 | /* GNU Compiler
174 | ------------
175 | RAM functions are defined using a specific toolchain attribute
176 | "__attribute__((section(".RamFunc")))".
177 | */
178 | #define __RAM_FUNC __attribute__((section(".RamFunc")))
179 |
180 | #endif
181 |
182 | /**
183 | * @brief __NOINLINE definition
184 | */
185 | #if defined ( __CC_ARM ) || defined ( __GNUC__ )
186 | /* ARM & GNUCompiler
187 | ----------------
188 | */
189 | #define __NOINLINE __attribute__ ( (noinline) )
190 |
191 | #elif defined ( __ICCARM__ )
192 | /* ICCARM Compiler
193 | ---------------
194 | */
195 | #define __NOINLINE _Pragma("optimize = no_inline")
196 |
197 | #endif
198 |
199 | #ifdef __cplusplus
200 | }
201 | #endif
202 |
203 | #endif /* ___STM32F7xx_HAL_DEF */
204 |
205 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
206 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_dma_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_dma_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of DMA HAL extension module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __STM32F7xx_HAL_DMA_EX_H
22 | #define __STM32F7xx_HAL_DMA_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f7xx_hal_def.h"
30 |
31 | /** @addtogroup STM32F7xx_HAL_Driver
32 | * @{
33 | */
34 |
35 | /** @addtogroup DMAEx
36 | * @{
37 | */
38 |
39 | /* Exported types ------------------------------------------------------------*/
40 | /** @defgroup DMAEx_Exported_Types DMAEx Exported Types
41 | * @brief DMAEx Exported types
42 | * @{
43 | */
44 |
45 | /**
46 | * @brief HAL DMA Memory definition
47 | */
48 | typedef enum
49 | {
50 | MEMORY0 = 0x00U, /*!< Memory 0 */
51 | MEMORY1 = 0x01U, /*!< Memory 1 */
52 |
53 | }HAL_DMA_MemoryTypeDef;
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /* Exported constants --------------------------------------------------------*/
60 |
61 | /** @defgroup DMA_Exported_Constants DMA Exported Constants
62 | * @brief DMA Exported constants
63 | * @{
64 | */
65 |
66 | /** @defgroup DMAEx_Channel_selection DMA Channel selection
67 | * @brief DMAEx channel selection
68 | * @{
69 | */
70 | #define DMA_CHANNEL_0 0x00000000U /*!< DMA Channel 0 */
71 | #define DMA_CHANNEL_1 0x02000000U /*!< DMA Channel 1 */
72 | #define DMA_CHANNEL_2 0x04000000U /*!< DMA Channel 2 */
73 | #define DMA_CHANNEL_3 0x06000000U /*!< DMA Channel 3 */
74 | #define DMA_CHANNEL_4 0x08000000U /*!< DMA Channel 4 */
75 | #define DMA_CHANNEL_5 0x0A000000U /*!< DMA Channel 5 */
76 | #define DMA_CHANNEL_6 0x0C000000U /*!< DMA Channel 6 */
77 | #define DMA_CHANNEL_7 0x0E000000U /*!< DMA Channel 7 */
78 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\
79 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\
80 | defined (STM32F779xx) || defined (STM32F730xx)
81 | #define DMA_CHANNEL_8 0x10000000U /*!< DMA Channel 8 */
82 | #define DMA_CHANNEL_9 0x12000000U /*!< DMA Channel 9 */
83 | #define DMA_CHANNEL_10 0x14000000U /*!< DMA Channel 10*/
84 | #define DMA_CHANNEL_11 0x16000000U /*!< DMA Channel 11*/
85 | #define DMA_CHANNEL_12 0x18000000U /*!< DMA Channel 12*/
86 | #define DMA_CHANNEL_13 0x1A000000U /*!< DMA Channel 13*/
87 | #define DMA_CHANNEL_14 0x1C000000U /*!< DMA Channel 14*/
88 | #define DMA_CHANNEL_15 0x1E000000U /*!< DMA Channel 15*/
89 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx ||
90 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx */
91 |
92 | /**
93 | * @}
94 | */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /* Exported functions --------------------------------------------------------*/
101 | /** @defgroup DMAEx_Exported_Functions DMAEx Exported Functions
102 | * @brief DMAEx Exported functions
103 | * @{
104 | */
105 |
106 | /** @defgroup DMAEx_Exported_Functions_Group1 Extended features functions
107 | * @brief Extended features functions
108 | * @{
109 | */
110 |
111 | /* IO operation functions *******************************************************/
112 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength);
113 | HAL_StatusTypeDef HAL_DMAEx_MultiBufferStart_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t SecondMemAddress, uint32_t DataLength);
114 | HAL_StatusTypeDef HAL_DMAEx_ChangeMemory(DMA_HandleTypeDef *hdma, uint32_t Address, HAL_DMA_MemoryTypeDef memory);
115 |
116 | /**
117 | * @}
118 | */
119 | /**
120 | * @}
121 | */
122 |
123 | /* Private macros ------------------------------------------------------------*/
124 | /** @defgroup DMAEx_Private_Macros DMA Private Macros
125 | * @brief DMAEx private macros
126 | * @{
127 | */
128 | #if defined (STM32F722xx) || defined (STM32F723xx) || defined (STM32F732xx) || defined (STM32F733xx) ||\
129 | defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) ||\
130 | defined (STM32F779xx) || defined (STM32F730xx)
131 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \
132 | ((CHANNEL) == DMA_CHANNEL_1) || \
133 | ((CHANNEL) == DMA_CHANNEL_2) || \
134 | ((CHANNEL) == DMA_CHANNEL_3) || \
135 | ((CHANNEL) == DMA_CHANNEL_4) || \
136 | ((CHANNEL) == DMA_CHANNEL_5) || \
137 | ((CHANNEL) == DMA_CHANNEL_6) || \
138 | ((CHANNEL) == DMA_CHANNEL_7) || \
139 | ((CHANNEL) == DMA_CHANNEL_8) || \
140 | ((CHANNEL) == DMA_CHANNEL_9) || \
141 | ((CHANNEL) == DMA_CHANNEL_10) || \
142 | ((CHANNEL) == DMA_CHANNEL_11) || \
143 | ((CHANNEL) == DMA_CHANNEL_12) || \
144 | ((CHANNEL) == DMA_CHANNEL_13) || \
145 | ((CHANNEL) == DMA_CHANNEL_14) || \
146 | ((CHANNEL) == DMA_CHANNEL_15))
147 | #else
148 | #define IS_DMA_CHANNEL(CHANNEL) (((CHANNEL) == DMA_CHANNEL_0) || \
149 | ((CHANNEL) == DMA_CHANNEL_1) || \
150 | ((CHANNEL) == DMA_CHANNEL_2) || \
151 | ((CHANNEL) == DMA_CHANNEL_3) || \
152 | ((CHANNEL) == DMA_CHANNEL_4) || \
153 | ((CHANNEL) == DMA_CHANNEL_5) || \
154 | ((CHANNEL) == DMA_CHANNEL_6) || \
155 | ((CHANNEL) == DMA_CHANNEL_7))
156 | #endif /* STM32F722xx || STM32F723xx || STM32F732xx || STM32F733xx || STM32F765xx || STM32F767xx ||
157 | STM32F769xx || STM32F777xx || STM32F779xx || STM32F730xx*/
158 | /**
159 | * @}
160 | */
161 |
162 | /* Private functions ---------------------------------------------------------*/
163 | /** @defgroup DMAEx_Private_Functions DMAEx Private Functions
164 | * @brief DMAEx Private functions
165 | * @{
166 | */
167 | /**
168 | * @}
169 | */
170 |
171 | /**
172 | * @}
173 | */
174 |
175 | /**
176 | * @}
177 | */
178 |
179 | #ifdef __cplusplus
180 | }
181 | #endif
182 |
183 | #endif /* __STM32F7xx_HAL_DMA_H */
184 |
185 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
186 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_pcd_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_pcd_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of PCD HAL Extension module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef STM32F7xx_HAL_PCD_EX_H
22 | #define STM32F7xx_HAL_PCD_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f7xx_hal_def.h"
30 |
31 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
32 | /** @addtogroup STM32F7xx_HAL_Driver
33 | * @{
34 | */
35 |
36 | /** @addtogroup PCDEx
37 | * @{
38 | */
39 | /* Exported types ------------------------------------------------------------*/
40 | /* Exported constants --------------------------------------------------------*/
41 | /* Exported macros -----------------------------------------------------------*/
42 | /* Exported functions --------------------------------------------------------*/
43 | /** @addtogroup PCDEx_Exported_Functions PCDEx Exported Functions
44 | * @{
45 | */
46 | /** @addtogroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
47 | * @{
48 | */
49 |
50 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
51 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size);
52 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size);
53 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
54 |
55 |
56 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd);
57 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd);
58 |
59 | void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg);
60 | void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg);
61 |
62 | /**
63 | * @}
64 | */
65 |
66 | /**
67 | * @}
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /**
75 | * @}
76 | */
77 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
78 |
79 | #ifdef __cplusplus
80 | }
81 | #endif
82 |
83 |
84 | #endif /* STM32F7xx_HAL_PCD_EX_H */
85 |
86 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
87 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_spi_ex.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_spi_ex.h
4 | * @author MCD Application Team
5 | * @brief Header file of SPI HAL Extended module.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2017 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef STM32F7xx_HAL_SPI_EX_H
22 | #define STM32F7xx_HAL_SPI_EX_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "stm32f7xx_hal_def.h"
30 |
31 | /** @addtogroup STM32F7xx_HAL_Driver
32 | * @{
33 | */
34 |
35 | /** @addtogroup SPIEx
36 | * @{
37 | */
38 |
39 | /* Exported types ------------------------------------------------------------*/
40 | /* Exported constants --------------------------------------------------------*/
41 | /* Exported macros -----------------------------------------------------------*/
42 | /* Exported functions --------------------------------------------------------*/
43 | /** @addtogroup SPIEx_Exported_Functions
44 | * @{
45 | */
46 |
47 | /* Initialization and de-initialization functions ****************************/
48 | /* IO operation functions *****************************************************/
49 | /** @addtogroup SPIEx_Exported_Functions_Group1
50 | * @{
51 | */
52 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi);
53 | /**
54 | * @}
55 | */
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /**
62 | * @}
63 | */
64 |
65 | /**
66 | * @}
67 | */
68 |
69 | #ifdef __cplusplus
70 | }
71 | #endif
72 |
73 | #endif /* STM32F7xx_HAL_SPI_EX_H */
74 |
75 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
76 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_i2c_ex.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_i2c_ex.c
4 | * @author MCD Application Team
5 | * @brief I2C Extended HAL module driver.
6 | * This file provides firmware functions to manage the following
7 | * functionalities of I2C Extended peripheral:
8 | * + Extended features functions
9 | *
10 | @verbatim
11 | ==============================================================================
12 | ##### I2C peripheral Extended features #####
13 | ==============================================================================
14 |
15 | [..] Comparing to other previous devices, the I2C interface for STM32F7xx
16 | devices contains the following additional features
17 |
18 | (+) Possibility to disable or enable Analog Noise Filter
19 | (+) Use of a configured Digital Noise Filter
20 | (+) Disable or enable Fast Mode Plus
21 |
22 | ##### How to use this driver #####
23 | ==============================================================================
24 | [..] This driver provides functions to:
25 | (#) Configure I2C Analog noise filter using the function HAL_I2CEx_ConfigAnalogFilter()
26 | (#) Configure I2C Digital noise filter using the function HAL_I2CEx_ConfigDigitalFilter()
27 | (#) Configure the enable or disable of fast mode plus driving capability using the functions :
28 | (++) HAL_I2CEx_EnableFastModePlus()
29 | (++) HAL_I2CEx_DisableFastModePlus()
30 | @endverbatim
31 | ******************************************************************************
32 | * @attention
33 | *
34 | * © Copyright (c) 2017 STMicroelectronics.
35 | * All rights reserved.
36 | *
37 | * This software component is licensed by ST under BSD 3-Clause license,
38 | * the "License"; You may not use this file except in compliance with the
39 | * License. You may obtain a copy of the License at:
40 | * opensource.org/licenses/BSD-3-Clause
41 | *
42 | ******************************************************************************
43 | */
44 |
45 | /* Includes ------------------------------------------------------------------*/
46 | #include "stm32f7xx_hal.h"
47 |
48 | /** @addtogroup STM32F7xx_HAL_Driver
49 | * @{
50 | */
51 |
52 | /** @defgroup I2CEx I2CEx
53 | * @brief I2C Extended HAL module driver
54 | * @{
55 | */
56 |
57 | #ifdef HAL_I2C_MODULE_ENABLED
58 |
59 | /* Private typedef -----------------------------------------------------------*/
60 | /* Private define ------------------------------------------------------------*/
61 | /* Private macro -------------------------------------------------------------*/
62 | /* Private variables ---------------------------------------------------------*/
63 | /* Private function prototypes -----------------------------------------------*/
64 | /* Private functions ---------------------------------------------------------*/
65 |
66 | /** @defgroup I2CEx_Exported_Functions I2C Extended Exported Functions
67 | * @{
68 | */
69 |
70 | /** @defgroup I2CEx_Exported_Functions_Group1 Extended features functions
71 | * @brief Extended features functions
72 | *
73 | @verbatim
74 | ===============================================================================
75 | ##### Extended features functions #####
76 | ===============================================================================
77 | [..] This section provides functions allowing to:
78 | (+) Configure Noise Filters
79 | (+) Configure Fast Mode Plus
80 |
81 | @endverbatim
82 | * @{
83 | */
84 |
85 | /**
86 | * @brief Configure I2C Analog noise filter.
87 | * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
88 | * the configuration information for the specified I2Cx peripheral.
89 | * @param AnalogFilter New state of the Analog filter.
90 | * @retval HAL status
91 | */
92 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
93 | {
94 | /* Check the parameters */
95 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
96 | assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
97 |
98 | if (hi2c->State == HAL_I2C_STATE_READY)
99 | {
100 | /* Process Locked */
101 | __HAL_LOCK(hi2c);
102 |
103 | hi2c->State = HAL_I2C_STATE_BUSY;
104 |
105 | /* Disable the selected I2C peripheral */
106 | __HAL_I2C_DISABLE(hi2c);
107 |
108 | /* Reset I2Cx ANOFF bit */
109 | hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
110 |
111 | /* Set analog filter bit*/
112 | hi2c->Instance->CR1 |= AnalogFilter;
113 |
114 | __HAL_I2C_ENABLE(hi2c);
115 |
116 | hi2c->State = HAL_I2C_STATE_READY;
117 |
118 | /* Process Unlocked */
119 | __HAL_UNLOCK(hi2c);
120 |
121 | return HAL_OK;
122 | }
123 | else
124 | {
125 | return HAL_BUSY;
126 | }
127 | }
128 |
129 | /**
130 | * @brief Configure I2C Digital noise filter.
131 | * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
132 | * the configuration information for the specified I2Cx peripheral.
133 | * @param DigitalFilter Coefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F.
134 | * @retval HAL status
135 | */
136 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
137 | {
138 | uint32_t tmpreg;
139 |
140 | /* Check the parameters */
141 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
142 | assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
143 |
144 | if (hi2c->State == HAL_I2C_STATE_READY)
145 | {
146 | /* Process Locked */
147 | __HAL_LOCK(hi2c);
148 |
149 | hi2c->State = HAL_I2C_STATE_BUSY;
150 |
151 | /* Disable the selected I2C peripheral */
152 | __HAL_I2C_DISABLE(hi2c);
153 |
154 | /* Get the old register value */
155 | tmpreg = hi2c->Instance->CR1;
156 |
157 | /* Reset I2Cx DNF bits [11:8] */
158 | tmpreg &= ~(I2C_CR1_DNF);
159 |
160 | /* Set I2Cx DNF coefficient */
161 | tmpreg |= DigitalFilter << 8U;
162 |
163 | /* Store the new register value */
164 | hi2c->Instance->CR1 = tmpreg;
165 |
166 | __HAL_I2C_ENABLE(hi2c);
167 |
168 | hi2c->State = HAL_I2C_STATE_READY;
169 |
170 | /* Process Unlocked */
171 | __HAL_UNLOCK(hi2c);
172 |
173 | return HAL_OK;
174 | }
175 | else
176 | {
177 | return HAL_BUSY;
178 | }
179 | }
180 |
181 | #if (defined(SYSCFG_PMC_I2C_PB6_FMP) || defined(SYSCFG_PMC_I2C_PB7_FMP)) || (defined(SYSCFG_PMC_I2C_PB8_FMP) || defined(SYSCFG_PMC_I2C_PB9_FMP)) || (defined(SYSCFG_PMC_I2C1_FMP)) || (defined(SYSCFG_PMC_I2C2_FMP)) || defined(SYSCFG_PMC_I2C3_FMP) || defined(SYSCFG_PMC_I2C4_FMP)
182 | /**
183 | * @brief Enable the I2C fast mode plus driving capability.
184 | * @param ConfigFastModePlus Selects the pin.
185 | * This parameter can be one of the @ref I2CEx_FastModePlus values
186 | * @note For I2C1, fast mode plus driving capability can be enabled on all selected
187 | * I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
188 | * on each one of the following pins PB6, PB7, PB8 and PB9.
189 | * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
190 | * can be enabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
191 | * @note For all I2C2 pins fast mode plus driving capability can be enabled
192 | * only by using I2C_FASTMODEPLUS_I2C2 parameter.
193 | * @note For all I2C3 pins fast mode plus driving capability can be enabled
194 | * only by using I2C_FASTMODEPLUS_I2C3 parameter.
195 | * @note For all I2C4 pins fast mode plus driving capability can be enabled
196 | * only by using I2C_FASTMODEPLUS_I2C4 parameter.
197 | * @retval None
198 | */
199 | void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
200 | {
201 | /* Check the parameter */
202 | assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
203 |
204 | /* Enable SYSCFG clock */
205 | __HAL_RCC_SYSCFG_CLK_ENABLE();
206 |
207 | /* Enable fast mode plus driving capability for selected pin */
208 | SET_BIT(SYSCFG->PMC, (uint32_t)ConfigFastModePlus);
209 | }
210 |
211 | /**
212 | * @brief Disable the I2C fast mode plus driving capability.
213 | * @param ConfigFastModePlus Selects the pin.
214 | * This parameter can be one of the @ref I2CEx_FastModePlus values
215 | * @note For I2C1, fast mode plus driving capability can be disabled on all selected
216 | * I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
217 | * on each one of the following pins PB6, PB7, PB8 and PB9.
218 | * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
219 | * can be disabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
220 | * @note For all I2C2 pins fast mode plus driving capability can be disabled
221 | * only by using I2C_FASTMODEPLUS_I2C2 parameter.
222 | * @note For all I2C3 pins fast mode plus driving capability can be disabled
223 | * only by using I2C_FASTMODEPLUS_I2C3 parameter.
224 | * @note For all I2C4 pins fast mode plus driving capability can be disabled
225 | * only by using I2C_FASTMODEPLUS_I2C4 parameter.
226 | * @retval None
227 | */
228 | void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
229 | {
230 | /* Check the parameter */
231 | assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
232 |
233 | /* Enable SYSCFG clock */
234 | __HAL_RCC_SYSCFG_CLK_ENABLE();
235 |
236 | /* Disable fast mode plus driving capability for selected pin */
237 | CLEAR_BIT(SYSCFG->PMC, (uint32_t)ConfigFastModePlus);
238 | }
239 |
240 | #endif
241 | /**
242 | * @}
243 | */
244 |
245 | /**
246 | * @}
247 | */
248 |
249 | #endif /* HAL_I2C_MODULE_ENABLED */
250 | /**
251 | * @}
252 | */
253 |
254 | /**
255 | * @}
256 | */
257 |
258 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
259 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_pcd_ex.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_pcd_ex.c
4 | * @author MCD Application Team
5 | * @brief PCD Extended HAL module driver.
6 | * This file provides firmware functions to manage the following
7 | * functionalities of the USB Peripheral Controller:
8 | * + Extended features functions
9 | *
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * © Copyright (c) 2017 STMicroelectronics.
14 | * All rights reserved.
15 | *
16 | * This software component is licensed by ST under BSD 3-Clause license,
17 | * the "License"; You may not use this file except in compliance with the
18 | * License. You may obtain a copy of the License at:
19 | * opensource.org/licenses/BSD-3-Clause
20 | *
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes ------------------------------------------------------------------*/
25 | #include "stm32f7xx_hal.h"
26 |
27 | /** @addtogroup STM32F7xx_HAL_Driver
28 | * @{
29 | */
30 |
31 | /** @defgroup PCDEx PCDEx
32 | * @brief PCD Extended HAL module driver
33 | * @{
34 | */
35 |
36 | #ifdef HAL_PCD_MODULE_ENABLED
37 |
38 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
39 | /* Private types -------------------------------------------------------------*/
40 | /* Private variables ---------------------------------------------------------*/
41 | /* Private constants ---------------------------------------------------------*/
42 | /* Private macros ------------------------------------------------------------*/
43 | /* Private functions ---------------------------------------------------------*/
44 | /* Exported functions --------------------------------------------------------*/
45 |
46 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
47 | * @{
48 | */
49 |
50 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
51 | * @brief PCDEx control functions
52 | *
53 | @verbatim
54 | ===============================================================================
55 | ##### Extended features functions #####
56 | ===============================================================================
57 | [..] This section provides functions allowing to:
58 | (+) Update FIFO configuration
59 |
60 | @endverbatim
61 | * @{
62 | */
63 | #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
64 | /**
65 | * @brief Set Tx FIFO
66 | * @param hpcd PCD handle
67 | * @param fifo The number of Tx fifo
68 | * @param size Fifo size
69 | * @retval HAL status
70 | */
71 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
72 | {
73 | uint8_t i;
74 | uint32_t Tx_Offset;
75 |
76 | /* TXn min size = 16 words. (n : Transmit FIFO index)
77 | When a TxFIFO is not used, the Configuration should be as follows:
78 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes)
79 | --> Txm can use the space allocated for Txn.
80 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes)
81 | --> Txn should be configured with the minimum space of 16 words
82 | The FIFO is used optimally when used TxFIFOs are allocated in the top
83 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
84 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */
85 |
86 | Tx_Offset = hpcd->Instance->GRXFSIZ;
87 |
88 | if (fifo == 0U)
89 | {
90 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset;
91 | }
92 | else
93 | {
94 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16;
95 | for (i = 0U; i < (fifo - 1U); i++)
96 | {
97 | Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16);
98 | }
99 |
100 | /* Multiply Tx_Size by 2 to get higher performance */
101 | hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset;
102 | }
103 |
104 | return HAL_OK;
105 | }
106 |
107 | /**
108 | * @brief Set Rx FIFO
109 | * @param hpcd PCD handle
110 | * @param size Size of Rx fifo
111 | * @retval HAL status
112 | */
113 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size)
114 | {
115 | hpcd->Instance->GRXFSIZ = size;
116 |
117 | return HAL_OK;
118 | }
119 |
120 | /**
121 | * @brief Activate LPM feature.
122 | * @param hpcd PCD handle
123 | * @retval HAL status
124 | */
125 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd)
126 | {
127 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
128 |
129 | hpcd->lpm_active = 1U;
130 | hpcd->LPM_State = LPM_L0;
131 | USBx->GINTMSK |= USB_OTG_GINTMSK_LPMINTM;
132 | USBx->GLPMCFG |= (USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL);
133 |
134 | return HAL_OK;
135 | }
136 |
137 | /**
138 | * @brief Deactivate LPM feature.
139 | * @param hpcd PCD handle
140 | * @retval HAL status
141 | */
142 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd)
143 | {
144 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
145 |
146 | hpcd->lpm_active = 0U;
147 | USBx->GINTMSK &= ~USB_OTG_GINTMSK_LPMINTM;
148 | USBx->GLPMCFG &= ~(USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL);
149 |
150 | return HAL_OK;
151 | }
152 |
153 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
154 |
155 | /**
156 | * @brief Send LPM message to user layer callback.
157 | * @param hpcd PCD handle
158 | * @param msg LPM message
159 | * @retval HAL status
160 | */
161 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
162 | {
163 | /* Prevent unused argument(s) compilation warning */
164 | UNUSED(hpcd);
165 | UNUSED(msg);
166 |
167 | /* NOTE : This function should not be modified, when the callback is needed,
168 | the HAL_PCDEx_LPM_Callback could be implemented in the user file
169 | */
170 | }
171 |
172 | /**
173 | * @brief Send BatteryCharging message to user layer callback.
174 | * @param hpcd PCD handle
175 | * @param msg LPM message
176 | * @retval HAL status
177 | */
178 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg)
179 | {
180 | /* Prevent unused argument(s) compilation warning */
181 | UNUSED(hpcd);
182 | UNUSED(msg);
183 |
184 | /* NOTE : This function should not be modified, when the callback is needed,
185 | the HAL_PCDEx_BCD_Callback could be implemented in the user file
186 | */
187 | }
188 |
189 | /**
190 | * @}
191 | */
192 |
193 | /**
194 | * @}
195 | */
196 | #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
197 | #endif /* HAL_PCD_MODULE_ENABLED */
198 |
199 | /**
200 | * @}
201 | */
202 |
203 | /**
204 | * @}
205 | */
206 |
207 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
208 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_spi_ex.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f7xx_hal_spi_ex.c
4 | * @author MCD Application Team
5 | * @brief Extended SPI HAL module driver.
6 | * This file provides firmware functions to manage the following
7 | * SPI peripheral extended functionalities :
8 | * + IO operation functions
9 | *
10 | ******************************************************************************
11 | * @attention
12 | *
13 | * © Copyright (c) 2017 STMicroelectronics.
14 | * All rights reserved.
15 | *
16 | * This software component is licensed by ST under BSD 3-Clause license,
17 | * the "License"; You may not use this file except in compliance with the
18 | * License. You may obtain a copy of the License at:
19 | * opensource.org/licenses/BSD-3-Clause
20 | *
21 | ******************************************************************************
22 | */
23 |
24 | /* Includes ------------------------------------------------------------------*/
25 | #include "stm32f7xx_hal.h"
26 |
27 | /** @addtogroup STM32F7xx_HAL_Driver
28 | * @{
29 | */
30 |
31 | /** @defgroup SPIEx SPIEx
32 | * @brief SPI Extended HAL module driver
33 | * @{
34 | */
35 | #ifdef HAL_SPI_MODULE_ENABLED
36 |
37 | /* Private typedef -----------------------------------------------------------*/
38 | /* Private defines -----------------------------------------------------------*/
39 | /** @defgroup SPIEx_Private_Constants SPIEx Private Constants
40 | * @{
41 | */
42 | #define SPI_FIFO_SIZE 4UL
43 | /**
44 | * @}
45 | */
46 |
47 | /* Private macros ------------------------------------------------------------*/
48 | /* Private variables ---------------------------------------------------------*/
49 | /* Private function prototypes -----------------------------------------------*/
50 | /* Exported functions --------------------------------------------------------*/
51 |
52 | /** @defgroup SPIEx_Exported_Functions SPIEx Exported Functions
53 | * @{
54 | */
55 |
56 | /** @defgroup SPIEx_Exported_Functions_Group1 IO operation functions
57 | * @brief Data transfers functions
58 | *
59 | @verbatim
60 | ==============================================================================
61 | ##### IO operation functions #####
62 | ===============================================================================
63 | [..]
64 | This subsection provides a set of extended functions to manage the SPI
65 | data transfers.
66 |
67 | (#) Rx data flush function:
68 | (++) HAL_SPIEx_FlushRxFifo()
69 |
70 | @endverbatim
71 | * @{
72 | */
73 |
74 | /**
75 | * @brief Flush the RX fifo.
76 | * @param hspi pointer to a SPI_HandleTypeDef structure that contains
77 | * the configuration information for the specified SPI module.
78 | * @retval HAL status
79 | */
80 | HAL_StatusTypeDef HAL_SPIEx_FlushRxFifo(SPI_HandleTypeDef *hspi)
81 | {
82 | __IO uint32_t tmpreg;
83 | uint8_t count = 0U;
84 | while ((hspi->Instance->SR & SPI_FLAG_FRLVL) != SPI_FRLVL_EMPTY)
85 | {
86 | count++;
87 | tmpreg = hspi->Instance->DR;
88 | UNUSED(tmpreg); /* To avoid GCC warning */
89 | if (count == SPI_FIFO_SIZE)
90 | {
91 | return HAL_TIMEOUT;
92 | }
93 | }
94 | return HAL_OK;
95 | }
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | /**
102 | * @}
103 | */
104 |
105 | #endif /* HAL_SPI_MODULE_ENABLED */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /**
112 | * @}
113 | */
114 |
115 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
116 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/IMU/MPU9250.h:
--------------------------------------------------------------------------------
1 | #ifndef __MPU9250_H__
2 | #define __MPU9250_H__
3 | #include "SPI.h"
4 |
5 | #define MPU9250_SPI hspi1
6 | #define MPU9250_CS_GPIO 0
7 | #define MPU9250_CS_PIN 1
8 |
9 |
10 | extern SPI_HandleTypeDef hspi1;
11 |
12 | typedef enum accel_range {
13 | ACCEL_RANGE_2G = 0,
14 | ACCEL_RANGE_4G,
15 | ACCEL_RANGE_8G,
16 | ACCEL_RANGE_16G
17 | } accel_range;
18 |
19 | typedef enum gyro_range {
20 | GYRO_RANGE_250DPS = 0,
21 | GYRO_RANGE_500DPS,
22 | GYRO_RANGE_1000DPS,
23 | GYRO_RANGE_2000DPS
24 | } gyro_range;
25 |
26 | typedef enum dlpf_bandwidth {
27 | DLPF_BANDWIDTH_184HZ = 0,
28 | DLPF_BANDWIDTH_92HZ,
29 | DLPF_BANDWIDTH_41HZ,
30 | DLPF_BANDWIDTH_20HZ,
31 | DLPF_BANDWIDTH_10HZ,
32 | DLPF_BANDWIDTH_5HZ
33 | } dlpf_bandwidth;
34 |
35 | typedef enum sample_rate_divider {
36 | LP_ACCEL_ODR_0_24HZ = 0,
37 | LP_ACCEL_ODR_0_49HZ,
38 | LP_ACCEL_ODR_0_98HZ,
39 | LP_ACCEL_ODR_1_95HZ,
40 | LP_ACCEL_ODR_3_91HZ,
41 | LP_ACCEL_ODR_7_81HZ,
42 | LP_ACCEL_ODR_15_63HZ,
43 | LP_ACCEL_ODR_31_25HZ,
44 | LP_ACCEL_ODR_62_50HZ,
45 | LP_ACCEL_ODR_125HZ,
46 | LP_ACCEL_ODR_250HZ,
47 | LP_ACCEL_ODR_500HZ
48 | } sample_rate_divider;
49 |
50 | uint8_t MPU9250_init();
51 | void MPU9250_getData(int16_t* acc_data, int16_t* gyro_data, int16_t* mag_data);
52 | void MPU9250_setSampleRateDivider(sample_rate_divider value);
53 | void MPU9250_setDLPFBandwidth(dlpf_bandwidth value);
54 | void MPU9250_setAccelRange(accel_range range);
55 | void MPU9250_setGyroRange(gyro_range range);
56 |
57 | #endif /* __MPU9250_H__ */
58 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/IMU/SPI.h:
--------------------------------------------------------------------------------
1 | #ifndef __SPI_H__
2 | #define __SPI_H__
3 | #include "stm32f7xx_hal.h"
4 | extern SPI_HandleTypeDef hspi1;
5 |
6 | uint8_t SPI1_WriteRead(uint8_t Byte)
7 | {
8 | uint8_t receivedbyte = 0;
9 | if(HAL_SPI_TransmitReceive(&hspi1,(uint8_t*) &Byte,(uint8_t*) &receivedbyte,1,0x1000)!=HAL_OK)
10 | {
11 | return -1;
12 | }else
13 | {
14 | }
15 | return receivedbyte;
16 | }
17 |
18 |
19 | #endif /* __SPI_H__ */
20 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_cdc.h
4 | * @author MCD Application Team
5 | * @brief header file for the usbd_cdc.c file.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * http://www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USB_CDC_H
22 | #define __USB_CDC_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_ioreq.h"
30 |
31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
32 | * @{
33 | */
34 |
35 | /** @defgroup usbd_cdc
36 | * @brief This file is the Header file for usbd_cdc.c
37 | * @{
38 | */
39 |
40 |
41 | /** @defgroup usbd_cdc_Exported_Defines
42 | * @{
43 | */
44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */
45 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */
46 | #define CDC_CMD_EP 0x82U /* EP2 for CDC commands */
47 |
48 | #ifndef CDC_HS_BINTERVAL
49 | #define CDC_HS_BINTERVAL 0x10U
50 | #endif /* CDC_HS_BINTERVAL */
51 |
52 | #ifndef CDC_FS_BINTERVAL
53 | #define CDC_FS_BINTERVAL 0x10U
54 | #endif /* CDC_FS_BINTERVAL */
55 |
56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
59 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
60 |
61 | #define USB_CDC_CONFIG_DESC_SIZ 67U
62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
64 |
65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
67 |
68 | /*---------------------------------------------------------------------*/
69 | /* CDC definitions */
70 | /*---------------------------------------------------------------------*/
71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
73 | #define CDC_SET_COMM_FEATURE 0x02U
74 | #define CDC_GET_COMM_FEATURE 0x03U
75 | #define CDC_CLEAR_COMM_FEATURE 0x04U
76 | #define CDC_SET_LINE_CODING 0x20U
77 | #define CDC_GET_LINE_CODING 0x21U
78 | #define CDC_SET_CONTROL_LINE_STATE 0x22U
79 | #define CDC_SEND_BREAK 0x23U
80 |
81 | /**
82 | * @}
83 | */
84 |
85 |
86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
87 | * @{
88 | */
89 |
90 | /**
91 | * @}
92 | */
93 | typedef struct
94 | {
95 | uint32_t bitrate;
96 | uint8_t format;
97 | uint8_t paritytype;
98 | uint8_t datatype;
99 | }USBD_CDC_LineCodingTypeDef;
100 |
101 | typedef struct _USBD_CDC_Itf
102 | {
103 | int8_t (* Init) (void);
104 | int8_t (* DeInit) (void);
105 | int8_t (* Control) (uint8_t cmd, uint8_t* pbuf, uint16_t length);
106 | int8_t (* Receive) (uint8_t* Buf, uint32_t *Len);
107 |
108 | }USBD_CDC_ItfTypeDef;
109 |
110 |
111 | typedef struct
112 | {
113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */
114 | uint8_t CmdOpCode;
115 | uint8_t CmdLength;
116 | uint8_t *RxBuffer;
117 | uint8_t *TxBuffer;
118 | uint32_t RxLength;
119 | uint32_t TxLength;
120 |
121 | __IO uint32_t TxState;
122 | __IO uint32_t RxState;
123 | }
124 | USBD_CDC_HandleTypeDef;
125 |
126 |
127 |
128 | /** @defgroup USBD_CORE_Exported_Macros
129 | * @{
130 | */
131 |
132 | /**
133 | * @}
134 | */
135 |
136 | /** @defgroup USBD_CORE_Exported_Variables
137 | * @{
138 | */
139 |
140 | extern USBD_ClassTypeDef USBD_CDC;
141 | #define USBD_CDC_CLASS &USBD_CDC
142 | /**
143 | * @}
144 | */
145 |
146 | /** @defgroup USB_CORE_Exported_Functions
147 | * @{
148 | */
149 | uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev,
150 | USBD_CDC_ItfTypeDef *fops);
151 |
152 | uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev,
153 | uint8_t *pbuff,
154 | uint16_t length);
155 |
156 | uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev,
157 | uint8_t *pbuff);
158 |
159 | uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev);
160 |
161 | uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev);
162 | /**
163 | * @}
164 | */
165 |
166 | #ifdef __cplusplus
167 | }
168 | #endif
169 |
170 | #endif /* __USB_CDC_H */
171 | /**
172 | * @}
173 | */
174 |
175 | /**
176 | * @}
177 | */
178 |
179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
180 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_core.h
4 | * @author MCD Application Team
5 | * @brief Header file for usbd_core.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * http://www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USBD_CORE_H
22 | #define __USBD_CORE_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_conf.h"
30 | #include "usbd_def.h"
31 | #include "usbd_ioreq.h"
32 | #include "usbd_ctlreq.h"
33 |
34 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
35 | * @{
36 | */
37 |
38 | /** @defgroup USBD_CORE
39 | * @brief This file is the Header file for usbd_core.c file
40 | * @{
41 | */
42 |
43 |
44 | /** @defgroup USBD_CORE_Exported_Defines
45 | * @{
46 | */
47 | #ifndef USBD_DEBUG_LEVEL
48 | #define USBD_DEBUG_LEVEL 0U
49 | #endif /* USBD_DEBUG_LEVEL */
50 | /**
51 | * @}
52 | */
53 |
54 |
55 | /** @defgroup USBD_CORE_Exported_TypesDefinitions
56 | * @{
57 | */
58 |
59 |
60 | /**
61 | * @}
62 | */
63 |
64 |
65 |
66 | /** @defgroup USBD_CORE_Exported_Macros
67 | * @{
68 | */
69 |
70 | /**
71 | * @}
72 | */
73 |
74 | /** @defgroup USBD_CORE_Exported_Variables
75 | * @{
76 | */
77 | #define USBD_SOF USBD_LL_SOF
78 | /**
79 | * @}
80 | */
81 |
82 | /** @defgroup USBD_CORE_Exported_FunctionsPrototype
83 | * @{
84 | */
85 | USBD_StatusTypeDef USBD_Init(USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id);
86 | USBD_StatusTypeDef USBD_DeInit(USBD_HandleTypeDef *pdev);
87 | USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev);
88 | USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev);
89 | USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass);
90 |
91 | USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev);
92 | USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
93 | USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef *pdev, uint8_t cfgidx);
94 |
95 | USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup);
96 | USBD_StatusTypeDef USBD_LL_DataOutStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata);
97 | USBD_StatusTypeDef USBD_LL_DataInStage(USBD_HandleTypeDef *pdev , uint8_t epnum, uint8_t *pdata);
98 |
99 | USBD_StatusTypeDef USBD_LL_Reset(USBD_HandleTypeDef *pdev);
100 | USBD_StatusTypeDef USBD_LL_SetSpeed(USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed);
101 | USBD_StatusTypeDef USBD_LL_Suspend(USBD_HandleTypeDef *pdev);
102 | USBD_StatusTypeDef USBD_LL_Resume(USBD_HandleTypeDef *pdev);
103 |
104 | USBD_StatusTypeDef USBD_LL_SOF(USBD_HandleTypeDef *pdev);
105 | USBD_StatusTypeDef USBD_LL_IsoINIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
106 | USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete(USBD_HandleTypeDef *pdev, uint8_t epnum);
107 |
108 | USBD_StatusTypeDef USBD_LL_DevConnected(USBD_HandleTypeDef *pdev);
109 | USBD_StatusTypeDef USBD_LL_DevDisconnected(USBD_HandleTypeDef *pdev);
110 |
111 | /* USBD Low Level Driver */
112 | USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev);
113 | USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev);
114 | USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev);
115 | USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev);
116 | USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev,
117 | uint8_t ep_addr,
118 | uint8_t ep_type,
119 | uint16_t ep_mps);
120 |
121 | USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr);
122 | USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr);
123 | USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr);
124 | USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr);
125 | uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr);
126 | USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr);
127 | USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev,
128 | uint8_t ep_addr,
129 | uint8_t *pbuf,
130 | uint16_t size);
131 |
132 | USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev,
133 | uint8_t ep_addr,
134 | uint8_t *pbuf,
135 | uint16_t size);
136 |
137 | uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr);
138 | void USBD_LL_Delay (uint32_t Delay);
139 |
140 | /**
141 | * @}
142 | */
143 |
144 | #ifdef __cplusplus
145 | }
146 | #endif
147 |
148 | #endif /* __USBD_CORE_H */
149 |
150 | /**
151 | * @}
152 | */
153 |
154 | /**
155 | * @}
156 | */
157 |
158 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_ctlreq.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_req.h
4 | * @author MCD Application Team
5 | * @brief Header file for the usbd_req.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * http://www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __USB_REQUEST_H
22 | #define __USB_REQUEST_H
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | /* Includes ------------------------------------------------------------------*/
29 | #include "usbd_def.h"
30 |
31 |
32 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
33 | * @{
34 | */
35 |
36 | /** @defgroup USBD_REQ
37 | * @brief header file for the usbd_req.c file
38 | * @{
39 | */
40 |
41 | /** @defgroup USBD_REQ_Exported_Defines
42 | * @{
43 | */
44 | /**
45 | * @}
46 | */
47 |
48 |
49 | /** @defgroup USBD_REQ_Exported_Types
50 | * @{
51 | */
52 | /**
53 | * @}
54 | */
55 |
56 |
57 |
58 | /** @defgroup USBD_REQ_Exported_Macros
59 | * @{
60 | */
61 | /**
62 | * @}
63 | */
64 |
65 | /** @defgroup USBD_REQ_Exported_Variables
66 | * @{
67 | */
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBD_REQ_Exported_FunctionsPrototype
73 | * @{
74 | */
75 |
76 | USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
77 | USBD_StatusTypeDef USBD_StdItfReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
78 | USBD_StatusTypeDef USBD_StdEPReq (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
79 |
80 |
81 | void USBD_CtlError (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
82 |
83 | void USBD_ParseSetupRequest (USBD_SetupReqTypedef *req, uint8_t *pdata);
84 |
85 | void USBD_GetString (uint8_t *desc, uint8_t *unicode, uint16_t *len);
86 | /**
87 | * @}
88 | */
89 |
90 | #ifdef __cplusplus
91 | }
92 | #endif
93 |
94 | #endif /* __USB_REQUEST_H */
95 |
96 | /**
97 | * @}
98 | */
99 |
100 | /**
101 | * @}
102 | */
103 |
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file usbd_ioreq.c
4 | * @author MCD Application Team
5 | * @brief This file provides the IO requests APIs for control endpoints.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2015 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under Ultimate Liberty license
13 | * SLA0044, the "License"; You may not use this file except in compliance with
14 | * the License. You may obtain a copy of the License at:
15 | * http://www.st.com/SLA0044
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usbd_ioreq.h"
22 |
23 | /** @addtogroup STM32_USB_DEVICE_LIBRARY
24 | * @{
25 | */
26 |
27 |
28 | /** @defgroup USBD_IOREQ
29 | * @brief control I/O requests module
30 | * @{
31 | */
32 |
33 | /** @defgroup USBD_IOREQ_Private_TypesDefinitions
34 | * @{
35 | */
36 | /**
37 | * @}
38 | */
39 |
40 |
41 | /** @defgroup USBD_IOREQ_Private_Defines
42 | * @{
43 | */
44 |
45 | /**
46 | * @}
47 | */
48 |
49 |
50 | /** @defgroup USBD_IOREQ_Private_Macros
51 | * @{
52 | */
53 | /**
54 | * @}
55 | */
56 |
57 |
58 | /** @defgroup USBD_IOREQ_Private_Variables
59 | * @{
60 | */
61 |
62 | /**
63 | * @}
64 | */
65 |
66 |
67 | /** @defgroup USBD_IOREQ_Private_FunctionPrototypes
68 | * @{
69 | */
70 | /**
71 | * @}
72 | */
73 |
74 |
75 | /** @defgroup USBD_IOREQ_Private_Functions
76 | * @{
77 | */
78 |
79 | /**
80 | * @brief USBD_CtlSendData
81 | * send data on the ctl pipe
82 | * @param pdev: device instance
83 | * @param buff: pointer to data buffer
84 | * @param len: length of data to be sent
85 | * @retval status
86 | */
87 | USBD_StatusTypeDef USBD_CtlSendData (USBD_HandleTypeDef *pdev, uint8_t *pbuf,
88 | uint16_t len)
89 | {
90 | /* Set EP0 State */
91 | pdev->ep0_state = USBD_EP0_DATA_IN;
92 | pdev->ep_in[0].total_length = len;
93 | pdev->ep_in[0].rem_length = len;
94 |
95 | /* Start the transfer */
96 | USBD_LL_Transmit (pdev, 0x00U, pbuf, len);
97 |
98 | return USBD_OK;
99 | }
100 |
101 | /**
102 | * @brief USBD_CtlContinueSendData
103 | * continue sending data on the ctl pipe
104 | * @param pdev: device instance
105 | * @param buff: pointer to data buffer
106 | * @param len: length of data to be sent
107 | * @retval status
108 | */
109 | USBD_StatusTypeDef USBD_CtlContinueSendData (USBD_HandleTypeDef *pdev,
110 | uint8_t *pbuf, uint16_t len)
111 | {
112 | /* Start the next transfer */
113 | USBD_LL_Transmit (pdev, 0x00U, pbuf, len);
114 |
115 | return USBD_OK;
116 | }
117 |
118 | /**
119 | * @brief USBD_CtlPrepareRx
120 | * receive data on the ctl pipe
121 | * @param pdev: device instance
122 | * @param buff: pointer to data buffer
123 | * @param len: length of data to be received
124 | * @retval status
125 | */
126 | USBD_StatusTypeDef USBD_CtlPrepareRx (USBD_HandleTypeDef *pdev, uint8_t *pbuf,
127 | uint16_t len)
128 | {
129 | /* Set EP0 State */
130 | pdev->ep0_state = USBD_EP0_DATA_OUT;
131 | pdev->ep_out[0].total_length = len;
132 | pdev->ep_out[0].rem_length = len;
133 |
134 | /* Start the transfer */
135 | USBD_LL_PrepareReceive (pdev, 0U, pbuf, len);
136 |
137 | return USBD_OK;
138 | }
139 |
140 | /**
141 | * @brief USBD_CtlContinueRx
142 | * continue receive data on the ctl pipe
143 | * @param pdev: device instance
144 | * @param buff: pointer to data buffer
145 | * @param len: length of data to be received
146 | * @retval status
147 | */
148 | USBD_StatusTypeDef USBD_CtlContinueRx (USBD_HandleTypeDef *pdev, uint8_t *pbuf,
149 | uint16_t len)
150 | {
151 | USBD_LL_PrepareReceive(pdev, 0U, pbuf, len);
152 |
153 | return USBD_OK;
154 | }
155 |
156 | /**
157 | * @brief USBD_CtlSendStatus
158 | * send zero lzngth packet on the ctl pipe
159 | * @param pdev: device instance
160 | * @retval status
161 | */
162 | USBD_StatusTypeDef USBD_CtlSendStatus (USBD_HandleTypeDef *pdev)
163 | {
164 | /* Set EP0 State */
165 | pdev->ep0_state = USBD_EP0_STATUS_IN;
166 |
167 | /* Start the transfer */
168 | USBD_LL_Transmit(pdev, 0x00U, NULL, 0U);
169 |
170 | return USBD_OK;
171 | }
172 |
173 | /**
174 | * @brief USBD_CtlReceiveStatus
175 | * receive zero lzngth packet on the ctl pipe
176 | * @param pdev: device instance
177 | * @retval status
178 | */
179 | USBD_StatusTypeDef USBD_CtlReceiveStatus (USBD_HandleTypeDef *pdev)
180 | {
181 | /* Set EP0 State */
182 | pdev->ep0_state = USBD_EP0_STATUS_OUT;
183 |
184 | /* Start the transfer */
185 | USBD_LL_PrepareReceive (pdev, 0U, NULL, 0U);
186 |
187 | return USBD_OK;
188 | }
189 |
190 | /**
191 | * @brief USBD_GetRxCount
192 | * returns the received data length
193 | * @param pdev: device instance
194 | * @param ep_addr: endpoint address
195 | * @retval Rx Data blength
196 | */
197 | uint32_t USBD_GetRxCount (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
198 | {
199 | return USBD_LL_GetRxDataSize(pdev, ep_addr);
200 | }
201 |
202 | /**
203 | * @}
204 | */
205 |
206 |
207 | /**
208 | * @}
209 | */
210 |
211 |
212 | /**
213 | * @}
214 | */
215 |
216 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
217 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/command.pb.c:
--------------------------------------------------------------------------------
1 | /* Automatically generated nanopb constant definitions */
2 | /* Generated by nanopb-0.4.0-dev */
3 |
4 | #include "command.pb.h"
5 |
6 | /* @@protoc_insertion_point(includes) */
7 | #if PB_PROTO_HEADER_VERSION != 40
8 | #error Regenerate this file with the current version of nanopb generator.
9 | #endif
10 |
11 | PB_BIND(Command, Command, AUTO)
12 |
13 |
14 |
15 | /* @@protoc_insertion_point(eof) */
16 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/command.pb.h:
--------------------------------------------------------------------------------
1 | /* Automatically generated nanopb header */
2 | /* Generated by nanopb-0.4.0-dev */
3 |
4 | #ifndef PB_COMMAND_PB_H_INCLUDED
5 | #define PB_COMMAND_PB_H_INCLUDED
6 | #include
7 |
8 | /* @@protoc_insertion_point(includes) */
9 | #if PB_PROTO_HEADER_VERSION != 40
10 | #error Regenerate this file with the current version of nanopb generator.
11 | #endif
12 |
13 | #ifdef __cplusplus
14 | extern "C" {
15 | #endif
16 |
17 | /* Struct definitions */
18 | typedef struct _Command {
19 | int32_t type;
20 | bool has_id;
21 | int32_t id;
22 | bool has_header;
23 | int32_t header;
24 | pb_callback_t debug_info;
25 | /* @@protoc_insertion_point(struct:Command) */
26 | } Command;
27 |
28 |
29 | /* Initializer values for message structs */
30 | #define Command_init_default {0, false, 0, false, 0, {{NULL}, NULL}}
31 | #define Command_init_zero {0, false, 0, false, 0, {{NULL}, NULL}}
32 |
33 | /* Field tags (for use in manual encoding/decoding) */
34 | #define Command_type_tag 1
35 | #define Command_id_tag 2
36 | #define Command_header_tag 3
37 | #define Command_debug_info_tag 4
38 |
39 | /* Struct field encoding specification for nanopb */
40 | #define Command_FIELDLIST(X, a) \
41 | X(a, STATIC, REQUIRED, INT32, type, 1) \
42 | X(a, STATIC, OPTIONAL, INT32, id, 2) \
43 | X(a, STATIC, OPTIONAL, INT32, header, 3) \
44 | X(a, CALLBACK, REPEATED, INT32, debug_info, 4)
45 | #define Command_CALLBACK pb_default_field_callback
46 | #define Command_DEFAULT NULL
47 |
48 | extern const pb_msgdesc_t Command_msg;
49 |
50 | /* Defines for backwards compatibility with code written before nanopb-0.4.0 */
51 | #define Command_fields &Command_msg
52 |
53 | /* Maximum encoded size of messages (where known) */
54 | /* Command_size depends on runtime parameters */
55 |
56 | #ifdef __cplusplus
57 | } /* extern "C" */
58 | #endif
59 | /* @@protoc_insertion_point(eof) */
60 |
61 | #endif
62 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/command.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto2";
2 |
3 | message Command {
4 | required int32 type = 1;
5 | optional int32 id = 2;
6 | optional int32 header = 3;
7 | repeated int32 debug_info = 4;
8 | }
9 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/pb_common.c:
--------------------------------------------------------------------------------
1 | /* pb_common.c: Common support functions for pb_encode.c and pb_decode.c.
2 | *
3 | * 2014 Petteri Aimonen
4 | */
5 |
6 | #include "pb_common.h"
7 |
8 | static bool load_descriptor_values(pb_field_iter_t *iter)
9 | {
10 | uint32_t word0;
11 | uint32_t data_offset;
12 | uint8_t format;
13 | int8_t size_offset;
14 |
15 | if (iter->index >= iter->descriptor->field_count)
16 | return false;
17 |
18 | word0 = iter->descriptor->field_info[iter->field_info_index];
19 | format = word0 & 3;
20 | iter->tag = (pb_size_t)((word0 >> 2) & 0x3F);
21 | iter->type = (pb_type_t)((word0 >> 8) & 0xFF);
22 |
23 | if (format == 0)
24 | {
25 | /* 1-word format */
26 | iter->array_size = 1;
27 | size_offset = (int8_t)((word0 >> 24) & 0x0F);
28 | data_offset = (word0 >> 16) & 0xFF;
29 | iter->data_size = (pb_size_t)((word0 >> 28) & 0x0F);
30 | }
31 | else if (format == 1)
32 | {
33 | /* 2-word format */
34 | uint32_t word1 = iter->descriptor->field_info[iter->field_info_index + 1];
35 |
36 | iter->array_size = (pb_size_t)((word0 >> 16) & 0x0FFF);
37 | iter->tag = (pb_size_t)(iter->tag | ((word1 >> 28) << 6));
38 | size_offset = (int8_t)((word0 >> 28) & 0x0F);
39 | data_offset = word1 & 0xFFFF;
40 | iter->data_size = (pb_size_t)((word1 >> 16) & 0x0FFF);
41 | }
42 | else if (format == 2)
43 | {
44 | /* 4-word format */
45 | uint32_t word1 = iter->descriptor->field_info[iter->field_info_index + 1];
46 | uint32_t word2 = iter->descriptor->field_info[iter->field_info_index + 2];
47 | uint32_t word3 = iter->descriptor->field_info[iter->field_info_index + 3];
48 |
49 | iter->array_size = (pb_size_t)(word0 >> 16);
50 | iter->tag = (pb_size_t)(iter->tag | ((word1 >> 8) << 6));
51 | size_offset = (int8_t)(word1 & 0xFF);
52 | data_offset = word2;
53 | iter->data_size = (pb_size_t)word3;
54 | }
55 | else
56 | {
57 | /* 8-word format */
58 | uint32_t word1 = iter->descriptor->field_info[iter->field_info_index + 1];
59 | uint32_t word2 = iter->descriptor->field_info[iter->field_info_index + 2];
60 | uint32_t word3 = iter->descriptor->field_info[iter->field_info_index + 3];
61 | uint32_t word4 = iter->descriptor->field_info[iter->field_info_index + 4];
62 |
63 | iter->array_size = (pb_size_t)word4;
64 | iter->tag = (pb_size_t)(iter->tag | ((word1 >> 8) << 6));
65 | size_offset = (int8_t)(word1 & 0xFF);
66 | data_offset = word2;
67 | iter->data_size = (pb_size_t)word3;
68 | }
69 |
70 | iter->pField = (char*)iter->message + data_offset;
71 |
72 | if (size_offset)
73 | {
74 | iter->pSize = (char*)iter->pField - size_offset;
75 | }
76 | else if (PB_HTYPE(iter->type) == PB_HTYPE_REPEATED &&
77 | (PB_ATYPE(iter->type) == PB_ATYPE_STATIC ||
78 | PB_ATYPE(iter->type) == PB_ATYPE_POINTER))
79 | {
80 | /* Fixed count array */
81 | iter->pSize = &iter->array_size;
82 | }
83 | else
84 | {
85 | iter->pSize = NULL;
86 | }
87 |
88 | if (PB_ATYPE(iter->type) == PB_ATYPE_POINTER && iter->pField != NULL)
89 | {
90 | iter->pData = *(void**)iter->pField;
91 | }
92 | else
93 | {
94 | iter->pData = iter->pField;
95 | }
96 |
97 | if (PB_LTYPE(iter->type) == PB_LTYPE_SUBMESSAGE)
98 | {
99 | iter->submsg_desc = iter->descriptor->submsg_info[iter->submessage_index];
100 | }
101 | else
102 | {
103 | iter->submsg_desc = NULL;
104 | }
105 |
106 | return true;
107 | }
108 |
109 | static void advance_iterator(pb_field_iter_t *iter)
110 | {
111 | iter->index++;
112 |
113 | if (iter->index >= iter->descriptor->field_count)
114 | {
115 | /* Restart */
116 | iter->index = 0;
117 | iter->field_info_index = 0;
118 | iter->submessage_index = 0;
119 | iter->required_field_index = 0;
120 | }
121 | else
122 | {
123 | /* Increment indexes based on previous field type.
124 | * All field info formats have the following fields:
125 | * - lowest 2 bits tell the amount of words in the descriptor (2^n words)
126 | * - bits 2..7 give the lowest bits of tag number.
127 | * - bits 8..15 give the field type.
128 | */
129 | uint32_t prev_descriptor = iter->descriptor->field_info[iter->field_info_index];
130 | pb_type_t prev_type = (prev_descriptor >> 8) & 0xFF;
131 | pb_size_t descriptor_len = (pb_size_t)(1 << (prev_descriptor & 3));
132 |
133 | iter->field_info_index = (pb_size_t)(iter->field_info_index + descriptor_len);
134 |
135 | if (PB_HTYPE(prev_type) == PB_HTYPE_REQUIRED)
136 | {
137 | iter->required_field_index++;
138 | }
139 |
140 | if (PB_LTYPE(prev_type) == PB_LTYPE_SUBMESSAGE)
141 | {
142 | iter->submessage_index++;
143 | }
144 | }
145 | }
146 |
147 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_msgdesc_t *desc, void *message)
148 | {
149 | memset(iter, 0, sizeof(*iter));
150 |
151 | iter->descriptor = desc;
152 | iter->message = message;
153 |
154 | return load_descriptor_values(iter);
155 | }
156 |
157 | bool pb_field_iter_begin_extension(pb_field_iter_t *iter, pb_extension_t *extension)
158 | {
159 | const pb_msgdesc_t *msg = (const pb_msgdesc_t*)extension->type->arg;
160 | bool status;
161 |
162 | if (PB_ATYPE(msg->field_info[0] >> 8) == PB_ATYPE_POINTER)
163 | {
164 | /* For pointer extensions, the pointer is stored directly
165 | * in the extension structure. This avoids having an extra
166 | * indirection. */
167 | status = pb_field_iter_begin(iter, msg, &extension->dest);
168 | }
169 | else
170 | {
171 | status = pb_field_iter_begin(iter, msg, extension->dest);
172 | }
173 |
174 | iter->pSize = &extension->found;
175 | return status;
176 | }
177 |
178 | bool pb_field_iter_next(pb_field_iter_t *iter)
179 | {
180 | advance_iterator(iter);
181 | (void)load_descriptor_values(iter);
182 | return iter->index != 0;
183 | }
184 |
185 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag)
186 | {
187 | if (iter->tag == tag)
188 | {
189 | return true; /* Nothing to do, correct field already. */
190 | }
191 | else
192 | {
193 | pb_size_t start = iter->index;
194 | uint32_t fieldinfo;
195 |
196 | do
197 | {
198 | /* Advance iterator but don't load values yet */
199 | advance_iterator(iter);
200 |
201 | /* Do fast check for tag number match */
202 | fieldinfo = iter->descriptor->field_info[iter->field_info_index];
203 |
204 | if (((fieldinfo >> 2) & 0x3F) == (tag & 0x3F))
205 | {
206 | /* Good candidate, check further */
207 | (void)load_descriptor_values(iter);
208 |
209 | if (iter->tag == tag &&
210 | PB_LTYPE(iter->type) != PB_LTYPE_EXTENSION)
211 | {
212 | /* Found it */
213 | return true;
214 | }
215 | }
216 | } while (iter->index != start);
217 |
218 | /* Searched all the way back to start, and found nothing. */
219 | (void)load_descriptor_values(iter);
220 | return false;
221 | }
222 | }
223 |
224 | bool pb_default_field_callback(pb_istream_t *istream, pb_ostream_t *ostream, const pb_field_t *field)
225 | {
226 | if (field->data_size == sizeof(pb_callback_t))
227 | {
228 | pb_callback_t *pCallback = (pb_callback_t*)field->pData;
229 |
230 | if (pCallback != NULL)
231 | {
232 | if (istream != NULL && pCallback->funcs.decode != NULL)
233 | {
234 | #ifdef PB_OLD_CALLBACK_STYLE
235 | return pCallback->funcs.decode(istream, field, pCallback->arg);
236 | #else
237 | return pCallback->funcs.decode(istream, field, &pCallback->arg);
238 | #endif
239 | }
240 |
241 | if (ostream != NULL && pCallback->funcs.encode != NULL)
242 | {
243 | #ifdef PB_OLD_CALLBACK_STYLE
244 | return pCallback->funcs.encode(ostream, field, pCallback->arg);
245 | #else
246 | return pCallback->funcs.encode(ostream, field, &pCallback->arg);
247 | #endif
248 | }
249 | }
250 | }
251 |
252 | return true; /* Success, but didn't do anything */
253 |
254 | }
255 |
256 |
257 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/pb_common.h:
--------------------------------------------------------------------------------
1 | /* pb_common.h: Common support functions for pb_encode.c and pb_decode.c.
2 | * These functions are rarely needed by applications directly.
3 | */
4 |
5 | #ifndef PB_COMMON_H_INCLUDED
6 | #define PB_COMMON_H_INCLUDED
7 |
8 | #include "pb.h"
9 |
10 | #ifdef __cplusplus
11 | extern "C" {
12 | #endif
13 |
14 | /* Initialize the field iterator structure to beginning.
15 | * Returns false if the message type is empty. */
16 | bool pb_field_iter_begin(pb_field_iter_t *iter, const pb_msgdesc_t *desc, void *message);
17 |
18 | /* Get a field iterator for extension field. */
19 | bool pb_field_iter_begin_extension(pb_field_iter_t *iter, pb_extension_t *extension);
20 |
21 | /* Advance the iterator to the next field.
22 | * Returns false when the iterator wraps back to the first field. */
23 | bool pb_field_iter_next(pb_field_iter_t *iter);
24 |
25 | /* Advance the iterator until it points at a field with the given tag.
26 | * Returns false if no such field exists. */
27 | bool pb_field_iter_find(pb_field_iter_t *iter, uint32_t tag);
28 |
29 | #ifdef __cplusplus
30 | } /* extern "C" */
31 | #endif
32 |
33 | #endif
34 |
35 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/pb_decode.h:
--------------------------------------------------------------------------------
1 | /* pb_decode.h: Functions to decode protocol buffers. Depends on pb_decode.c.
2 | * The main function is pb_decode. You also need an input stream, and the
3 | * field descriptions created by nanopb_generator.py.
4 | */
5 |
6 | #ifndef PB_DECODE_H_INCLUDED
7 | #define PB_DECODE_H_INCLUDED
8 |
9 | #include "pb.h"
10 |
11 | #ifdef __cplusplus
12 | extern "C" {
13 | #endif
14 |
15 | /* Structure for defining custom input streams. You will need to provide
16 | * a callback function to read the bytes from your storage, which can be
17 | * for example a file or a network socket.
18 | *
19 | * The callback must conform to these rules:
20 | *
21 | * 1) Return false on IO errors. This will cause decoding to abort.
22 | * 2) You can use state to store your own data (e.g. buffer pointer),
23 | * and rely on pb_read to verify that no-body reads past bytes_left.
24 | * 3) Your callback may be used with substreams, in which case bytes_left
25 | * is different than from the main stream. Don't use bytes_left to compute
26 | * any pointers.
27 | */
28 | struct pb_istream_s
29 | {
30 | #ifdef PB_BUFFER_ONLY
31 | /* Callback pointer is not used in buffer-only configuration.
32 | * Having an int pointer here allows binary compatibility but
33 | * gives an error if someone tries to assign callback function.
34 | */
35 | int *callback;
36 | #else
37 | bool (*callback)(pb_istream_t *stream, pb_byte_t *buf, size_t count);
38 | #endif
39 |
40 | void *state; /* Free field for use by callback implementation */
41 | size_t bytes_left;
42 |
43 | #ifndef PB_NO_ERRMSG
44 | const char *errmsg;
45 | #endif
46 | };
47 |
48 | #ifndef PB_NO_ERRMSG
49 | #define PB_ISTREAM_EMPTY {0,0,0,0}
50 | #else
51 | #define PB_ISTREAM_EMPTY {0,0,0}
52 | #endif
53 |
54 | /***************************
55 | * Main decoding functions *
56 | ***************************/
57 |
58 | /* Decode a single protocol buffers message from input stream into a C structure.
59 | * Returns true on success, false on any failure.
60 | * The actual struct pointed to by dest must match the description in fields.
61 | * Callback fields of the destination structure must be initialized by caller.
62 | * All other fields will be initialized by this function.
63 | *
64 | * Example usage:
65 | * MyMessage msg = {};
66 | * uint8_t buffer[64];
67 | * pb_istream_t stream;
68 | *
69 | * // ... read some data into buffer ...
70 | *
71 | * stream = pb_istream_from_buffer(buffer, count);
72 | * pb_decode(&stream, MyMessage_fields, &msg);
73 | */
74 | bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct);
75 |
76 | /* Extended version of pb_decode, with several options to control
77 | * the decoding process:
78 | *
79 | * PB_DECODE_NOINIT: Do not initialize the fields to default values.
80 | * This is slightly faster if you do not need the default
81 | * values and instead initialize the structure to 0 using
82 | * e.g. memset(). This can also be used for merging two
83 | * messages, i.e. combine already existing data with new
84 | * values.
85 | *
86 | * PB_DECODE_DELIMITED: Input message starts with the message size as varint.
87 | * Corresponds to parseDelimitedFrom() in Google's
88 | * protobuf API.
89 | *
90 | * PB_DECODE_NULLTERMINATED: Stop reading when field tag is read as 0. This allows
91 | * reading null terminated messages.
92 | * NOTE: Until nanopb-0.4.0, pb_decode() also allows
93 | * null-termination. This behaviour is not supported in
94 | * most other protobuf implementations, so PB_DECODE_DELIMITED
95 | * is a better option for compatibility.
96 | *
97 | * Multiple flags can be combined with bitwise or (| operator)
98 | */
99 | #define PB_DECODE_NOINIT 0x01U
100 | #define PB_DECODE_DELIMITED 0x02U
101 | #define PB_DECODE_NULLTERMINATED 0x04U
102 | bool pb_decode_ex(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct, unsigned int flags);
103 |
104 | /* Defines for backwards compatibility with code written before nanopb-0.4.0 */
105 | #define pb_decode_noinit(s,f,d) pb_decode_ex(s,f,d, PB_DECODE_NOINIT)
106 | #define pb_decode_delimited(s,f,d) pb_decode_ex(s,f,d, PB_DECODE_DELIMITED)
107 | #define pb_decode_delimited_noinit(s,f,d) pb_decode_ex(s,f,d, PB_DECODE_DELIMITED | PB_DECODE_NOINIT)
108 | #define pb_decode_nullterminated(s,f,d) pb_decode_ex(s,f,d, PB_DECODE_NULLTERMINATED)
109 |
110 | #ifdef PB_ENABLE_MALLOC
111 | /* Release any allocated pointer fields. If you use dynamic allocation, you should
112 | * call this for any successfully decoded message when you are done with it. If
113 | * pb_decode() returns with an error, the message is already released.
114 | */
115 | void pb_release(const pb_msgdesc_t *fields, void *dest_struct);
116 | #endif
117 |
118 |
119 | /**************************************
120 | * Functions for manipulating streams *
121 | **************************************/
122 |
123 | /* Create an input stream for reading from a memory buffer.
124 | *
125 | * Alternatively, you can use a custom stream that reads directly from e.g.
126 | * a file or a network socket.
127 | */
128 | pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t bufsize);
129 |
130 | /* Function to read from a pb_istream_t. You can use this if you need to
131 | * read some custom header data, or to read data in field callbacks.
132 | */
133 | bool pb_read(pb_istream_t *stream, pb_byte_t *buf, size_t count);
134 |
135 |
136 | /************************************************
137 | * Helper functions for writing field callbacks *
138 | ************************************************/
139 |
140 | /* Decode the tag for the next field in the stream. Gives the wire type and
141 | * field tag. At end of the message, returns false and sets eof to true. */
142 | bool pb_decode_tag(pb_istream_t *stream, pb_wire_type_t *wire_type, uint32_t *tag, bool *eof);
143 |
144 | /* Skip the field payload data, given the wire type. */
145 | bool pb_skip_field(pb_istream_t *stream, pb_wire_type_t wire_type);
146 |
147 | /* Decode an integer in the varint format. This works for enum, int32,
148 | * int64, uint32 and uint64 field types. */
149 | #ifndef PB_WITHOUT_64BIT
150 | bool pb_decode_varint(pb_istream_t *stream, uint64_t *dest);
151 | #else
152 | #define pb_decode_varint pb_decode_varint32
153 | #endif
154 |
155 | /* Decode an integer in the varint format. This works for enum, int32,
156 | * and uint32 field types. */
157 | bool pb_decode_varint32(pb_istream_t *stream, uint32_t *dest);
158 |
159 | /* Decode a bool value in varint format. */
160 | bool pb_decode_bool(pb_istream_t *stream, bool *dest);
161 |
162 | /* Decode an integer in the zig-zagged svarint format. This works for sint32
163 | * and sint64. */
164 | #ifndef PB_WITHOUT_64BIT
165 | bool pb_decode_svarint(pb_istream_t *stream, int64_t *dest);
166 | #else
167 | bool pb_decode_svarint(pb_istream_t *stream, int32_t *dest);
168 | #endif
169 |
170 | /* Decode a fixed32, sfixed32 or float value. You need to pass a pointer to
171 | * a 4-byte wide C variable. */
172 | bool pb_decode_fixed32(pb_istream_t *stream, void *dest);
173 |
174 | #ifndef PB_WITHOUT_64BIT
175 | /* Decode a fixed64, sfixed64 or double value. You need to pass a pointer to
176 | * a 8-byte wide C variable. */
177 | bool pb_decode_fixed64(pb_istream_t *stream, void *dest);
178 | #endif
179 |
180 | /* Make a limited-length substream for reading a PB_WT_STRING field. */
181 | bool pb_make_string_substream(pb_istream_t *stream, pb_istream_t *substream);
182 | bool pb_close_string_substream(pb_istream_t *stream, pb_istream_t *substream);
183 |
184 | #ifdef __cplusplus
185 | } /* extern "C" */
186 | #endif
187 |
188 | #endif
189 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/PROTOBUF/pb_encode.h:
--------------------------------------------------------------------------------
1 | /* pb_encode.h: Functions to encode protocol buffers. Depends on pb_encode.c.
2 | * The main function is pb_encode. You also need an output stream, and the
3 | * field descriptions created by nanopb_generator.py.
4 | */
5 |
6 | #ifndef PB_ENCODE_H_INCLUDED
7 | #define PB_ENCODE_H_INCLUDED
8 |
9 | #include "pb.h"
10 |
11 | #ifdef __cplusplus
12 | extern "C" {
13 | #endif
14 |
15 | /* Structure for defining custom output streams. You will need to provide
16 | * a callback function to write the bytes to your storage, which can be
17 | * for example a file or a network socket.
18 | *
19 | * The callback must conform to these rules:
20 | *
21 | * 1) Return false on IO errors. This will cause encoding to abort.
22 | * 2) You can use state to store your own data (e.g. buffer pointer).
23 | * 3) pb_write will update bytes_written after your callback runs.
24 | * 4) Substreams will modify max_size and bytes_written. Don't use them
25 | * to calculate any pointers.
26 | */
27 | struct pb_ostream_s
28 | {
29 | #ifdef PB_BUFFER_ONLY
30 | /* Callback pointer is not used in buffer-only configuration.
31 | * Having an int pointer here allows binary compatibility but
32 | * gives an error if someone tries to assign callback function.
33 | * Also, NULL pointer marks a 'sizing stream' that does not
34 | * write anything.
35 | */
36 | int *callback;
37 | #else
38 | bool (*callback)(pb_ostream_t *stream, const pb_byte_t *buf, size_t count);
39 | #endif
40 | void *state; /* Free field for use by callback implementation. */
41 | size_t max_size; /* Limit number of output bytes written (or use SIZE_MAX). */
42 | size_t bytes_written; /* Number of bytes written so far. */
43 |
44 | #ifndef PB_NO_ERRMSG
45 | const char *errmsg;
46 | #endif
47 | };
48 |
49 | /***************************
50 | * Main encoding functions *
51 | ***************************/
52 |
53 | /* Encode a single protocol buffers message from C structure into a stream.
54 | * Returns true on success, false on any failure.
55 | * The actual struct pointed to by src_struct must match the description in fields.
56 | * All required fields in the struct are assumed to have been filled in.
57 | *
58 | * Example usage:
59 | * MyMessage msg = {};
60 | * uint8_t buffer[64];
61 | * pb_ostream_t stream;
62 | *
63 | * msg.field1 = 42;
64 | * stream = pb_ostream_from_buffer(buffer, sizeof(buffer));
65 | * pb_encode(&stream, MyMessage_fields, &msg);
66 | */
67 | bool pb_encode(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct);
68 |
69 | /* Extended version of pb_encode, with several options to control the
70 | * encoding process:
71 | *
72 | * PB_ENCODE_DELIMITED: Prepend the length of message as a varint.
73 | * Corresponds to writeDelimitedTo() in Google's
74 | * protobuf API.
75 | *
76 | * PB_ENCODE_NULLTERMINATED: Append a null byte to the message for termination.
77 | * NOTE: This behaviour is not supported in most other
78 | * protobuf implementations, so PB_ENCODE_DELIMITED
79 | * is a better option for compatibility.
80 | */
81 | #define PB_ENCODE_DELIMITED 0x02U
82 | #define PB_ENCODE_NULLTERMINATED 0x04U
83 | bool pb_encode_ex(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct, unsigned int flags);
84 |
85 | /* Defines for backwards compatibility with code written before nanopb-0.4.0 */
86 | #define pb_encode_delimited(s,f,d) pb_encode_ex(s,f,d, PB_ENCODE_DELIMITED)
87 | #define pb_encode_nullterminated(s,f,d) pb_encode_ex(s,f,d, PB_ENCODE_NULLTERMINATED)
88 |
89 | /* Encode the message to get the size of the encoded data, but do not store
90 | * the data. */
91 | bool pb_get_encoded_size(size_t *size, const pb_msgdesc_t *fields, const void *src_struct);
92 |
93 | /**************************************
94 | * Functions for manipulating streams *
95 | **************************************/
96 |
97 | /* Create an output stream for writing into a memory buffer.
98 | * The number of bytes written can be found in stream.bytes_written after
99 | * encoding the message.
100 | *
101 | * Alternatively, you can use a custom stream that writes directly to e.g.
102 | * a file or a network socket.
103 | */
104 | pb_ostream_t pb_ostream_from_buffer(pb_byte_t *buf, size_t bufsize);
105 |
106 | /* Pseudo-stream for measuring the size of a message without actually storing
107 | * the encoded data.
108 | *
109 | * Example usage:
110 | * MyMessage msg = {};
111 | * pb_ostream_t stream = PB_OSTREAM_SIZING;
112 | * pb_encode(&stream, MyMessage_fields, &msg);
113 | * printf("Message size is %d\n", stream.bytes_written);
114 | */
115 | #ifndef PB_NO_ERRMSG
116 | #define PB_OSTREAM_SIZING {0,0,0,0,0}
117 | #else
118 | #define PB_OSTREAM_SIZING {0,0,0,0}
119 | #endif
120 |
121 | /* Function to write into a pb_ostream_t stream. You can use this if you need
122 | * to append or prepend some custom headers to the message.
123 | */
124 | bool pb_write(pb_ostream_t *stream, const pb_byte_t *buf, size_t count);
125 |
126 |
127 | /************************************************
128 | * Helper functions for writing field callbacks *
129 | ************************************************/
130 |
131 | /* Encode field header based on type and field number defined in the field
132 | * structure. Call this from the callback before writing out field contents. */
133 | bool pb_encode_tag_for_field(pb_ostream_t *stream, const pb_field_iter_t *field);
134 |
135 | /* Encode field header by manually specifing wire type. You need to use this
136 | * if you want to write out packed arrays from a callback field. */
137 | bool pb_encode_tag(pb_ostream_t *stream, pb_wire_type_t wiretype, uint32_t field_number);
138 |
139 | /* Encode an integer in the varint format.
140 | * This works for bool, enum, int32, int64, uint32 and uint64 field types. */
141 | #ifndef PB_WITHOUT_64BIT
142 | bool pb_encode_varint(pb_ostream_t *stream, uint64_t value);
143 | #else
144 | bool pb_encode_varint(pb_ostream_t *stream, uint32_t value);
145 | #endif
146 |
147 | /* Encode an integer in the zig-zagged svarint format.
148 | * This works for sint32 and sint64. */
149 | #ifndef PB_WITHOUT_64BIT
150 | bool pb_encode_svarint(pb_ostream_t *stream, int64_t value);
151 | #else
152 | bool pb_encode_svarint(pb_ostream_t *stream, int32_t value);
153 | #endif
154 |
155 | /* Encode a string or bytes type field. For strings, pass strlen(s) as size. */
156 | bool pb_encode_string(pb_ostream_t *stream, const pb_byte_t *buffer, size_t size);
157 |
158 | /* Encode a fixed32, sfixed32 or float value.
159 | * You need to pass a pointer to a 4-byte wide C variable. */
160 | bool pb_encode_fixed32(pb_ostream_t *stream, const void *value);
161 |
162 | #ifndef PB_WITHOUT_64BIT
163 | /* Encode a fixed64, sfixed64 or double value.
164 | * You need to pass a pointer to a 8-byte wide C variable. */
165 | bool pb_encode_fixed64(pb_ostream_t *stream, const void *value);
166 | #endif
167 |
168 | /* Encode a submessage field.
169 | * You need to pass the pb_field_t array and pointer to struct, just like
170 | * with pb_encode(). This internally encodes the submessage twice, first to
171 | * calculate message size and then to actually write it out.
172 | */
173 | bool pb_encode_submessage(pb_ostream_t *stream, const pb_msgdesc_t *fields, const void *src_struct);
174 |
175 | #ifdef __cplusplus
176 | } /* extern "C" */
177 | #endif
178 |
179 | #endif
180 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/RoboMaster_S1_Reference_Design Debug.cfg:
--------------------------------------------------------------------------------
1 | # This is an genericBoard board with a single STM32F746ZGTx chip
2 | #
3 | # Generated by STM32CubeIDE
4 | # Take care that such file, as generated, may be overridden without any early notice. Please have a look to debug launch configuration setup(s)
5 |
6 | source [find interface/stlink.cfg]
7 |
8 | set WORKAREASIZE 0x8000
9 |
10 | transport select "hla_swd"
11 |
12 | set CHIPNAME STM32F746ZGTx
13 | set BOARDNAME genericBoard
14 |
15 | # Enable debug when in low power modes
16 | set ENABLE_LOW_POWER 1
17 |
18 | # Stop Watchdog counters when halt
19 | set STOP_WATCHDOG 1
20 |
21 | # STlink Debug clock frequency
22 | set CLOCK_FREQ 8000
23 |
24 | # Reset configuration
25 | # use hardware reset, connect under reset
26 | # connect_assert_srst needed if low power mode application running (WFI...)
27 | reset_config srst_only srst_nogate connect_assert_srst
28 | set CONNECT_UNDER_RESET 1
29 | set CORE_RESET 0
30 |
31 |
32 |
33 | # BCTM CPU variables
34 |
35 |
36 |
37 | source [find target/stm32f7x.cfg]
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/RoboMaster_S1_Reference_Design Debug.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/STM32F746ZGTX_FLASH.ld:
--------------------------------------------------------------------------------
1 | /*
2 | ******************************************************************************
3 | **
4 | ** File : LinkerScript.ld
5 | **
6 | ** Author : Auto-generated by STM32CubeIDE
7 | **
8 | ** Abstract : Linker script for STM32F746ZGTx Device from STM32F7 series
9 | ** 1024Kbytes FLASH
10 | ** 320Kbytes RAM
11 | **
12 | ** Set heap size, stack size and stack location according
13 | ** to application requirements.
14 | **
15 | ** Set memory bank area and size if external memory is used.
16 | **
17 | ** Target : STMicroelectronics STM32
18 | **
19 | ** Distribution: The file is distributed as is without any warranty
20 | ** of any kind.
21 | **
22 | *****************************************************************************
23 | ** @attention
24 | **
25 | ** © COPYRIGHT(c) 2019 STMicroelectronics
26 | **
27 | ** Redistribution and use in source and binary forms, with or without modification,
28 | ** are permitted provided that the following conditions are met:
29 | ** 1. Redistributions of source code must retain the above copyright notice,
30 | ** this list of conditions and the following disclaimer.
31 | ** 2. Redistributions in binary form must reproduce the above copyright notice,
32 | ** this list of conditions and the following disclaimer in the documentation
33 | ** and/or other materials provided with the distribution.
34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors
35 | ** may be used to endorse or promote products derived from this software
36 | ** without specific prior written permission.
37 | **
38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 | **
49 | *****************************************************************************
50 | */
51 |
52 | /* Entry Point */
53 | ENTRY(Reset_Handler)
54 |
55 | /* Highest address of the user mode stack */
56 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
57 |
58 | _Min_Heap_Size = 0x200 ; /* required amount of heap */
59 | _Min_Stack_Size = 0x400 ; /* required amount of stack */
60 |
61 | /* Memories definition */
62 | MEMORY
63 | {
64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
66 | }
67 |
68 | /* Sections */
69 | SECTIONS
70 | {
71 | /* The startup code into "FLASH" Rom type memory */
72 | .isr_vector :
73 | {
74 | . = ALIGN(4);
75 | KEEP(*(.isr_vector)) /* Startup code */
76 | . = ALIGN(4);
77 | } >FLASH
78 |
79 | /* The program code and other data into "FLASH" Rom type memory */
80 | .text :
81 | {
82 | . = ALIGN(4);
83 | *(.text) /* .text sections (code) */
84 | *(.text*) /* .text* sections (code) */
85 | *(.glue_7) /* glue arm to thumb code */
86 | *(.glue_7t) /* glue thumb to arm code */
87 | *(.eh_frame)
88 |
89 | KEEP (*(.init))
90 | KEEP (*(.fini))
91 |
92 | . = ALIGN(4);
93 | _etext = .; /* define a global symbols at end of code */
94 | } >FLASH
95 |
96 | /* Constant data into "FLASH" Rom type memory */
97 | .rodata :
98 | {
99 | . = ALIGN(4);
100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
102 | . = ALIGN(4);
103 | } >FLASH
104 |
105 | .ARM.extab : {
106 | . = ALIGN(4);
107 | *(.ARM.extab* .gnu.linkonce.armextab.*)
108 | . = ALIGN(4);
109 | } >FLASH
110 |
111 | .ARM : {
112 | . = ALIGN(4);
113 | __exidx_start = .;
114 | *(.ARM.exidx*)
115 | __exidx_end = .;
116 | . = ALIGN(4);
117 | } >FLASH
118 |
119 | .preinit_array :
120 | {
121 | . = ALIGN(4);
122 | PROVIDE_HIDDEN (__preinit_array_start = .);
123 | KEEP (*(.preinit_array*))
124 | PROVIDE_HIDDEN (__preinit_array_end = .);
125 | . = ALIGN(4);
126 | } >FLASH
127 |
128 | .init_array :
129 | {
130 | . = ALIGN(4);
131 | PROVIDE_HIDDEN (__init_array_start = .);
132 | KEEP (*(SORT(.init_array.*)))
133 | KEEP (*(.init_array*))
134 | PROVIDE_HIDDEN (__init_array_end = .);
135 | . = ALIGN(4);
136 | } >FLASH
137 |
138 | .fini_array :
139 | {
140 | . = ALIGN(4);
141 | PROVIDE_HIDDEN (__fini_array_start = .);
142 | KEEP (*(SORT(.fini_array.*)))
143 | KEEP (*(.fini_array*))
144 | PROVIDE_HIDDEN (__fini_array_end = .);
145 | . = ALIGN(4);
146 | } >FLASH
147 |
148 | /* Used by the startup to initialize data */
149 | _sidata = LOADADDR(.data);
150 |
151 | /* Initialized data sections into "RAM" Ram type memory */
152 | .data :
153 | {
154 | . = ALIGN(4);
155 | _sdata = .; /* create a global symbol at data start */
156 | *(.data) /* .data sections */
157 | *(.data*) /* .data* sections */
158 |
159 | . = ALIGN(4);
160 | _edata = .; /* define a global symbol at data end */
161 |
162 | } >RAM AT> FLASH
163 |
164 | /* Uninitialized data section into "RAM" Ram type memory */
165 | . = ALIGN(4);
166 | .bss :
167 | {
168 | /* This is used by the startup in order to initialize the .bss section */
169 | _sbss = .; /* define a global symbol at bss start */
170 | __bss_start__ = _sbss;
171 | *(.bss)
172 | *(.bss*)
173 | *(COMMON)
174 |
175 | . = ALIGN(4);
176 | _ebss = .; /* define a global symbol at bss end */
177 | __bss_end__ = _ebss;
178 | } >RAM
179 |
180 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
181 | ._user_heap_stack :
182 | {
183 | . = ALIGN(8);
184 | PROVIDE ( end = . );
185 | PROVIDE ( _end = . );
186 | . = . + _Min_Heap_Size;
187 | . = . + _Min_Stack_Size;
188 | . = ALIGN(8);
189 | } >RAM
190 |
191 | /* Remove information from the compiler libraries */
192 | /DISCARD/ :
193 | {
194 | libc.a ( * )
195 | libm.a ( * )
196 | libgcc.a ( * )
197 | }
198 |
199 | .ARM.attributes 0 : { *(.ARM.attributes) }
200 | }
201 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/STM32F746ZGTX_RAM.ld:
--------------------------------------------------------------------------------
1 | /*
2 | ******************************************************************************
3 | **
4 | ** File : LinkerScript.ld (debug in RAM dedicated)
5 | **
6 | ** Author : Auto-generated by STM32CubeIDE
7 | **
8 | ** Abstract : Linker script for STM32F746ZGTx Device from STM32F7 series
9 | ** 1024Kbytes FLASH
10 | ** 320Kbytes RAM
11 | **
12 | ** Set heap size, stack size and stack location according
13 | ** to application requirements.
14 | **
15 | ** Set memory bank area and size if external memory is used.
16 | **
17 | ** Target : STMicroelectronics STM32
18 | **
19 | ** Distribution: The file is distributed as is without any warranty
20 | ** of any kind.
21 | **
22 | *****************************************************************************
23 | ** @attention
24 | **
25 | ** © COPYRIGHT(c) 2019 STMicroelectronics
26 | **
27 | ** Redistribution and use in source and binary forms, with or without modification,
28 | ** are permitted provided that the following conditions are met:
29 | ** 1. Redistributions of source code must retain the above copyright notice,
30 | ** this list of conditions and the following disclaimer.
31 | ** 2. Redistributions in binary form must reproduce the above copyright notice,
32 | ** this list of conditions and the following disclaimer in the documentation
33 | ** and/or other materials provided with the distribution.
34 | ** 3. Neither the name of STMicroelectronics nor the names of its contributors
35 | ** may be used to endorse or promote products derived from this software
36 | ** without specific prior written permission.
37 | **
38 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
39 | ** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 | ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 | ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
42 | ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43 | ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44 | ** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45 | ** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 | ** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 | **
49 | *****************************************************************************
50 | */
51 |
52 | /* Entry Point */
53 | ENTRY(Reset_Handler)
54 |
55 | /* Highest address of the user mode stack */
56 | _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
57 |
58 | _Min_Heap_Size = 0x200; /* required amount of heap */
59 | _Min_Stack_Size = 0x400; /* required amount of stack */
60 |
61 | /* Memories definition */
62 | MEMORY
63 | {
64 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
65 | FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 1024K
66 | }
67 |
68 | /* Sections */
69 | SECTIONS
70 | {
71 | /* The startup code into "RAM" Ram type memory */
72 | .isr_vector :
73 | {
74 | . = ALIGN(4);
75 | KEEP(*(.isr_vector)) /* Startup code */
76 | . = ALIGN(4);
77 | } >RAM
78 |
79 | /* The program code and other data into "RAM" Ram type memory */
80 | .text :
81 | {
82 | . = ALIGN(4);
83 | *(.text) /* .text sections (code) */
84 | *(.text*) /* .text* sections (code) */
85 | *(.glue_7) /* glue arm to thumb code */
86 | *(.glue_7t) /* glue thumb to arm code */
87 | *(.eh_frame)
88 |
89 | KEEP (*(.init))
90 | KEEP (*(.fini))
91 |
92 | . = ALIGN(4);
93 | _etext = .; /* define a global symbols at end of code */
94 | } >RAM
95 |
96 | /* Constant data into "RAM" Ram type memory */
97 | .rodata :
98 | {
99 | . = ALIGN(4);
100 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
101 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
102 | . = ALIGN(4);
103 | } >RAM
104 |
105 | .ARM.extab : {
106 | . = ALIGN(4);
107 | *(.ARM.extab* .gnu.linkonce.armextab.*)
108 | . = ALIGN(4);
109 | } >RAM
110 |
111 | .ARM : {
112 | . = ALIGN(4);
113 | __exidx_start = .;
114 | *(.ARM.exidx*)
115 | __exidx_end = .;
116 | . = ALIGN(4);
117 | } >RAM
118 |
119 | .preinit_array :
120 | {
121 | . = ALIGN(4);
122 | PROVIDE_HIDDEN (__preinit_array_start = .);
123 | KEEP (*(.preinit_array*))
124 | PROVIDE_HIDDEN (__preinit_array_end = .);
125 | . = ALIGN(4);
126 | } >RAM
127 |
128 | .init_array :
129 | {
130 | . = ALIGN(4);
131 | PROVIDE_HIDDEN (__init_array_start = .);
132 | KEEP (*(SORT(.init_array.*)))
133 | KEEP (*(.init_array*))
134 | PROVIDE_HIDDEN (__init_array_end = .);
135 | . = ALIGN(4);
136 | } >RAM
137 |
138 | .fini_array :
139 | {
140 | . = ALIGN(4);
141 | PROVIDE_HIDDEN (__fini_array_start = .);
142 | KEEP (*(SORT(.fini_array.*)))
143 | KEEP (*(.fini_array*))
144 | PROVIDE_HIDDEN (__fini_array_end = .);
145 | . = ALIGN(4);
146 | } >RAM
147 |
148 | /* Used by the startup to initialize data */
149 | _sidata = LOADADDR(.data);
150 |
151 | /* Initialized data sections into "RAM" Ram type memory */
152 | .data :
153 | {
154 | . = ALIGN(4);
155 | _sdata = .; /* create a global symbol at data start */
156 | *(.data) /* .data sections */
157 | *(.data*) /* .data* sections */
158 |
159 | . = ALIGN(4);
160 | _edata = .; /* define a global symbol at data end */
161 |
162 | } >RAM
163 |
164 | /* Uninitialized data section into "RAM" Ram type memory */
165 | . = ALIGN(4);
166 | .bss :
167 | {
168 | /* This is used by the startup in order to initialize the .bss section */
169 | _sbss = .; /* define a global symbol at bss start */
170 | __bss_start__ = _sbss;
171 | *(.bss)
172 | *(.bss*)
173 | *(COMMON)
174 |
175 | . = ALIGN(4);
176 | _ebss = .; /* define a global symbol at bss end */
177 | __bss_end__ = _ebss;
178 | } >RAM
179 |
180 | /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */
181 | ._user_heap_stack :
182 | {
183 | . = ALIGN(8);
184 | PROVIDE ( end = . );
185 | PROVIDE ( _end = . );
186 | . = . + _Min_Heap_Size;
187 | . = . + _Min_Stack_Size;
188 | . = ALIGN(8);
189 | } >RAM
190 |
191 | /* Remove information from the compiler libraries */
192 | /DISCARD/ :
193 | {
194 | libc.a ( * )
195 | libm.a ( * )
196 | libgcc.a ( * )
197 | }
198 |
199 | .ARM.attributes 0 : { *(.ARM.attributes) }
200 | }
201 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/USB_DEVICE/App/usb_device.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usb_device.c
5 | * @version : v1.0_Cube
6 | * @brief : This file implements the USB Device
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 |
24 | #include "usb_device.h"
25 | #include "usbd_core.h"
26 | #include "usbd_desc.h"
27 | #include "usbd_cdc.h"
28 | #include "usbd_cdc_if.h"
29 |
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* USER CODE BEGIN PV */
35 | /* Private variables ---------------------------------------------------------*/
36 |
37 | /* USER CODE END PV */
38 |
39 | /* USER CODE BEGIN PFP */
40 | /* Private function prototypes -----------------------------------------------*/
41 |
42 | /* USER CODE END PFP */
43 |
44 | /* USB Device Core handle declaration. */
45 | USBD_HandleTypeDef hUsbDeviceFS;
46 |
47 | /*
48 | * -- Insert your variables declaration here --
49 | */
50 | /* USER CODE BEGIN 0 */
51 |
52 | /* USER CODE END 0 */
53 |
54 | /*
55 | * -- Insert your external function declaration here --
56 | */
57 | /* USER CODE BEGIN 1 */
58 |
59 | /* USER CODE END 1 */
60 |
61 | /**
62 | * Init USB device Library, add supported class and start the library
63 | * @retval None
64 | */
65 | void MX_USB_DEVICE_Init(void)
66 | {
67 | /* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
68 |
69 | /* USER CODE END USB_DEVICE_Init_PreTreatment */
70 |
71 | /* Init Device Library, add supported class and start the library. */
72 | if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
73 | {
74 | Error_Handler();
75 | }
76 | if (USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC) != USBD_OK)
77 | {
78 | Error_Handler();
79 | }
80 | if (USBD_CDC_RegisterInterface(&hUsbDeviceFS, &USBD_Interface_fops_FS) != USBD_OK)
81 | {
82 | Error_Handler();
83 | }
84 | if (USBD_Start(&hUsbDeviceFS) != USBD_OK)
85 | {
86 | Error_Handler();
87 | }
88 |
89 | /* USER CODE BEGIN USB_DEVICE_Init_PostTreatment */
90 |
91 | /* USER CODE END USB_DEVICE_Init_PostTreatment */
92 | }
93 |
94 | /**
95 | * @}
96 | */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
103 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/USB_DEVICE/App/usb_device.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usb_device.h
5 | * @version : v1.0_Cube
6 | * @brief : Header for usb_device.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USB_DEVICE__H__
24 | #define __USB_DEVICE__H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f7xx.h"
32 | #include "stm32f7xx_hal.h"
33 | #include "usbd_def.h"
34 |
35 | /* USER CODE BEGIN INCLUDE */
36 |
37 | /* USER CODE END INCLUDE */
38 |
39 | /** @addtogroup USBD_OTG_DRIVER
40 | * @{
41 | */
42 |
43 | /** @defgroup USBD_DEVICE USBD_DEVICE
44 | * @brief Device file for Usb otg low level driver.
45 | * @{
46 | */
47 |
48 | /** @defgroup USBD_DEVICE_Exported_Variables USBD_DEVICE_Exported_Variables
49 | * @brief Public variables.
50 | * @{
51 | */
52 |
53 | /* Private variables ---------------------------------------------------------*/
54 | /* USER CODE BEGIN PV */
55 |
56 | /* USER CODE END PV */
57 |
58 | /* Private function prototypes -----------------------------------------------*/
59 | /* USER CODE BEGIN PFP */
60 |
61 | /* USER CODE END PFP */
62 |
63 | /*
64 | * -- Insert your variables declaration here --
65 | */
66 | /* USER CODE BEGIN VARIABLES */
67 |
68 | /* USER CODE END VARIABLES */
69 | /**
70 | * @}
71 | */
72 |
73 | /** @defgroup USBD_DEVICE_Exported_FunctionsPrototype USBD_DEVICE_Exported_FunctionsPrototype
74 | * @brief Declaration of public functions for Usb device.
75 | * @{
76 | */
77 |
78 | /** USB Device initialization function. */
79 | void MX_USB_DEVICE_Init(void);
80 |
81 | /*
82 | * -- Insert functions declaration here --
83 | */
84 | /* USER CODE BEGIN FD */
85 |
86 | /* USER CODE END FD */
87 | /**
88 | * @}
89 | */
90 |
91 | /**
92 | * @}
93 | */
94 |
95 | /**
96 | * @}
97 | */
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
103 | #endif /* __USB_DEVICE__H__ */
104 |
105 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
106 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/USB_DEVICE/App/usbd_cdc_if.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_cdc_if.c
5 | * @version : v1.0_Cube
6 | * @brief : Usb device for Virtual Com Port.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "usbd_cdc_if.h"
24 |
25 | /* USER CODE BEGIN INCLUDE */
26 |
27 | /* USER CODE END INCLUDE */
28 |
29 | /* Private typedef -----------------------------------------------------------*/
30 | /* Private define ------------------------------------------------------------*/
31 | /* Private macro -------------------------------------------------------------*/
32 |
33 | /* USER CODE BEGIN PV */
34 | /* Private variables ---------------------------------------------------------*/
35 |
36 | /* USER CODE END PV */
37 |
38 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
39 | * @brief Usb device library.
40 | * @{
41 | */
42 |
43 | /** @addtogroup USBD_CDC_IF
44 | * @{
45 | */
46 |
47 | /** @defgroup USBD_CDC_IF_Private_TypesDefinitions USBD_CDC_IF_Private_TypesDefinitions
48 | * @brief Private types.
49 | * @{
50 | */
51 |
52 | /* USER CODE BEGIN PRIVATE_TYPES */
53 |
54 | /* USER CODE END PRIVATE_TYPES */
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /** @defgroup USBD_CDC_IF_Private_Defines USBD_CDC_IF_Private_Defines
61 | * @brief Private defines.
62 | * @{
63 | */
64 |
65 | /* USER CODE BEGIN PRIVATE_DEFINES */
66 | /* Define size for the receive and transmit buffer over CDC */
67 | /* It's up to user to redefine and/or remove those define */
68 | #define APP_RX_DATA_SIZE 2048
69 | #define APP_TX_DATA_SIZE 2048
70 | /* USER CODE END PRIVATE_DEFINES */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_CDC_IF_Private_Macros USBD_CDC_IF_Private_Macros
77 | * @brief Private macros.
78 | * @{
79 | */
80 |
81 | /* USER CODE BEGIN PRIVATE_MACRO */
82 |
83 | /* USER CODE END PRIVATE_MACRO */
84 |
85 | /**
86 | * @}
87 | */
88 |
89 | /** @defgroup USBD_CDC_IF_Private_Variables USBD_CDC_IF_Private_Variables
90 | * @brief Private variables.
91 | * @{
92 | */
93 | /* Create buffer for reception and transmission */
94 | /* It's up to user to redefine and/or remove those define */
95 | /** Received data over USB are stored in this buffer */
96 | uint8_t UserRxBufferFS[APP_RX_DATA_SIZE];
97 |
98 | /** Data to send over USB CDC are stored in this buffer */
99 | uint8_t UserTxBufferFS[APP_TX_DATA_SIZE];
100 |
101 | /* USER CODE BEGIN PRIVATE_VARIABLES */
102 | volatile uint8_t usb_rBuf[APP_RX_DATA_SIZE];
103 | volatile int usb_rBuf_wp;
104 | volatile int usb_rBuf_rp;
105 | /* USER CODE END PRIVATE_VARIABLES */
106 |
107 | /**
108 | * @}
109 | */
110 |
111 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
112 | * @brief Public variables.
113 | * @{
114 | */
115 |
116 | extern USBD_HandleTypeDef hUsbDeviceFS;
117 |
118 | /* USER CODE BEGIN EXPORTED_VARIABLES */
119 |
120 | /* USER CODE END EXPORTED_VARIABLES */
121 |
122 | /**
123 | * @}
124 | */
125 |
126 | /** @defgroup USBD_CDC_IF_Private_FunctionPrototypes USBD_CDC_IF_Private_FunctionPrototypes
127 | * @brief Private functions declaration.
128 | * @{
129 | */
130 |
131 | static int8_t CDC_Init_FS(void);
132 | static int8_t CDC_DeInit_FS(void);
133 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length);
134 | static int8_t CDC_Receive_FS(uint8_t* pbuf, uint32_t *Len);
135 |
136 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_DECLARATION */
137 |
138 | /* USER CODE END PRIVATE_FUNCTIONS_DECLARATION */
139 |
140 | /**
141 | * @}
142 | */
143 |
144 | USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =
145 | {
146 | CDC_Init_FS,
147 | CDC_DeInit_FS,
148 | CDC_Control_FS,
149 | CDC_Receive_FS
150 | };
151 |
152 | /* Private functions ---------------------------------------------------------*/
153 | /**
154 | * @brief Initializes the CDC media low layer over the FS USB IP
155 | * @retval USBD_OK if all operations are OK else USBD_FAIL
156 | */
157 | static int8_t CDC_Init_FS(void)
158 | {
159 | /* USER CODE BEGIN 3 */
160 | /* Set Application Buffers */
161 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, UserTxBufferFS, 0);
162 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, UserRxBufferFS);
163 | return (USBD_OK);
164 | /* USER CODE END 3 */
165 | }
166 |
167 | /**
168 | * @brief DeInitializes the CDC media low layer
169 | * @retval USBD_OK if all operations are OK else USBD_FAIL
170 | */
171 | static int8_t CDC_DeInit_FS(void)
172 | {
173 | /* USER CODE BEGIN 4 */
174 | return (USBD_OK);
175 | /* USER CODE END 4 */
176 | }
177 |
178 | /**
179 | * @brief Manage the CDC class requests
180 | * @param cmd: Command code
181 | * @param pbuf: Buffer containing command data (request parameters)
182 | * @param length: Number of data to be sent (in bytes)
183 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
184 | */
185 | static int8_t CDC_Control_FS(uint8_t cmd, uint8_t* pbuf, uint16_t length)
186 | {
187 | /* USER CODE BEGIN 5 */
188 | switch(cmd)
189 | {
190 | case CDC_SEND_ENCAPSULATED_COMMAND:
191 |
192 | break;
193 |
194 | case CDC_GET_ENCAPSULATED_RESPONSE:
195 |
196 | break;
197 |
198 | case CDC_SET_COMM_FEATURE:
199 |
200 | break;
201 |
202 | case CDC_GET_COMM_FEATURE:
203 |
204 | break;
205 |
206 | case CDC_CLEAR_COMM_FEATURE:
207 |
208 | break;
209 |
210 | /*******************************************************************************/
211 | /* Line Coding Structure */
212 | /*-----------------------------------------------------------------------------*/
213 | /* Offset | Field | Size | Value | Description */
214 | /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
215 | /* 4 | bCharFormat | 1 | Number | Stop bits */
216 | /* 0 - 1 Stop bit */
217 | /* 1 - 1.5 Stop bits */
218 | /* 2 - 2 Stop bits */
219 | /* 5 | bParityType | 1 | Number | Parity */
220 | /* 0 - None */
221 | /* 1 - Odd */
222 | /* 2 - Even */
223 | /* 3 - Mark */
224 | /* 4 - Space */
225 | /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
226 | /*******************************************************************************/
227 | case CDC_SET_LINE_CODING:
228 |
229 | break;
230 |
231 | case CDC_GET_LINE_CODING:
232 |
233 | break;
234 |
235 | case CDC_SET_CONTROL_LINE_STATE:
236 |
237 | break;
238 |
239 | case CDC_SEND_BREAK:
240 |
241 | break;
242 |
243 | default:
244 | break;
245 | }
246 |
247 | return (USBD_OK);
248 | /* USER CODE END 5 */
249 | }
250 |
251 | /**
252 | * @brief Data received over USB OUT endpoint are sent over CDC interface
253 | * through this function.
254 | *
255 | * @note
256 | * This function will block any OUT packet reception on USB endpoint
257 | * untill exiting this function. If you exit this function before transfer
258 | * is complete on CDC interface (ie. using DMA controller) it will result
259 | * in receiving more data while previous ones are still not sent.
260 | *
261 | * @param Buf: Buffer of data to be received
262 | * @param Len: Number of data received (in bytes)
263 | * @retval Result of the operation: USBD_OK if all operations are OK else USBD_FAIL
264 | */
265 | static int8_t CDC_Receive_FS(uint8_t* Buf, uint32_t *Len)
266 | {
267 | /* USER CODE BEGIN 6 */
268 | USBD_CDC_SetRxBuffer(&hUsbDeviceFS, &Buf[0]);
269 | USBD_CDC_ReceivePacket(&hUsbDeviceFS);
270 |
271 | for(int i= 0; i< *Len; i++)
272 | {
273 | usb_rBuf[usb_rBuf_wp] = Buf[i];
274 | usb_rBuf_wp++;
275 | usb_rBuf_wp %= APP_RX_DATA_SIZE;
276 | }
277 |
278 | return (USBD_OK);
279 | /* USER CODE END 6 */
280 | }
281 |
282 | /**
283 | * @brief CDC_Transmit_FS
284 | * Data to send over USB IN endpoint are sent over CDC interface
285 | * through this function.
286 | * @note
287 | *
288 | *
289 | * @param Buf: Buffer of data to be sent
290 | * @param Len: Number of data to be sent (in bytes)
291 | * @retval USBD_OK if all operations are OK else USBD_FAIL or USBD_BUSY
292 | */
293 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
294 | {
295 | uint8_t result = USBD_OK;
296 | /* USER CODE BEGIN 7 */
297 | USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*)hUsbDeviceFS.pClassData;
298 | if (hcdc->TxState != 0){
299 | return USBD_BUSY;
300 | }
301 | USBD_CDC_SetTxBuffer(&hUsbDeviceFS, Buf, Len);
302 | result = USBD_CDC_TransmitPacket(&hUsbDeviceFS);
303 | /* USER CODE END 7 */
304 | return result;
305 | }
306 |
307 | /* USER CODE BEGIN PRIVATE_FUNCTIONS_IMPLEMENTATION */
308 |
309 | /* USER CODE END PRIVATE_FUNCTIONS_IMPLEMENTATION */
310 |
311 | /**
312 | * @}
313 | */
314 |
315 | /**
316 | * @}
317 | */
318 |
319 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
320 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/USB_DEVICE/App/usbd_cdc_if.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_cdc_if.h
5 | * @version : v1.0_Cube
6 | * @brief : Header for usbd_cdc_if.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CDC_IF_H__
24 | #define __USBD_CDC_IF_H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "usbd_cdc.h"
32 |
33 | /* USER CODE BEGIN INCLUDE */
34 |
35 | /* USER CODE END INCLUDE */
36 |
37 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
38 | * @brief For Usb device.
39 | * @{
40 | */
41 |
42 | /** @defgroup USBD_CDC_IF USBD_CDC_IF
43 | * @brief Usb VCP device module
44 | * @{
45 | */
46 |
47 | /** @defgroup USBD_CDC_IF_Exported_Defines USBD_CDC_IF_Exported_Defines
48 | * @brief Defines.
49 | * @{
50 | */
51 | /* USER CODE BEGIN EXPORTED_DEFINES */
52 |
53 | /* USER CODE END EXPORTED_DEFINES */
54 |
55 | /**
56 | * @}
57 | */
58 |
59 | /** @defgroup USBD_CDC_IF_Exported_Types USBD_CDC_IF_Exported_Types
60 | * @brief Types.
61 | * @{
62 | */
63 |
64 | /* USER CODE BEGIN EXPORTED_TYPES */
65 |
66 | /* USER CODE END EXPORTED_TYPES */
67 |
68 | /**
69 | * @}
70 | */
71 |
72 | /** @defgroup USBD_CDC_IF_Exported_Macros USBD_CDC_IF_Exported_Macros
73 | * @brief Aliases.
74 | * @{
75 | */
76 |
77 | /* USER CODE BEGIN EXPORTED_MACRO */
78 |
79 | /* USER CODE END EXPORTED_MACRO */
80 |
81 | /**
82 | * @}
83 | */
84 |
85 | /** @defgroup USBD_CDC_IF_Exported_Variables USBD_CDC_IF_Exported_Variables
86 | * @brief Public variables.
87 | * @{
88 | */
89 |
90 | /** CDC Interface callback. */
91 | extern USBD_CDC_ItfTypeDef USBD_Interface_fops_FS;
92 |
93 | /* USER CODE BEGIN EXPORTED_VARIABLES */
94 |
95 | /* USER CODE END EXPORTED_VARIABLES */
96 |
97 | /**
98 | * @}
99 | */
100 |
101 | /** @defgroup USBD_CDC_IF_Exported_FunctionsPrototype USBD_CDC_IF_Exported_FunctionsPrototype
102 | * @brief Public functions declaration.
103 | * @{
104 | */
105 |
106 | uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len);
107 |
108 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */
109 |
110 | /* USER CODE END EXPORTED_FUNCTIONS */
111 |
112 | /**
113 | * @}
114 | */
115 |
116 | /**
117 | * @}
118 | */
119 |
120 | /**
121 | * @}
122 | */
123 |
124 | #ifdef __cplusplus
125 | }
126 | #endif
127 |
128 | #endif /* __USBD_CDC_IF_H__ */
129 |
130 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
131 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/USB_DEVICE/App/usbd_desc.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_desc.c
5 | * @version : v1.0_Cube
6 | * @brief : Header for usbd_conf.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __USBD_DESC__C__
23 | #define __USBD_DESC__C__
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Includes ------------------------------------------------------------------*/
30 | #include "usbd_def.h"
31 |
32 | /* USER CODE BEGIN INCLUDE */
33 |
34 | /* USER CODE END INCLUDE */
35 |
36 | /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
37 | * @{
38 | */
39 |
40 | /** @defgroup USBD_DESC USBD_DESC
41 | * @brief Usb device descriptors module.
42 | * @{
43 | */
44 |
45 | /** @defgroup USBD_DESC_Exported_Constants USBD_DESC_Exported_Constants
46 | * @brief Constants.
47 | * @{
48 | */
49 | #define DEVICE_ID1 (UID_BASE)
50 | #define DEVICE_ID2 (UID_BASE + 0x4)
51 | #define DEVICE_ID3 (UID_BASE + 0x8)
52 |
53 | #define USB_SIZ_STRING_SERIAL 0x1A
54 |
55 | /* USER CODE BEGIN EXPORTED_CONSTANTS */
56 |
57 | /* USER CODE END EXPORTED_CONSTANTS */
58 |
59 | /**
60 | * @}
61 | */
62 |
63 | /** @defgroup USBD_DESC_Exported_Defines USBD_DESC_Exported_Defines
64 | * @brief Defines.
65 | * @{
66 | */
67 |
68 | /* USER CODE BEGIN EXPORTED_DEFINES */
69 |
70 | /* USER CODE END EXPORTED_DEFINES */
71 |
72 | /**
73 | * @}
74 | */
75 |
76 | /** @defgroup USBD_DESC_Exported_TypesDefinitions USBD_DESC_Exported_TypesDefinitions
77 | * @brief Types.
78 | * @{
79 | */
80 |
81 | /* USER CODE BEGIN EXPORTED_TYPES */
82 |
83 | /* USER CODE END EXPORTED_TYPES */
84 |
85 | /**
86 | * @}
87 | */
88 |
89 | /** @defgroup USBD_DESC_Exported_Macros USBD_DESC_Exported_Macros
90 | * @brief Aliases.
91 | * @{
92 | */
93 |
94 | /* USER CODE BEGIN EXPORTED_MACRO */
95 |
96 | /* USER CODE END EXPORTED_MACRO */
97 |
98 | /**
99 | * @}
100 | */
101 |
102 | /** @defgroup USBD_DESC_Exported_Variables USBD_DESC_Exported_Variables
103 | * @brief Public variables.
104 | * @{
105 | */
106 |
107 | /** Descriptor for the Usb device. */
108 | extern USBD_DescriptorsTypeDef FS_Desc;
109 |
110 | /* USER CODE BEGIN EXPORTED_VARIABLES */
111 |
112 | /* USER CODE END EXPORTED_VARIABLES */
113 |
114 | /**
115 | * @}
116 | */
117 |
118 | /** @defgroup USBD_DESC_Exported_FunctionsPrototype USBD_DESC_Exported_FunctionsPrototype
119 | * @brief Public functions declaration.
120 | * @{
121 | */
122 |
123 | /* USER CODE BEGIN EXPORTED_FUNCTIONS */
124 |
125 | /* USER CODE END EXPORTED_FUNCTIONS */
126 |
127 | /**
128 | * @}
129 | */
130 |
131 | /**
132 | * @}
133 | */
134 |
135 | /**
136 | * @}
137 | */
138 |
139 | #ifdef __cplusplus
140 | }
141 | #endif
142 |
143 | #endif /* __USBD_DESC__C__ */
144 |
145 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
146 |
--------------------------------------------------------------------------------
/software/opencr_firmware/RoboMaster_S1_Reference_Design/USB_DEVICE/Target/usbd_conf.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : usbd_conf.h
5 | * @version : v1.0_Cube
6 | * @brief : Header for usbd_conf.c file.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under Ultimate Liberty license
14 | * SLA0044, the "License"; You may not use this file except in compliance with
15 | * the License. You may obtain a copy of the License at:
16 | * www.st.com/SLA0044
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __USBD_CONF__H__
24 | #define __USBD_CONF__H__
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include
32 | #include
33 | #include
34 | #include "main.h"
35 | #include "stm32f7xx.h"
36 | #include "stm32f7xx_hal.h"
37 |
38 | /* USER CODE BEGIN INCLUDE */
39 |
40 | /* USER CODE END INCLUDE */
41 |
42 | /** @addtogroup USBD_OTG_DRIVER
43 | * @{
44 | */
45 |
46 | /** @defgroup USBD_CONF USBD_CONF
47 | * @brief Configuration file for Usb otg low level driver.
48 | * @{
49 | */
50 |
51 | /** @defgroup USBD_CONF_Exported_Variables USBD_CONF_Exported_Variables
52 | * @brief Public variables.
53 | * @{
54 | */
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /** @defgroup USBD_CONF_Exported_Defines USBD_CONF_Exported_Defines
61 | * @brief Defines for configuration of the Usb device.
62 | * @{
63 | */
64 |
65 | /*---------- -----------*/
66 | #define USBD_MAX_NUM_INTERFACES 1U
67 | /*---------- -----------*/
68 | #define USBD_MAX_NUM_CONFIGURATION 1U
69 | /*---------- -----------*/
70 | #define USBD_MAX_STR_DESC_SIZ 512U
71 | /*---------- -----------*/
72 | #define USBD_DEBUG_LEVEL 0U
73 | /*---------- -----------*/
74 | #define USBD_LPM_ENABLED 1U
75 | /*---------- -----------*/
76 | #define USBD_SELF_POWERED 1U
77 |
78 | /****************************************/
79 | /* #define for FS and HS identification */
80 | #define DEVICE_FS 0
81 | #define DEVICE_HS 1
82 |
83 | /**
84 | * @}
85 | */
86 |
87 | /** @defgroup USBD_CONF_Exported_Macros USBD_CONF_Exported_Macros
88 | * @brief Aliases.
89 | * @{
90 | */
91 |
92 | /* Memory management macros */
93 |
94 | /** Alias for memory allocation. */
95 | #define USBD_malloc malloc
96 |
97 | /** Alias for memory release. */
98 | #define USBD_free free
99 |
100 | /** Alias for memory set. */
101 | #define USBD_memset memset
102 |
103 | /** Alias for memory copy. */
104 | #define USBD_memcpy memcpy
105 |
106 | /** Alias for delay. */
107 | #define USBD_Delay HAL_Delay
108 |
109 | /* DEBUG macros */
110 |
111 | #if (USBD_DEBUG_LEVEL > 0)
112 | #define USBD_UsrLog(...) printf(__VA_ARGS__);\
113 | printf("\n");
114 | #else
115 | #define USBD_UsrLog(...)
116 | #endif
117 |
118 | #if (USBD_DEBUG_LEVEL > 1)
119 |
120 | #define USBD_ErrLog(...) printf("ERROR: ") ;\
121 | printf(__VA_ARGS__);\
122 | printf("\n");
123 | #else
124 | #define USBD_ErrLog(...)
125 | #endif
126 |
127 | #if (USBD_DEBUG_LEVEL > 2)
128 | #define USBD_DbgLog(...) printf("DEBUG : ") ;\
129 | printf(__VA_ARGS__);\
130 | printf("\n");
131 | #else
132 | #define USBD_DbgLog(...)
133 | #endif
134 |
135 | /**
136 | * @}
137 | */
138 |
139 | /** @defgroup USBD_CONF_Exported_Types USBD_CONF_Exported_Types
140 | * @brief Types.
141 | * @{
142 | */
143 |
144 | /**
145 | * @}
146 | */
147 |
148 | /** @defgroup USBD_CONF_Exported_FunctionsPrototype USBD_CONF_Exported_FunctionsPrototype
149 | * @brief Declaration of public functions for Usb device.
150 | * @{
151 | */
152 |
153 | /* Exported functions -------------------------------------------------------*/
154 |
155 | /**
156 | * @}
157 | */
158 |
159 | /**
160 | * @}
161 | */
162 |
163 | /**
164 | * @}
165 | */
166 |
167 | #ifdef __cplusplus
168 | }
169 | #endif
170 |
171 | #endif /* __USBD_CONF__H__ */
172 |
173 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
174 |
--------------------------------------------------------------------------------