dev: 暂时禁用指令下发处理

This commit is contained in:
Timothy Yin 2025-05-08 21:20:18 +08:00
parent 41ccefb980
commit d96b2070f2
6 changed files with 163 additions and 76 deletions

88
.idea/workspace.xml generated
View File

@ -29,15 +29,12 @@
</configurations> </configurations>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="56631632-52f0-4e39-b905-89e46eb6e768" name="Changes" comment="break: before freertos"> <list default="true" id="56631632-52f0-4e39-b905-89e46eb6e768" name="Changes" comment="chore: update .gitignore">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/FreeRTOSConfig.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/FreeRTOSConfig.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/esp8266.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/esp8266.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Inc/main.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/main.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Core/Inc/main.h" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Inc/main.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/OneNet.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/OneNet.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/esp8266.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/esp8266.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/freertos.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/freertos.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Core/Src/freertos.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/freertos.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/main.c" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Core/Src/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/main.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Core/Src/tim.c" beforeDir="false" afterPath="$PROJECT_DIR$/Core/Src/tim.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IntelliChargingPile.ioc" beforeDir="false" afterPath="$PROJECT_DIR$/IntelliChargingPile.ioc" afterDir="false" /> <change beforePath="$PROJECT_DIR$/IntelliChargingPile.ioc" beforeDir="false" afterPath="$PROJECT_DIR$/IntelliChargingPile.ioc" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -202,6 +199,8 @@
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" /> <setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
</component> </component>
<component name="ProjectApplicationVersion"> <component name="ProjectApplicationVersion">
<option name="ide" value="CLion" /> <option name="ide" value="CLion" />
@ -220,32 +219,32 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;, "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
&quot;CMake Application.IntelliChargingPile.elf.executor&quot;: &quot;Run&quot;, "CMake Application.IntelliChargingPile.elf.executor": "Run",
&quot;OpenOCD Download &amp; Run.IntelliChargingPile.elf.executor&quot;: &quot;Run&quot;, "OpenOCD Download & Run.IntelliChargingPile.elf.executor": "Run",
&quot;OpenOCD Download &amp; Run.OCD IntelliChargingPile.executor&quot;: &quot;Run&quot;, "OpenOCD Download & Run.OCD IntelliChargingPile.executor": "Run",
&quot;RunOnceActivity.RadMigrateCodeStyle&quot;: &quot;true&quot;, "RunOnceActivity.RadMigrateCodeStyle": "true",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;, "RunOnceActivity.cidr.known.project.marker": "true",
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;, "RunOnceActivity.git.unshallow": "true",
&quot;RunOnceActivity.readMode.enableVisualFormatting&quot;: &quot;true&quot;, "RunOnceActivity.readMode.enableVisualFormatting": "true",
&quot;RunOnceActivity.west.config.association.type.startup.service&quot;: &quot;true&quot;, "RunOnceActivity.west.config.association.type.startup.service": "true",
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;, "SHARE_PROJECT_CONFIGURATION_FILES": "true",
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;, "cf.first.check.clang-format": "false",
&quot;cidr.known.project.marker&quot;: &quot;true&quot;, "cidr.known.project.marker": "true",
&quot;git-widget-placeholder&quot;: &quot;main&quot;, "git-widget-placeholder": "main",
&quot;last_opened_file_path&quot;: &quot;/Users/timothy/Workbench/embedded/project/IntelliChargingPile/Core/Src&quot;, "last_opened_file_path": "/Users/timothy/Workbench/embedded/project/IntelliChargingPile/Core/Src",
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, "node.js.detected.package.eslint": "true",
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, "node.js.detected.package.tslint": "true",
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, "node.js.selected.package.eslint": "(autodetect)",
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, "node.js.selected.package.tslint": "(autodetect)",
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, "nodejs_package_manager_path": "npm",
&quot;settings.editor.selected.configurable&quot;: &quot;CMakeSettings&quot;, "settings.editor.selected.configurable": "preferences.lookFeel",
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; "vue.rearranger.settings.migration": "true"
} }
}</component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/Core/Src" /> <recent name="$PROJECT_DIR$/Core/Src" />
@ -306,7 +305,7 @@
<workItem from="1743488783461" duration="3691000" /> <workItem from="1743488783461" duration="3691000" />
<workItem from="1743492489952" duration="8816000" /> <workItem from="1743492489952" duration="8816000" />
<workItem from="1743525779889" duration="15870000" /> <workItem from="1743525779889" duration="15870000" />
<workItem from="1746680992201" duration="17379000" /> <workItem from="1746680992201" duration="23593000" />
</task> </task>
<task id="LOCAL-00001" summary="initial commit: oled, rc522, exti"> <task id="LOCAL-00001" summary="initial commit: oled, rc522, exti">
<option name="closed" value="true" /> <option name="closed" value="true" />
@ -380,7 +379,23 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1743531723695</updated> <updated>1743531723695</updated>
</task> </task>
<option name="localTasksCounter" value="10" /> <task id="LOCAL-00010" summary="feat: before tring to fix cmdHandler">
<option name="closed" value="true" />
<created>1746704030956</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1746704030956</updated>
</task>
<task id="LOCAL-00011" summary="chore: update .gitignore">
<option name="closed" value="true" />
<created>1746705282234</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1746705282234</updated>
</task>
<option name="localTasksCounter" value="12" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -400,26 +415,29 @@
<MESSAGE value="feat: implement OneNet communication and ESP8266 integration&#10;break: switch to c8t6" /> <MESSAGE value="feat: implement OneNet communication and ESP8266 integration&#10;break: switch to c8t6" />
<MESSAGE value="feat: update USART1 baud rate and implement IM1281B communication" /> <MESSAGE value="feat: update USART1 baud rate and implement IM1281B communication" />
<MESSAGE value="break: before freertos" /> <MESSAGE value="break: before freertos" />
<option name="LAST_COMMIT_MESSAGE" value="break: before freertos" /> <MESSAGE value="feat: before tring to fix cmdHandler" />
<MESSAGE value="chore: update .gitignore" />
<option name="LAST_COMMIT_MESSAGE" value="chore: update .gitignore" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType"> <line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Core/Src/OneNet.c</url> <url>file://$PROJECT_DIR$/Core/Src/OneNet.c</url>
<line>199</line> <line>195</line>
<option name="timeStamp" value="3" /> <option name="timeStamp" value="3" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
<watches-manager> <watches-manager>
<configuration name="com.jetbrains.cidr.embedded.openocd.conf.type"> <configuration name="com.jetbrains.cidr.embedded.openocd.conf.type">
<watch expression="(float) uwTick/1000.0f" language="C++" />
<watch expression="new_crc.word16" language="C++" /> <watch expression="new_crc.word16" language="C++" />
<watch expression="IM_RxBuf" language="C++" /> <watch expression="IM_RxBuf" language="C++" />
<watch expression="IM_TxBuf" language="C++" /> <watch expression="IM_TxBuf" language="C++" />
<watch expression="new_crc" /> <watch expression="new_crc" />
</configuration> </configuration>
<inline-watch fileUrl="file://$PROJECT_DIR$/Core/Src/main.c" line="307"> <inline-watch fileUrl="file://$PROJECT_DIR$/Core/Src/main.c" line="314">
<watch expression="@ ALREADY PREPROCESSED @UART2_RxData" /> <watch expression="@ ALREADY PREPROCESSED @UART2_RxData" />
</inline-watch> </inline-watch>
<inline-watch fileUrl="file://$PROJECT_DIR$/Core/Src/IM1281B.c" line="87"> <inline-watch fileUrl="file://$PROJECT_DIR$/Core/Src/IM1281B.c" line="87">

View File

@ -36,7 +36,10 @@ extern "C" {
/* Exported types ------------------------------------------------------------*/ /* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */ /* USER CODE BEGIN ET */
extern char flag_1s;
extern char flag_2s;
extern char flag_5s;
extern char flag_10s;
/* USER CODE END ET */ /* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/

View File

@ -33,6 +33,7 @@
#include "stm32f1xx_hal.h" #include "stm32f1xx_hal.h"
#include <string.h> #include <string.h>
#include "retarget.h" #include "retarget.h"
#include "tim.h"
#include "timers.h" #include "timers.h"
/* USER CODE END Includes */ /* USER CODE END Includes */
@ -57,6 +58,9 @@
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */ /* USER CODE BEGIN Variables */
char ONENET_CONNECTED = 0; char ONENET_CONNECTED = 0;
// Flags
char KEY_PRESSED[4] = {0, 0, 0, 0};
/* USER CODE END Variables */ /* USER CODE END Variables */
/* Definitions for defaultTask */ /* Definitions for defaultTask */
osThreadId_t defaultTaskHandle; osThreadId_t defaultTaskHandle;
@ -114,6 +118,8 @@ void MX_FREERTOS_Init(void) {
OLED_ShowString(0,0,"OneNet online ",12); OLED_ShowString(0,0,"OneNet online ",12);
HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LED0_GPIO_Port, LED0_Pin, GPIO_PIN_RESET);
HAL_TIM_Base_Start_IT(&htim1);
/* USER CODE END Init */ /* USER CODE END Init */
/* USER CODE BEGIN RTOS_MUTEX */ /* USER CODE BEGIN RTOS_MUTEX */
@ -165,17 +171,48 @@ void StartDefaultTask(void *argument)
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
IM_ReadFlag = 1; //抄读标志
IM_Read();
osDelay(500); // osDelay(500);
//
// OneNet_SendData();
// osDelay(500);
// ESP8266_Clear();
if (KEY_PRESSED[0] || KEY_PRESSED[1])
{
KEY_PRESSED[0] = 0;
KEY_PRESSED[1] = 0;
HAL_GPIO_TogglePin(RELAY1_GPIO_Port, RELAY1_Pin);
}
if (flag_1s)
{
flag_1s = 0;
IM_ReadFlag = 1;
}
if (flag_2s)
{
flag_2s = 0;
HAL_GPIO_TogglePin(LED0_GPIO_Port, LED0_Pin);
}
if (flag_5s)
{
flag_5s = 0;
OneNet_SendData(); OneNet_SendData();
osDelay(500);
ESP8266_Clear(); ESP8266_Clear();
}
if (IM_RecvDone)
{
IM_Analyze();
Display_IM1281B(); Display_IM1281B();
} }
IM_Read();
}
/* USER CODE END StartDefaultTask */ /* USER CODE END StartDefaultTask */
} }
@ -210,14 +247,14 @@ void startCmdTask(void *argument)
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
if (ONENET_CONNECTED) // if (ONENET_CONNECTED)
{ // {
uint8_t* dataPtr = ESP8266_GetIPD_soft(0); // uint8_t* dataPtr = ESP8266_GetIPD_soft(0);
if (dataPtr != NULL) // if (dataPtr != NULL)
{ // {
OneNet_RevPro(dataPtr); // OneNet_RevPro(dataPtr);
} // }
} // }
} }
/* USER CODE END startCmdTask */ /* USER CODE END startCmdTask */
} }
@ -228,41 +265,37 @@ void KeyScan(void)
{ {
if (K1 == GPIO_PIN_RESET) if (K1 == GPIO_PIN_RESET)
{ {
// HAL_Delay(5);
osDelay(5); osDelay(5);
if (K1 == GPIO_PIN_RESET) if (K1 == GPIO_PIN_RESET)
{ {
HAL_GPIO_TogglePin(RELAY1_GPIO_Port, RELAY1_Pin); KEY_PRESSED[0] = 1;
} }
while (K1 == GPIO_PIN_RESET); while (K1 == GPIO_PIN_RESET);
} }
if (K2 == GPIO_PIN_RESET) if (K2 == GPIO_PIN_RESET)
{ {
// HAL_Delay(5);
osDelay(5); osDelay(5);
if (K2 == GPIO_PIN_RESET) if (K2 == GPIO_PIN_RESET)
{ {
HAL_GPIO_TogglePin(RELAY1_GPIO_Port, RELAY1_Pin); KEY_PRESSED[1] = 1;
} }
while (K2 == GPIO_PIN_RESET); while (K2 == GPIO_PIN_RESET);
} }
if (K3 == GPIO_PIN_RESET) if (K3 == GPIO_PIN_RESET)
{ {
// HAL_Delay(5);
osDelay(5); osDelay(5);
if (K3 == GPIO_PIN_RESET) if (K3 == GPIO_PIN_RESET)
{ {
HAL_GPIO_TogglePin(RELAY1_GPIO_Port, RELAY1_Pin); KEY_PRESSED[2] = 1;
} }
while (K3 == GPIO_PIN_RESET); while (K3 == GPIO_PIN_RESET);
} }
if (K4 == GPIO_PIN_RESET) if (K4 == GPIO_PIN_RESET)
{ {
// HAL_Delay(5);
osDelay(5); osDelay(5);
if (K4 == GPIO_PIN_RESET) if (K4 == GPIO_PIN_RESET)
{ {
HAL_GPIO_TogglePin(RELAY1_GPIO_Port, RELAY1_Pin); KEY_PRESSED[3] = 1;
} }
while (K4 == GPIO_PIN_RESET); while (K4 == GPIO_PIN_RESET);
} }

View File

@ -57,6 +57,13 @@
/* USER CODE BEGIN PV */ /* USER CODE BEGIN PV */
extern unsigned short esp8266_cnt; extern unsigned short esp8266_cnt;
extern unsigned char esp8266_buf[128]; extern unsigned char esp8266_buf[128];
volatile uint32_t systick_1ms = 0;
char flag_1s = 0;
char flag_2s = 0;
char flag_5s = 0;
uint8_t* UART1_RxData[40]; uint8_t* UART1_RxData[40];
uint8_t UART2_RxData; uint8_t UART2_RxData;
@ -292,7 +299,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
memcpy(IM_RxBuf, UART1_RxData, Size); memcpy(IM_RxBuf, UART1_RxData, Size);
IM_RecvLen = Size; IM_RecvLen = Size;
IM_RecvDone = 1; IM_RecvDone = 1;
IM_Analyze(); // IM_Analyze();
HAL_UARTEx_ReceiveToIdle_IT(&huart1, (uint8_t*)UART1_RxData, 40); HAL_UARTEx_ReceiveToIdle_IT(&huart1, (uint8_t*)UART1_RxData, 40);
} }
} }
@ -322,17 +329,23 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{ {
/* USER CODE BEGIN Callback 0 */ /* USER CODE BEGIN Callback 0 */
// if(htim->Instance == TIM1){ // if(htim->Instance == TIM1)
// KeyScan(); // {
// systick_1ms++;
//
// if(systick_1ms % 1000 == 0) {
// flag_1s = 1;
//
// static uint8_t cnt_2s = 0;
// if(++cnt_2s >= 2) {
// cnt_2s = 0;
// flag_2s = 1;
// } // }
// if (htim->Instance == TIM3) //
// { // static uint8_t cnt_5s = 0;
// if (ONENET_CONNECTED) // if(++cnt_5s >= 5) {
// { // cnt_5s = 0;
// dataPtr = ESP8266_GetIPD(0); // flag_5s = 1;
// if (dataPtr != NULL)
// {
// OneNet_RevPro(dataPtr);
// } // }
// } // }
// } // }
@ -342,7 +355,27 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
HAL_IncTick(); HAL_IncTick();
} }
/* USER CODE BEGIN Callback 1 */ /* USER CODE BEGIN Callback 1 */
if (htim->Instance == TIM4)
{
if (uwTick % 1000 == 0)
{
flag_1s = 1;
static uint8_t cnt_2s = 0;
if (++cnt_2s >= 2)
{
cnt_2s = 0;
flag_2s = 1;
}
static uint8_t cnt_5s = 0;
if (++cnt_5s >= 5)
{
cnt_5s = 0;
flag_5s = 1;
}
}
}
/* USER CODE END Callback 1 */ /* USER CODE END Callback 1 */
} }

View File

@ -42,9 +42,9 @@ void MX_TIM1_Init(void)
/* USER CODE END TIM1_Init 1 */ /* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1; htim1.Instance = TIM1;
htim1.Init.Prescaler = 7199; htim1.Init.Prescaler = 71;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP; htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 99; htim1.Init.Period = 9999;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0; htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE; htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;

View File

@ -216,8 +216,8 @@ SPI1.Mode=SPI_MODE_MASTER
SPI1.VirtualType=VM_MASTER SPI1.VirtualType=VM_MASTER
TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM1.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM1.IPParameters=Prescaler,Period,AutoReloadPreload TIM1.IPParameters=Prescaler,Period,AutoReloadPreload
TIM1.Period=99 TIM1.Period=9999
TIM1.Prescaler=7199 TIM1.Prescaler=71
TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM3.IPParameters=Prescaler,Period,AutoReloadPreload TIM3.IPParameters=Prescaler,Period,AutoReloadPreload
TIM3.Period=59 TIM3.Period=59