forked from gary/BCU
2
0
Fork 0

临时上传4g,存档

This commit is contained in:
ahu_gq 2025-02-12 17:28:30 +08:00
parent 7624dbe183
commit bf00bc84f8
6 changed files with 149 additions and 114 deletions

View File

@ -44,11 +44,14 @@ const GpioArray io_array[kGpioType_End] =
kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 10), kGpioPort_A, kGpioPin_10 , //rs485C Rx(mcu uart1) kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 10), kGpioPort_A, kGpioPin_10 , //rs485C Rx(mcu uart1)
kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 9), kGpioPort_A, kGpioPin_9 , //rs485C Tx(mcu uart1) kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 9), kGpioPort_A, kGpioPin_9 , //rs485C Tx(mcu uart1)
kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_D, 9), kGpioPort_D, kGpioPin_9 , //rs485B Rx(mcu uart1) kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_D, 9), kGpioPort_D, kGpioPin_9 , //rs485B Rx(mcu uart3)
kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_D, 8), kGpioPort_D, kGpioPin_8 , //rs485B Tx(mcu uart1) kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_D, 8), kGpioPort_D, kGpioPin_8 , //rs485B Tx(mcu uart3)
kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 1), kGpioPort_A, kGpioPin_1 , //rs485A Rx(mcu uart1) kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 1), kGpioPort_A, kGpioPin_1 , //rs485A Rx(mcu uart4)
kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 0), kGpioPort_A, kGpioPin_0 , //rs485A Tx(mcu uart1) kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 0), kGpioPort_A, kGpioPin_0 , //rs485A Tx(mcu uart4)
kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 2), kGpioPort_A, kGpioPin_2 , //SIM UART Rx(mcu uart2)
kGpioMode_Comm_Tx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 3), kGpioPort_A, kGpioPin_3 , //SIM UART Tx(mcu uart2)
/*CAN枚举*/ /*CAN枚举*/
kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 11), kGpioPort_A, kGpioPin_11 , //can1 rx kGpioMode_Comm_Rx, kGpioStatus_Low, GPIO_PORT_PIN(kGpioPort_A, 11), kGpioPort_A, kGpioPin_11 , //can1 rx

View File

@ -57,6 +57,9 @@ typedef enum
kGpioType_Rs485_Ch3_Rx, kGpioType_Rs485_Ch3_Rx,
kGpioType_Rs485_Ch3_Tx, kGpioType_Rs485_Ch3_Tx,
kGpioType_SIMUart_Rx, //Sim卡
kGpioType_SIMUart_Tx, //Sim卡
/*CAN枚举*/ /*CAN枚举*/
kGpioType_Can_Ch1_Rx, kGpioType_Can_Ch1_Rx,
kGpioType_Can_Ch1_Tx, kGpioType_Can_Ch1_Tx,

View File

@ -10,15 +10,15 @@
<TargetName>stm32f407</TargetName> <TargetName>stm32f407</TargetName>
<ToolsetNumber>0x4</ToolsetNumber> <ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName> <ToolsetName>ARM-ADS</ToolsetName>
<pArmCC>5060750::V5.06 update 6 (build 750)::ARMCC</pArmCC> <pArmCC>5060960::V5.06 update 7 (build 960)::.\ARMCC</pArmCC>
<pCCUsed>5060750::V5.06 update 6 (build 750)::ARMCC</pCCUsed> <pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<uAC6>0</uAC6> <uAC6>0</uAC6>
<TargetOption> <TargetOption>
<TargetCommonOption> <TargetCommonOption>
<Device>STM32F407ZGTx</Device> <Device>STM32F407ZGTx</Device>
<Vendor>STMicroelectronics</Vendor> <Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32F4xx_DFP.2.14.0</PackID> <PackID>Keil.STM32F4xx_DFP.3.0.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL> <PackURL>https://www.keil.com/pack/</PackURL>
<Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu> <Cpu>IRAM(0x20000000,0x00020000) IRAM2(0x10000000,0x00010000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M4") FPU2 CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec> <FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile> <StartupFile></StartupFile>
@ -186,6 +186,7 @@
<uocXRam>0</uocXRam> <uocXRam>0</uocXRam>
<RvdsVP>2</RvdsVP> <RvdsVP>2</RvdsVP>
<RvdsMve>0</RvdsMve> <RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<hadIRAM2>1</hadIRAM2> <hadIRAM2>1</hadIRAM2>
<hadIROM2>0</hadIROM2> <hadIROM2>0</hadIROM2>
<StupSel>8</StupSel> <StupSel>8</StupSel>
@ -352,7 +353,7 @@
<NoWarn>0</NoWarn> <NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc> <uSurpInc>0</uSurpInc>
<useXO>0</useXO> <useXO>0</useXO>
<uClangAs>0</uClangAs> <ClangAsOpt>4</ClangAsOpt>
<VariousControls> <VariousControls>
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define></Define>
@ -471,7 +472,7 @@
<NoWarn>2</NoWarn> <NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc> <uSurpInc>2</uSurpInc>
<useXO>2</useXO> <useXO>2</useXO>
<uClangAs>2</uClangAs> <ClangAsOpt>0</ClangAsOpt>
<VariousControls> <VariousControls>
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define></Define>
@ -632,6 +633,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\..\..\library\drv_peripheral\drv_w5500.c</FilePath> <FilePath>..\..\..\library\drv_peripheral\drv_w5500.c</FilePath>
</File> </File>
<File>
<FileName>drv_eg25gminipice.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\library\drv_peripheral\drv_eg25gminipice.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@ -641,57 +647,6 @@
<FileName>main.c</FileName> <FileName>main.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\app\main.c</FilePath> <FilePath>..\app\main.c</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
</File> </File>
<File> <File>
<FileName>task_register.c</FileName> <FileName>task_register.c</FileName>
@ -707,57 +662,6 @@
<FileName>bmu_manager.c</FileName> <FileName>bmu_manager.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\app\bmu_manager.c</FilePath> <FilePath>..\app\bmu_manager.c</FilePath>
<FileOption>
<CommonProperty>
<UseCPPCompiler>2</UseCPPCompiler>
<RVCTCodeConst>0</RVCTCodeConst>
<RVCTZI>0</RVCTZI>
<RVCTOtherData>0</RVCTOtherData>
<ModuleSelection>0</ModuleSelection>
<IncludeInBuild>1</IncludeInBuild>
<AlwaysBuild>2</AlwaysBuild>
<GenerateAssemblyFile>2</GenerateAssemblyFile>
<AssembleAssemblyFile>2</AssembleAssemblyFile>
<PublicsOnly>2</PublicsOnly>
<StopOnExitCode>11</StopOnExitCode>
<CustomArgument></CustomArgument>
<IncludeLibraryModules></IncludeLibraryModules>
<ComprImg>1</ComprImg>
</CommonProperty>
<FileArmAds>
<Cads>
<interw>2</interw>
<Optim>0</Optim>
<oTime>2</oTime>
<SplitLS>2</SplitLS>
<OneElfS>2</OneElfS>
<Strict>2</Strict>
<EnumInt>2</EnumInt>
<PlainCh>2</PlainCh>
<Ropi>2</Ropi>
<Rwpi>2</Rwpi>
<wLevel>0</wLevel>
<uThumb>2</uThumb>
<uSurpInc>2</uSurpInc>
<uC99>2</uC99>
<uGnu>2</uGnu>
<useXO>2</useXO>
<v6Lang>0</v6Lang>
<v6LangP>0</v6LangP>
<vShortEn>2</vShortEn>
<vShortWch>2</vShortWch>
<v6Lto>2</v6Lto>
<v6WtE>2</v6WtE>
<v6Rtti>2</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
</VariousControls>
</Cads>
</FileArmAds>
</FileOption>
</File> </File>
<File> <File>
<FileName>comm_manager.c</FileName> <FileName>comm_manager.c</FileName>
@ -972,7 +876,7 @@
<NoWarn>2</NoWarn> <NoWarn>2</NoWarn>
<uSurpInc>2</uSurpInc> <uSurpInc>2</uSurpInc>
<useXO>2</useXO> <useXO>2</useXO>
<uClangAs>2</uClangAs> <ClangAsOpt>0</ClangAsOpt>
<VariousControls> <VariousControls>
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define></Define>
@ -1312,6 +1216,7 @@
<uocXRam>0</uocXRam> <uocXRam>0</uocXRam>
<RvdsVP>2</RvdsVP> <RvdsVP>2</RvdsVP>
<RvdsMve>0</RvdsMve> <RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<hadIRAM2>1</hadIRAM2> <hadIRAM2>1</hadIRAM2>
<hadIROM2>0</hadIROM2> <hadIROM2>0</hadIROM2>
<StupSel>8</StupSel> <StupSel>8</StupSel>
@ -1478,7 +1383,7 @@
<NoWarn>0</NoWarn> <NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc> <uSurpInc>0</uSurpInc>
<useXO>0</useXO> <useXO>0</useXO>
<uClangAs>0</uClangAs> <ClangAsOpt>4</ClangAsOpt>
<VariousControls> <VariousControls>
<MiscControls></MiscControls> <MiscControls></MiscControls>
<Define></Define> <Define></Define>
@ -1689,6 +1594,11 @@
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\..\..\library\drv_peripheral\drv_w5500.c</FilePath> <FilePath>..\..\..\library\drv_peripheral\drv_w5500.c</FilePath>
</File> </File>
<File>
<FileName>drv_eg25gminipice.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\library\drv_peripheral\drv_eg25gminipice.c</FilePath>
</File>
</Files> </Files>
</Group> </Group>
<Group> <Group>
@ -2033,4 +1943,13 @@
</files> </files>
</RTE> </RTE>
<LayerInfo>
<Layers>
<Layer>
<LayName>BCU_APP</LayName>
<LayPrjMark>1</LayPrjMark>
</Layer>
</Layers>
</LayerInfo>
</Project> </Project>

View File

View File

@ -0,0 +1,84 @@
/******************************************************************************
* @file drv_eg25gminipice.c
* @brief drv_eg25gminipice.c drivers
* @version V1.0
* @author Gary
* @copyright
******************************************************************************/
#include "drv_eg25gminipice.h"
#define UART2_BAUDRATE 115200
void drv_uart2_Init(void)
{
RCC->APB1ENR |= RCC_APB1ENR_USART2EN; // 使能 USART2 时钟
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; // 使能 GPIOA 时钟
GPIOA->MODER |= (2 << (2 * 2)) | (2 << (3 * 2)); // PA2(TX), PA3(RX) 复用模式
GPIOA->AFR[0] |= (7 << (2 * 4)) | (7 << (3 * 4)); // 复用 AF7 (USART2)
USART2->BRR = SystemCoreClock / UART2_BAUDRATE;
USART2->CR1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_UE; // 使能串口、发送和接收
}
void drv_uart2_sendbyte(char c)
{
while (!(USART2->SR & USART_SR_TXE)); // 等待发送完成
USART2->DR = c;
}
void drv_uart2_sendString(const char *str)
{
while (*str) {
drv_uart2_sendbyte(*str++);
}
}
void drv_send_at_cmd(const char *cmd, int delay_ms)
{
drv_uart2_sendString(cmd);
drv_uart2_sendString("\r\n"); // AT 指令以 "\r\n" 结尾
for (volatile int i = 0; i < delay_ms * 1000; i++); // 简单延时
}
void drv_eg25g_init(void)
{
drv_send_at_cmd("AT", 500);
drv_send_at_cmd("AT+CPIN?", 500);
drv_send_at_cmd("AT+CREG?", 500);
drv_send_at_cmd("AT+CGATT=1", 500);
drv_send_at_cmd("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"", 500);
drv_send_at_cmd("AT+SAPBR=3,1,\"APN\",\"your_apn\"", 500);
drv_send_at_cmd("AT+SAPBR=1,1", 2000);
}
void drv_mqtt_connect(void)
{
drv_send_at_cmd("AT+QMTCFG=\"recv/mode\",0,0,1", 500);
drv_send_at_cmd("AT+QMTOPEN=0,\"mqtt.example.com\",1883", 5000);
drv_send_at_cmd("AT+QMTCONN=0,\"client_id\",\"username\",\"password\"", 5000);
}
void drv_mqtt_publish(const char *topic, const char *message)
{
char cmd[128];
sprintf(cmd, "AT+QMTPUB=0,0,0,0,\"%s\",\"%s\"", topic, message);
drv_send_at_cmd(cmd, 500);
}
/*
int main(void) {
SystemInit();
drv_uart2_Init();
drv_eg25g_init();
drv_mqtt_connect();
while (1)
{
drv_mqtt_publish("sensor/data", "{\"temperature\":25.3}");
for (volatile int i = 0; i < 10000000; i++); // 发送间隔
}
}
*/

View File

@ -0,0 +1,26 @@
/******************************************************************************
* @file drv_eg25gminipice.h
* @brief drv_eg25gminipice drivers
* @version V1.0
* @author Gary
* @copyright
******************************************************************************/
#ifndef DRV_EG25GMINIPICE_H_
#define DRV_EG25GMINIPICE_H_
#include "drv_gpio.h"
#include "stm32f4xx.h"
#include "bsp_task.h"
#include "kit_time.h"
#include "kit_data.h"
#include "kit_debug.h"
#include "ucos_ii.h"
#endif //DRV_EG25GMINIPICE_H_