Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .eide/eide.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,14 @@ virtualFolder:
- path: GSRL/Dependence/CMSIS-DSP/Source/TransformFunctions/TransformFunctionsF16.c
- path: GSRL/Dependence/CMSIS-DSP/Source/WindowFunctions/WindowFunctions.c
folders: []
- name: chariot
files:
- path: chariot/src/crt_chassis.cpp
- path: chariot/src/crt_module.cpp
folders: []
- name: Task
files:
- path: Task/src/tsk_test.cpp
- path: Task/src/tsk_chassis.cpp
folders: []
dependenceList: []
outDir: build
Expand Down Expand Up @@ -201,6 +206,9 @@ targets:
- GSRL/Algorithm/inc
- GSRL/Device/inc
- GSRL/Dependence/eigen
- Task/src
- chariot/inc
- chariot/src
libList: []
excludeList: []
toolchain: GCC
Expand Down Expand Up @@ -252,7 +260,7 @@ targets:
OpenOCD:
baseAddr: "0x08000000"
bin: ""
interface: cmsis-dap
interface: stlink
target: stm32f4x
STLink:
address: "0x08000000"
Expand Down
42 changes: 42 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!-- Copilot instructions for the GSRL codebase -->
# GSRL — AI coding assistant guide

Purpose: give concise, actionable context so AI agents are immediately productive in this embedded robot repository.

- **Big picture:** This repo builds an STM32-based robot firmware composed of:
- platform BSP generated by STM32CubeMX: [CubeMX_BSP](CubeMX_BSP) (toolchain file: [CubeMX_BSP/cmake/gcc-arm-none-eabi.cmake](CubeMX_BSP/cmake/gcc-arm-none-eabi.cmake)).
- core libraries under [GSRL](GSRL) and driver/vehicle modules under [chariot](chariot) and [Task](Task).
- The top-level build is configured with CMake and CMake presets ([CMakePresets.json](CMakePresets.json)) — use `cmake --preset Debug` or `cmake --preset Release` then `cmake --build --preset Debug`.

- **Architecture & boundaries:**
- Hardware / BSP: [CubeMX_BSP](CubeMX_BSP) provides low-level drivers and the cross-toolchain.
- Platform services: FreeRTOS is used for concurrency — task implementations live in `Task/src` (look at `Task/src/tsk_chassis.cpp`).
- Vehicle subsystem: `chariot` contains chassis/module implementations and motor wrappers (`chariot/src/crt_chassis.cpp`, `chariot/inc`). AI should not change low-level HAL without explicit mention.

- **Key developer workflows (reproducible commands):**
- Configure & build (uses Ninja + arm-none-eabi toolchain):
- `cmake --preset Debug`
- `cmake --build --preset Debug`
- Use `build/` output and `compile_commands.json` (CMake sets `CMAKE_EXPORT_COMPILE_COMMANDS`) for static analysis / clangd.

- **Project-specific conventions & patterns:**
- Task functions use `tsk` prefix and provide C-compatible wrappers: e.g., `tskChassisInit()` with `extern "C"` wrapper `TSK_CHASSIS_Init` (see `Task/src/tsk_chassis.cpp`).
- Configuration and TODOs are documented inline in Chinese; follow existing FIXME/TODO markers when making changes.
- Placeholder interfaces exist (e.g., temporary `TemporaryCrtChassis` and commented `// TODO` blocks in `tsk_chassis.cpp`) — prefer integrating with the real `CrtChassis` only after confirming its API (search `chariot/inc` and `chariot/src`).
- Motor and control classes follow names like `MotorGM6020`, `MotorM3508`, `SimplePID`, `CrtModule`, `CrtChassis` — inspect `chariot/inc` for exact method signatures before calling.

- **Integration points & external dependencies:**
- Toolchain: `gcc-arm-none-eabi` via the toolchain file in `CubeMX_BSP/cmake`.
- FreeRTOS sources are in `CubeMX_BSP/Middlewares/...` and tasks use `xTaskCreate`, `xQueueCreate`, `vTaskDelayUntil`.
- Build links to `stm32cubemx` and `gsrl` libraries in top-level [CMakeLists.txt](CMakeLists.txt).

- **When editing code, prefer small, local changes:**
- Preserve task timing semantics: `CHASSIS_TASK_PERIOD_MS` and `vTaskDelayUntil` usage in `tsk_chassis.cpp` are critical.
- Keep C ABI wrappers intact. Update both C++ and `extern "C"` functions together.

- **Examples to guide code edits (search & reference):**
- Read the chassis task: [Task/src/tsk_chassis.cpp](Task/src/tsk_chassis.cpp)
- See top-level build integration: [CMakeLists.txt](CMakeLists.txt)
- Toolchain/presets: [CMakePresets.json](CMakePresets.json) and [CubeMX_BSP/cmake/gcc-arm-none-eabi.cmake](CubeMX_BSP/cmake/gcc-arm-none-eabi.cmake)

If anything here is unclear or you want more detail on a subsystem, say which file or workflow to expand and I will update this file.
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "shell",
"command": "${command:eide.project.build}",
"group": "build",
"problemMatcher": []
"problemMatcher": "$gcc"
},
{
"label": "flash",
Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
# Add user sources here
Task/src/tsk_test.cpp
chariot/src/crt_chassis.cpp
chariot/src/crt_module.cpp
Task/src/tsk_chassis.cpp
)

# Add include paths
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined include paths
Task/inc
chariot/inc
)

# Add project symbols (macros)
Expand Down
4 changes: 2 additions & 2 deletions CubeMX_BSP/.mxproject

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions CubeMX_BSP/GMStdRobotLib.ioc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Dma.USART6_TX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
Dma.USART6_TX.5.PeriphInc=DMA_PINC_DISABLE
Dma.USART6_TX.5.Priority=DMA_PRIORITY_MEDIUM
Dma.USART6_TX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
FREERTOS.FootprintOK=true
FREERTOS.INCLUDE_eTaskGetState=1
FREERTOS.INCLUDE_pcTaskGetTaskName=1
FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1
Expand All @@ -117,8 +118,8 @@ FREERTOS.INCLUDE_xTaskAbortDelay=1
FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1
FREERTOS.INCLUDE_xTaskGetHandle=1
FREERTOS.INCLUDE_xTimerPendFunctionCall=1
FREERTOS.IPParameters=Tasks01,configTOTAL_HEAP_SIZE,INCLUDE_vTaskDelayUntil,INCLUDE_eTaskGetState,INCLUDE_uxTaskGetStackHighWaterMark,INCLUDE_xQueueGetMutexHolder,INCLUDE_xSemaphoreGetMutexHolder,INCLUDE_pcTaskGetTaskName,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTimerPendFunctionCall,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_xTaskAbortDelay,INCLUDE_xTaskGetHandle,INCLUDE_vTaskCleanUpResources
FREERTOS.Tasks01=test,24,128,test_task,As weak,NULL,Dynamic,NULL,NULL
FREERTOS.IPParameters=Tasks01,configTOTAL_HEAP_SIZE,INCLUDE_vTaskDelayUntil,INCLUDE_eTaskGetState,INCLUDE_uxTaskGetStackHighWaterMark,INCLUDE_xQueueGetMutexHolder,INCLUDE_xSemaphoreGetMutexHolder,INCLUDE_pcTaskGetTaskName,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTimerPendFunctionCall,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_xTaskAbortDelay,INCLUDE_xTaskGetHandle,INCLUDE_vTaskCleanUpResources,FootprintOK
FREERTOS.Tasks01=chassis,24,1024,chassis_task,As weak,NULL,Static,chassisBuffer,chassisControlBlock
FREERTOS.configTOTAL_HEAP_SIZE=24576
File.Version=6
I2C1.I2C_Mode=I2C_Fast
Expand Down Expand Up @@ -233,8 +234,8 @@ Mcu.PinsNb=68
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F407IGHx
MxCube.Version=6.15.0
MxDb.Version=DB.6.0.150
MxCube.Version=6.16.1
MxDb.Version=DB.6.0.161
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
NVIC.CAN1_RX0_IRQn=true\:6\:0\:true\:false\:true\:true\:true\:true\:true
NVIC.CAN2_RX0_IRQn=true\:6\:0\:true\:false\:true\:true\:true\:true\:true
Expand Down Expand Up @@ -404,6 +405,13 @@ PC9.GPIO_Pu=GPIO_PULLUP
PC9.Locked=true
PC9.Mode=I2C
PC9.Signal=I2C3_SDA
PCC.Checker=false
PCC.Line=STM32F407/417
PCC.MCU=STM32F407I(E-G)Hx
PCC.PartNumber=STM32F407IGHx
PCC.Series=STM32F4
PCC.Temperature=25
PCC.Vdd=3.3
PD0.Locked=true
PD0.Mode=CAN_Activate
PD0.Signal=CAN1_RX
Expand Down Expand Up @@ -525,6 +533,7 @@ ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F407IGHx
ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.28.3
ProjectManager.FreePins=false
ProjectManager.FreePinsContext=
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x2000
ProjectManager.KeepUserCode=true
Expand Down
34 changes: 20 additions & 14 deletions CubeMX_BSP/Src/freertos.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
typedef StaticTask_t osStaticThreadDef_t;
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */
Expand All @@ -47,11 +48,16 @@
/* USER CODE BEGIN Variables */

/* USER CODE END Variables */
/* Definitions for test */
osThreadId_t testHandle;
const osThreadAttr_t test_attributes = {
.name = "test",
.stack_size = 128 * 4,
/* Definitions for chassis */
osThreadId_t chassisHandle;
uint32_t chassisBuffer[ 1024 ];
osStaticThreadDef_t chassisControlBlock;
const osThreadAttr_t chassis_attributes = {
.name = "chassis",
.cb_mem = &chassisControlBlock,
.cb_size = sizeof(chassisControlBlock),
.stack_mem = &chassisBuffer[0],
.stack_size = sizeof(chassisBuffer),
.priority = (osPriority_t) osPriorityNormal,
};

Expand All @@ -60,7 +66,7 @@ const osThreadAttr_t test_attributes = {

/* USER CODE END FunctionPrototypes */

void test_task(void *argument);
void chassis_task(void *argument);

extern void MX_USB_DEVICE_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
Expand Down Expand Up @@ -92,8 +98,8 @@ void MX_FREERTOS_Init(void) {
/* USER CODE END RTOS_QUEUES */

/* Create the thread(s) */
/* creation of test */
testHandle = osThreadNew(test_task, NULL, &test_attributes);
/* creation of chassis */
chassisHandle = osThreadNew(chassis_task, NULL, &chassis_attributes);

/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
Expand All @@ -105,24 +111,24 @@ void MX_FREERTOS_Init(void) {

}

/* USER CODE BEGIN Header_test_task */
/* USER CODE BEGIN Header_chassis_task */
/**
* @brief Function implementing the test thread.
* @brief Function implementing the chassis thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_test_task */
__weak void test_task(void *argument)
/* USER CODE END Header_chassis_task */
__weak void chassis_task(void *argument)
{
/* init code for USB_DEVICE */
MX_USB_DEVICE_Init();
/* USER CODE BEGIN test_task */
/* USER CODE BEGIN chassis_task */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END test_task */
/* USER CODE END chassis_task */
}

/* Private application code --------------------------------------------------*/
Expand Down
1 change: 0 additions & 1 deletion CubeMX_BSP/cmake/stm32cubemx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ set(STM32_Drivers_Src
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_can.c
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c
${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c
Expand Down
Loading