“12.2:初步实现esp8266处理响应数据,暂不完善。”

This commit is contained in:
2025-12-02 20:19:38 +08:00
parent 948c1324e1
commit bd85b7395e
19 changed files with 811 additions and 580 deletions

View File

@@ -4,15 +4,15 @@
#include "stm32f10x.h" // Device header
#define LED_PC13_WORK_MODE LED_PC13_LIGHT_MODE
#define LED_PC13_WORK_MODE LIGHT_MODE
#define LED_PC13_STM32_STATE_MODE 0
#define LED_PC13_LIGHT_MODE 1
#define STM32_STATE_MODE 0
#define LIGHT_MODE 1
/* PC13LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#define LED_PC13_GPIO_CLOCK RCC_APB2Periph_GPIOC
#define LED_PC13_GPIO_PORT GPIOC
#define LED_PC13_GPIO_PIN GPIO_Pin_13
#define LED_PC13_GPIO_CLOCK RCC_APB2Periph_GPIOC
#define LED_PC13_GPIO_PORT GPIOC
#define LED_PC13_GPIO_PIN GPIO_Pin_13
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
void vPc13LedInit(void);

File diff suppressed because one or more lines are too long

View File

@@ -1016,7 +1016,7 @@
<Group>
<GroupName>Drivers</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@@ -12,17 +12,17 @@ void vUsartInit(USART_TypeDef *xUsartId, uint32_t ulBaudrate)
if (xUsartId == USART1)
{
/* code */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
RCC_APB2PeriphClockCmd(USART1_GPIO_CLOCK,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART1_GPIO_PIN_TX;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(USART1_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART1_GPIO_PIN_RX;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(USART1_GPIO_PORT, &GPIO_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = ulBaudrate; // <20><EFBFBD><E8B6A8><EFBFBD><EFBFBD>USART_Init<69><74><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>9600<30><30>Ӧ<EFBFBD>ķ<EFBFBD>Ƶϵ<C6B5><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>BRR<52>Ĵ<EFBFBD><C4B4><EFBFBD>
@@ -48,15 +48,15 @@ void vUsartInit(USART_TypeDef *xUsartId, uint32_t ulBaudrate)
} else if (xUsartId == USART2)
{
/* code */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB2PeriphClockCmd(USART2_GPIO_CLOCK,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART2_GPIO_PIN_TX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(USART2_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = USART2_GPIO_PIN_RX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(USART2_GPIO_PORT, &GPIO_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = ulBaudrate; // <20><EFBFBD><E8B6A8><EFBFBD><EFBFBD>USART_Init<69><74><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>9600<30><30>Ӧ<EFBFBD>ķ<EFBFBD>Ƶϵ<C6B5><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>BRR<52>Ĵ<EFBFBD><C4B4><EFBFBD>
@@ -82,16 +82,16 @@ void vUsartInit(USART_TypeDef *xUsartId, uint32_t ulBaudrate)
} else if (xUsartId == USART3)
{
/* code */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
RCC_APB2PeriphClockCmd(USART3_GPIO_CLOCK,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART3_GPIO_PIN_TX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(USART3_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = USART3_GPIO_PIN_RX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_Init(USART3_GPIO_PORT, &GPIO_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = ulBaudrate; // <20><EFBFBD><E8B6A8><EFBFBD><EFBFBD>USART_Init<69><74><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>9600<30><30>Ӧ<EFBFBD>ķ<EFBFBD>Ƶϵ<C6B5><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>BRR<52>Ĵ<EFBFBD><C4B4><EFBFBD>
@@ -220,13 +220,13 @@ void USART1_IRQHandler(void)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART1);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#if (USE_SYSTEM == NONE)
#elif (USE_SYSTEM == FREERTOS)
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(xQueueUsart1IrqHdlr, &ulRxData, &xHigherPriorityTaskWoken);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD> */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
#elif (USE_OSAL == 1)
#elif (USE_SYSTEM == OSAL)
#endif
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}
@@ -244,13 +244,13 @@ void USART2_IRQHandler(void)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART2);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#if (USE_SYSTEM == NONE)
#elif (USE_SYSTEM == FREERTOS)
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(xQueueUsart2IrqHdlr, &ulRxData, &xHigherPriorityTaskWoken);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD> */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
#elif (USE_OSAL == 1)
#elif (USE_SYSTEM == OSAL)
#endif
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
}
@@ -268,13 +268,13 @@ void USART3_IRQHandler(void)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART3);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#if (USE_SYSTEM == NONE)
#elif (USE_SYSTEM == FREERTOS)
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
xQueueSendFromISR(xQueueUsart3IrqHdlr, &ulRxData, &xHigherPriorityTaskWoken);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD> */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
#elif (USE_OSAL == 1)
#elif (USE_SYSTEM == OSAL)
#endif
USART_ClearITPendingBit(USART3, USART_IT_RXNE);
}

View File

@@ -1,12 +1,19 @@
#ifndef __USART_H__
#define __USART_H__
#define USE_NONE_SYSTEM 0
#define USE_FREERTOS 1
#define USE_OSAL 0
#define USE_SYSTEM FREERTOS
#define NONE 0
#define FREERTOS 1
#define OSAL 2
#define vUsart1IrqHandler USART1_IRQHandler
#define vEsp8266IrqHandler USART2_IRQHandler
#define vLoRaIrqHandler USART3_IRQHandler
#define USART1_GPIO_CLOCK RCC_APB2Periph_GPIOA
#define USART2_GPIO_CLOCK RCC_APB2Periph_GPIOA
#define USART3_GPIO_CLOCK RCC_APB2Periph_GPIOB
#define USART1_GPIO_PORT GPIOA
#define USART2_GPIO_PORT GPIOA
#define USART3_GPIO_PORT GPIOB
#define USART1_GPIO_PIN_TX GPIO_Pin_9
#define USART1_GPIO_PIN_RX GPIO_Pin_10
#define USART2_GPIO_PIN_TX GPIO_Pin_2
@@ -14,11 +21,11 @@
#define USART3_GPIO_PIN_TX GPIO_Pin_10
#define USART3_GPIO_PIN_RX GPIO_Pin_11
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#if (USE_SYSTEM == NONE)
#elif (USE_SYSTEM == FREERTOS)
#include "FreeRTOS.h"
#include "queue.h"
#elif (USE_OSAL == 1)
#elif (USE_SYSTEM == OSAL)
#endif
#include "stm32f10x.h" // Device header
@@ -26,12 +33,12 @@
#include <stdarg.h>
#include <string.h>
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#if (USE_SYSTEM == NONE)
#elif (USE_SYSTEM == FREERTOS)
extern QueueHandle_t xQueueUsart1IrqHdlr;
extern QueueHandle_t xQueueUsart2IrqHdlr;
extern QueueHandle_t xQueueUsart3IrqHdlr;
#elif (USE_OSAL == 1)
#elif (USE_SYSTEM == OSAL)
#endif
void vUsartInit(USART_TypeDef *xUsartId, uint32_t ulBaudrate);

View File

@@ -5,7 +5,6 @@
#include "semphr.h"
#include "LED.h"
#include "DHT11.h"
// #include "USART3.h"
#include "USART.h"
#include "LoRa.h"
#include "Relay.h"
@@ -183,7 +182,7 @@ void vTaskLoRaMsgRec(void *pvParameters)
void vCreateTasksList(void)
{
// #if defined __LED_H__
#if LED_PC13_WORK_MODE == LED_PC13_STM32_STATE_MODE
#if LED_PC13_WORK_MODE == STM32_STATE_MODE
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>񣬲<EFBFBD><F1A3ACB2><EFBFBD><EFBFBD>ֱ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ơ<EFBFBD><C6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ջ<EFBFBD><D5BB>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
xTaskCreate(
(TaskFunction_t ) vTaskStateLed,