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>
</component>
<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$/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/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/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" />
</list>
<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" />
</component>
<component name="ProjectApplicationVersion">
<option name="ide" value="CLion" />
@ -220,32 +219,32 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;CMake Application.IntelliChargingPile.elf.executor&quot;: &quot;Run&quot;,
&quot;OpenOCD Download &amp; Run.IntelliChargingPile.elf.executor&quot;: &quot;Run&quot;,
&quot;OpenOCD Download &amp; Run.OCD IntelliChargingPile.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.RadMigrateCodeStyle&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.readMode.enableVisualFormatting&quot;: &quot;true&quot;,
&quot;RunOnceActivity.west.config.association.type.startup.service&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;last_opened_file_path&quot;: &quot;/Users/timothy/Workbench/embedded/project/IntelliChargingPile/Core/Src&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;CMakeSettings&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"CMake Application.IntelliChargingPile.elf.executor": "Run",
"OpenOCD Download & Run.IntelliChargingPile.elf.executor": "Run",
"OpenOCD Download & Run.OCD IntelliChargingPile.executor": "Run",
"RunOnceActivity.RadMigrateCodeStyle": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"RunOnceActivity.west.config.association.type.startup.service": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"git-widget-placeholder": "main",
"last_opened_file_path": "/Users/timothy/Workbench/embedded/project/IntelliChargingPile/Core/Src",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.lookFeel",
"vue.rearranger.settings.migration": "true"
}
}</component>
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/Core/Src" />
@ -306,7 +305,7 @@
<workItem from="1743488783461" duration="3691000" />
<workItem from="1743492489952" duration="8816000" />
<workItem from="1743525779889" duration="15870000" />
<workItem from="1746680992201" duration="17379000" />
<workItem from="1746680992201" duration="23593000" />
</task>
<task id="LOCAL-00001" summary="initial commit: oled, rc522, exti">
<option name="closed" value="true" />
@ -380,7 +379,23 @@
<option name="project" value="LOCAL" />
<updated>1743531723695</updated>
</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 />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -400,26 +415,29 @@
<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="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 name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
<url>file://$PROJECT_DIR$/Core/Src/OneNet.c</url>
<line>199</line>
<line>195</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<watches-manager>
<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="IM_RxBuf" language="C++" />
<watch expression="IM_TxBuf" language="C++" />
<watch expression="new_crc" />
</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" />
</inline-watch>
<inline-watch fileUrl="file://$PROJECT_DIR$/Core/Src/IM1281B.c" line="87">

View File

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

View File

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

View File

@ -57,6 +57,13 @@
/* USER CODE BEGIN PV */
extern unsigned short esp8266_cnt;
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 UART2_RxData;
@ -292,7 +299,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
memcpy(IM_RxBuf, UART1_RxData, Size);
IM_RecvLen = Size;
IM_RecvDone = 1;
IM_Analyze();
// IM_Analyze();
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)
{
/* USER CODE BEGIN Callback 0 */
// if(htim->Instance == TIM1){
// KeyScan();
// }
// if (htim->Instance == TIM3)
// if(htim->Instance == TIM1)
// {
// if (ONENET_CONNECTED)
// {
// dataPtr = ESP8266_GetIPD(0);
// if (dataPtr != NULL)
// {
// OneNet_RevPro(dataPtr);
// 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;
// }
//
// static uint8_t cnt_5s = 0;
// if(++cnt_5s >= 5) {
// cnt_5s = 0;
// flag_5s = 1;
// }
// }
// }
@ -342,7 +355,27 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
HAL_IncTick();
}
/* 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 */
}

View File

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

View File

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