与master分支同步更改
This commit is contained in:
parent
3e312b0041
commit
390e168b46
|
@ -52,3 +52,4 @@ build
|
|||
.vscode/.cortex-debug.peripherals.state.json
|
||||
.vscode/.cortex-debug.registers.state.json
|
||||
*.jdebug*
|
||||
settings.json
|
10
.mxproject
10
.mxproject
File diff suppressed because one or more lines are too long
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"files.associations": {
|
||||
"memory.h": "c",
|
||||
"stdint.h": "c",
|
||||
"led_task.h": "c",
|
||||
"stdinf.h": "c",
|
||||
"usart.h": "c",
|
||||
"controller.h": "c",
|
||||
"ins_task.h": "c",
|
||||
"task.h": "c",
|
||||
"user_lib.h": "c",
|
||||
"chassis.h": "c",
|
||||
"can_comm.h": "c",
|
||||
"string.h": "c",
|
||||
"stdlib.h": "c",
|
||||
"crc8.h": "c",
|
||||
"main.h": "c",
|
||||
"can.h": "c",
|
||||
"bsp_can.h": "c",
|
||||
"dji_motor.h": "c",
|
||||
"master_process.h": "c",
|
||||
"seasky_protocol.h": "c",
|
||||
"bsp_usart.h": "c",
|
||||
"message_center.h": "c",
|
||||
"stddef.h": "c",
|
||||
"stm32_hal_legacy.h": "c",
|
||||
"message_buffer.h": "c",
|
||||
"robot_def.h": "c",
|
||||
"remote_control.h": "c",
|
||||
"robot_cmd.h": "c",
|
||||
"chassis_cmd.h": "c",
|
||||
"referee.h": "c",
|
||||
"arm_math.h": "c",
|
||||
"bsp_dwt.h": "c",
|
||||
"compare": "c",
|
||||
"*.tcc": "c",
|
||||
"type_traits": "c",
|
||||
"typeinfo": "c",
|
||||
"general_def.h": "c",
|
||||
"super_cap.h": "c",
|
||||
"motor_def.h": "c",
|
||||
"quaternionekf.h": "c",
|
||||
"shoot.h": "c",
|
||||
"lk9025.h": "c",
|
||||
"ht04.h": "c",
|
||||
"rtc.h": "c",
|
||||
"tim.h": "c",
|
||||
"usb_device.h": "c",
|
||||
"gpio.h": "c",
|
||||
"rng.h": "c",
|
||||
"cmsis_os.h": "c"
|
||||
},
|
||||
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
|
||||
"C_Cpp.intelliSenseEngineFallback": "enabled",
|
||||
}
|
|
@ -59,8 +59,12 @@ void Error_Handler(void);
|
|||
/* Private defines -----------------------------------------------------------*/
|
||||
#define IMU_TEMP_Pin GPIO_PIN_8
|
||||
#define IMU_TEMP_GPIO_Port GPIOB
|
||||
#define MAG_RST_Pin GPIO_PIN_6
|
||||
#define MAG_RST_GPIO_Port GPIOG
|
||||
#define LED_R_Pin GPIO_PIN_12
|
||||
#define LED_R_GPIO_Port GPIOH
|
||||
#define MAG_DR_Pin GPIO_PIN_3
|
||||
#define MAG_DR_GPIO_Port GPIOG
|
||||
#define LED_G_Pin GPIO_PIN_11
|
||||
#define LED_G_GPIO_Port GPIOH
|
||||
#define LED_B_Pin GPIO_PIN_10
|
||||
|
@ -75,6 +79,7 @@ void Error_Handler(void);
|
|||
#define SERVO_GPIO_Port GPIOE
|
||||
#define CS1_GYRO_Pin GPIO_PIN_0
|
||||
#define CS1_GYRO_GPIO_Port GPIOB
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
|
|
@ -34,11 +34,14 @@ extern "C" {
|
|||
|
||||
extern SPI_HandleTypeDef hspi1;
|
||||
|
||||
extern SPI_HandleTypeDef hspi2;
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
void MX_SPI1_Init(void);
|
||||
void MX_SPI2_Init(void);
|
||||
|
||||
/* USER CODE BEGIN Prototypes */
|
||||
|
||||
|
|
|
@ -37,12 +37,11 @@
|
|||
*/
|
||||
#define HAL_MODULE_ENABLED
|
||||
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
#define HAL_CAN_MODULE_ENABLED
|
||||
/* #define HAL_CRC_MODULE_ENABLED */
|
||||
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
|
||||
/* #define HAL_CRYP_MODULE_ENABLED */
|
||||
/* #define HAL_DAC_MODULE_ENABLED */
|
||||
/* #define HAL_DCMI_MODULE_ENABLED */
|
||||
/* #define HAL_DMA2D_MODULE_ENABLED */
|
||||
|
@ -53,7 +52,7 @@
|
|||
/* #define HAL_SRAM_MODULE_ENABLED */
|
||||
/* #define HAL_SDRAM_MODULE_ENABLED */
|
||||
/* #define HAL_HASH_MODULE_ENABLED */
|
||||
/* #define HAL_I2C_MODULE_ENABLED */
|
||||
#define HAL_I2C_MODULE_ENABLED
|
||||
/* #define HAL_I2S_MODULE_ENABLED */
|
||||
/* #define HAL_IWDG_MODULE_ENABLED */
|
||||
/* #define HAL_LTDC_MODULE_ENABLED */
|
||||
|
@ -214,7 +213,7 @@
|
|||
#define MAC_ADDR5 0U
|
||||
|
||||
/* Definition of the Ethernet driver buffers size and count */
|
||||
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
|
||||
#define ETH_RX_BUF_SIZE /* buffer size for receive */
|
||||
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
|
||||
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
|
||||
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
|
||||
|
|
|
@ -51,15 +51,32 @@ void MX_GPIO_Init(void)
|
|||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOI_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(MAG_RST_GPIO_Port, MAG_RST_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(CS1_ACCEL_GPIO_Port, CS1_ACCEL_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(CS1_GYRO_GPIO_Port, CS1_GYRO_Pin, GPIO_PIN_SET);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = MAG_RST_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
|
||||
HAL_GPIO_Init(MAG_RST_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = MAG_DR_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
HAL_GPIO_Init(MAG_DR_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pin : PtPin */
|
||||
GPIO_InitStruct.Pin = KEY_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
/* USER CODE END 0 */
|
||||
|
||||
SPI_HandleTypeDef hspi1;
|
||||
SPI_HandleTypeDef hspi2;
|
||||
|
||||
/* SPI1 init function */
|
||||
void MX_SPI1_Init(void)
|
||||
|
@ -57,6 +58,38 @@ void MX_SPI1_Init(void)
|
|||
|
||||
/* USER CODE END SPI1_Init 2 */
|
||||
|
||||
}
|
||||
/* SPI2 init function */
|
||||
void MX_SPI2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
/* USER CODE END SPI2_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 1 */
|
||||
|
||||
/* USER CODE END SPI2_Init 1 */
|
||||
hspi2.Instance = SPI2;
|
||||
hspi2.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi2.Init.CLKPolarity = SPI_POLARITY_HIGH;
|
||||
hspi2.Init.CLKPhase = SPI_PHASE_2EDGE;
|
||||
hspi2.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
|
||||
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi2.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
|
||||
/* USER CODE END SPI2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
||||
|
@ -96,6 +129,31 @@ void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
|
|||
|
||||
/* USER CODE END SPI1_MspInit 1 */
|
||||
}
|
||||
else if(spiHandle->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 0 */
|
||||
/* SPI2 clock enable */
|
||||
__HAL_RCC_SPI2_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB14 ------> SPI2_MISO
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
||||
|
@ -122,6 +180,25 @@ void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
|
|||
|
||||
/* USER CODE END SPI1_MspDeInit 1 */
|
||||
}
|
||||
else if(spiHandle->Instance==SPI2)
|
||||
{
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SPI2_CLK_DISABLE();
|
||||
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB14 ------> SPI2_MISO
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15);
|
||||
|
||||
/* USER CODE BEGIN SPI2_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END SPI2_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
|
|
@ -387,7 +387,9 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
|||
*/
|
||||
static void Get_SerialNum(void)
|
||||
{
|
||||
uint32_t deviceserial0, deviceserial1, deviceserial2;
|
||||
uint32_t deviceserial0;
|
||||
uint32_t deviceserial1;
|
||||
uint32_t deviceserial2;
|
||||
|
||||
deviceserial0 = *(uint32_t *) DEVICE_ID1;
|
||||
deviceserial1 = *(uint32_t *) DEVICE_ID2;
|
||||
|
|
6
Makefile
6
Makefile
|
@ -39,6 +39,7 @@ BUILD_DIR = build
|
|||
C_SOURCES = \
|
||||
HAL_N_Middlewares/Src/main.c \
|
||||
HAL_N_Middlewares/Src/gpio.c \
|
||||
HAL_N_Middlewares/Src/i2c.c \
|
||||
HAL_N_Middlewares/Src/adc.c \
|
||||
HAL_N_Middlewares/Src/can.c \
|
||||
HAL_N_Middlewares/Src/dma.c \
|
||||
|
@ -64,6 +65,8 @@ HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
|
|||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
|
||||
HAL_N_Middlewares/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
|
||||
|
@ -99,8 +102,11 @@ HAL_N_Middlewares/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/
|
|||
HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT_printf.c \
|
||||
HAL_N_Middlewares/Middlewares/Third_Party/SEGGER/RTT/SEGGER_RTT.c \
|
||||
bsp/bsp_dwt.c \
|
||||
bsp/bsp_pwm.c \
|
||||
bsp/bsp_temperature.c \
|
||||
bsp/bsp_led.c \
|
||||
bsp/bsp_spi.c \
|
||||
bsp/bsp_iic.c \
|
||||
bsp/bsp_can.c \
|
||||
bsp/bsp_buzzer.c \
|
||||
bsp/bsp_usart.c \
|
||||
|
|
|
@ -1,3 +1,59 @@
|
|||
# application
|
||||
|
||||
这是application层的说明
|
||||
<p align='right'>neozng1@hnu.edu.cn</p>
|
||||
|
||||
这是application层的说明。
|
||||
|
||||
|
||||
|
||||
## 使用说明
|
||||
|
||||
在main函数中包含`robot.h`头文件,这是对整车的抽象。将`INStask`,`motortask`,`ledtask`,`monitortask`这四个task加入`freertos.c`中,创建对应的任务,设置合适的任务运行间隔;然后将`robottask`放入freertos.c中,同样以一定的频率运行。 在初始化实时系统之前,在`main()`中调用`RobotInit()`进行整车的初始化。
|
||||
|
||||
INStask的运行频率为1kHz,motortask推荐的运行频率为200Hz\~500Hz,对于高实时性要求的电机可以提升到1kHz,不过要注意CAN总线的负载。ledtask的运行频率推荐为1kHz,monitortask的运行频率推荐为50\~100Hz;robottask的运行频率推荐为150Hz以上,应当高于视觉发送的频率,若后续使用插帧,应该保证不低过motortask太多。
|
||||
|
||||
若使用双板,则在`robot_def.h`中给对应的开发板设定宏定义,如底盘板使用`#define CHASSIS_BOARD`,云台板使用`#define GIMBAL_BOARD`;单个开发板控制整车,则定义`#define ONE_BOARD`。在每个应用中,都已经使用编译预处理指令完成条件编译,会自动根据设定的宏切换功能。使用双板的时候,目前板间通信通过CAN完成,因此两个开发板会挂载在一条总线上,在两个开发板对这条总线的其他使用CAN的设备进行配置时注意**不要发生ID冲突**,还要注意**防止负载过大**。
|
||||
|
||||
**同样,在该文件中你需要修改一些关于机器人的参数**。比如底盘和云台对齐时yaw电机编码器的值,拨盘的单圈载弹量、底盘的轴距等等。
|
||||
|
||||
|
||||
|
||||
## 封装总览
|
||||
|
||||
Robot.c是整个机器人的抽象,其下有4个应用:robot_cmd,gimbal,chassis,shoot。此框架当前是针对步兵/英雄/哨兵设计的,其他机器人只需要根据各自的特殊机构进行修改即可。robot_cmd是整个机器人的核心应用,其负责接受遥控器/上位机发来的指令,并将指令转化为实际的运动控制目标,发送给其他三个应用。后者会根据robot_cmd发来的命令,设定电机和其他执行单元的参考值等。
|
||||
|
||||
为了进一步解耦应用之间的关系,这里并没有采用层级结构(或设计模式中所谓的**工厂模式**,即robot_cmd包含其他三个模块),而采用了应用并列的**发布-订阅**机制,四个应用之间没有任何相互包含关系,他们之间的通信通过module层提供的`message_center`实现。每个应用会通过该模块向一些话题(事件)发布一些消息,同时从一些话题订阅消息。如robot_cmd应用会发布其他三个模块的控制信息,同时订阅其他三个模块的反馈信息。其他三个模块会订阅robot_cmd发布的控制信息,同时发布反馈给robot_cmd的信息,他们不需要知道彼此的存在,只是从`message_center`处获取其他应用发布的消息或向自己发布的话题推送消息。
|
||||
|
||||
|
||||
|
||||
## 整车程序流程
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
main调用RobotInit进行初始化 --> RobotInit调用基础bsp初始化以及各个app的初始化 --> 各个app进行消息订阅初始化和自有模块的初始化 --> 启动实时系统 --> 各任务开始运行
|
||||
|
||||
```
|
||||
|
||||
任务开始之后,每个app之间的交互关系如下:
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
robot_cmd获取遥控器/上位机指令以及各个应用发布的回传信息 --> 将指令转化为具体的控制信息 --> 发布指令到对应话题
|
||||
```
|
||||
|
||||
gimbal/chassis/shoot则根据订阅的robot_cmd发布的消息,将具体的控制信息根据当前模式转化为执行单元的目标值,通过自己拥有的模块完成这些指令,然后把回传的信息发布到对应话题。
|
||||
|
||||
每个应用的具体流程和实现,参见它们各自的说明文档。
|
||||
|
||||
|
||||
|
||||
## 开发要点
|
||||
|
||||
各个应用之间务必通过`message_center`以发布-订阅的方式进行消息交换,不要出现包含关系,这可以大大减小耦合度并提高合作开发的效率。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ static void EmergencyHandler()
|
|||
}
|
||||
}
|
||||
|
||||
void GimbalCMDTask()
|
||||
void RobotCMDTask()
|
||||
{
|
||||
// 从其他应用获取回传数据
|
||||
#ifdef ONE_BOARD
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
|
||||
void GimbalCMDInit();
|
||||
|
||||
void GimbalCMDTask();
|
||||
void RobotCMDTask();
|
||||
|
||||
#endif // !GIMBAL_CMD_H
|
|
@ -0,0 +1,28 @@
|
|||
# robot_cmd
|
||||
|
||||
<p align='right'>neozng1@hnu.edu.cn</p>
|
||||
|
||||
## 运行流程
|
||||
|
||||
运行流程可以很直观的从`RobotCMDTask()`中看出。首先通过消息订阅机制,获取其他应用的反馈信息,然后使用`CalcOffsetAngle()`计算底盘和云台的offset angle(使得底盘始终获知当前的正方向),接着根据当前是通过键鼠or遥控器控制,调用对应的函数,将控制指令量化为具体的控制信息;得到控制信息之后,先不急着发布,而是检测重要的模块和应用是否掉线或出现异常,以及遥控器是否进入紧急停止模式,如果以上情况发生,那么将所有的控制信息都置零,即让电机和其他执行单元保持静止。最后还是通过pubsub机制,把具体的控制信息发布到对应话题,让其他应用获取。
|
||||
|
||||
|
||||
|
||||
## 外部接口
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 私有函数和变量
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ void RobotInit()
|
|||
void RobotTask()
|
||||
{
|
||||
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
|
||||
GimbalCMDTask();
|
||||
RobotCMDTask();
|
||||
GimbalTask();
|
||||
ShootTask();
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,9 @@ ADC1.NbrOfConversionFlag=1
|
|||
ADC1.Rank-0\#ChannelRegularConversion=1
|
||||
ADC1.SamplingTime-0\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
|
||||
ADC1.master=1
|
||||
CAD.formats=
|
||||
CAD.pinconfig=
|
||||
CAD.provider=
|
||||
CAN1.BS1=CAN_BS1_10TQ
|
||||
CAN1.BS2=CAN_BS2_3TQ
|
||||
CAN1.CalculateBaudRate=1000000
|
||||
|
@ -18,12 +21,82 @@ CAN2.CalculateBaudRate=1000000
|
|||
CAN2.CalculateTimeQuantum=71.42857142857143
|
||||
CAN2.IPParameters=CalculateTimeQuantum,BS1,BS2,Prescaler,CalculateBaudRate
|
||||
CAN2.Prescaler=3
|
||||
Dma.MEMTOMEM.5.Direction=DMA_MEMORY_TO_MEMORY
|
||||
Dma.MEMTOMEM.5.FIFOMode=DMA_FIFOMODE_ENABLE
|
||||
Dma.MEMTOMEM.5.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
|
||||
Dma.MEMTOMEM.5.Instance=DMA2_Stream3
|
||||
Dma.MEMTOMEM.5.MemBurst=DMA_MBURST_SINGLE
|
||||
Dma.MEMTOMEM.5.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.MEMTOMEM.5.MemInc=DMA_MINC_ENABLE
|
||||
Dma.MEMTOMEM.5.Mode=DMA_NORMAL
|
||||
Dma.MEMTOMEM.5.PeriphBurst=DMA_PBURST_SINGLE
|
||||
Dma.MEMTOMEM.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.MEMTOMEM.5.PeriphInc=DMA_PINC_ENABLE
|
||||
Dma.MEMTOMEM.5.Priority=DMA_PRIORITY_HIGH
|
||||
Dma.MEMTOMEM.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
||||
Dma.Request0=USART3_RX
|
||||
Dma.Request1=USART6_RX
|
||||
Dma.Request2=USART6_TX
|
||||
Dma.Request3=USART1_TX
|
||||
Dma.Request4=USART1_RX
|
||||
Dma.RequestsNb=5
|
||||
Dma.Request5=MEMTOMEM
|
||||
Dma.Request6=SPI1_RX
|
||||
Dma.Request7=SPI1_TX
|
||||
Dma.Request8=SPI2_RX
|
||||
Dma.Request9=SPI2_TX
|
||||
Dma.RequestsNb=10
|
||||
Dma.SPI1_RX.6.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.SPI1_RX.6.FIFOMode=DMA_FIFOMODE_ENABLE
|
||||
Dma.SPI1_RX.6.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
|
||||
Dma.SPI1_RX.6.Instance=DMA2_Stream0
|
||||
Dma.SPI1_RX.6.MemBurst=DMA_MBURST_SINGLE
|
||||
Dma.SPI1_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.SPI1_RX.6.MemInc=DMA_MINC_ENABLE
|
||||
Dma.SPI1_RX.6.Mode=DMA_NORMAL
|
||||
Dma.SPI1_RX.6.PeriphBurst=DMA_PBURST_SINGLE
|
||||
Dma.SPI1_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.SPI1_RX.6.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.SPI1_RX.6.Priority=DMA_PRIORITY_LOW
|
||||
Dma.SPI1_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
||||
Dma.SPI1_TX.7.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.SPI1_TX.7.FIFOMode=DMA_FIFOMODE_ENABLE
|
||||
Dma.SPI1_TX.7.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
|
||||
Dma.SPI1_TX.7.Instance=DMA2_Stream5
|
||||
Dma.SPI1_TX.7.MemBurst=DMA_MBURST_SINGLE
|
||||
Dma.SPI1_TX.7.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.SPI1_TX.7.MemInc=DMA_MINC_ENABLE
|
||||
Dma.SPI1_TX.7.Mode=DMA_NORMAL
|
||||
Dma.SPI1_TX.7.PeriphBurst=DMA_PBURST_SINGLE
|
||||
Dma.SPI1_TX.7.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.SPI1_TX.7.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.SPI1_TX.7.Priority=DMA_PRIORITY_LOW
|
||||
Dma.SPI1_TX.7.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
||||
Dma.SPI2_RX.8.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.SPI2_RX.8.FIFOMode=DMA_FIFOMODE_ENABLE
|
||||
Dma.SPI2_RX.8.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
|
||||
Dma.SPI2_RX.8.Instance=DMA1_Stream3
|
||||
Dma.SPI2_RX.8.MemBurst=DMA_MBURST_SINGLE
|
||||
Dma.SPI2_RX.8.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.SPI2_RX.8.MemInc=DMA_MINC_ENABLE
|
||||
Dma.SPI2_RX.8.Mode=DMA_NORMAL
|
||||
Dma.SPI2_RX.8.PeriphBurst=DMA_PBURST_SINGLE
|
||||
Dma.SPI2_RX.8.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.SPI2_RX.8.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.SPI2_RX.8.Priority=DMA_PRIORITY_LOW
|
||||
Dma.SPI2_RX.8.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
||||
Dma.SPI2_TX.9.Direction=DMA_MEMORY_TO_PERIPH
|
||||
Dma.SPI2_TX.9.FIFOMode=DMA_FIFOMODE_ENABLE
|
||||
Dma.SPI2_TX.9.FIFOThreshold=DMA_FIFO_THRESHOLD_FULL
|
||||
Dma.SPI2_TX.9.Instance=DMA1_Stream4
|
||||
Dma.SPI2_TX.9.MemBurst=DMA_MBURST_SINGLE
|
||||
Dma.SPI2_TX.9.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||
Dma.SPI2_TX.9.MemInc=DMA_MINC_ENABLE
|
||||
Dma.SPI2_TX.9.Mode=DMA_NORMAL
|
||||
Dma.SPI2_TX.9.PeriphBurst=DMA_PBURST_SINGLE
|
||||
Dma.SPI2_TX.9.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||
Dma.SPI2_TX.9.PeriphInc=DMA_PINC_DISABLE
|
||||
Dma.SPI2_TX.9.Priority=DMA_PRIORITY_LOW
|
||||
Dma.SPI2_TX.9.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode,FIFOThreshold,MemBurst,PeriphBurst
|
||||
Dma.USART1_RX.4.Direction=DMA_PERIPH_TO_MEMORY
|
||||
Dma.USART1_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||
Dma.USART1_RX.4.Instance=DMA2_Stream2
|
||||
|
@ -79,31 +152,38 @@ FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NU
|
|||
FREERTOS.configENABLE_FPU=1
|
||||
File.Version=6
|
||||
GPIO.groupedBy=Group By Peripherals
|
||||
I2C2.I2C_Mode=I2C_Fast
|
||||
I2C2.IPParameters=I2C_Mode
|
||||
I2C3.I2C_Mode=I2C_Fast
|
||||
I2C3.IPParameters=I2C_Mode
|
||||
KeepUserPlacement=false
|
||||
Mcu.CPN=STM32F407IGH6
|
||||
Mcu.Family=STM32F4
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=CAN1
|
||||
Mcu.IP10=SYS
|
||||
Mcu.IP11=TIM1
|
||||
Mcu.IP12=TIM4
|
||||
Mcu.IP13=TIM5
|
||||
Mcu.IP14=TIM8
|
||||
Mcu.IP15=TIM10
|
||||
Mcu.IP16=USART1
|
||||
Mcu.IP17=USART3
|
||||
Mcu.IP18=USART6
|
||||
Mcu.IP19=USB_DEVICE
|
||||
Mcu.IP10=RTC
|
||||
Mcu.IP11=SPI1
|
||||
Mcu.IP12=SPI2
|
||||
Mcu.IP13=SYS
|
||||
Mcu.IP14=TIM1
|
||||
Mcu.IP15=TIM4
|
||||
Mcu.IP16=TIM5
|
||||
Mcu.IP17=TIM8
|
||||
Mcu.IP18=TIM10
|
||||
Mcu.IP19=USART1
|
||||
Mcu.IP2=CAN2
|
||||
Mcu.IP20=USB_OTG_FS
|
||||
Mcu.IP20=USART3
|
||||
Mcu.IP21=USART6
|
||||
Mcu.IP22=USB_DEVICE
|
||||
Mcu.IP23=USB_OTG_FS
|
||||
Mcu.IP3=DMA
|
||||
Mcu.IP4=FREERTOS
|
||||
Mcu.IP5=NVIC
|
||||
Mcu.IP6=RCC
|
||||
Mcu.IP7=RNG
|
||||
Mcu.IP8=RTC
|
||||
Mcu.IP9=SPI1
|
||||
Mcu.IPNb=21
|
||||
Mcu.IP5=I2C2
|
||||
Mcu.IP6=I2C3
|
||||
Mcu.IP7=NVIC
|
||||
Mcu.IP8=RCC
|
||||
Mcu.IP9=RNG
|
||||
Mcu.IPNb=24
|
||||
Mcu.Name=STM32F407I(E-G)Hx
|
||||
Mcu.Package=UFBGA176
|
||||
Mcu.Pin0=PB8
|
||||
|
@ -116,58 +196,71 @@ Mcu.Pin14=PI6
|
|||
Mcu.Pin15=PG9
|
||||
Mcu.Pin16=PD1
|
||||
Mcu.Pin17=PA11
|
||||
Mcu.Pin18=PA9
|
||||
Mcu.Pin19=PH0-OSC_IN
|
||||
Mcu.Pin18=PF0
|
||||
Mcu.Pin19=PA9
|
||||
Mcu.Pin2=PG14
|
||||
Mcu.Pin20=PH1-OSC_OUT
|
||||
Mcu.Pin21=PC6
|
||||
Mcu.Pin22=PH12
|
||||
Mcu.Pin23=PH11
|
||||
Mcu.Pin24=PH10
|
||||
Mcu.Pin25=PD14
|
||||
Mcu.Pin26=PA0-WKUP
|
||||
Mcu.Pin27=PA4
|
||||
Mcu.Pin28=PE13
|
||||
Mcu.Pin29=PE9
|
||||
Mcu.Pin20=PC9
|
||||
Mcu.Pin21=PA8
|
||||
Mcu.Pin22=PH0-OSC_IN
|
||||
Mcu.Pin23=PH1-OSC_OUT
|
||||
Mcu.Pin24=PF1
|
||||
Mcu.Pin25=PC6
|
||||
Mcu.Pin26=PG6
|
||||
Mcu.Pin27=PH12
|
||||
Mcu.Pin28=PG3
|
||||
Mcu.Pin29=PH11
|
||||
Mcu.Pin3=PB4
|
||||
Mcu.Pin30=PE11
|
||||
Mcu.Pin31=PE14
|
||||
Mcu.Pin32=PA7
|
||||
Mcu.Pin33=PB0
|
||||
Mcu.Pin34=VP_ADC1_TempSens_Input
|
||||
Mcu.Pin35=VP_ADC1_Vref_Input
|
||||
Mcu.Pin36=VP_FREERTOS_VS_CMSIS_V1
|
||||
Mcu.Pin37=VP_RNG_VS_RNG
|
||||
Mcu.Pin38=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin39=VP_SYS_VS_Systick
|
||||
Mcu.Pin30=PH10
|
||||
Mcu.Pin31=PD14
|
||||
Mcu.Pin32=PA0-WKUP
|
||||
Mcu.Pin33=PA4
|
||||
Mcu.Pin34=PE13
|
||||
Mcu.Pin35=PE9
|
||||
Mcu.Pin36=PE11
|
||||
Mcu.Pin37=PE14
|
||||
Mcu.Pin38=PB13
|
||||
Mcu.Pin39=PA7
|
||||
Mcu.Pin4=PB3
|
||||
Mcu.Pin40=VP_TIM1_VS_ClockSourceINT
|
||||
Mcu.Pin41=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin42=VP_TIM5_VS_ClockSourceINT
|
||||
Mcu.Pin43=VP_TIM8_VS_ClockSourceINT
|
||||
Mcu.Pin44=VP_TIM10_VS_ClockSourceINT
|
||||
Mcu.Pin45=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
|
||||
Mcu.Pin46=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.3.0_1.3.0
|
||||
Mcu.Pin40=PB0
|
||||
Mcu.Pin41=PB14
|
||||
Mcu.Pin42=PB15
|
||||
Mcu.Pin43=VP_ADC1_TempSens_Input
|
||||
Mcu.Pin44=VP_ADC1_Vref_Input
|
||||
Mcu.Pin45=VP_FREERTOS_VS_CMSIS_V1
|
||||
Mcu.Pin46=VP_RNG_VS_RNG
|
||||
Mcu.Pin47=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin48=VP_SYS_VS_Systick
|
||||
Mcu.Pin49=VP_TIM1_VS_ClockSourceINT
|
||||
Mcu.Pin5=PA14
|
||||
Mcu.Pin50=VP_TIM4_VS_ClockSourceINT
|
||||
Mcu.Pin51=VP_TIM5_VS_ClockSourceINT
|
||||
Mcu.Pin52=VP_TIM8_VS_ClockSourceINT
|
||||
Mcu.Pin53=VP_TIM10_VS_ClockSourceINT
|
||||
Mcu.Pin54=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS
|
||||
Mcu.Pin55=VP_STMicroelectronics.X-CUBE-ALGOBUILD_VS_DSPOoLibraryJjLibrary_1.3.0_1.3.0
|
||||
Mcu.Pin6=PA13
|
||||
Mcu.Pin7=PB7
|
||||
Mcu.Pin8=PB6
|
||||
Mcu.Pin9=PD0
|
||||
Mcu.PinsNb=47
|
||||
Mcu.PinsNb=56
|
||||
Mcu.ThirdParty0=STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0
|
||||
Mcu.ThirdPartyNb=1
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32F407IGHx
|
||||
MxCube.Version=6.6.1
|
||||
MxDb.Version=DB.6.0.60
|
||||
MxCube.Version=6.7.0
|
||||
MxDb.Version=DB.6.0.70
|
||||
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.CAN1_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.CAN2_RX0_IRQn=true\:6\:0\:true\:false\:true\:true\:true\:true\:true
|
||||
NVIC.CAN2_RX1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.DMA1_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA1_Stream3_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA1_Stream4_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA2_Stream1_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA2_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA2_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA2_Stream6_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DMA2_Stream7_IRQn=true\:5\:0\:true\:false\:true\:true\:false\:true\:true
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||
|
@ -178,6 +271,8 @@ NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:fa
|
|||
NVIC.OTG_FS_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false\:false
|
||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SPI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.SPI2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false\:false
|
||||
NVIC.SavedPendsvIrqHandlerGenerated=true
|
||||
NVIC.SavedSvcallIrqHandlerGenerated=true
|
||||
|
@ -212,6 +307,8 @@ PA7.GPIO_PuPd=GPIO_PULLUP
|
|||
PA7.Locked=true
|
||||
PA7.Mode=Full_Duplex_Master
|
||||
PA7.Signal=SPI1_MOSI
|
||||
PA8.Mode=I2C
|
||||
PA8.Signal=I2C3_SCL
|
||||
PA9.Locked=true
|
||||
PA9.Mode=Asynchronous
|
||||
PA9.Signal=USART1_TX
|
||||
|
@ -222,6 +319,15 @@ PB0.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
|||
PB0.Locked=true
|
||||
PB0.PinState=GPIO_PIN_SET
|
||||
PB0.Signal=GPIO_Output
|
||||
PB13.Locked=true
|
||||
PB13.Mode=Full_Duplex_Master
|
||||
PB13.Signal=SPI2_SCK
|
||||
PB14.Locked=true
|
||||
PB14.Mode=Full_Duplex_Master
|
||||
PB14.Signal=SPI2_MISO
|
||||
PB15.Locked=true
|
||||
PB15.Mode=Full_Duplex_Master
|
||||
PB15.Signal=SPI2_MOSI
|
||||
PB3.GPIOParameters=GPIO_PuPd
|
||||
PB3.GPIO_PuPd=GPIO_PULLUP
|
||||
PB3.Locked=true
|
||||
|
@ -255,6 +361,8 @@ PC11.Mode=Asynchronous
|
|||
PC11.Signal=USART3_RX
|
||||
PC6.Locked=true
|
||||
PC6.Signal=S_TIM8_CH1
|
||||
PC9.Mode=I2C
|
||||
PC9.Signal=I2C3_SDA
|
||||
PD0.Locked=true
|
||||
PD0.Mode=CAN_Activate
|
||||
PD0.Signal=CAN1_RX
|
||||
|
@ -277,9 +385,25 @@ PE9.GPIO_PuPd=GPIO_PULLUP
|
|||
PE9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||
PE9.Locked=true
|
||||
PE9.Signal=S_TIM1_CH1
|
||||
PF0.Mode=I2C
|
||||
PF0.Signal=I2C2_SDA
|
||||
PF1.Mode=I2C
|
||||
PF1.Signal=I2C2_SCL
|
||||
PG14.Locked=true
|
||||
PG14.Mode=Asynchronous
|
||||
PG14.Signal=USART6_TX
|
||||
PG3.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
||||
PG3.GPIO_Label=MAG_DR
|
||||
PG3.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
||||
PG3.GPIO_PuPd=GPIO_PULLUP
|
||||
PG3.Locked=true
|
||||
PG3.Signal=GPXTI3
|
||||
PG6.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label
|
||||
PG6.GPIO_Label=MAG_RST
|
||||
PG6.GPIO_PuPd=GPIO_PULLUP
|
||||
PG6.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
||||
PG6.Locked=true
|
||||
PG6.Signal=GPIO_Output
|
||||
PG9.Locked=true
|
||||
PG9.Mode=Asynchronous
|
||||
PG9.Signal=USART6_RX
|
||||
|
@ -336,7 +460,7 @@ ProjectManager.StackSize=0x4000
|
|||
ProjectManager.TargetToolchain=Makefile
|
||||
ProjectManager.ToolChainLocation=
|
||||
ProjectManager.UnderRoot=false
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_CAN2_Init-CAN2-false-HAL-true,7-MX_SPI1_Init-SPI1-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_TIM5_Init-TIM5-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_RNG_Init-RNG-false-HAL-true,12-MX_RTC_Init-RTC-false-HAL-true,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_TIM10_Init-TIM10-false-HAL-true,15-MX_USART1_UART_Init-USART1-false-HAL-true,16-MX_USART6_UART_Init-USART6-false-HAL-true,17-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,18-MX_TIM8_Init-TIM8-false-HAL-true
|
||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-false,4-MX_ADC1_Init-ADC1-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_CAN2_Init-CAN2-false-HAL-true,7-MX_SPI1_Init-SPI1-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_TIM5_Init-TIM5-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_RNG_Init-RNG-false-HAL-true,12-MX_RTC_Init-RTC-false-HAL-true,13-MX_TIM1_Init-TIM1-false-HAL-true,14-MX_TIM10_Init-TIM10-false-HAL-true,15-MX_USART1_UART_Init-USART1-false-HAL-true,16-MX_USART6_UART_Init-USART6-false-HAL-true,17-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,18-MX_TIM8_Init-TIM8-false-HAL-true,19-MX_I2C2_Init-I2C2-false-HAL-true,20-MX_I2C3_Init-I2C3-false-HAL-true,21-MX_SPI2_Init-SPI2-false-HAL-true
|
||||
RCC.48MHZClocksFreq_Value=48000000
|
||||
RCC.AHBFreq_Value=168000000
|
||||
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
||||
|
@ -375,6 +499,8 @@ RCC.VcooutputI2S=192000000
|
|||
RTC.AsynchPrediv=124
|
||||
RTC.IPParameters=SynchPrediv,AsynchPrediv
|
||||
RTC.SynchPrediv=3199
|
||||
SH.GPXTI3.0=GPIO_EXTI3
|
||||
SH.GPXTI3.ConfNb=1
|
||||
SH.S_TIM10_CH1.0=TIM10_CH1,PWM Generation1 CH1
|
||||
SH.S_TIM10_CH1.ConfNb=1
|
||||
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
|
||||
|
@ -407,6 +533,14 @@ SPI1.Direction=SPI_DIRECTION_2LINES
|
|||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,CLKPolarity,CLKPhase
|
||||
SPI1.Mode=SPI_MODE_MASTER
|
||||
SPI1.VirtualType=VM_MASTER
|
||||
SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_256
|
||||
SPI2.CLKPhase=SPI_PHASE_2EDGE
|
||||
SPI2.CLKPolarity=SPI_POLARITY_HIGH
|
||||
SPI2.CalculateBaudRate=164.062 KBits/s
|
||||
SPI2.Direction=SPI_DIRECTION_2LINES
|
||||
SPI2.IPParameters=VirtualType,Mode,Direction,CLKPhase,CLKPolarity,CalculateBaudRate,BaudRatePrescaler
|
||||
SPI2.Mode=SPI_MODE_MASTER
|
||||
SPI2.VirtualType=VM_MASTER
|
||||
STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0.DSPOoLibraryJjLibrary_Checked=true
|
||||
STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0.IPParameters=LibraryCcDSPOoLibraryJjDSPOoLibrary
|
||||
STMicroelectronics.X-CUBE-ALGOBUILD.1.3.0.LibraryCcDSPOoLibraryJjDSPOoLibrary=true
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "bsp_can.h"
|
||||
#include "main.h"
|
||||
#include <stdlib.h>
|
||||
#include "memory.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/* can instance ptrs storage, used for recv callback */
|
||||
// 在CAN产生接收中断会遍历数组,选出hcan和rxid与发生中断的实例相同的那个,调用其回调函数
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#include "bsp_iic.h"
|
||||
#include "memory.h"
|
||||
#include "stdlib.h"
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#include "i2c.h"
|
||||
#include "stdint.h"
|
||||
|
||||
#define IIC_DEVICE_CNT ()
|
||||
|
||||
typedef struct
|
||||
{
|
||||
I2C_HandleTypeDef* handle;
|
||||
|
||||
};
|
||||
|
143
bsp/bsp_spi.c
143
bsp/bsp_spi.c
|
@ -0,0 +1,143 @@
|
|||
#include "bsp_spi.h"
|
||||
#include "memory.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/* 所有的spi instance保存于此,用于callback时判断中断来源*/
|
||||
static SPIInstance *spi_instance[SPI_DEVICE_CNT] = {NULL};
|
||||
static uint8_t idx = 0; // 配合中断以及初始化
|
||||
|
||||
/**
|
||||
* @brief 当SPI接收完成,将会调用此回调函数,可以进行协议解析或其他必须的数据处理等
|
||||
*
|
||||
* @param hspi spi handle
|
||||
*/
|
||||
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
|
||||
{
|
||||
for (size_t i = 0; i < idx; i++)
|
||||
{
|
||||
if (spi_instance[i]->spi_handle == hspi && spi_instance[i]->callback)
|
||||
{
|
||||
// 拉高片选(关闭传输),调用解析回调函数
|
||||
HAL_GPIO_WritePin(spi_instance[i]->GPIO_cs, spi_instance[i]->cs_pin, GPIO_PIN_SET);
|
||||
spi_instance[i]->callback(spi_instance[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 和RxCpltCallback共用解析即可,这里只是形式上封装一下,不用重复写
|
||||
*
|
||||
* @param hspi spi handle
|
||||
*/
|
||||
void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi)
|
||||
{
|
||||
HAL_SPI_RxCpltCallback(hspi);
|
||||
}
|
||||
|
||||
SPIInstance *SPIRegister(SPI_Init_Config_s *conf)
|
||||
{
|
||||
spi_instance[idx] = (SPIInstance *)malloc(sizeof(SPIInstance));
|
||||
spi_instance[idx]->callback = conf->callback;
|
||||
spi_instance[idx]->spi_work_mode = conf->spi_work_mode;
|
||||
spi_instance[idx]->spi_handle = conf->spi_handle;
|
||||
return spi_instance[idx++];
|
||||
}
|
||||
|
||||
void SPITransmit(SPIInstance *spi_ins, uint8_t *ptr_data, uint8_t len)
|
||||
{
|
||||
// 拉低片选,开始传输
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_RESET);
|
||||
switch (spi_ins->spi_work_mode)
|
||||
{
|
||||
case SPI_DMA_MODE:
|
||||
HAL_SPI_Transmit_DMA(spi_ins->spi_handle, ptr_data, len);
|
||||
break;
|
||||
case SPI_IT_MODE:
|
||||
HAL_SPI_Transmit_IT(spi_ins->spi_handle, ptr_data, len);
|
||||
break;
|
||||
case SPI_BLOCK_MODE:
|
||||
HAL_SPI_Transmit(spi_ins->spi_handle, ptr_data, len, 10);
|
||||
// 阻塞模式不会调用回调函数,传输完成后直接拉高片选结束
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_SET);
|
||||
break;
|
||||
default:
|
||||
while (1)
|
||||
; // error mode! 请查看是否正确设置模式,或出现指针越界导致模式被异常修改的情况
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SPIRecv(SPIInstance *spi_ins, uint8_t *ptr_data, uint8_t len)
|
||||
{
|
||||
// 拉低片选,开始传输
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_RESET);
|
||||
switch (spi_ins->spi_work_mode)
|
||||
{
|
||||
case SPI_DMA_MODE:
|
||||
HAL_SPI_Receive_DMA(spi_ins->spi_handle, ptr_data, len);
|
||||
break;
|
||||
case SPI_IT_MODE:
|
||||
HAL_SPI_Receive_IT(spi_ins->spi_handle, ptr_data, len);
|
||||
break;
|
||||
case SPI_BLOCK_MODE:
|
||||
HAL_SPI_Receive(spi_ins->spi_handle, ptr_data, len, 10);
|
||||
// 阻塞模式不会调用回调函数,传输完成后直接拉高片选结束
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_SET);
|
||||
break;
|
||||
default:
|
||||
while (1)
|
||||
; // error mode! 请查看是否正确设置模式,或出现指针越界导致模式被异常修改的情况
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SPITransRecv(SPIInstance *spi_ins, uint8_t *ptr_data_rx, uint8_t *ptr_data_tx, uint8_t len)
|
||||
{
|
||||
// 拉低片选,开始传输
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_RESET);
|
||||
switch (spi_ins->spi_work_mode)
|
||||
{
|
||||
case SPI_DMA_MODE:
|
||||
HAL_SPI_TransmitReceive_DMA(spi_ins->spi_handle, ptr_data_tx, ptr_data_rx, len);
|
||||
break;
|
||||
case SPI_IT_MODE:
|
||||
HAL_SPI_TransmitReceive_IT(spi_ins->spi_handle, ptr_data_tx, ptr_data_rx, len);
|
||||
break;
|
||||
case SPI_BLOCK_MODE:
|
||||
HAL_SPI_TransmitReceive(spi_ins->spi_handle, ptr_data_tx, ptr_data_rx, len, 10);
|
||||
// 阻塞模式不会调用回调函数,传输完成后直接拉高片选结束
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_SET);
|
||||
break;
|
||||
default:
|
||||
while (1)
|
||||
; // error mode! 请查看是否正确设置模式,或出现指针越界导致模式被异常修改的情况
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SPISetMode(SPIInstance *spi_ins, SPI_TXRX_MODE_e spi_mode)
|
||||
{
|
||||
if (spi_ins->spi_work_mode != spi_mode)
|
||||
{
|
||||
switch (spi_ins->spi_work_mode)
|
||||
{
|
||||
case SPI_IT_MODE:
|
||||
case SPI_DMA_MODE:
|
||||
// IT和DMA处理相同,都是先终止传输,防止传输未完成直接切换导致spi死机
|
||||
HAL_SPI_Abort_IT(spi_ins->spi_handle);
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_SET); // 关闭后拉高片选
|
||||
break;
|
||||
case SPI_BLOCK_MODE:
|
||||
// 阻塞模式仍然有可能在多线程的情况下出现传输到一半切换,因此先终止
|
||||
HAL_SPI_Abort(spi_ins->spi_handle);
|
||||
HAL_GPIO_WritePin(spi_ins->GPIO_cs, spi_ins->cs_pin, GPIO_PIN_SET); // 关闭后拉高片选
|
||||
break;
|
||||
default:
|
||||
while (1)
|
||||
; // error mode! 请查看是否正确设置模式,或出现指针越界导致模式被异常修改的情况
|
||||
break;
|
||||
}
|
||||
spi_ins->spi_work_mode = spi_mode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
#include "spi.h"
|
||||
#include "stdint.h"
|
||||
#include "gpio.h"
|
||||
|
||||
/* 根据开发板引出的spi引脚以及CubeMX中的初始化配置设定 */
|
||||
#define SPI_DEVICE_CNT 2 // C型开发板引出两路spi,分别连接BMI088/作为扩展IO在8pin牛角座引出
|
||||
#define MX_SPI_BUS_SLAVE_CNT 4 // 单个spi总线上挂载的从机数目
|
||||
|
||||
/* spi transmit recv mode enumerate*/
|
||||
typedef enum
|
||||
{
|
||||
SPI_BLOCK_MODE = 0, // 默认使用阻塞模式
|
||||
SPI_IT_MODE,
|
||||
SPI_DMA_MODE,
|
||||
} SPI_TXRX_MODE_e;
|
||||
|
||||
/* SPI实例结构体定义 */
|
||||
typedef struct spi_ins_temp
|
||||
{
|
||||
SPI_HandleTypeDef *spi_handle; // SPI外设handle
|
||||
GPIO_TypeDef *GPIO_cs; // 片选信号对应的GPIO,如GPIOA,GPIOB等等
|
||||
uint16_t cs_pin; // 片选信号对应的引脚号,GPIO_PIN_1,GPIO_PIN_2等等
|
||||
SPI_TXRX_MODE_e spi_work_mode; // 传输工作模式
|
||||
void (*callback)(struct spi_ins_temp *); // 接收回调函数
|
||||
} SPIInstance;
|
||||
|
||||
/* rx data resolve callback*/
|
||||
typedef void (*spi_rx_callback)(SPIInstance *);
|
||||
|
||||
/* SPI初始化配置,其实和SPIIstance一模一样,为了代码风格统一因此再次定义 */
|
||||
typedef struct
|
||||
{
|
||||
SPI_HandleTypeDef *spi_handle; // SPI外设handle
|
||||
GPIO_TypeDef *GPIO_cs; // 片选信号对应的GPIO,如GPIOA,GPIOB等等
|
||||
uint16_t cs_pin; // 片选信号对应的引脚号,GPIO_PIN_1,GPIO_PIN_2等等
|
||||
SPI_TXRX_MODE_e spi_work_mode; // 传输工作模式
|
||||
spi_rx_callback callback; // 接收回调函数
|
||||
} SPI_Init_Config_s;
|
||||
|
||||
/**
|
||||
* @brief 注册一个spi instance
|
||||
*
|
||||
* @param conf 传入spi配置
|
||||
* @return SPIInstance* 返回一个spi实例指针,之后通过该指针操作spi外设
|
||||
*/
|
||||
SPIInstance *SPIRegister(SPI_Init_Config_s *conf);
|
||||
|
||||
/**
|
||||
* @brief 通过spi向对应从机发送数据
|
||||
*
|
||||
* @param spi_ins spi实例指针
|
||||
* @param ptr_data 要发送的数据
|
||||
* @param len 待发送的数据长度
|
||||
*/
|
||||
void SPITransmit(SPIInstance *spi_ins, uint8_t *ptr_data, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief 通过spi从从机获取数据
|
||||
*
|
||||
* @param spi_ins spi实例指针
|
||||
* @param ptr_data 接受数据buffer的首地址
|
||||
* @param len 待接收的长度
|
||||
*/
|
||||
void SPIRecv(SPIInstance *spi_ins, uint8_t *ptr_data, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief 通过spi利用移位寄存器同时收发数据
|
||||
*
|
||||
* @param spi_ins spi实例指针
|
||||
* @param ptr_data_rx 接收数据地址
|
||||
* @param ptr_data_tx 发送数据地址
|
||||
* @param len 接收&发送的长度
|
||||
*/
|
||||
void SPITransRecv(SPIInstance *spi_ins, uint8_t *ptr_data_rx, uint8_t *ptr_data_tx, uint8_t len);
|
||||
|
||||
/**
|
||||
* @brief 设定spi收发的工作模式
|
||||
*
|
||||
* @param spi_ins spi实例指针
|
||||
* @param spi_mode 工作模式,包括阻塞模式(block),中断模式(IT),DMA模式.详见SPI_TXRX_MODE_e的定义
|
||||
*/
|
||||
void SPISetMode(SPIInstance *spi_ins, SPI_TXRX_MODE_e spi_mode);
|
|
@ -317,7 +317,7 @@ uint8_t bmi088_gyro_init(void)
|
|||
|
||||
void BMI088_Read(IMU_Data_t *bmi088)
|
||||
{
|
||||
static uint8_t buf[8] = {0, 0, 0, 0, 0, 0};
|
||||
static uint8_t buf[8] = {0};
|
||||
static int16_t bmi088_raw_temp;
|
||||
static float dt = 1.0;
|
||||
static uint8_t first_read_flag = 0;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
- 订阅者:获取消息的对象。订阅者在订阅了某个事件之后,可以通过接口获得该事件的消息。
|
||||
- 事件(event / topic):用于区分消息来源的对象。可以将一个事件看作一刊杂志,不同的发布者会将文章汇集到杂志上,而订阅者选择订阅一种杂志,然后就可以获取所有写在杂志上的文章。
|
||||
|
||||
Message Center不同应用间进行消息传递的中介,它的存在可以在相当大的程度上解耦不同的app,使得不同的应用之间**不存在包含关系**,让代码的自由度更大,将不同模块之间的关系降为**松耦合**。在以往,如果一个.c文件中的数据需要被其他任务/源文件共享,那么其他模块应该要包含前者的头文件,或头文件中应当存在获取该模块数据的接口(即函数,一般是返回数据指针或直接返回数据);但现在,不同的应用之间完全隔离,他们不需要了解彼此的存在,而是只能看见一个**消息中心**。
|
||||
Message Center不同应用间进行消息传递的中介,它的存在可以在相当大的程度上解耦不同的app,使得不同的应用之间**不存在包含关系**,让代码的自由度更大,将不同模块之间的关系降为**松耦合**。在以往,如果一个.c文件中的数据需要被其他任务/源文件共享,那么其他模块应该要包含前者的头文件,且头文件中应当存在获取该模块数据的接口(即函数,一般是返回数据指针或直接返回数据,**强烈建议不要使用全局变量**);但现在,不同的应用之间完全隔离,他们不需要了解彼此的存在,而是只能看见一个**消息中心**以及一些事件(有些地方也称**话题**)。
|
||||
|
||||
需要被共享的消息,将会被**发布者**(publisher)发送到消息中心;要获取消息,则由**订阅者**(subscriber)从消息中心根据订阅的消息名(事件)获取。在这之前,发布者要在消息中心完成**注册**,将自己要发布的消息类型和消息名称提交到消息中心;订阅者同样要先在消息中心完成订阅,将自己要接收的消息类型和消息名称提交到订阅中心。消息中心会根据**消息名称**,把订阅者绑定到发布相同名称的发布者上。
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# 选择调试器为jlink
|
||||
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
# source [find interface/jlink.cfg] #使用jlink硬件进行调试,注意其他地方也要更改
|
||||
# source [find interface/jlink.cfg] #使用cmsis-dap硬件进行调试,注意其他地方也要更改
|
||||
# OpenOCD作为GDB和硬件调试器的桥梁(为硬件提供抽象,把接口给GDB),支持多种硬件调试器.
|
||||
# OpenOCD会自动在其根目录的share/openocd/scripts/interface里面寻找对应的配置文件
|
||||
|
||||
|
|
Loading…
Reference in New Issue