From e7101a7064d3e6da5a946d64bb0e43a77377e2f0 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期四, 22 五月 2025 18:11:43 +0800 Subject: [PATCH] 1.22,提交,待测试,给张博先修改 --- keil/include/components/internet/src/AIR780EDriver.c | 158 +++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 125 insertions(+), 33 deletions(-) diff --git a/keil/include/components/internet/src/AIR780EDriver.c b/keil/include/components/internet/src/AIR780EDriver.c index ee7ad60..d377607 100644 --- a/keil/include/components/internet/src/AIR780EDriver.c +++ b/keil/include/components/internet/src/AIR780EDriver.c @@ -19,18 +19,18 @@ #include "HIDO_Util.h" #include "HIDO_Debug.h" #include "HIDO_Log.h" - +#include "DBG.h" /******************************************************************************* * Macro * *******************************************************************************/ /* 串口相关 */ #define AIR780E_UART_TX_BUF_SIZE (100) /* 串口未使用DMA模式,不需要buff */ -#define AIR780E_UART_RX_BUF_SIZE (1024) -#define AIR780E_UART_TX_QUEUE_MEMBER_CNT 8 /* 串口未使用DMA模式,不需要 */ +#define AIR780E_UART_RX_BUF_SIZE (1024 * 2 + 512) +#define AIR780E_UART_TX_QUEUE_MEMBER_CNT 16 /* 串口未使用DMA模式,不需要 */ /* AT相关 */ -#define AIR780E_AT_SEND_BUF_SIZE (128) /* 发送的单条AT指令的最大长度 */ -#define AIR780E_AT_RECV_BUF_SIZE (128) /* 单挑AT指令 */ +#define AIR780E_AT_SEND_BUF_SIZE ((5 * 1024) + 512) /* 发送的单条AT指令的最大长度 */ +#define AIR780E_AT_RECV_BUF_SIZE ((5 * 1024) + 512) /* 单挑AT指令 */ /******************************************************************************* * Type Definition * @@ -215,6 +215,7 @@ * Author : 杜键 * Modified Date: : 2018年5月22日 *******************************************************************************/ +extern uint8_t log_4g_enable_flag; static HIDO_INT32 AIR780E_ReadLine(HIDO_ATLiteDeviceStruct *_pstATDevice) { static HIDO_UINT8 l_u8Mode = 0; @@ -333,11 +334,15 @@ { if((_pstATDevice->m_u32LineLen > 0) && (_pstATDevice->m_pcLineBuf[_pstATDevice->m_u32LineLen - 1] == '\n')) { - HIDO_Debug( "[AT Recv] %s", _pstATDevice->m_pcLineBuf); + if(log_4g_enable_flag&&DBG_GetMode() == DBG_MODE_SHELL) + LOG_INFO(TRACE_MODULE_APP, "[AT Recv] %s", _pstATDevice->m_pcLineBuf);//修改4G + //HIDO_Debug( "[AT Recv] %s", _pstATDevice->m_pcLineBuf); } else { - HIDO_Debug("[AT Recv] %s\r\n", _pstATDevice->m_pcLineBuf); + if(log_4g_enable_flag&&DBG_GetMode() == DBG_MODE_SHELL) + LOG_INFO(TRACE_MODULE_APP, "[AT Recv] %s\r\n", _pstATDevice->m_pcLineBuf);//修改4G + //HIDO_Debug("[AT Recv] %s\r\n", _pstATDevice->m_pcLineBuf); } } @@ -364,11 +369,15 @@ { if((_u32Len > 0) && (_pu8Data[_u32Len - 1] == '\n')) { - HIDO_Debug("[AT Send] %s", _pu8Data); + // HIDO_Debug("[AT Send] %s", _pu8Data); + if(log_4g_enable_flag&&DBG_GetMode() == DBG_MODE_SHELL) + LOG_INFO(TRACE_MODULE_APP, "[AT Send] %s", _pu8Data);//修改4G } else { - HIDO_Debug("[AT Send] %s\r\n", _pu8Data); + // HIDO_Debug("[AT Send] %s\r\n", _pu8Data); + if(log_4g_enable_flag&&DBG_GetMode() == DBG_MODE_SHELL) + LOG_INFO(TRACE_MODULE_APP, "[AT Send] %s", _pu8Data);//修改4G } } } @@ -407,8 +416,7 @@ *******************************************************************************/ HIDO_INT32 AIR780EDriver_PowerOn(void) { - gpio_pin_set(l_stAIR780EPin[AIR780E_PIN_3V8_EN]); - + AIR780E_Reset(); return HIDO_OK; } @@ -423,8 +431,8 @@ *******************************************************************************/ HIDO_INT32 AIR780EDriver_PowerOff(void) { - gpio_pin_clr(l_stAIR780EPin[AIR780E_PIN_3V8_EN]); - + air780_power_state = 0; + update_led_power_state(); return HIDO_OK; } @@ -517,6 +525,7 @@ * Author : 杜键 * Modified Date: : 2018年5月22日 *******************************************************************************/ +extern uint8_t log_4g_enable_flag; HIDO_INT32 AIR780EDriver_FSMDebug(HIDO_FSMStruct *_pstStateMachine, HIDO_INT32 _i32Level, HIDO_CHAR *_pcFmt, va_list _ap) { HIDO_CHAR acBuff[384]; @@ -524,8 +533,10 @@ vsnprintf(acBuff, sizeof(acBuff), _pcFmt, _ap); // HIDO_Log(HIDO_LOG_LEVEL_DEBUG, "%s", acBuff); - HIDO_Debug(acBuff); - + //HIDO_Debug(acBuff); +if(log_4g_enable_flag&&DBG_GetMode() == DBG_MODE_SHELL) + LOG_INFO(TRACE_MODULE_APP, acBuff);//修改4G + return HIDO_OK; } @@ -546,21 +557,6 @@ } /******************************************************************************* - * Function Name : AIR780EDriver_TimerPoll - * Description : - * Input : - * Output : - * Return : - * Author : 杜键 - * Modified Date: : 2018年5月22日 - *******************************************************************************/ -void AIR780EDriver_TimerPoll(void) -{ - //HIDO_TimerPollByID(l_stDriverData.m_u32FSMTimerID); - //HIDO_TimerPollByID(l_stAIR780EDevice.m_u32TimerID); -} - -/******************************************************************************* * Function Name : AIR780EDriver_Init * Description : * Input : @@ -569,18 +565,41 @@ * Author : 杜键 * Modified Date: : 2018年5月22日 *******************************************************************************/ -HIDO_INT32 AIR780EDriver_Init(void) +//#ifdef _UWB_4G +//#else +//#endif +#ifdef _GPS_115200 +void AIR780EUartInit(void) { - ST_UartInit stUartInit; + ST_UartInit stUartInit; /* 串口初始化 */ - stUartInit.m_eRxMode = UART_RX_MODE_DMA; + stUartInit.m_eRxMode = UART_RX_MODE_INT; stUartInit.m_eTxMode = UART_TX_MODE_POLL; stUartInit.m_pu8RxBuf = l_au8AIR780EUartRxBuf; stUartInit.m_u32RxBufSize = AIR780E_UART_RX_BUF_SIZE; stUartInit.m_pu8TxBuf = l_au8AIR780EUartTxBuf; stUartInit.m_u32TxBufSize = AIR780E_UART_TX_BUF_SIZE; stUartInit.m_u32TxQueueMemberCnt = AIR780E_UART_TX_QUEUE_MEMBER_CNT; + stUartInit.m_u32BaudRate = 115200; + if(Uart_Init(UART_ID_4G, &stUartInit) != HIDO_OK) + { + + } +} +HIDO_INT32 AIR780EDriver_Init(void) +{ + ST_UartInit stUartInit; + + /* 串口初始化 */ + stUartInit.m_eRxMode = UART_RX_MODE_INT; + stUartInit.m_eTxMode = UART_TX_MODE_POLL; + stUartInit.m_pu8RxBuf = l_au8AIR780EUartRxBuf; + stUartInit.m_u32RxBufSize = AIR780E_UART_RX_BUF_SIZE; + stUartInit.m_pu8TxBuf = l_au8AIR780EUartTxBuf; + stUartInit.m_u32TxBufSize = AIR780E_UART_TX_BUF_SIZE; + stUartInit.m_u32TxQueueMemberCnt = AIR780E_UART_TX_QUEUE_MEMBER_CNT; + stUartInit.m_u32BaudRate = 115200; if(Uart_Init(UART_ID_4G, &stUartInit) != HIDO_OK) { return HIDO_ERR; @@ -621,3 +640,76 @@ return HIDO_OK; } +#else +void AIR780EUartInit(void) +{ + ST_UartInit stUartInit; + + /* 串口初始化 */ + stUartInit.m_eRxMode = UART_RX_MODE_INT; + stUartInit.m_eTxMode = UART_TX_MODE_POLL; + stUartInit.m_pu8RxBuf = l_au8AIR780EUartRxBuf; + stUartInit.m_u32RxBufSize = AIR780E_UART_RX_BUF_SIZE; + stUartInit.m_pu8TxBuf = l_au8AIR780EUartTxBuf; + stUartInit.m_u32TxBufSize = AIR780E_UART_TX_BUF_SIZE; + stUartInit.m_u32TxQueueMemberCnt = AIR780E_UART_TX_QUEUE_MEMBER_CNT; + stUartInit.m_u32BaudRate = 9600; + if(Uart_Init(UART_ID_4G, &stUartInit) != HIDO_OK) + { + + } +} +HIDO_INT32 AIR780EDriver_Init(void) +{ + ST_UartInit stUartInit; + + /* 串口初始化 */ + stUartInit.m_eRxMode = UART_RX_MODE_INT; + stUartInit.m_eTxMode = UART_TX_MODE_POLL; + stUartInit.m_pu8RxBuf = l_au8AIR780EUartRxBuf; + stUartInit.m_u32RxBufSize = AIR780E_UART_RX_BUF_SIZE; + stUartInit.m_pu8TxBuf = l_au8AIR780EUartTxBuf; + stUartInit.m_u32TxBufSize = AIR780E_UART_TX_BUF_SIZE; + stUartInit.m_u32TxQueueMemberCnt = AIR780E_UART_TX_QUEUE_MEMBER_CNT; + stUartInit.m_u32BaudRate = 9600; + if(Uart_Init(UART_ID_4G, &stUartInit) != HIDO_OK) + { + return HIDO_ERR; + } + + /* 定时器初始化 */ + if (HIDO_TimerCreate(&l_stDriverData.m_u32FSMTimerID) != HIDO_OK) + { + return HIDO_ERR; + } + + /* AT驱动初始化 */ + HIDO_ATLiteDeviceInitStruct stATInit; + + stATInit.m_pstFSM = HIDO_FSM(AIR780E); + stATInit.m_pstAtSets = l_astATCmdSetList; + stATInit.m_u32AtSetsCount = HIDO_ARRARY_COUNT(l_astATCmdSetList); + stATInit.m_fnGetc = AIR780E_GetChar; + stATInit.m_fnReadLine = AIR780E_ReadLine; + stATInit.m_fnOutput = AIR780E_Output; + stATInit.m_pcSendBuf = (HIDO_CHAR *) l_au8ATSendBuf; + stATInit.m_u32SendBufSize = HIDO_ARRARY_COUNT(l_au8ATSendBuf); + stATInit.m_pcLineBuf = (HIDO_CHAR *) l_au8ATRecvBuf; + stATInit.m_u32LineBufSize = HIDO_ARRARY_COUNT(l_au8ATRecvBuf); + stATInit.m_pUserData = &l_stDriverData; + + /* AT设备初始化 */ + if (HIDO_ATLiteDeviceInit(&l_stAIR780EDevice, &stATInit) != HIDO_OK) + { + return HIDO_ERR; + } + + /* 状态机初始化 */ + HIDO_FSMRegister(HIDO_FSM(AIR780E), HIDO_FSM_STATE(AIR780E), "AIR780E", l_apcEventName, &l_stAIR780EDevice, + HIDO_FSM_DBG_FLAG_ON); + + HIDO_FSMRegisterDebugFunc(HIDO_FSM(AIR780E), AIR780EDriver_FSMDebug); + + return HIDO_OK; +} +#endif -- Gitblit v1.9.3