Skip to content

Commit

Permalink
feat: Driver层全面适配STM32F4系列
Browse files Browse the repository at this point in the history
  • Loading branch information
PoisonNF committed Jan 26, 2024
1 parent c55c880 commit 7c7af15
Show file tree
Hide file tree
Showing 1,070 changed files with 901,406 additions and 303 deletions.
2 changes: 2 additions & 0 deletions Apply/Logic/Inc/usercode.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __USERCODE_H_
#define __USERCODE_H_

#include "drv_hal_conf.h"

void UserLogic_Code(void);

#endif
33 changes: 29 additions & 4 deletions Apply/Logic/Src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,19 @@ tagUART_T demoUart =

//串口DMA接收参数配置
.tUartDMA.bRxEnable = true, /* DMA接收使能 */
#ifdef STM32F1_SGA_ENABLE
.tUartDMA.tDMARx.Instance = DMA1_Channel5,
#endif
#ifdef STM32F4_SGA_ENABLE
.tUartDMA.tDMARx.Instance = DMA2_Stream2,
.tUartDMA.tDMARx.Init.Channel = DMA_CHANNEL_4,
#endif
.tUartDMA.tDMARx.Init.Direction = DMA_PERIPH_TO_MEMORY,
.tUartDMA.tDMARx.Init.PeriphInc = DMA_PINC_DISABLE,
.tUartDMA.tDMARx.Init.MemInc = DMA_MINC_ENABLE,
.tUartDMA.tDMARx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE,
.tUartDMA.tDMARx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE,
.tUartDMA.tDMARx.Init.Mode = DMA_CIRCULAR,
.tUartDMA.tDMARx.Init.Mode = DMA_NORMAL,
.tUartDMA.tDMARx.Init.Priority = DMA_PRIORITY_LOW,

.tRxInfo.usDMARxMAXSize = 100, /* DMA接收缓冲区大小 大小保持在协议最长字节*2以上,确保缓存池一定能够稳定接收一个完整的数据帧*/
Expand All @@ -71,14 +77,21 @@ tagUART_T demoUart =

//串口DMA发送参数配置
.tUartDMA.bTxEnable = true, /* DMA发送使能 */
#ifdef STM32F1_SGA_ENABLE
.tUartDMA.tDMATx.Instance = DMA1_Channel4,
#endif
#ifdef STM32F4_SGA_ENABLE
.tUartDMA.tDMATx.Instance = DMA2_Stream7,
.tUartDMA.tDMATx.Init.Channel = DMA_CHANNEL_4,
.tUartDMA.tDMATx.Init.FIFOMode = DMA_FIFOMODE_ENABLE,
#endif
.tUartDMA.tDMATx.Init.Direction = DMA_MEMORY_TO_PERIPH,
.tUartDMA.tDMATx.Init.PeriphInc = DMA_PINC_DISABLE,
.tUartDMA.tDMATx.Init.MemInc = DMA_MINC_ENABLE,
.tUartDMA.tDMATx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE,
.tUartDMA.tDMATx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE,
.tUartDMA.tDMATx.Init.Mode = DMA_NORMAL,
.tUartDMA.tDMATx.Init.Priority = DMA_PRIORITY_LOW,
.tUartDMA.tDMATx.Init.Priority = DMA_PRIORITY_HIGH,

.tTxInfo.usDMATxMAXSize = 50, /* DMA发送缓冲区大小 */

Expand All @@ -91,12 +104,24 @@ tagUART_T demoUart =
.tGPIO[0].tGPIOInit.Pull = GPIO_NOPULL, /* GPIO上下拉设置,是否需要上下拉看硬件 */
.tGPIO[0].tGPIOInit.Speed = GPIO_SPEED_FREQ_HIGH, /* GPIO速度 */
.tGPIO[0].tGPIOPort = GPIOA, /* GPIO分组 */
#ifdef STM32F1_SGA_ENABLE
.tGPIO[0].ucAFMode = NO_REMAP, /* GPIO重映射 */

#endif
#ifdef STM32F4_SGA_ENABLE
.tGPIO[0].tGPIOInit.Alternate = GPIO_AF7_USART1,
#endif

.tGPIO[1].tGPIOInit.Pin = GPIO_PIN_10, /* GPIO引脚 */
.tGPIO[1].tGPIOInit.Mode = GPIO_MODE_INPUT, /* GPIO模式 */
.tGPIO[1].tGPIOInit.Pull = GPIO_NOPULL, /* GPIO上下拉设置,是否需要上下拉看硬件 */
.tGPIO[1].tGPIOInit.Speed = GPIO_SPEED_FREQ_HIGH, /* GPIO速度 */
.tGPIO[1].tGPIOPort = GPIOA, /* GPIO分组 */
#ifdef STM32F1_SGA_ENABLE
.tGPIO[1].tGPIOInit.Mode = GPIO_MODE_INPUT, /* F4系列需要设置为输入模式 */
.tGPIO[1].ucAFMode = NO_REMAP, /* GPIO重映射 */
#endif
#ifdef STM32F4_SGA_ENABLE
.tGPIO[1].tGPIOInit.Mode = GPIO_MODE_AF_PP, /* F4系列需要设置为复用推挽 */
.tGPIO[1].tGPIOInit.Alternate = GPIO_AF7_USART1,
#endif
};

2 changes: 1 addition & 1 deletion Bsp/OCD/Inc/ocd_ms5837.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define C6 _tMS5837->usaCaliData[6]

/* 重力加速度(m/s^2) */
#define G 9.8
#define G 9.8f
/* 标准大气压值(mBar) */
#define ATM 1013

Expand Down
2 changes: 1 addition & 1 deletion Bsp/OCD/Src/ocd_ms5837.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void OCD_MS5837_GetData(tagMS5837_T *_tMS5837)
OFF2 = OFF - OFFi;
SENS2 = SENS - SENSi;
_tMS5837->fPress2 = (float)((D1_Press * SENS2)/2097152L - OFF2) / 8192L / 10; /* 校准后压力数据 */
_tMS5837->fTemp2 = (float)(TEMP - Ti)/100.0; /* 校准后温度数据 */
_tMS5837->fTemp2 = (float)(TEMP - Ti)/100.0f; /* 校准后温度数据 */

_tMS5837->fTemperature = _tMS5837->fTemp2; /* 保存实际温度 */
_tMS5837->fDepth = (_tMS5837->fPress2 - ATM)/1000 * G * 100; /* 保存实际深度 */
Expand Down
12 changes: 12 additions & 0 deletions Bsp/RTOS/FreeRTOS/include/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,18 @@ extern "C" {
#define traceTASK_NOTIFY_GIVE_FROM_ISR()
#endif

#ifndef traceISR_EXIT_TO_SCHEDULER
#define traceISR_EXIT_TO_SCHEDULER()
#endif

#ifndef traceISR_EXIT
#define traceISR_EXIT()
#endif

#ifndef traceISR_ENTER
#define traceISR_ENTER()
#endif

#ifndef traceSTREAM_BUFFER_CREATE_FAILED
#define traceSTREAM_BUFFER_CREATE_FAILED( xIsMessageBuffer )
#endif
Expand Down
Loading

0 comments on commit 7c7af15

Please sign in to comment.