按键功能备份

This commit is contained in:
王绪洁 2025-03-10 16:53:42 +08:00
parent b399ccf974
commit b23d90952a
6 changed files with 5837 additions and 5787 deletions

View File

@ -42,6 +42,7 @@
"communication_protocol.h": "c",
"user_gpio.h": "c",
"user_lib.h": "c",
"init.h": "c"
"init.h": "c",
"uart_lcd.h": "c"
}
}

View File

@ -67,24 +67,25 @@ osThreadId ec11_taskHandle;
extern float current_buff[2];
extern uint8_t tcp_echo_flags_control;
extern uint8_t send_data_flag_cmd;
int direction = 0;
int encode_num = 0;
ec11_t ec11_data = {0};
uint8_t di_state_last[DI_MAX] = {0};
uint8_t di_state_now[DI_MAX] = {0};
/* USER CODE END FunctionPrototypes */
void start_tcp_task(void const * argument);
void start_led_toggle_task(void const * argument);
void start_dac_task(void const * argument);
void start_adc_task(void const * argument);
void start_gpio_di_do_task(void const * argument);
void start_ec11_task(void const * argument);
void start_tcp_task(void const *argument);
void start_led_toggle_task(void const *argument);
void start_dac_task(void const *argument);
void start_adc_task(void const *argument);
void start_gpio_di_do_task(void const *argument);
void start_ec11_task(void const *argument);
extern void MX_LWIP_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
/* GetIdleTaskMemory prototype (linked to static allocation support) */
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize);
/* USER CODE BEGIN GET_IDLE_TASK_MEMORY */
static StaticTask_t xIdleTaskTCBBuffer;
@ -100,11 +101,12 @@ void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer, StackTyp
/* USER CODE END GET_IDLE_TASK_MEMORY */
/**
* @brief FreeRTOS initialization
* @param None
* @retval None
*/
void MX_FREERTOS_Init(void) {
* @brief FreeRTOS initialization
* @param None
* @retval None
*/
void MX_FREERTOS_Init(void)
{
/* USER CODE BEGIN Init */
/* USER CODE END Init */
@ -153,7 +155,6 @@ void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
}
/* USER CODE BEGIN Header_start_tcp_task */
@ -163,7 +164,7 @@ void MX_FREERTOS_Init(void) {
* @retval None
*/
/* USER CODE END Header_start_tcp_task */
void start_tcp_task(void const * argument)
void start_tcp_task(void const *argument)
{
/* init code for LWIP */
MX_LWIP_Init();
@ -185,14 +186,34 @@ void start_tcp_task(void const * argument)
* @retval None
*/
/* USER CODE END Header_start_led_toggle_task */
void start_led_toggle_task(void const * argument)
void start_led_toggle_task(void const *argument)
{
/* USER CODE BEGIN start_led_toggle_task */
/* Infinite loop */
for (;;)
{
HAL_GPIO_TogglePin(LED2_G_GPIO_Port, LED2_G_Pin);
vTaskDelay(500);
if (ec11_data.confirm_key_flag == 0)
{
HAL_GPIO_TogglePin(LED2_Y_GPIO_Port, LED2_Y_Pin);
}
else if (ec11_data.confirm_key_flag == 1)
{
ec11_data.confirm_key_flag_last++;
if (ec11_data.confirm_key_flag_last > 3)
{
HAL_GPIO_TogglePin(LED2_G_GPIO_Port, LED2_G_Pin);
ec11_data.confirm_key_flag_last = 0;
ec11_data.confirm_key_flag = 0;
}
}
else if (ec11_data.confirm_key_flag == 2)
{
ec11_data.confirm_key_flag_last = 0;
HAL_GPIO_TogglePin(LED2_R_GPIO_Port, LED2_R_Pin);
ec11_data.confirm_key_flag = 0;
}
vTaskDelay(1000);
}
/* USER CODE END start_led_toggle_task */
}
@ -204,7 +225,7 @@ void start_led_toggle_task(void const * argument)
* @retval None
*/
/* USER CODE END Header_start_dac_task */
void start_dac_task(void const * argument)
void start_dac_task(void const *argument)
{
/* USER CODE BEGIN start_dac_task */
dac161s997_init();
@ -227,7 +248,7 @@ void start_dac_task(void const * argument)
* @retval None
*/
/* USER CODE END Header_start_adc_task */
void start_adc_task(void const * argument)
void start_adc_task(void const *argument)
{
/* USER CODE BEGIN start_adc_task */
ad7124_setup();
@ -262,7 +283,7 @@ void start_adc_task(void const * argument)
* @retval None
*/
/* USER CODE END Header_start_gpio_di_do_task */
void start_gpio_di_do_task(void const * argument)
void start_gpio_di_do_task(void const *argument)
{
/* USER CODE BEGIN start_gpio_di_do_task */
/* Infinite loop */
@ -273,9 +294,9 @@ void start_gpio_di_do_task(void const * argument)
uint8_t tx_data_len = 7 + DI_MAX;
uint8_t tx_data[32] = {0};
tx_data[0] = FRAME_HEAD; // 帧头
tx_data[1] = COM_OK; // 状æ?<3F>ç <C3A7>
tx_data[2] = DEVICE_NUM; // 设备å<EFBFBD>?
tx_data[3] = SEND_STATE_CMD; // 命令å<EFBFBD>?
tx_data[1] = COM_OK; // <EFBFBD>?<3F>
tx_data[2] = DEVICE_NUM; // 设备<EFBFBD>?
tx_data[3] = SEND_STATE_CMD; // 命令<EFBFBD>?
tx_data[4] = DI_MAX; // 数据长度
for (di_ch = 0; di_ch < DI_MAX; di_ch++)
{
@ -310,14 +331,14 @@ void start_gpio_di_do_task(void const * argument)
* @retval None
*/
/* USER CODE END Header_start_ec11_task */
void start_ec11_task(void const * argument)
void start_ec11_task(void const *argument)
{
/* USER CODE BEGIN start_ec11_task */
/* Infinite loop */
for (;;)
{
direction = __HAL_TIM_IS_TIM_COUNTING_DOWN(&htim1);
encode_num = (short)__HAL_TIM_GET_COUNTER(&htim1);
ec11_data.direction = __HAL_TIM_IS_TIM_COUNTING_DOWN(&htim1);
ec11_data.encode_num = (short)__HAL_TIM_GET_COUNTER(&htim1);
vTaskDelay(10);
}
/* USER CODE END start_ec11_task */

View File

@ -26,6 +26,7 @@
#include "usart.h"
#include "tcpserverc.h"
#include "ht1200m.h"
#include "uart_lcd.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
@ -58,7 +59,7 @@ uint8_t buzzer_flag = 0;
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
// extern ec11_t ec11_data;
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
@ -91,8 +92,8 @@ extern TIM_HandleTypeDef htim4;
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
@ -106,8 +107,8 @@ void NMI_Handler(void)
}
/**
* @brief This function handles Hard fault interrupt.
*/
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
@ -121,8 +122,8 @@ void HardFault_Handler(void)
}
/**
* @brief This function handles Memory management fault.
*/
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
@ -136,8 +137,8 @@ void MemManage_Handler(void)
}
/**
* @brief This function handles Pre-fetch fault, memory access fault.
*/
* @brief This function handles Pre-fetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
@ -151,8 +152,8 @@ void BusFault_Handler(void)
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
@ -166,8 +167,8 @@ void UsageFault_Handler(void)
}
/**
* @brief This function handles Debug monitor.
*/
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
@ -186,8 +187,8 @@ void DebugMon_Handler(void)
/******************************************************************************/
/**
* @brief This function handles EXTI line1 interrupt.
*/
* @brief This function handles EXTI line1 interrupt.
*/
void EXTI1_IRQHandler(void)
{
/* USER CODE BEGIN EXTI1_IRQn 0 */
@ -200,8 +201,8 @@ void EXTI1_IRQHandler(void)
}
/**
* @brief This function handles EXTI line3 interrupt.
*/
* @brief This function handles EXTI line3 interrupt.
*/
void EXTI3_IRQHandler(void)
{
/* USER CODE BEGIN EXTI3_IRQn 0 */
@ -214,8 +215,8 @@ void EXTI3_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream0 global interrupt.
*/
* @brief This function handles DMA1 stream0 global interrupt.
*/
void DMA1_Stream0_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream0_IRQn 0 */
@ -228,8 +229,8 @@ void DMA1_Stream0_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream1 global interrupt.
*/
* @brief This function handles DMA1 stream1 global interrupt.
*/
void DMA1_Stream1_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream1_IRQn 0 */
@ -242,8 +243,8 @@ void DMA1_Stream1_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream2 global interrupt.
*/
* @brief This function handles DMA1 stream2 global interrupt.
*/
void DMA1_Stream2_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream2_IRQn 0 */
@ -256,8 +257,8 @@ void DMA1_Stream2_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream3 global interrupt.
*/
* @brief This function handles DMA1 stream3 global interrupt.
*/
void DMA1_Stream3_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream3_IRQn 0 */
@ -270,8 +271,8 @@ void DMA1_Stream3_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream4 global interrupt.
*/
* @brief This function handles DMA1 stream4 global interrupt.
*/
void DMA1_Stream4_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream4_IRQn 0 */
@ -284,8 +285,8 @@ void DMA1_Stream4_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream5 global interrupt.
*/
* @brief This function handles DMA1 stream5 global interrupt.
*/
void DMA1_Stream5_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream5_IRQn 0 */
@ -298,8 +299,8 @@ void DMA1_Stream5_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream6 global interrupt.
*/
* @brief This function handles DMA1 stream6 global interrupt.
*/
void DMA1_Stream6_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream6_IRQn 0 */
@ -312,8 +313,8 @@ void DMA1_Stream6_IRQHandler(void)
}
/**
* @brief This function handles EXTI line[9:5] interrupts.
*/
* @brief This function handles EXTI line[9:5] interrupts.
*/
void EXTI9_5_IRQHandler(void)
{
/* USER CODE BEGIN EXTI9_5_IRQn 0 */
@ -321,22 +322,20 @@ void EXTI9_5_IRQHandler(void)
/* USER CODE END EXTI9_5_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(EC11_KEY_Pin);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
if (buzzer_flag == 1)
if (ec11_data.confirm_key_flag == 1)
{
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3); // 蜂鸣器PWM输出用于蜂鸣器发声
buzzer_flag = 0;
ec11_data.confirm_key_flag = 2;
}
else if (buzzer_flag == 0)
else if (ec11_data.confirm_key_flag == 0)
{
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出用于关闭蜂鸣器发声
buzzer_flag = 1;
ec11_data.confirm_key_flag = 1;
}
/* USER CODE END EXTI9_5_IRQn 1 */
}
/**
* @brief This function handles TIM4 global interrupt.
*/
* @brief This function handles TIM4 global interrupt.
*/
void TIM4_IRQHandler(void)
{
/* USER CODE BEGIN TIM4_IRQn 0 */
@ -349,8 +348,8 @@ void TIM4_IRQHandler(void)
}
/**
* @brief This function handles USART1 global interrupt.
*/
* @brief This function handles USART1 global interrupt.
*/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
@ -363,8 +362,8 @@ void USART1_IRQHandler(void)
}
/**
* @brief This function handles USART2 global interrupt.
*/
* @brief This function handles USART2 global interrupt.
*/
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN USART2_IRQn 0 */
@ -376,8 +375,8 @@ void USART2_IRQHandler(void)
}
/**
* @brief This function handles USART3 global interrupt.
*/
* @brief This function handles USART3 global interrupt.
*/
void USART3_IRQHandler(void)
{
/* USER CODE BEGIN USART3_IRQn 0 */
@ -390,8 +389,8 @@ void USART3_IRQHandler(void)
}
/**
* @brief This function handles DMA1 stream7 global interrupt.
*/
* @brief This function handles DMA1 stream7 global interrupt.
*/
void DMA1_Stream7_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream7_IRQn 0 */
@ -404,8 +403,8 @@ void DMA1_Stream7_IRQHandler(void)
}
/**
* @brief This function handles UART4 global interrupt.
*/
* @brief This function handles UART4 global interrupt.
*/
void UART4_IRQHandler(void)
{
/* USER CODE BEGIN UART4_IRQn 0 */
@ -417,8 +416,8 @@ void UART4_IRQHandler(void)
}
/**
* @brief This function handles UART5 global interrupt.
*/
* @brief This function handles UART5 global interrupt.
*/
void UART5_IRQHandler(void)
{
/* USER CODE BEGIN UART5_IRQn 0 */
@ -429,8 +428,8 @@ void UART5_IRQHandler(void)
}
/**
* @brief This function handles DMA2 stream1 global interrupt.
*/
* @brief This function handles DMA2 stream1 global interrupt.
*/
void DMA2_Stream1_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream1_IRQn 0 */
@ -443,8 +442,8 @@ void DMA2_Stream1_IRQHandler(void)
}
/**
* @brief This function handles DMA2 stream2 global interrupt.
*/
* @brief This function handles DMA2 stream2 global interrupt.
*/
void DMA2_Stream2_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream2_IRQn 0 */
@ -457,8 +456,8 @@ void DMA2_Stream2_IRQHandler(void)
}
/**
* @brief This function handles Ethernet global interrupt.
*/
* @brief This function handles Ethernet global interrupt.
*/
void ETH_IRQHandler(void)
{
/* USER CODE BEGIN ETH_IRQn 0 */
@ -471,8 +470,8 @@ void ETH_IRQHandler(void)
}
/**
* @brief This function handles DMA2 stream6 global interrupt.
*/
* @brief This function handles DMA2 stream6 global interrupt.
*/
void DMA2_Stream6_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream6_IRQn 0 */
@ -485,8 +484,8 @@ void DMA2_Stream6_IRQHandler(void)
}
/**
* @brief This function handles DMA2 stream7 global interrupt.
*/
* @brief This function handles DMA2 stream7 global interrupt.
*/
void DMA2_Stream7_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream7_IRQn 0 */
@ -499,8 +498,8 @@ void DMA2_Stream7_IRQHandler(void)
}
/**
* @brief This function handles USART6 global interrupt.
*/
* @brief This function handles USART6 global interrupt.
*/
void USART6_IRQHandler(void)
{
/* USER CODE BEGIN USART6_IRQn 0 */

View File

@ -117,6 +117,26 @@
<pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
</DebugOpt>
<TargetDriverDllRegistry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMRTXEVENTFLAGS</Key>
<Name>-L70 -Z18 -C0 -M0 -T1</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGTARM</Key>
<Name>(1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>ARMDBGFLAGS</Key>
<Name></Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>DLGUARM</Key>
<Name>(105=-1,-1,-1,-1,0)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
<Key>UL2CM3</Key>
@ -125,10 +145,17 @@
<SetRegEntry>
<Number>0</Number>
<Key>ST-LINKIII-KEIL_SWO</Key>
<Name>-U090F00028316303030303032 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("") -D00(00000000) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
<Name>-U090F00028316303030303032 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>ec11_data,0x0A</ItemText>
</Ww>
</WatchWindow1>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
@ -183,7 +210,7 @@
<Group>
<GroupName>Application/MDK-ARM</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -203,7 +230,7 @@
<Group>
<GroupName>Application/User/Core</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,14 @@
#define __UART_LCD_H__
#include "main.h"
typedef struct
{
uint8_t confirm_key_flag;
uint8_t confirm_key_flag_last;
int direction;
int encode_num;
} ec11_t;
extern ec11_t ec11_data;
void uart_lcd_draw_ipaddr(void);
#endif