11.22:完善注释;提高代码的移植性;完善串口程序。

This commit is contained in:
2025-11-22 20:16:58 +08:00
parent 2891992946
commit 33e53ec469
32 changed files with 5308 additions and 266 deletions

View File

@@ -2,6 +2,7 @@
"files.associations": {
"stm32f10x_crc.h": "c",
"stm32f10x.h": "c",
"semaphore.h": "c"
"semaphore.h": "c",
"freertos.h": "c"
}
}

View File

@@ -5,7 +5,7 @@ void vDht11Rst(void)
{
vDht11Mode(OUT); //SET OUTPUT
DHT11_Low; //<2F><><EFBFBD><EFBFBD>DQ
vTaskDelay(20); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>18~30ms
vDelayMs(20); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>18~30ms
DHT11_High; //DQ=1
vDelayUs(13); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>10~35us
}

View File

@@ -1,10 +1,8 @@
#ifndef __DHT11_H
#define __DHT11_H
#ifndef __DHT11_H__
#define __DHT11_H__
#include "stm32f10x.h" // Device header
#include "Delay.h"
#include "FreeRTOS.h"
#include "task.h"
/* DHT11<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#define DHT11_GPIO_CLK RCC_APB2Periph_GPIOB

View File

@@ -4,6 +4,11 @@
#include "stm32f10x.h" // Device header
#define LED_PC13_WORK_MODE LED_PC13_LIGHT_MODE
#define LED_PC13_STM32_STATE_MODE 0
#define LED_PC13_LIGHT_MODE 1
/* PC13LED<45><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#define LED_PC13_GPIO_CLOCK RCC_APB2Periph_GPIOC
#define LED_PC13_GPIO_PORT GPIOC

View File

@@ -1,5 +1,11 @@
#include "LoRa.h"
/**
* @brief LoRa<52><61><EFBFBD>ͽڵ<CDBD>ID<49><44><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note LoRa<52>ڶ<EFBFBD><DAB6><EFBFBD>ģʽ<C4A3><CABD>ִ<EFBFBD>нڵ<D0BD><DAB5><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param ucNodeId <20>ڵ<EFBFBD>ID<49><44><EFBFBD><EFBFBD>Node1<65><31>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>D1<44>ȵȡ<C8B5>
* @retval None
*/
void vLoRaConnectionPkt(uint8_t ucNodeId)
{
if (ucNodeId == xLoRaNode1Config.ucLoRaNode1Identifier)
@@ -20,9 +26,9 @@ void vLoRaConnectionPkt(uint8_t ucNodeId)
}
/**
* @brief LoRa<52><61><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD>hex<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><D2B2>LoRa<52>ڶ<EFBFBD><DAB6><EFBFBD>ģʽ<C4A3><CABD>ִ<EFBFBD>нڵ<D0BD><DAB5><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note hex<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD>ĸ<EFBFBD>ʽΪ<EFBFBD>̶<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param None
* @brief LoRa<52><61><EFBFBD>ͽڵ<EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͽڵ<EFBFBD>ID<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><EFBFBD><EFBFBD>ʲô<EFBFBD>ڵ㡣
* @param ucNodeId <20>ڵ<EFBFBD>ID<49><44><EFBFBD><EFBFBD>Node1<65><31>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>D1<44>ȵȡ<C8B5>
* @retval None
*/
void vLoRaToGateIdPkt(uint8_t ucNodeId)
@@ -38,6 +44,12 @@ void vLoRaToGateIdPkt(uint8_t ucNodeId)
}
}
/**
* @brief LoRa<52><61><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>ID<49><44><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD><EFBFBD><EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ʲô<CAB2><C3B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param ucSensorId <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID<49><44><EFBFBD><EFBFBD>DHT11<31><31>ʪ<EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ucIdDht11<31>ȵȡ<C8B5>
* @retval None
*/
void vLoRaToGateSenIdPkt(uint8_t ucSensorId)
{
if (ucSensorId == xLoRaSensorID.ucIdDht11)
@@ -59,6 +71,12 @@ void vLoRaToGateSenIdPkt(uint8_t ucSensorId)
}
}
/**
* @brief LoRa<52><61><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ID<49><44><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ʲôִ<C3B4><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param ucExeId ִ<><D6B4><EFBFBD><EFBFBD>ID<49><44><EFBFBD><EFBFBD>LED<45>ƣ<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ucIdLed<65>ȵȡ<C8B5>
* @retval None
*/
void vLoRaToGateExeIdPkt(uint8_t ucExeId)
{
if (ucExeId == xLoRaExecutorID.ucIdLed)
@@ -84,6 +102,12 @@ void vLoRaToGateExeIdPkt(uint8_t ucExeId)
}
}
/**
* @brief LoRa<52>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ͨ<><CDA8><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>н<EFBFBD><D0BD><EFBFBD>ʲô<CAB2><C3B4><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ʲôָ<C3B4>
* @param *pucData <20><><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @retval eLoRaMsgRecStatus ö<>٣<EFBFBD><D9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID<49><44>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ID<49>Ϳ<EFBFBD><CDBF><EFBFBD>ָ<EFBFBD>
*/
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData)
{
switch (*pucData)
@@ -121,13 +145,21 @@ eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData)
}
}
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeSta)
/**
* @brief LoRa<52>ڵ㴦<DAB5><E3B4A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ͨ<><CDA8>LoRa<52>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD>շ<EFBFBD><D5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD>װ<EFBFBD><D7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ʲôָ<C3B4><EFBFBD><EEA3AC>ϸ<EFBFBD><CFB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC>ٴ<EFBFBD><D9B4><EFBFBD>Ӷȡ<D3B6><C8A1><EFBFBD>API<50><49>ֱ<EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>á<EFBFBD>
* @param ucDataRecNodeId Ҫ<>жϵĽڵ<C4BD>ID<49><44>
* @param ucDataRecExeId Ҫ<>жϵ<D0B6>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ID<49><44>
* @param ucDataRecExeStatus Ҫ<>жϵĴ<CFB5><C4B4><EFBFBD><EFBFBD><EFBFBD>ID<49><44>
* @retval eLoRaMsgRecStatus ö<>٣<EFBFBD><D9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>ID<49><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ID<49><44>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ID<49>Ϳ<EFBFBD><CDBF><EFBFBD>ָ<EFBFBD>
*/
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeStatus)
{
switch (xLoRaMessageReceived(&ucDataRecNodeId))
{
case statusNode1:
/* code */
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOn)
while (xLoRaMessageReceived(&ucDataRecExeStatus) == statusExeOn)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeLed)
@@ -144,7 +176,7 @@ eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeI
return statusHumidifierOn;
}
}
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOff)
while (xLoRaMessageReceived(&ucDataRecExeStatus) == statusExeOff)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeLed)
@@ -163,7 +195,7 @@ eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeI
}
case statusNode2:
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOn)
while (xLoRaMessageReceived(&ucDataRecExeStatus) == statusExeOn)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeBuzzer)
@@ -176,7 +208,7 @@ eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeI
return statusServoOn;
}
}
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOff)
while (xLoRaMessageReceived(&ucDataRecExeStatus) == statusExeOff)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeBuzzer)

View File

@@ -1,12 +1,9 @@
#ifndef __LORA_H__
#define __LORA_H__
#include "USART3.h"
// #define LORA_MODE
/* LoRa<52>ľ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD> */
#define LORA_MODE_INIT 1
#define LORA_IS_GATEWAY_NODE 0
#define LORA_GPIO_PIN_TX GPIO_Pin_10
#define LORA_GPIO_PIN_RX GPIO_Pin_11
#define LORA_GPIO_PIN_ATK_AUX GPIO_Pin_4 //PA4
@@ -34,6 +31,8 @@
#define LORA_EXECUTOR_COMMAND_ON 0x01
#define LORA_EXECUTOR_COMMAND_OFF 0x00
#include "USART3.h"
/* LoRa<52><61>ֲ<EFBFBD><D6B2> */
typedef enum {
@@ -141,10 +140,14 @@ static LoRaExecutorCmd_t xLoRaExecutorCommand = {
};
void vLoRaConnectionPkt(uint8_t ucNodeId);
void vLoRaToGateIdPkt(uint8_t ucNodeId);
void vLoRaToGateSenIdPkt(uint8_t ucSensorId);
void vLoRaToGateExeIdPkt(uint8_t ucExecutorId);
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData);
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeSta);
#if(LORA_IS_GATEWAY_NODE == 1)
#elif(LORA_IS_GATEWAY_NODE == 0)
void vLoRaToGateIdPkt(uint8_t ucNodeId);
void vLoRaToGateSenIdPkt(uint8_t ucSensorId);
void vLoRaToGateExeIdPkt(uint8_t ucExecutorId);
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData);
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeStatus);
#endif
#endif

View File

@@ -110,8 +110,8 @@
<MDIClientArea>
<RegID>0</RegID>
<MDITabState>
<Len>1223</Len>
<Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000008000000000000000100000063433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C557365725C6D61696E2E6300000000066D61696E2E6300000000C5D4F200FFFFFFFF67433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C53797374656D5C5553415254332E6800000000085553415254332E6800000000FFDC7800FFFFFFFF67433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C53797374656D5C5553415254332E6300000000085553415254332E6300000000BECEA100FFFFFFFF66433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C4C6F52612E6800000000064C6F52612E6800000000F0A0A100FFFFFFFF66433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C4C6F52612E6300000000064C6F52612E6300000000BCA8E100FFFFFFFF7A433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C53797374656D46696C65735C737461727475705F73746D3332663130785F6D642E730000000016737461727475705F73746D3332663130785F6D642E73000000009CC1B600FFFFFFFF67433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C52656C61792E63000000000752656C61792E6300000000F7B88600FFFFFFFF67433A5C55736572735C4578706C6F726174696F6E5C4465736B746F705C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C52656C61792E68000000000752656C61792E6800000000D9ADC200FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F4000000660000008007000030030000</Data>
<Len>1215</Len>
<Data>01000000040000000100000001000000010000000100000000000000020000000000000001000000010000000000000028000000280000000100000008000000000000000100000062453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C557365725C6D61696E2E6300000000066D61696E2E6300000000C5D4F200FFFFFFFF66453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C53797374656D5C5553415254332E6800000000085553415254332E6800000000FFDC7800FFFFFFFF66453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C53797374656D5C5553415254332E6300000000085553415254332E6300000000BECEA100FFFFFFFF65453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C4C6F52612E6800000000064C6F52612E6800000000F0A0A100FFFFFFFF65453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C4C6F52612E6300000000064C6F52612E6300000000BCA8E100FFFFFFFF79453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C53797374656D46696C65735C737461727475705F73746D3332663130785F6D642E730000000016737461727475705F73746D3332663130785F6D642E73000000009CC1B600FFFFFFFF66453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C52656C61792E63000000000752656C61792E6300000000F7B88600FFFFFFFF66453A5C446174615C50726F6A6563745C496F5450726F6A656374735C4672656552544F535F4C6F52615F456E7669726F6E6D656E745F417373697374616E745C53544D33325C456E7669726F6E6D656E745F4E6F64655C447269766572735C52656C61792E68000000000752656C61792E6800000000D9ADC200FFFFFFFF0100000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD500010000000000000002000000F4000000660000008007000030030000</Data>
</MDITabState>
</MDIClientArea>
<ViewEx>
@@ -174,7 +174,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000003E01000075020000</Data>
<Data>BE000000D5000000DA01000011030000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -274,7 +274,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -314,7 +314,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -374,7 +374,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>2200000039000000EA020000C7000000</Data>
<Data>BE000000D50000008603000063010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -454,7 +454,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000003E01000075020000</Data>
<Data>BE000000D5000000DA01000011030000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -474,7 +474,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000003E01000075020000</Data>
<Data>BE000000D5000000DA01000011030000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -526,7 +526,7 @@
<IsActivated>0</IsActivated>
<MRUWidth>32767</MRUWidth>
<PinState>0</PinState>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentFrameAlignment>32768</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
@@ -554,7 +554,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>2200000039000000EA020000C7000000</Data>
<Data>A4000000BB0000006C03000049010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -614,7 +614,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -694,7 +694,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -714,7 +714,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>2200000039000000EA020000C7000000</Data>
<Data>A4000000BB0000006C03000049010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -734,7 +734,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -754,7 +754,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -774,7 +774,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -874,7 +874,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -934,7 +934,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -954,7 +954,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -974,7 +974,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -994,7 +994,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1014,7 +1014,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1034,7 +1034,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1094,7 +1094,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1154,7 +1154,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000003E01000075020000</Data>
<Data>BE000000D5000000DA01000011030000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1186,7 +1186,7 @@
<IsActivated>0</IsActivated>
<MRUWidth>32767</MRUWidth>
<PinState>0</PinState>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentFrameAlignment>32768</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
@@ -1266,7 +1266,7 @@
<IsActivated>0</IsActivated>
<MRUWidth>32767</MRUWidth>
<PinState>0</PinState>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentFrameAlignment>32768</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<RectRecentDocked>
<Len>16</Len>
@@ -1314,7 +1314,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1334,7 +1334,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1354,7 +1354,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1374,7 +1374,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1394,7 +1394,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1454,7 +1454,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1474,7 +1474,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1494,7 +1494,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1514,7 +1514,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1554,7 +1554,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1634,7 +1634,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1654,7 +1654,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1674,7 +1674,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1694,7 +1694,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>BE000000D5000000AE0100009E010000</Data>
</RectRecentFloat>
</Window>
<Window>
@@ -1794,7 +1794,7 @@
</RectRecentDocked>
<RectRecentFloat>
<Len>16</Len>
<Data>22000000390000001201000002010000</Data>
<Data>A4000000BB0000009401000084010000</Data>
</RectRecentFloat>
</Window>
<DockMan>
@@ -1822,7 +1822,7 @@
<Name>Build</Name>
<Buttons>
<Len>976</Len>
<Data>00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000000001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000002001E000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6EC7040000000000006A0000000C4261746368204275696C2664000000000000000000000000010000000100000000000000000000000100000004000580C7040000000000006A0000000C4261746368204275696C266400000000000000000000000001000000010000000000000000000000010000000000058046070000000000006B0000000D42617463682052656275696C640000000000000000000000000100000001000000000000000000000001000000000005804707000000000000FFFFFFFF0B426174636820436C65616E0100000000000000000000000100000001000000000000000000000001000000000005809E8A0000000000001F0000000F4261746326682053657475702E2E2E000000000000000000000000010000000100000000000000000000000100000000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA000000000000000000000000000000000000000000000000010000000100000096000000030020500000000008546172676574203196000000000000000100085461726765742031000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64DC010000</Data>
<Data>00200000010000001000FFFF01001100434D4643546F6F6C426172427574746F6ECF7F0000000000001C0000000000000000000000000000000001000000010000000180D07F0000000000001D000000000000000000000000000000000100000001000000018030800000000000001E000000000000000000000000000000000100000001000000FFFF01001500434D4643546F6F6C4261724D656E75427574746F6EC7040000000000006A0000000C4261746368204275696C2664000000000000000000000000010000000100000000000000000000000100000004000580C7040000000000006A0000000C4261746368204275696C266400000000000000000000000001000000010000000000000000000000010000000000058046070000000000006B0000000D42617463682052656275696C640000000000000000000000000100000001000000000000000000000001000000000005804707000000000000FFFFFFFF0B426174636820436C65616E0100000000000000000000000100000001000000000000000000000001000000000005809E8A0000000000001F0000000F4261746326682053657475702E2E2E000000000000000000000000010000000100000000000000000000000100000000000180D17F0000000004002000000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF00000000000000000000000000010000000100000001804C8A0000000000002100000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF000000000000000000000000000100000001000000FFFF01001900434D4643546F6F6C426172436F6D626F426F78427574746F6EBA000000000000000000000000000000000000000000000000010000000100000096000000030020500000000008546172676574203196000000000000000100085461726765742031000000000180EB880000000000002200000000000000000000000000000000010000000100000001800000000001000000FFFFFFFF0000000000000000000000000001000000010000000180C07F000000000000230000000000000000000000000000000001000000010000000180B08A000000000400240000000000000000000000000000000001000000010000000180A8010000000000004E00000000000000000000000000000000010000000100000001807202000000000000530000000000000000000000000000000001000000010000000180BE010000000000005000000000000000000000000000000000010000000100000000000000054275696C64DC010000</Data>
</Buttons>
<OriginalItems>
<Len>583</Len>
@@ -3606,9 +3606,9 @@
<ActiveTab>0</ActiveTab>
<Doc>
<Name>.\User\main.c</Name>
<ColumnNumber>9</ColumnNumber>
<TopLine>43</TopLine>
<CurrentLine>57</CurrentLine>
<ColumnNumber>13</ColumnNumber>
<TopLine>112</TopLine>
<CurrentLine>203</CurrentLine>
<Folding>1</Folding>
<ContractedFolders></ContractedFolders>
<PaneID>0</PaneID>
@@ -3624,9 +3624,9 @@
</Doc>
<Doc>
<Name>.\System\USART3.c</Name>
<ColumnNumber>33</ColumnNumber>
<TopLine>44</TopLine>
<CurrentLine>58</CurrentLine>
<ColumnNumber>24</ColumnNumber>
<TopLine>1</TopLine>
<CurrentLine>106</CurrentLine>
<Folding>1</Folding>
<ContractedFolders></ContractedFolders>
<PaneID>0</PaneID>
@@ -3634,7 +3634,7 @@
<Doc>
<Name>.\Drivers\LoRa.h</Name>
<ColumnNumber>6</ColumnNumber>
<TopLine>25</TopLine>
<TopLine>3</TopLine>
<CurrentLine>4</CurrentLine>
<Folding>1</Folding>
<ContractedFolders></ContractedFolders>
@@ -3642,9 +3642,9 @@
</Doc>
<Doc>
<Name>.\Drivers\LoRa.c</Name>
<ColumnNumber>36</ColumnNumber>
<ColumnNumber>18</ColumnNumber>
<TopLine>1</TopLine>
<CurrentLine>46</CurrentLine>
<CurrentLine>18</CurrentLine>
<Folding>1</Folding>
<ContractedFolders></ContractedFolders>
<PaneID>0</PaneID>

View File

@@ -1,28 +0,0 @@
#ifndef __SysTick_H__
#define __SysTick_H__
#include "stm32f10x.h" // Device header
#define SYSTEM SYSTEM_FREERTOS
#define SYSTEM_NONE 0
#define SYSTEM_FREERTOS 1
#define SYSTEM_UCOSII 2
#define SYSTEM_UCOSIII 3
#define SYSTEM_RT_THREAD 4
#define SYSTEM_AZURE_RTOS 5
typedef struct {
uint8_t ucFacUs;
int16_t usFacMs;
} UcFacInit_t;
static UcFacInit_t xUcFacInit = {
.ucFacUs = 0,
.usFacMs = 0
};
void vSysTickInit(uint8_t ucSYSCLK);
void vDelayUs(uint32_t ulNus);
void vDelayMs(uint16_t usNms);
#endif

View File

@@ -128,11 +128,15 @@ void USART3_IRQHandler(void)
if (USART_GetITStatus(USART3, USART_IT_RXNE) == SET)
{
/* code */
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART3);
xQueueSendFromISR(xQueueUsart3IrqHdlr, &ulRxData, &xHigherPriorityTaskWoken);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
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)
#endif
USART_ClearITPendingBit(USART3, USART_IT_RXNE);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD> */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}

View File

@@ -1,21 +1,32 @@
#ifndef __USART3_H__
#define __USART3_H__
#include "stm32f10x.h" // Device header
#include "FreeRTOS.h"
#include "queue.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#define USE_NONE_SYSTEM 0
#define USE_FREERTOS 1
#define USE_OSAL 0
#define vLoRaIrqHandler USART3_IRQHandler
#define USART3_GPIO_PIN_TX GPIO_Pin_10
#define USART3_GPIO_PIN_RX GPIO_Pin_11
#define USART3_GPIO_PIN_ATK_AUX GPIO_Pin_4 // PA4
#define USART3_GPIO_PIN_ATK_MD0 GPIO_Pin_3 // PB3
extern QueueHandle_t xQueueUsart3IrqHdlr;
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#include "FreeRTOS.h"
#include "queue.h"
#elif (USE_OSAL == 1)
#endif
#include "stm32f10x.h" // Device header
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
extern QueueHandle_t xQueueUsart3IrqHdlr;
#elif (USE_OSAL == 1)
#endif
void vUsart3Init(uint32_t ulUsart3Baudrate);
void vUsart3SendByte(uint8_t ucByte);

View File

@@ -108,21 +108,21 @@ void vTaskLoRaToGatePkt(void *pvParameters)
{
uint8_t ucRecTempData = 0, ucRecHumiData = 0;
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ճɹ<D5B3> */
BaseType_t xQueueTempRetval, xQueueHumiRetval;
BaseType_t xRetvalQueueTemp, xRetvalQueueHumi;
while (1)
{
/* code */
/* <20><><EFBFBD>ն<EFBFBD><D5B6>У<EFBFBD><D0A3><EFBFBD><EFBFBD>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>ݵĵȴ<C4B5>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD>Ϊ0<CEAA><30>0~portMAX_DELAY<41><59>portMAX_DELAY<41><59><EFBFBD>֣<EFBFBD><D6A3>ֱ<EFBFBD><D6B1><EFBFBD>Ӧ
* һ<><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>һ<EFBFBD><D2BB>ʱ<EFBFBD><CAB1><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>ڵȴ<DAB5><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3>ý<EFBFBD><C3BD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̬<EFBFBD><CCAC>
*/
xQueueTempRetval = xQueueReceive(xQueueTempHdlr, &ucRecTempData, pdMS_TO_TICKS(10));
xQueueHumiRetval = xQueueReceive(xQueueHumiHdlr, &ucRecHumiData, pdMS_TO_TICKS(10));
xRetvalQueueTemp = xQueueReceive(xQueueTempHdlr, &ucRecTempData, pdMS_TO_TICKS(10));
xRetvalQueueHumi = xQueueReceive(xQueueHumiHdlr, &ucRecHumiData, pdMS_TO_TICKS(10));
/* <20><><EFBFBD><EFBFBD> */
vLoRaConnectionPkt(xLoRaGateConfig.ucLoRaGateChannel);
vLoRaToGateIdPkt(xLoRaNode1Config.ucLoRaNode1Identifier);
vLoRaToGateSenIdPkt(xLoRaSensorID.ucIdDht11);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD> */
if (xQueueTempRetval == pdTRUE && xQueueHumiRetval == pdTRUE)
if (xRetvalQueueTemp == pdTRUE && xRetvalQueueHumi == pdTRUE)
{
/* code */
vUsart3SendArray(&ucRecTempData, 1);
@@ -179,49 +179,60 @@ void vTaskLoRaMsgRec(void *pvParameters)
void vCreateTasksList(void)
{
#if defined __LED_H__
#if LED_PC13_WORK_MODE == LED_PC13_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,
// (char * ) "TaskName_StateLed",
// (configSTACK_DEPTH_TYPE) 256,
// (void * ) NULL,
// (UBaseType_t ) 2,
// (TaskHandle_t * ) &xTaskStateLedHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskLedControl,
(char * ) "TaskName_LedControl",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskLedCtrlHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskFanControl,
(char * ) "TaskName_FanControl",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskFanCtrlHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskDht11,
(char * ) "TaskName_DHT11",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskDht11Hdlr);
xTaskCreate(
(TaskFunction_t ) vTaskLoRaToGatePkt,
(char * ) "TaskName_LoRaSendToGateway",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskLoRaToGateHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskLoRaMsgRec,
(char * ) "TaskName_LoRaReceivedMessage",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskLoRaMsgRecHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskStateLed,
(char * ) "TaskName_StateLed",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskStateLedHdlr);
#else
xTaskCreate(
(TaskFunction_t ) vTaskLedControl,
(char * ) "TaskName_LedControl",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskLedCtrlHdlr);
#endif
#endif
#if defined __RELAY_H__
xTaskCreate(
(TaskFunction_t ) vTaskFanControl,
(char * ) "TaskName_FanControl",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskFanCtrlHdlr);
#endif
#if defined __DHT11_H__
xTaskCreate(
(TaskFunction_t ) vTaskDht11,
(char * ) "TaskName_DHT11",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskDht11Hdlr);
#endif
#if defined __LORA_H__
xTaskCreate(
(TaskFunction_t ) vTaskLoRaToGatePkt,
(char * ) "TaskName_LoRaSendToGateway",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskLoRaToGateHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskLoRaMsgRec,
(char * ) "TaskName_LoRaReceivedMessage",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskLoRaMsgRecHdlr);
#endif
}
void vCreateQueuesList(void)
@@ -249,8 +260,8 @@ void vCreateSemaphoresList(void)
{
xSemLedOnHdlr = xSemaphoreCreateBinary();
xSemLedOffHdlr = xSemaphoreCreateBinary();
xSemFanOnHdlr = xSemaphoreCreateBinary();
xSemFanOffHdlr = xSemaphoreCreateBinary();
xSemFanOnHdlr = xSemaphoreCreateBinary();
xSemFanOffHdlr = xSemaphoreCreateBinary();
}
int main(void)

View File

@@ -0,0 +1,6 @@
{
"files.associations": {
"stm32f10x.h": "c",
"core_cm3.h": "c"
}
}

View File

@@ -0,0 +1 @@
#include "ESP8266.h"

View File

@@ -0,0 +1,5 @@
#ifndef __ESP8266_H__
#define __ESP8266_H__
#endif

View File

@@ -0,0 +1,35 @@
#include "LED.h"
void vPc13LedInit(void)
{
RCC_APB2PeriphClockCmd(LED_PC13_GPIO_CLOCK,ENABLE);
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin = LED_PC13_GPIO_PIN; //PC13
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(LED_PC13_GPIO_PORT,&GPIO_InitStructure);
GPIO_SetBits(LED_PC13_GPIO_PORT,LED_PC13_GPIO_PIN);
}
/* <20><><EFBFBD><EFBFBD>led<65>϶࣬<CFB6><E0A3AC><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD>һ<EFBFBD><D2BB>LED_Set<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȼ<EFBFBD><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8>ƣ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>񿪻<EFBFBD><F1BFAABB>ǹ<EFBFBD> */
void vPc13LedOn(void)
{
GPIO_ResetBits(LED_PC13_GPIO_PORT,LED_PC13_GPIO_PIN);
}
void vPc13LedOff(void)
{
GPIO_SetBits(LED_PC13_GPIO_PORT,LED_PC13_GPIO_PIN);
}
/* ʵ<>ְ<EFBFBD>һ<EFBFBD><D2BB>Ϩ<EFBFBD><CFA8><EFBFBD><EFBFBD><EFBFBD>ٰ<EFBFBD>һ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD>LED<45><44>״̬ȡ<CCAC><C8A1><EFBFBD><EFBFBD>ʵ<EFBFBD>ֵ<EFBFBD>ƽ<EFBFBD><C6BD>ת<EFBFBD><D7AA>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD> */
void vPc13LedTurn(void)
{
if(GPIO_ReadOutputDataBit(LED_PC13_GPIO_PORT,LED_PC13_GPIO_PIN) == 0)//<2F><><EFBFBD><EFBFBD>PA0<41><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>Ϊ0
{
GPIO_SetBits(LED_PC13_GPIO_PORT,LED_PC13_GPIO_PIN); //<2F><>PA0<41><30>1
}else
{
GPIO_ResetBits(LED_PC13_GPIO_PORT,LED_PC13_GPIO_PIN);
}
}

View File

@@ -0,0 +1,18 @@
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ֹͷ<D6B9>ļ<EFBFBD><C4BC>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>if not define<6E><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô<EFBFBD><C3B4><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD>һ<EFBFBD><D2BB> */
#ifndef __LED_H__
#define __LED_H__
#include "stm32f10x.h" // Device header
/* 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
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
void vPc13LedInit(void);
void vPc13LedOn(void);
void vPc13LedOff(void);
void vPc13LedTurn(void);
#endif

View File

@@ -0,0 +1,195 @@
#include "LoRa.h"
void vLoRaConnectionPkt(uint8_t ucNodeId)
{
if (ucNodeId == xLoRaNode1Config.ucLoRaNode1Identifier)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaNode1Config, 3);
}
else if (ucNodeId == xLoRaNode2Config.ucLoRaNode2Identifier)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaNode2Config, 3);
}
else
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaGateConfig, 3);
}
}
/**
* @brief LoRa<52><61><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>hex<65><78><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD><EFBFBD><EFBFBD><><D2B2>LoRa<52>ڶ<EFBFBD><DAB6><EFBFBD>ģʽ<C4A3><CABD>ִ<EFBFBD>нڵ<D0BD><DAB5><EFBFBD>ͨ<EFBFBD>ŵ<EFBFBD><C5B5><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note hex<65><78><EFBFBD>ݰ<EFBFBD><DDB0>ĸ<EFBFBD>ʽΪ<CABD>̶<EFBFBD><CCB6><EFBFBD><EFBFBD><EFBFBD>
* @param None
* @retval None
*/
void vLoRaToGateIdPkt(uint8_t ucNodeId)
{
if (ucNodeId == xLoRaNode1Config.ucLoRaNode1Identifier)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaNode1Config.ucLoRaNode1Identifier, 1);
} else if (ucNodeId == xLoRaNode2Config.ucLoRaNode2Identifier)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaNode2Config.ucLoRaNode2Identifier, 1);
}
}
void vLoRaToGateSenIdPkt(uint8_t ucSensorId)
{
if (ucSensorId == xLoRaSensorID.ucIdDht11)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaSensorID.ucIdDht11, 1);
} else if (ucSensorId == xLoRaSensorID.ucIdMq2)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaSensorID.ucIdMq2, 1);
} else if (ucSensorId == xLoRaSensorID.ucIdFire)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaSensorID.ucIdFire, 1);
} else if (ucSensorId == xLoRaSensorID.ucIdLight)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaSensorID.ucIdLight, 1);
}
}
void vLoRaToGateExeIdPkt(uint8_t ucExeId)
{
if (ucExeId == xLoRaExecutorID.ucIdLed)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaExecutorID.ucIdLed, 1);
} else if (ucExeId == xLoRaExecutorID.ucIdFan)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaExecutorID.ucIdFan, 1);
} else if (ucExeId == xLoRaExecutorID.ucIdHumidifier)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaExecutorID.ucIdHumidifier, 1);
} else if (ucExeId == xLoRaExecutorID.ucIdBuzzer)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaExecutorID.ucIdBuzzer, 1);
} else if (ucExeId == xLoRaExecutorID.ucIdServo)
{
/* code */
vUsartSendArray(USART3, (uint8_t *)&xLoRaExecutorID.ucIdServo, 1);
}
}
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData)
{
switch (*pucData)
{
case 0xD1:
/* code */
return statusNode1;
case 0xD2:
return statusNode2;
case 0xFA:
return statusExeLed;
case 0xFB:
return statusExeFan;
case 0xFC:
return statusExeHumidifier;
case 0xFD:
return statusExeBuzzer;
case 0xFE:
return statusExeServo;
case 0x01:
return statusExeOn;
case 0x00:
return statusExeOff;
default:
return null;
}
}
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeSta)
{
switch (xLoRaMessageReceived(&ucDataRecNodeId))
{
case statusNode1:
/* code */
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOn)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeLed)
{
/* code */
return statusLedOn;
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeFan)
{
/* code */
return statusFanOn;
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeHumidifier)
{
/* code */
return statusHumidifierOn;
}
}
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOff)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeLed)
{
/* code */
return statusLedOff;
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeFan)
{
/* code */
return statusFanOff;
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeHumidifier)
{
/* code */
return statusHumidifierOff;
}
}
case statusNode2:
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOn)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeBuzzer)
{
/* code */
return statusBuzzerOn;
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeServo)
{
/* code */
return statusServoOn;
}
}
while (xLoRaMessageReceived(&ucDataRecExeSta) == statusExeOff)
{
/* code */
if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeBuzzer)
{
/* code */
return statusBuzzerOff;
} else if (xLoRaMessageReceived(&ucDataRecExeId) == statusExeServo)
{
/* code */
return statusServoOff;
}
}
default:
return null;
}
}

View File

@@ -0,0 +1,151 @@
#ifndef __LORA_H__
#define __LORA_H__
//#include "USART3.h"
#include "USART.h"
// #define LORA_MODE
/* LoRa<52>ľ<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD> */
#define LORA_MODE_INIT 1
#define LORA_GPIO_PIN_TX GPIO_Pin_10
#define LORA_GPIO_PIN_RX GPIO_Pin_11
#define LORA_GPIO_PIN_ATK_AUX GPIO_Pin_4 //PA4
#define LORA_GPIO_PIN_ATK_MD0 GPIO_Pin_3 //PB3
#define LORA_GATE_ADDR_HIGH 0x03
#define LORA_GATE_ADDR_LOW 0xE9
#define LORA_GATE_CHANNEL 0x17
#define LORA_NODE1_ADDR_HIGH 0x03
#define LORA_NODE1_ADDR_LOW 0xEA
#define LORA_NODE1_CHANNEL 0x17
#define LORA_NODE1_IDENTIFIER 0xD1
#define LORA_NODE2_ADDR_HIGH 0x03
#define LORA_NODE2_ADDR_LOW 0xEB
#define LORA_NODE2_CHANNEL 0x17
#define LORA_NODE2_IDENTIFIER 0xD2
#define LORA_SENSOR_DHT11 0xEA
#define LORA_SENSOR_MQ2 0xEB
#define LORA_SENSOR_LIGHT 0xEC
#define LORA_SENSOR_FIRE 0xED
#define LORA_EXECUTOR_LED 0xFA
#define LORA_EXECUTOR_FAN 0xFB
#define LORA_EXECUTOR_HUMIDIFIER 0xFC
#define LORA_EXECUTOR_BUZZER 0xFD
#define LORA_EXECUTOR_SERVO 0xFE
#define LORA_EXECUTOR_COMMAND_ON 0x01
#define LORA_EXECUTOR_COMMAND_OFF 0x00
/* LoRa<52><61>ֲ<EFBFBD><D6B2> */
typedef enum {
statusGatawayNode = 1,
statusNode1,
statusNode2,
statusExeLed,
statusExeFan,
statusExeHumidifier,
statusExeBuzzer,
statusExeServo,
statusExeOn,
statusExeOff,
statusLedOn,
statusLedOff,
statusFanOn,
statusFanOff,
statusHumidifierOn,
statusHumidifierOff,
statusBuzzerOn,
statusBuzzerOff,
statusServoOn,
statusServoOff,
null
}eLoRaMsgRecStatus;
typedef struct {
uint8_t ucLoRaGateAddrHigh;
uint8_t ucLoRaGateAddrLow;
uint8_t ucLoRaGateChannel;
} LoRaGateConfig_t;
typedef struct {
uint8_t ucLoRaNode1AddrHigh;
uint8_t ucLoRaNode1AddrLow;
uint8_t ucLoRaNode1Channel;
uint8_t ucLoRaNode1Identifier;
} LoRaNode1Config_t;
typedef struct {
uint8_t ucLoRaNode2AddrHigh;
uint8_t ucLoRaNode2AddrLow;
uint8_t ucLoRaNode2Channel;
uint8_t ucLoRaNode2Identifier;
} LoRaNode2Config_t;
typedef struct {
uint8_t ucIdDht11;
uint8_t ucIdMq2;
uint8_t ucIdLight;
uint8_t ucIdFire;
} LoRaSensorID_t;
typedef struct {
uint8_t ucIdLed;
uint8_t ucIdFan;
uint8_t ucIdHumidifier;
uint8_t ucIdBuzzer;
uint8_t ucIdServo;
} LoRaExecutorID_t;
typedef struct {
uint8_t ucCommandOn;
uint8_t ucCommandOff;
} LoRaExecutorCmd_t;
static LoRaGateConfig_t xLoRaGateConfig = {
.ucLoRaGateAddrHigh = LORA_GATE_ADDR_HIGH,
.ucLoRaGateAddrLow = LORA_GATE_ADDR_LOW,
.ucLoRaGateChannel = LORA_GATE_CHANNEL
};
static LoRaNode1Config_t xLoRaNode1Config = {
.ucLoRaNode1AddrHigh = LORA_NODE1_ADDR_HIGH,
.ucLoRaNode1AddrLow = LORA_NODE1_ADDR_LOW,
.ucLoRaNode1Channel = LORA_NODE1_CHANNEL,
.ucLoRaNode1Identifier = LORA_NODE1_IDENTIFIER,
};
static LoRaNode2Config_t xLoRaNode2Config = {
.ucLoRaNode2AddrHigh = LORA_NODE2_ADDR_HIGH,
.ucLoRaNode2AddrLow = LORA_NODE2_ADDR_LOW,
.ucLoRaNode2Channel = LORA_NODE2_CHANNEL,
.ucLoRaNode2Identifier = LORA_NODE2_IDENTIFIER
};
static LoRaSensorID_t xLoRaSensorID = {
.ucIdDht11 = LORA_SENSOR_DHT11,
.ucIdMq2 = LORA_SENSOR_MQ2,
.ucIdLight = LORA_SENSOR_LIGHT,
.ucIdFire = LORA_SENSOR_FIRE
};
static LoRaExecutorID_t xLoRaExecutorID = {
.ucIdLed = LORA_EXECUTOR_LED,
.ucIdFan = LORA_EXECUTOR_FAN,
.ucIdHumidifier = LORA_EXECUTOR_HUMIDIFIER,
.ucIdBuzzer = LORA_EXECUTOR_BUZZER,
.ucIdServo = LORA_EXECUTOR_SERVO
};
static LoRaExecutorCmd_t xLoRaExecutorCommand = {
.ucCommandOn = LORA_EXECUTOR_COMMAND_ON,
.ucCommandOff = LORA_EXECUTOR_COMMAND_OFF,
};
void vLoRaConnectionPkt(uint8_t ucNodeId);
void vLoRaToGateIdPkt(uint8_t ucNodeId);
void vLoRaToGateSenIdPkt(uint8_t ucSensorId);
void vLoRaToGateExeIdPkt(uint8_t ucExecutorId);
eLoRaMsgRecStatus xLoRaMessageReceived(uint8_t *pucData);
eLoRaMsgRecStatus xLoRaMsgProcess(uint8_t ucDataRecNodeId, uint8_t ucDataRecExeId, uint8_t ucDataRecExeSta);
#endif

File diff suppressed because one or more lines are too long

View File

@@ -120,7 +120,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U/ -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("") -D00(00000000) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 -WK0</Name>
<Name>-U/ -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103C8$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 -WK0-R0</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@@ -172,7 +172,7 @@
<pSingCmdsp></pSingCmdsp>
<pMultCmdsp></pMultCmdsp>
<DebugDescription>
<Enable>1</Enable>
<Enable>0</Enable>
<EnableFlashSeq>0</EnableFlashSeq>
<EnableLog>0</EnableLog>
<Protocol>2</Protocol>
@@ -883,14 +883,134 @@
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>57</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\System\Delay.c</PathWithFileName>
<FilenameWithoutPath>Delay.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>58</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\System\Delay.h</PathWithFileName>
<FilenameWithoutPath>Delay.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>59</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\System\USART.c</PathWithFileName>
<FilenameWithoutPath>USART.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>4</GroupNumber>
<FileNumber>60</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\System\USART.h</PathWithFileName>
<FilenameWithoutPath>USART.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>Drivers</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>61</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Drivers\LED.c</PathWithFileName>
<FilenameWithoutPath>LED.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>62</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Drivers\LED.h</PathWithFileName>
<FilenameWithoutPath>LED.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>63</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Drivers\LoRa.c</PathWithFileName>
<FilenameWithoutPath>LoRa.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>64</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Drivers\LoRa.h</PathWithFileName>
<FilenameWithoutPath>LoRa.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>65</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Drivers\ESP8266.c</PathWithFileName>
<FilenameWithoutPath>ESP8266.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>5</GroupNumber>
<FileNumber>66</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\Drivers\ESP8266.h</PathWithFileName>
<FilenameWithoutPath>ESP8266.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@@ -901,7 +1021,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>57</FileNumber>
<FileNumber>67</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -913,7 +1033,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>58</FileNumber>
<FileNumber>68</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -925,7 +1045,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>59</FileNumber>
<FileNumber>69</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -937,7 +1057,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>60</FileNumber>
<FileNumber>70</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -949,7 +1069,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>61</FileNumber>
<FileNumber>71</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -961,7 +1081,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>62</FileNumber>
<FileNumber>72</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -973,7 +1093,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>63</FileNumber>
<FileNumber>73</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -985,7 +1105,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>64</FileNumber>
<FileNumber>74</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -997,7 +1117,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>65</FileNumber>
<FileNumber>75</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1009,7 +1129,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>66</FileNumber>
<FileNumber>76</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1021,7 +1141,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>67</FileNumber>
<FileNumber>77</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1033,7 +1153,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>68</FileNumber>
<FileNumber>78</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1045,7 +1165,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>69</FileNumber>
<FileNumber>79</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1057,7 +1177,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>70</FileNumber>
<FileNumber>80</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1069,7 +1189,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>71</FileNumber>
<FileNumber>81</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1081,7 +1201,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>72</FileNumber>
<FileNumber>82</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1093,7 +1213,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>73</FileNumber>
<FileNumber>83</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1105,7 +1225,7 @@
</File>
<File>
<GroupNumber>6</GroupNumber>
<FileNumber>74</FileNumber>
<FileNumber>84</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1125,7 +1245,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>75</FileNumber>
<FileNumber>85</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1137,7 +1257,7 @@
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>76</FileNumber>
<FileNumber>86</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1149,7 +1269,7 @@
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>77</FileNumber>
<FileNumber>87</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1161,7 +1281,7 @@
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>78</FileNumber>
<FileNumber>88</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1173,7 +1293,7 @@
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>79</FileNumber>
<FileNumber>89</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1185,7 +1305,7 @@
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>80</FileNumber>
<FileNumber>90</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1197,7 +1317,7 @@
</File>
<File>
<GroupNumber>7</GroupNumber>
<FileNumber>81</FileNumber>
<FileNumber>91</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1217,7 +1337,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>8</GroupNumber>
<FileNumber>82</FileNumber>
<FileNumber>92</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1229,7 +1349,7 @@
</File>
<File>
<GroupNumber>8</GroupNumber>
<FileNumber>83</FileNumber>
<FileNumber>93</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1241,7 +1361,7 @@
</File>
<File>
<GroupNumber>8</GroupNumber>
<FileNumber>84</FileNumber>
<FileNumber>94</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1261,7 +1381,7 @@
<RteFlg>0</RteFlg>
<File>
<GroupNumber>9</GroupNumber>
<FileNumber>85</FileNumber>
<FileNumber>95</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

View File

@@ -679,9 +679,63 @@
</Group>
<Group>
<GroupName>System</GroupName>
<Files>
<File>
<FileName>Delay.c</FileName>
<FileType>1</FileType>
<FilePath>.\System\Delay.c</FilePath>
</File>
<File>
<FileName>Delay.h</FileName>
<FileType>5</FileType>
<FilePath>.\System\Delay.h</FilePath>
</File>
<File>
<FileName>USART.c</FileName>
<FileType>1</FileType>
<FilePath>.\System\USART.c</FilePath>
</File>
<File>
<FileName>USART.h</FileName>
<FileType>5</FileType>
<FilePath>.\System\USART.h</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>Drivers</GroupName>
<Files>
<File>
<FileName>LED.c</FileName>
<FileType>1</FileType>
<FilePath>.\Drivers\LED.c</FilePath>
</File>
<File>
<FileName>LED.h</FileName>
<FileType>5</FileType>
<FilePath>.\Drivers\LED.h</FilePath>
</File>
<File>
<FileName>LoRa.c</FileName>
<FileType>1</FileType>
<FilePath>.\Drivers\LoRa.c</FilePath>
</File>
<File>
<FileName>LoRa.h</FileName>
<FileType>5</FileType>
<FilePath>.\Drivers\LoRa.h</FilePath>
</File>
<File>
<FileName>ESP8266.c</FileName>
<FileType>1</FileType>
<FilePath>.\Drivers\ESP8266.c</FilePath>
</File>
<File>
<FileName>ESP8266.h</FileName>
<FileType>5</FileType>
<FilePath>.\Drivers\ESP8266.h</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>FreeRTOS/inc</GroupName>

View File

@@ -1,11 +1,13 @@
#include "SysTick.h"
#include "Delay.h"
#if MODE == USE_SYS_TICK
#if SYSTEM == SYSTEM_NONE
//初始化延迟函数
//SYSTICK的时钟固定为AHB时钟的1/8
//SYSCLK:系统时钟频率
void vSysTickInit(uint8_t ucSYSCLK)
void vDelayInit(void)
{
uint8_t ucSYSCLK;
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);
xUcFacInit.ucFacUs=ucSYSCLK/8;
xUcFacInit.usFacMs=(uint16_t)xUcFacInit.ucFacUs*1000;
@@ -24,7 +26,7 @@ void vDelayUs(uint32_t ulNus)
ulTemp=SysTick->CTRL;
} while((ulTemp&0x01)&&!(ulTemp&(1<<16))); //等待时间到达
SysTick->CTRL&=~SysTick_CTRL_ENABLE_Msk; //关闭计数器
SysTick->VAL =0X00; //清空计数器
SysTick->VAL =0x00; //清空计数器
}
//延时nms
@@ -58,7 +60,71 @@ void vDelayMs(uint16_t usNms)
ulTemp = SysTick->CTRL;
} while ((ulTemp & 0x01) && !(ulTemp & (1 << 16)));
SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
SysTick->VAL = 0X00;
SysTick->VAL = 0x00;
}
}
#elif MODE == USE_DWT
void vDelayInit(void)
{
//使能DWT外设
DEMCR |= (uint32_t)TRCENA;
//DWT CYCCNT寄存器计数清0
DWT_CYCCNT = (uint32_t)0u;
//使能Cortex-M3 DWT CYCCNT寄存器
DWT_CTRL |= (uint32_t)DWT_CTRL_CYCCNTENA;
}
// 微秒延时
void vDelayUs(uint32_t ulNus)
{
if(ulNus > 10000) ulNus = 10000;
uint32_t ulTicksStart, ulTicksEnd, ulTicksDelay;
ulTicksStart = DWT_CYCCNT;
ulTicksDelay = ( ulNus * ( SystemCoreClock / (1000000) ) ); // 将微秒数换算成滴答数
ulTicksEnd = ulTicksStart + ulTicksDelay;
// ulTicksEnd没有溢出
if ( ulTicksEnd >= ulTicksStart )
{
// DWT_CYCCNT在上述计算的这段时间中没有溢出
if(DWT_CYCCNT > ulTicksStart)
{
while( DWT_CYCCNT < ulTicksEnd );
}
// DWT_CYCCNT溢出
else
{
// 已经超时,直接退出
return;
}
}
else // ulTicksEnd溢出
{
// DWT_CYCCNT在上述计算的这段时间中没有溢出
if(DWT_CYCCNT > ulTicksStart)
{
// 等待DWT_CYCCNT的值溢出
while( DWT_CYCCNT > ulTicksEnd );
}
// 等待溢出后的DWT_CYCCNT到达ulTicksEnd
while( DWT_CYCCNT < ulTicksEnd );
}
}
void vDelayMs(uint16_t usNms)
{
for(uint16_t i = 0; i < usNms; i++)
{
// delay 1 ms
vDelayUs(1000);
}
}
#else
#endif

View File

@@ -0,0 +1,40 @@
#ifndef __DELAY_H__
#define __DELAY_H__
#include "stm32f10x_conf.h"
#include "stm32f10x.h"
#define MODE USE_DWT
#define USE_SYS_TICK 0
#define USE_DWT 1
// 0xE000EDFC DEMCR RW Debug Exception and Monitor Control Register.
#define DEMCR ( *(__IO uint32_t *)0xE000EDFC )
#define TRCENA ( 0x01 << 24) // DEMCR的DWT使能位
#define DBGMCU_CR *(__IO uint32_t *)0xE0042004 //MCU调试模块控制寄存器详细内容参考《stm32中文参考手册》调试支持DBG章节747页
// 0xE0001000 DWT_CTRL RW The Debug Watchpoint and Trace (DWT) unit
#define DWT_CTRL ( *(__IO uint32_t *)0xE0001000 )
#define DWT_CTRL_CYCCNTENA ( 0x01 << 0 ) // DWT的SYCCNT使能位
// 0xE0001004 DWT_CYCCNT RW Cycle Count register,
#define DWT_CYCCNT ( *(__IO uint32_t *)0xE0001004) // 显示或设置处理器的周期计数值
//#define DWT_DELAY_mS(mSec) DWT_DELAY_uS(mSec*1000)
typedef struct {
uint8_t ucFacUs;
int16_t usFacMs;
} UcFacInit_t;
static UcFacInit_t xUcFacInit = {
.ucFacUs = 0,
.usFacMs = 0
};
void vDelayInit(void);
void vDelayUs(uint32_t ulNus);
void vDelayMs(uint16_t usNms);
#endif

View File

@@ -0,0 +1,281 @@
#include "USART.h"
/**
* @brief <20><><EFBFBD><EFBFBD>1<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ʹ<><CAB9>USART1<54><31><EFBFBD>ڣ<EFBFBD>PA9->USART1_RX<52><58>PA10->USART1_TX<54><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ115200<30><30>
* @param *xUsartId ѡ<>񴮿ں<F1B4AEBF>
* @param ulBaudrate Ҫ<><D2AA><EFBFBD>õIJ<C3B5><C4B2><EFBFBD><EFBFBD><EFBFBD>
* @retval None
*/
void vUsartInit(USART_TypeDef *xUsartId, uint32_t ulBaudrate)
{
if (xUsartId == USART1)
{
/* code */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,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_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);
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>
RCC_APB1PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
USART_InitStructure.USART_Mode = USART_Mode_Tx|USART_Mode_Rx; // <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>ͽ<EFBFBD><CDBD><EFBFBD>ģʽ
USART_InitStructure.USART_Parity = USART_Parity_No; // <20><>У<EFBFBD><D0A3>λ
USART_InitStructure.USART_StopBits = USART_StopBits_1; // һλֹͣλ
USART_InitStructure.USART_WordLength = USART_WordLength_8b; // <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪУ<D2AA><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>ѡ<EFBFBD><D1A1>
USART_Init(USART1,&USART_InitStructure);
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4>ڵIJ<DAB5>ѯģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>NVIC
USART_ITConfig(USART1,USART_IT_RXNE,ENABLE); // ѡ<><D1A1>RXNE<4E><45><EFBFBD>ж<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>1<EFBFBD><31><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // <20><><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD>4Ϊ4bit<69><74>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0bit<69><74>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0-15<31><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FreeRTOSû<53><C3BB><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><E0B5B1><34><CEBB>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><30><CEBB>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
NVIC_InitTypeDef NVIC_InitStructure; // <20><>ʼ<EFBFBD><CABC>NVIC<49><43>USART1ͨ<31><CDA8>
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; // <20>ж<EFBFBD>ͨ<EFBFBD><CDA8>
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; // <20><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>FreeRTOS<4F><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ڷ<EFBFBD>Χ<EFBFBD>ڿ<EFBFBD><DABF>Ե<EFBFBD><D4B5><EFBFBD>FreeRTOS<4F><53><EFBFBD>ԡ<EFBFBD>FromISR()<29><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>api<70><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
NVIC_Init(&NVIC_InitStructure); // ָ<><D6B8>NVIC_InitStructure<72>ĵ<EFBFBD>ַ
USART_Cmd(USART1,ENABLE);
} else if (xUsartId == USART2)
{
/* code */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,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_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = USART2_GPIO_PIN_RX;
GPIO_Init(GPIOB, &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>
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
USART_InitStructure.USART_Mode = USART_Mode_Tx|USART_Mode_Rx; // <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>ͽ<EFBFBD><CDBD><EFBFBD>ģʽ
USART_InitStructure.USART_Parity = USART_Parity_No; // <20><>У<EFBFBD><D0A3>λ
USART_InitStructure.USART_StopBits = USART_StopBits_1; // һλֹͣλ
USART_InitStructure.USART_WordLength = USART_WordLength_8b; // <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪУ<D2AA><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>ѡ<EFBFBD><D1A1>
USART_Init(USART2,&USART_InitStructure);
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4>ڵIJ<DAB5>ѯģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>NVIC
USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); // ѡ<><D1A1>RXNE<4E><45><EFBFBD>ж<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>1<EFBFBD><31><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // <20><><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD>4Ϊ4bit<69><74>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0bit<69><74>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0-15<31><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FreeRTOSû<53><C3BB><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><E0B5B1><34><CEBB>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><30><CEBB>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
NVIC_InitTypeDef NVIC_InitStructure; // <20><>ʼ<EFBFBD><CABC>NVIC<49><43>USART1ͨ<31><CDA8>
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; // <20>ж<EFBFBD>ͨ<EFBFBD><CDA8>
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; // <20><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>FreeRTOS<4F><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ڷ<EFBFBD>Χ<EFBFBD>ڿ<EFBFBD><DABF>Ե<EFBFBD><D4B5><EFBFBD>FreeRTOS<4F><53><EFBFBD>ԡ<EFBFBD>FromISR()<29><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>api<70><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
NVIC_Init(&NVIC_InitStructure); // ָ<><D6B8>NVIC_InitStructure<72>ĵ<EFBFBD>ַ
USART_Cmd(USART2, ENABLE);
} else if (xUsartId == USART3)
{
/* code */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,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_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin = USART3_GPIO_PIN_RX;
GPIO_Init(GPIOB, &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>
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
USART_InitStructure.USART_Mode = USART_Mode_Tx|USART_Mode_Rx; // <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>ͽ<EFBFBD><CDBD><EFBFBD>ģʽ
USART_InitStructure.USART_Parity = USART_Parity_No; // <20><>У<EFBFBD><D0A3>λ
USART_InitStructure.USART_StopBits = USART_StopBits_1; // һλֹͣλ
USART_InitStructure.USART_WordLength = USART_WordLength_8b; // <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪУ<D2AA><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>ѡ<EFBFBD><D1A1>
USART_Init(USART3,&USART_InitStructure);
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4>ڵIJ<DAB5>ѯģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>NVIC
USART_ITConfig(USART3,USART_IT_RXNE,ENABLE); // ѡ<><D1A1>RXNE<4E><45><EFBFBD>ж<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>1<EFBFBD><31><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // <20><><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD>4Ϊ4bit<69><74>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0bit<69><74>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0-15<31><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FreeRTOSû<53><C3BB><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><E0B5B1><34><CEBB>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><30><CEBB>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
NVIC_InitTypeDef NVIC_InitStructure; // <20><>ʼ<EFBFBD><CABC>NVIC<49><43>USART1ͨ<31><CDA8>
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; // <20>ж<EFBFBD>ͨ<EFBFBD><CDA8>
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; // <20><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>FreeRTOS<4F><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ڷ<EFBFBD>Χ<EFBFBD>ڿ<EFBFBD><DABF>Ե<EFBFBD><D4B5><EFBFBD>FreeRTOS<4F><53><EFBFBD>ԡ<EFBFBD>FromISR()<29><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>api<70><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
NVIC_Init(&NVIC_InitStructure); // ָ<><D6B8>NVIC_InitStructure<72>ĵ<EFBFBD>ַ
USART_Cmd(USART3, ENABLE);
}
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ֽں<D6BD><DABA><EFBFBD>
* @note <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF>Դ<EFBFBD>TX<54><58><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @param *xUsartId ѡ<>񴮿ں<F1B4AEBF>
* @param ucByte Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5>ֽ<EFBFBD>
* @retval None
*/
void vUsartSendByte(USART_TypeDef *xUsartId, uint8_t ucByte)
{
USART_SendData(xUsartId, ucByte); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Byte<74><65>д<EFBFBD><D0B4>TDR<44>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
// д<><D0B4>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD>TDR<44><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>TDR<44>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݾͻ<DDBE><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>ǣ<EFBFBD><C7A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD>±<EFBFBD>־λ
while(USART_GetFlagStatus(xUsartId, USART_FLAG_TXE) == RESET); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD><EFBFBD>ձ<EFBFBD>־λ<D6BE><CEBB><EFBFBD>ȴ<EFBFBD>TXE<58><45>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>һ<EFBFBD><D2BB>whileѭ<65><D1AD> TXE:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD><EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ<D6BE>Զ<EFBFBD><D4B6><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB>
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
* @note һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16<31><36><EFBFBD><EFBFBD>ģʽ<C4A3>¡<EFBFBD>uint8_t<5F><74>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><DEB7>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD>һ<EFBFBD><D2BB>Length<74><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param *xUsartId ѡ<>񴮿ں<F1B4AEBF>
* @param *pucArray Ҫ<><D2AA><EFBFBD>͵<EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param usLength <20><><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD>
* @retval None
*/
void vUsartSendArray(USART_TypeDef *xUsartId, uint8_t *pucArray, uint16_t usLength)
{
for(uint16_t i = 0; i < usLength; i ++) // forѭ<72><D1AD>ִ<EFBFBD><D6B4>Length<74>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD>Զ<EFBFBD>Array<61><79><EFBFBD>ݽ<EFBFBD><DDBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鲻Ҫ<E9B2BB><D2AA><EFBFBD><EFBFBD>uint16_t<5F>ķ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>
{
vUsartSendByte(xUsartId, pucArray[i]); // <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Array<61><79>ÿһ<C3BF><D2BB>
}
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9B3A4>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>͡<EFBFBD>
* @param *xUsartId ѡ<>񴮿ں<F1B4AEBF>
* @param *pcString Ҫ<><D2AA><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
* @retval None
*/
void vUsartSendString(USART_TypeDef *xUsartId, char *pcString) // <20><>uint8_t *Ҳ<><D2B2><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Դ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>־λ<D6BE><CEBB><EFBFBD><EFBFBD><EFBFBD>ԾͲ<D4BE><CDB2><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD><EFBFBD>
{
for(uint8_t i = 0; pcString[i] != '\0'; i++) // ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>ñ<EFBFBD>־λ<D6BE><CEBB><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>,<2C><>'\0'<27>ǿ<EFBFBD><C7BF>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ʾ<EFBFBD><CABE>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>д0<D0B4><30>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
{
vUsartSendByte(xUsartId, pcString[i]); // <20><>String<6E>ַ<EFBFBD><D6B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>SendByte<74><65><EFBFBD><EFBFBD>
}
}
/**
* @brief <20><><EFBFBD>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9B3A4>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>͡<EFBFBD>
* @param *xUsartId ѡ<>񴮿ں<F1B4AEBF>
* @param *format <20>ַ<EFBFBD><D6B7><EFBFBD>
* @param ... <20>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
* @retval None
*/
void vUsartPrintf(USART_TypeDef *xUsartId, char *format, ...)
{
char cBuffer[100];
va_list arg; // arg<72>Ƕ<EFBFBD><C7B6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
va_start(arg, format); // <20><>formatλ<74>ÿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg<72><67><EFBFBD><EFBFBD>
vsprintf(cBuffer, format, arg); // <20><>װ<EFBFBD><D7B0>ʽҪ<CABD><D2AA>vsprintf<74><66><EFBFBD><EFBFBD>Ϊsprintfֻ<66>ܽ<EFBFBD><DCBD><EFBFBD>ֱ<EFBFBD><D6B1>д<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>format<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg<72><67>
va_end(arg); // <20>ͷŲ<CDB7><C5B2><EFBFBD><EFBFBD><EFBFBD>
char *p = cBuffer;
if (xUsartId == USART1)
{
/* code */
while (*p)
{
/* code */
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); // <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
USART_SendData(USART1, *p++);
}
} else if (xUsartId == USART2)
{
/* code */
while (*p)
{
/* code */
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
USART_SendData(USART2, *p++);
}
} else if (xUsartId == USART3)
{
/* code */
while (*p)
{
/* code */
while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET);
USART_SendData(USART3, *p++);
}
}
}
/**
* @brief <20><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD>жϷ<D0B6><CFB7>͵<EFBFBD>ÿ֡<C3BF><D6A1><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @param None
* @retval None
*/
void USART1_IRQHandler(void)
{
if (USART_GetITStatus(USART1, USART_IT_RXNE) == SET)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART1);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
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)
#endif
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}
}
/**
* @brief <20><><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD>жϷ<D0B6><CFB7>͵<EFBFBD>ÿ֡<C3BF><D6A1><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @param None
* @retval None
*/
void USART2_IRQHandler(void)
{
if (USART_GetITStatus(USART2, USART_IT_RXNE) == SET)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART2);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
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)
#endif
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
}
}
/**
* @brief <20><><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD><EFBFBD>жϴ<D0B6><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD>жϷ<D0B6><CFB7>͵<EFBFBD>ÿ֡<C3BF><D6A1><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @param None
* @retval None
*/
void USART3_IRQHandler(void)
{
if (USART_GetITStatus(USART3, USART_IT_RXNE) == SET)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART3);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
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)
#endif
USART_ClearITPendingBit(USART3, USART_IT_RXNE);
}
}

View File

@@ -0,0 +1,43 @@
#ifndef __USART_H__
#define __USART_H__
#define USE_NONE_SYSTEM 0
#define USE_FREERTOS 1
#define USE_OSAL 0
#define vUsart1IrqHandler USART1_IRQHandler
#define vEsp8266IrqHandler USART2_IRQHandler
#define vLoRaIrqHandler USART3_IRQHandler
#define USART1_GPIO_PIN_TX GPIO_Pin_9
#define USART1_GPIO_PIN_RX GPIO_Pin_10
#define USART2_GPIO_PIN_TX GPIO_Pin_2
#define USART2_GPIO_PIN_RX GPIO_Pin_3
#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)
#include "FreeRTOS.h"
#include "queue.h"
#elif (USE_OSAL == 1)
#endif
#include "stm32f10x.h" // Device header
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
extern QueueHandle_t xQueueUsart1IrqHdlr;
extern QueueHandle_t xQueueUsart2IrqHdlr;
extern QueueHandle_t xQueueUsart3IrqHdlr;
#elif (USE_OSAL == 1)
#endif
void vUsartInit(USART_TypeDef *xUsartId, uint32_t ulBaudrate);
void vUsartSendByte(USART_TypeDef *xUsartId, uint8_t ucByte);
void vUsartSendArray(USART_TypeDef *xUsartId, uint8_t *pucArray, uint16_t usLength);
void vUsartSendString(USART_TypeDef *xUsartId, char *pcString);
void vUsartPrintf(USART_TypeDef *xUsartId, char *format, ...);
#endif

View File

@@ -0,0 +1,132 @@
#include "USART2.h"
/**
* @brief <20><><EFBFBD><EFBFBD>2<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ʹ<><CAB9>USART2<54><32><EFBFBD>ڣ<EFBFBD>PB10->LoRa_RX<52><58>PB11->LoRa_TX<54><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ115200<30><30>
* @param ulUsart2Baudrate
* @retval None
*/
void vUsart2Init(uint32_t ulUsart2Baudrate)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,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_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART2_GPIO_PIN_RX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = ulUsart2Baudrate; // <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>
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
USART_InitStructure.USART_Mode = USART_Mode_Tx|USART_Mode_Rx; // <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>ͽ<EFBFBD><CDBD><EFBFBD>ģʽ
USART_InitStructure.USART_Parity = USART_Parity_No; // <20><>У<EFBFBD><D0A3>λ
USART_InitStructure.USART_StopBits = USART_StopBits_1; // һλֹͣλ
USART_InitStructure.USART_WordLength = USART_WordLength_8b; // <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪУ<D2AA><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>ѡ<EFBFBD><D1A1>
USART_Init(USART2,&USART_InitStructure);
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4>ڵIJ<DAB5>ѯģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>NVIC
USART_ITConfig(USART2,USART_IT_RXNE,ENABLE); // ѡ<><D1A1>RXNE<4E><45><EFBFBD>ж<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>1<EFBFBD><31><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // <20><><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD>4Ϊ4bit<69><74>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0bit<69><74>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0-15<31><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FreeRTOSû<53><C3BB><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><E0B5B1><34><CEBB>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><30><CEBB>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
NVIC_InitTypeDef NVIC_InitStructure; // <20><>ʼ<EFBFBD><CABC>NVIC<49><43>USART1ͨ<31><CDA8>
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; // <20>ж<EFBFBD>ͨ<EFBFBD><CDA8>
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; // <20><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>FreeRTOS<4F><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ڷ<EFBFBD>Χ<EFBFBD>ڿ<EFBFBD><DABF>Ե<EFBFBD><D4B5><EFBFBD>FreeRTOS<4F><53><EFBFBD>ԡ<EFBFBD>FromISR()<29><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>api<70><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
NVIC_Init(&NVIC_InitStructure); // ָ<><D6B8>NVIC_InitStructure<72>ĵ<EFBFBD>ַ
USART_Cmd(USART2,ENABLE);
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ֽں<D6BD><DABA><EFBFBD>
* @note <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF>Դ<EFBFBD>TX<54><58><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @param ucByte
* @retval None
*/
void vUsart2SendByte(uint8_t ucByte)
{
USART_SendData(USART2, ucByte); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Byte<74><65>д<EFBFBD><D0B4>TDR<44>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
// д<><D0B4>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD>TDR<44><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>TDR<44>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݾͻ<DDBE><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>ǣ<EFBFBD><C7A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD>±<EFBFBD>־λ
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD><EFBFBD>ձ<EFBFBD>־λ<D6BE><CEBB><EFBFBD>ȴ<EFBFBD>TXE<58><45>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>һ<EFBFBD><D2BB>whileѭ<65><D1AD> TXE:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD><EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ<D6BE>Զ<EFBFBD><D4B6><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB>
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
* @note һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16<31><36><EFBFBD><EFBFBD>ģʽ<C4A3>¡<EFBFBD>
* @note uint8_t<5F><74>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><DEB7>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD>һ<EFBFBD><D2BB>Length<74><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param *pucArray<61><79>usLength
* @retval None
*/
void vUsart2SendArray(uint8_t *pucArray, uint16_t usLength)
{
for(uint16_t i = 0; i < usLength; i ++) // forѭ<72><D1AD>ִ<EFBFBD><D6B4>Length<74>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD>Զ<EFBFBD>Array<61><79><EFBFBD>ݽ<EFBFBD><DDBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鲻Ҫ<E9B2BB><D2AA><EFBFBD><EFBFBD>uint16_t<5F>ķ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>
{
vUsart2SendByte(pucArray[i]); // <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Array<61><79>ÿһ<C3BF><D2BB>
}
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9B3A4>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>͡<EFBFBD>
* @param *pcString
* @retval None
*/
void vUsart2SendString(char *pcString) // <20><>uint8_t *Ҳ<><D2B2><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Դ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>־λ<D6BE><CEBB><EFBFBD><EFBFBD><EFBFBD>ԾͲ<D4BE><CDB2><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD><EFBFBD>
{
for(uint8_t i = 0; pcString[i] != '\0'; i++) // ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>ñ<EFBFBD>־λ<D6BE><CEBB><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>,<2C><>'\0'<27>ǿ<EFBFBD><C7BF>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ʾ<EFBFBD><CABE>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>д0<D0B4><30>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
{
vUsart2SendByte(pcString[i]); // <20><>String<6E>ַ<EFBFBD><D6B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>SendByte<74><65><EFBFBD><EFBFBD>
}
}
/**
* @brief printf<74>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note fputc<74><63>printf<74><66><EFBFBD><EFBFBD><EFBFBD>ĵײ㣬printf<74><66><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>ӡ<EFBFBD><D3A1>ʱ<EFBFBD>򣬾<EFBFBD><F2A3ACBE>Dz<EFBFBD><C7B2>ϵ<EFBFBD><CFB5><EFBFBD>fputc<74><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1>
* @param ch,*f
* @retval ch
*/
int fputc(int ch, FILE *f)
{
vUsart2SendByte(ch);
return ch;
}
/**
* @brief printf<74><66>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
* @note <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>տɱ<D5BF><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
* @param *format,...
* @retval None
*/
void vUsart2Printf(char *format, ...)
{
char String[100];
va_list arg; // arg<72>Ƕ<EFBFBD><C7B6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
va_start(arg, format); // <20><>formatλ<74>ÿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg<72><67><EFBFBD><EFBFBD>
vsprintf(String, format, arg); // <20><>װ<EFBFBD><D7B0>ʽҪ<CABD><D2AA>vsprintf<74><66><EFBFBD><EFBFBD>Ϊsprintfֻ<66>ܽ<EFBFBD><DCBD><EFBFBD>ֱ<EFBFBD><D6B1>д<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>format<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg<72><67>
va_end(arg); // <20>ͷŲ<CDB7><C5B2><EFBFBD><EFBFBD><EFBFBD>
vUsart2SendString(String);
}
void USART2_IRQHandler(void)
{
if (USART_GetITStatus(USART2, USART_IT_RXNE) == SET)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART2);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
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)
#endif
USART_ClearITPendingBit(USART2, USART_IT_RXNE);
}
}

View File

@@ -0,0 +1,35 @@
#ifndef __USART2_H__
#define __USART2_H__
#define USE_NONE_SYSTEM 0
#define USE_FREERTOS 1
#define USE_OSAL 0
#define vEsp8266IrqHandler USART2_IRQHandler
#define USART2_GPIO_PIN_TX GPIO_Pin_2
#define USART2_GPIO_PIN_RX GPIO_Pin_3
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#include "FreeRTOS.h"
#include "queue.h"
#elif (USE_OSAL == 1)
#endif
#include "stm32f10x.h" // Device header
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
extern QueueHandle_t xQueueUsart2IrqHdlr;
#elif (USE_OSAL == 1)
#endif
void vUsart2Init(uint32_t ulUsart2Baudrate);
void vUsart2SendByte(uint8_t ucByte);
void vUsart2SendArray(uint8_t *pucArray, uint16_t usLength);
void vUsart2SendString(char *pcString);
void vUsart2Printf(char *format, ...);
#endif

View File

@@ -0,0 +1,142 @@
#include "USART3.h"
/**
* @brief <20><><EFBFBD><EFBFBD>3<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note ʹ<><CAB9>USART3<54><33><EFBFBD>ڣ<EFBFBD>PB10->LoRa_RX<52><58>PB11->LoRa_TX<54><58><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ115200<30><30>
* @param ulUsart3Baudrate
* @retval None
*/
void vUsart3Init(uint32_t ulUsart3Baudrate)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,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_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART3_GPIO_PIN_RX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate = ulUsart3Baudrate; // <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>
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // Ӳ<><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
USART_InitStructure.USART_Mode = USART_Mode_Tx|USART_Mode_Rx; // <20><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3>ͽ<EFBFBD><CDBD><EFBFBD>ģʽ
USART_InitStructure.USART_Parity = USART_Parity_No; // <20><>У<EFBFBD><D0A3>λ
USART_InitStructure.USART_StopBits = USART_StopBits_1; // һλֹͣλ
USART_InitStructure.USART_WordLength = USART_WordLength_8b; // <20>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҪУ<D2AA><EFBFBD>ֳ<EFBFBD><D6B3><EFBFBD>ѡ<EFBFBD><D1A1>
USART_Init(USART3,&USART_InitStructure);
// <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4>ڵIJ<DAB5>ѯģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD>NVIC
USART_ITConfig(USART3,USART_IT_RXNE,ENABLE); // ѡ<><D1A1>RXNE<4E><45><EFBFBD>ж<EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RXNE<4E><45>־λ<D6BE><CEBB>1<EFBFBD><31><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>NVIC<49><43><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϺ<D0B6><CFBA><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // <20><><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD>4Ϊ4bit<69><74>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>0bit<69><74>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0-15<31><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>FreeRTOSû<53><C3BB><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD>4<EFBFBD><EFBFBD><E0B5B1><34><CEBB>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><30><CEBB>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>
NVIC_InitTypeDef NVIC_InitStructure; // <20><>ʼ<EFBFBD><CABC>NVIC<49><43>USART1ͨ<31><CDA8>
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; // <20>ж<EFBFBD>ͨ<EFBFBD><CDA8>
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 5; // <20><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>FreeRTOS<4F><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ڷ<EFBFBD>Χ<EFBFBD>ڿ<EFBFBD><DABF>Ե<EFBFBD><D4B5><EFBFBD>FreeRTOS<4F><53><EFBFBD>ԡ<EFBFBD>FromISR()<29><><EFBFBD><EFBFBD>β<EFBFBD><CEB2>api<70><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; // <20><>Ӧ<EFBFBD><D3A6><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ã<EFBFBD><C3A3>ò<EFBFBD><C3B2><EFBFBD><EFBFBD><EFBFBD>
NVIC_Init(&NVIC_InitStructure); // ָ<><D6B8>NVIC_InitStructure<72>ĵ<EFBFBD>ַ
USART_Cmd(USART3,ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART3_GPIO_PIN_ATK_MD0;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = USART3_GPIO_PIN_ATK_AUX;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7>͵<EFBFBD><CDB5><EFBFBD><EFBFBD>ֽں<D6BD><DABA><EFBFBD>
* @note <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF>Դ<EFBFBD>TX<54><58><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD><EFBFBD>ݡ<EFBFBD>
* @param ucByte
* @retval None
*/
void vUsart3SendByte(uint8_t ucByte)
{
USART_SendData(USART3, ucByte); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Byte<74><65>д<EFBFBD><D0B4>TDR<44>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>
// д<><D0B4>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD>TDR<44><52><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>λ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>TDR<44>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ݾͻ<DDBE><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><DDB8>ǣ<EFBFBD><C7A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ȴ<EFBFBD>һ<EFBFBD>±<EFBFBD>־λ
while(USART_GetFlagStatus(USART3, USART_FLAG_TXE) == RESET); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD><EFBFBD>ձ<EFBFBD>־λ<D6BE><CEBB><EFBFBD>ȴ<EFBFBD>TXE<58><45>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>һ<EFBFBD><D2BB>whileѭ<65><D1AD> TXE:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<DDBC><C4B4><EFBFBD><EFBFBD>գ<EFBFBD><D5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ<D6BE>Զ<EFBFBD><D4B6><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB>
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF>
* @note һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>16<31><36><EFBFBD><EFBFBD>ģʽ<C4A3>¡<EFBFBD>
* @note uint8_t<5F><74>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׵<EFBFBD>ַ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޷<EFBFBD><DEB7>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4><EFBFBD>һ<EFBFBD><D2BB>Length<74><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param *pucArray<61><79>usLength
* @retval None
*/
void vUsart3SendArray(uint8_t *pucArray, uint16_t usLength)
{
for(uint16_t i = 0; i < usLength; i ++) // forѭ<72><D1AD>ִ<EFBFBD><D6B4>Length<74>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD>Զ<EFBFBD>Array<61><79><EFBFBD>ݽ<EFBFBD><DDBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>鲻Ҫ<E9B2BB><D2AA><EFBFBD><EFBFBD>uint16_t<5F>ķ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD>
{
vUsart3SendByte(pucArray[i]); // <20><><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Array<61><79>ÿһ<C3BF><D2BB>
}
}
/**
* @brief <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @note <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><D7B0>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9B3A4>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9><CEB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2>ɴ<EFBFBD><C9B4><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>͡<EFBFBD>
* @param *pcString
* @retval None
*/
void vUsart3SendString(char *pcString) // <20><>uint8_t *Ҳ<><D2B2><EFBFBD>ԣ<EFBFBD><D4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Դ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>־λ<D6BE><CEBB><EFBFBD><EFBFBD><EFBFBD>ԾͲ<D4BE><CDB2><EFBFBD>Ҫ<EFBFBD>ٴ<EFBFBD><D9B4>ݳ<EFBFBD><DDB3>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD><EFBFBD>
{
for(uint8_t i = 0; pcString[i] != '\0'; i++) // ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϳ<EFBFBD><CDBF><EFBFBD><EFBFBD>ñ<EFBFBD>־λ<D6BE><CEBB><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>,<2C><>'\0'<27>ǿ<EFBFBD><C7BF>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ʾ<EFBFBD><CABE>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>д0<D0B4><30>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>
{
vUsart3SendByte(pcString[i]); // <20><>String<6E>ַ<EFBFBD><D6B7><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>SendByte<74><65><EFBFBD><EFBFBD>
}
}
///**
// * @brief printf<74>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// * @note fputc<74><63>printf<74><66><EFBFBD><EFBFBD><EFBFBD>ĵײ㣬printf<74><66><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>ӡ<EFBFBD><D3A1>ʱ<EFBFBD>򣬾<EFBFBD><F2A3ACBE>Dz<EFBFBD><C7B2>ϵ<EFBFBD><CFB5><EFBFBD>fputc<74><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1>
// * @param ch,*f
// * @retval ch
// */
//int fputc(int ch, FILE *f)
//{
// vUsart3SendByte(ch);
// return ch;
//}
///**
// * @brief printf<74><66>װ<EFBFBD><D7B0><EFBFBD><EFBFBD>
// * @note <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD>ǽ<EFBFBD><C7BD>տɱ<D5BF><C9B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD>
// * @param *format,...
// * @retval None
// */
//void vUsart3Printf(char *format, ...)
//{
// char String[100];
// va_list arg; // arg<72>Ƕ<EFBFBD><C7B6><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
// va_start(arg, format); // <20><>formatλ<74>ÿ<EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ղ<EFBFBD><D5B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg<72><67><EFBFBD><EFBFBD>
// vsprintf(String, format, arg); // <20><>װ<EFBFBD><D7B0>ʽҪ<CABD><D2AA>vsprintf<74><66><EFBFBD><EFBFBD>Ϊsprintfֻ<66>ܽ<EFBFBD><DCBD><EFBFBD>ֱ<EFBFBD><D6B1>д<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>format<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>arg<72><67>
// va_end(arg); // <20>ͷŲ<CDB7><C5B2><EFBFBD><EFBFBD><EFBFBD>
// vUsart3SendString(String);
//}
void USART3_IRQHandler(void)
{
if (USART_GetITStatus(USART3, USART_IT_RXNE) == SET)
{
/* code */
uint8_t ulRxData = (uint8_t)USART_ReceiveData(USART3);
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
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)
#endif
USART_ClearITPendingBit(USART3, USART_IT_RXNE);
}
}

View File

@@ -0,0 +1,37 @@
#ifndef __USART3_H__
#define __USART3_H__
#define USE_NONE_SYSTEM 0
#define USE_FREERTOS 1
#define USE_OSAL 0
#define vLoRaIrqHandler USART3_IRQHandler
#define USART3_GPIO_PIN_TX GPIO_Pin_10
#define USART3_GPIO_PIN_RX GPIO_Pin_11
#define USART3_GPIO_PIN_ATK_AUX GPIO_Pin_4 // PA4
#define USART3_GPIO_PIN_ATK_MD0 GPIO_Pin_3 // PB3
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
#include "FreeRTOS.h"
#include "queue.h"
#elif (USE_OSAL == 1)
#endif
#include "stm32f10x.h" // Device header
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#if (USE_NONE_SYSTEM == 1)
#elif (USE_FREERTOS == 1)
extern QueueHandle_t xQueueUsart3IrqHdlr;
#elif (USE_OSAL == 1)
#endif
void vUsart3Init(uint32_t ulUsart3Baudrate);
void vUsart3SendByte(uint8_t ucByte);
void vUsart3SendArray(uint8_t *pucArray, uint16_t usLength);
void vUsart3SendString(char *pcString);
void vUsart3Printf(char *format, ...);
#endif

View File

@@ -1,25 +1,110 @@
#include "stm32f10x.h" // Device header
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "Delay.h"
#include "USART.h"
#include "LED.h"
/* <20><><EFBFBD><EFBFBD>֤<EFBFBD>ĸĶ<C4B8><C4B6><EFBFBD><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD>ڡ<EFBFBD> */
/* <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һһ<D2BB><D2BB>Ӧ<EFBFBD><D3A6> */
TaskHandle_t xSampleTaskHandler;
TaskHandle_t xTaskStateLedHdlr;
TaskHandle_t xTaskWifiConnectHdlr;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>о<EFBFBD><D0BE><EFBFBD> */
QueueHandle_t xQueueUsart1IrqHdlr;
QueueHandle_t xQueueUsart2IrqHdlr;
QueueHandle_t xQueueUsart3IrqHdlr;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ź<EFBFBD><C5BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
SemaphoreHandle_t xSemWifiRetOkHdlr;
SemaphoreHandle_t xSemWifiRetErrHdlr;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
void vSampleTask(void *pvParameters)
void vTaskStateLed(void *pvParameters)
{
while(1)
{
while(1)
{
vPc13LedOn();
vTaskDelay(1000);
vUsartPrintf(USART3, "USART3 Printf Test\r%d\n", 123);
vPc13LedOff();
vTaskDelay(1000);
}
}
}
void vTaskWifiConnection(void *pvParameters)
{
uint8_t ucRetvalQueueWifiSt = 0;
uint8_t ucBufferQueueRec = 0;
while (1)
{
vUsartSendString(USART2, "AT\r\n");
vTaskDelay(1000);
ucRetvalQueueWifiSt = xQueueReceive(xQueueUsart2IrqHdlr, &ucBufferQueueRec, pdMS_TO_TICKS(30));
/* code */
if (ucRetvalQueueWifiSt == pdTRUE)
{
/* code */
vUsartSendString(USART3, (char *)&ucBufferQueueRec);
} else
{
vUsartSendString(USART3, "Queue Receive failed!\r\n");
vTaskDelay(300);
}
}
}
void vCreateTasksList(void)
{
xTaskCreate(
(TaskFunction_t ) vTaskStateLed,
(char * ) "TaskName_StateLed",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskStateLedHdlr);
xTaskCreate(
(TaskFunction_t ) vTaskWifiConnection,
(char * ) "TaskName_WifiConnectToAP",
(configSTACK_DEPTH_TYPE) 512,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xTaskWifiConnectHdlr);
}
void vCreateQueuesList(void)
{
xQueueUsart1IrqHdlr = xQueueCreate(
(UBaseType_t) 64,
(UBaseType_t) sizeof(uint8_t *));
xQueueUsart2IrqHdlr = xQueueCreate(
(UBaseType_t) 64,
(UBaseType_t) sizeof(uint8_t *));
xQueueUsart3IrqHdlr = xQueueCreate(
(UBaseType_t) 64,
(UBaseType_t) sizeof(uint8_t *));
}
void vCreateSemaphoresList(void)
{
xSemWifiRetOkHdlr = xSemaphoreCreateBinary();
xSemWifiRetErrHdlr = xSemaphoreCreateBinary();
}
int main(void)
{
xTaskCreate(vSampleTask, "SampleTask", 128, NULL, 2, &xSampleTaskHandler);
vTaskStartScheduler();
while(1)
{
vUsartInit(USART1, 115200);
vUsartInit(USART2, 115200);
vDelayInit();
vPc13LedInit();
vCreateTasksList();
vCreateQueuesList();
vCreateSemaphoresList();
vTaskStartScheduler();
while(1)
{
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -8,18 +8,41 @@ TaskHandle_t xSampleTaskHandler;
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
void vSampleTask(void *pvParameters)
{
while(1)
{
while(1)
{
}
}
void vCreateTasksList(void)
{
xTaskCreate(
(TaskFunction_t ) vSampleTask,
(char * ) "TaskName_SampleTask",
(configSTACK_DEPTH_TYPE) 256,
(void * ) NULL,
(UBaseType_t ) 2,
(TaskHandle_t * ) &xSampleTaskHandler);
}
void vCreateQueuesList(void)
{
}
void vCreateSemaphoresList(void)
{
}
}
int main(void)
{
xTaskCreate(vSampleTask, "SampleTask", 128, NULL, 2, &xSampleTaskHandler);
vTaskStartScheduler();
while(1)
{
vCreateTasksList();
vCreateQueuesList();
vCreateSemaphoresList();
vTaskStartScheduler();
while(1)
{
}
}
}