88ee1883 by 张亚玄

add AT system

1 parent bbbcab84
......@@ -28,9 +28,7 @@
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1032586580" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.558548144" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.2084640704" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;F:\IoT\STM32\workspace\STM32Test\Core\Src\LED&quot;"/>
<listOptionValue builtIn="false" value="../Core/Inc/Hardware"/>
<listOptionValue builtIn="false" value="../Core/Inc/LED"/>
</option>
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.119923394" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
</tool>
......@@ -117,7 +115,6 @@
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.59085921" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.1981320207" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g0" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths.1229672740" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.includepaths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;F:\IoT\STM32\workspace\STM32Test\Core\Src\LED&quot;"/>
<listOptionValue builtIn="false" value="../Core/Inc/Hardware"/>
<listOptionValue builtIn="false" value="../Core/Inc/LED"/>
</option>
......@@ -193,5 +190,12 @@
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="refreshScope"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Debug">
<resource resourceType="PROJECT" workspacePath="/STM32Test"/>
</configuration>
<configuration configurationName="Release">
<resource resourceType="PROJECT" workspacePath="/STM32Test"/>
</configuration>
</storageModule>
</cproject>
......
!.c
!.h
Debug
\ No newline at end of file
Debug
Release
\ No newline at end of file
......
/*
* ATSystem.h
*
* Created on: Nov 1, 2019
* Author: Hope
*/
#ifndef INC_ATSYSTEM_H_
#define INC_ATSYSTEM_H_
/* Includes ------------------------------------------------------------------*/
#include "usart.h"
/*****************************
* Private Define
*/
#define TRUE 1
#define FALSE 0
/*****************************************
config
****************************************/
/*********************
* compile options
*/
#define AT_FCS_VERIFY FALSE
#define AT_DEBUG_INF_SHOW FALSE
#define AT_CMD_PATTERN_CHECK TRUE
#define AT_UART_BACKSPACE FALSE
#define AT_SHOW_STATE_CHANGE FALSE
/********************************************************
* define UART message sent
*******************************************************/
#define AT_RESP(str, len) HAL_UART_Transmit(&huart2, (uint8_t*)str, len, 1000)
#define AT_OK() AT_RESP("\r\nOK\r\n", sizeof("\r\nOK\r\n")-1)
#define AT_NEXT_LINE() AT_RESP("\r\n", 2)
#define AT_NEW_LINE() AT_RESP("\r\n", 2)
#define AT_ERROR(x) AT_UARTWriteErrMsg(x)
#if AT_DEBUG_INF_SHOW
#define AT_DEBUG(str, len) AT_RESP(str, len)
#else
#define AT_DEBUG(str, len)
#endif
#if AT_CMD_PATTERN_CHECK
#define AT_PARSE_CMD_PATTERN_ERROR(x,y) \
{uint8_t err; \
err = AT_Pattern_Check(x,y); \
if (err != 0) { AT_ERROR(err); return;} }
#else
#define AT_PARSE_CMD_PATTERN_ERROR(x,y)
#endif
#if AT_CMD_PATTERN_CHECK
#define AT_PARSE_SINGLE_CMD_PATTERN_ERROR(x,y) \
{ if (x[0] != y->symbol) {AT_ERROR(AT_INVALID_PARA); return;}}
#else
#define AT_PARSE_CMD_PATTERN_ERROR(x,y)
#endif
/*********************************************************************
* DATA STRUCTURE
*/
typedef struct {
uint8_t symbol;
uint8_t unitLen;
uint8_t* unit;
} AT_CmdUnit;
typedef void (*AT_CmdFn_t)(uint8_t cmd_ptr, uint8_t* msg_ptr);
typedef struct {
char* AT_Cmd_str;
AT_CmdFn_t AT_CmdFn;
char* ATCmdDescription;
} AT_Cmd_t;
/*********************
* error message
*/
#define AT_NO_ERROR 0x00 // Everything OK - Success
#define AT_FATAL_ERROR 0x01 // Fatal Error
#define AT_UNKNOWN_CMD 0x02 // Unknown command
#define AT_LACK_CMD 0x03 // lack command
#define AT_INVALID_PARA 0x04 // Invalid parameter
#define AT_LACK_OPERATOR 0x05
#define AT_LACK_PARA 0x06
/*********************
* command constants
*/
#define AT_CMD_HELP_DESC_OFFSET 17
/*********************************************************************
* GLOBAL VARIABLES
*/
extern void AT_Process(uint8_t ch);
extern void AT_UARTWriteErrMsg(uint8_t errCode);
#endif /* INC_ATSYSTEM_H_ */
......@@ -39,7 +39,6 @@ extern UART_HandleTypeDef huart2;
extern uint8_t USART1_RingBuff[USART1_BUF_LEN]; // 接收缓冲
#define AT_RESP(str, len) HAL_UART_Transmit(&huart2, (uint8_t*)str, len, 1000)
#define DEBUG_PRINT(str, len) HAL_UART_Transmit(&huart1, (uint8_t*)str, len, 1000)
/* USER CODE END Private defines */
......
......@@ -30,6 +30,7 @@
#include "beep.h"
#include "key.h"
#include "usart.h"
#include "ATSystem.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
......@@ -269,6 +270,7 @@ void StartUartTask(void *argument)
{
RINGBUF_READ(&temp, 1);
mprintf("%c", temp);
AT_Process(temp);
}
times++;
......