This commit is contained in:
parent
a5d06b1b53
commit
77ac708abe
|
@ -42,6 +42,8 @@
|
|||
"communication_protocol.h": "c",
|
||||
"user_gpio.h": "c",
|
||||
"user_lib.h": "c",
|
||||
"init.h": "c"
|
||||
"init.h": "c",
|
||||
"user_flash.h": "c",
|
||||
"uart_lcd.h": "c"
|
||||
}
|
||||
}
|
|
@ -67,8 +67,7 @@ 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 */
|
||||
|
@ -147,7 +146,7 @@ void MX_FREERTOS_Init(void) {
|
|||
gpio_di_do_taskHandle = osThreadCreate(osThread(gpio_di_do_task), NULL);
|
||||
|
||||
/* definition and creation of ec11_task */
|
||||
osThreadDef(ec11_task, start_ec11_task, osPriorityNormal, 0, 128);
|
||||
osThreadDef(ec11_task, start_ec11_task, osPriorityNormal, 0, 512);
|
||||
ec11_taskHandle = osThreadCreate(osThread(ec11_task), NULL);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
|
@ -172,7 +171,7 @@ void start_tcp_task(void const * argument)
|
|||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
uart_lcd_draw_ipaddr(); // 更新LCD显示的IP地址
|
||||
uart_lcd_draw_ipaddr(); // åˆ<EFBFBD>始化显示IP地å<EFBFBD>€ä¿¡æ<EFBFBD>¯
|
||||
|
||||
osThreadTerminate(NULL);
|
||||
}
|
||||
|
@ -212,7 +211,7 @@ void start_dac_task(void const * argument)
|
|||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
osThreadSuspend(adc_taskHandle); // 暂停DAC任务,防止ADC采集时产生干<EFBFBD><EFBFBD>?,因为ADC和DAC采用的是同一路SPI,但是时序不<E5BA8F><EFBFBD>?
|
||||
osThreadSuspend(adc_taskHandle); // æš‚å<EFBFBD>œADC任务,防æ¢DAC采集时产生干æ‰?,å› ä¸ºADCå’ŒDAC采用的是å<C2AF>Œä¸€è·¯SPI,但是时åº<C3A5>ä¸<C3A4>å<EFBFBD>?
|
||||
dac161s997_output(DAC161S997_1, current_buff[0]);
|
||||
dac161s997_output(DAC161S997_2, current_buff[1]);
|
||||
osThreadResume(adc_taskHandle);
|
||||
|
@ -243,7 +242,7 @@ void start_adc_task(void const * argument)
|
|||
}
|
||||
HAL_GPIO_TogglePin(LED2_Y_GPIO_Port, LED2_Y_Pin);
|
||||
|
||||
/*此部分是因为通讯过程中会产生通讯中断并无法恢复的情况*/
|
||||
/*å§<EFBFBD>ら儴é<EFBFBD>’嗘槸é<EFBFBD>¥çŠ±è´Ÿé–«æ°³î††æ<EFBFBD>©å›©â–¼æ¶“î…<EFBFBD>細浜х敓閫氳涓柇骞舵棤娉曟仮澶嶇殑鎯å‘å–Œ*/
|
||||
if (huart5.RxState == HAL_UART_STATE_READY)
|
||||
{
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart5, hart1_uart5.rx_data_temp, ARRAY_LEN(hart1_uart5.rx_data_temp));
|
||||
|
@ -275,11 +274,11 @@ void start_gpio_di_do_task(void const * argument)
|
|||
uint8_t di_ch = 0;
|
||||
uint8_t tx_data_len = 7 + DI_MAX;
|
||||
uint8_t tx_data[32] = {0};
|
||||
tx_data[0] = FRAME_HEAD; // 帧头
|
||||
tx_data[1] = COM_OK; // 状<EFBFBD>?<3F>码
|
||||
tx_data[2] = DEVICE_NUM; // 设备<EFBFBD><EFBFBD>??
|
||||
tx_data[3] = SEND_STATE_CMD; // 命令<EFBFBD><EFBFBD>??
|
||||
tx_data[4] = DI_MAX; // 数据长度
|
||||
tx_data[0] = FRAME_HEAD; // 甯уã<EFBFBD>”
|
||||
tx_data[1] = COM_OK; // é<EFBFBD>˜è®¹æ‹??锟界çˆ?
|
||||
tx_data[2] = DEVICE_NUM; // ç’<EFBFBD>惧锟??
|
||||
tx_data[3] = SEND_STATE_CMD; // é<EFBFBD>›æˆ’护锟??
|
||||
tx_data[4] = DI_MAX; // é<EFBFBD><EFBFBD>版åµ<EFBFBD>闀垮害
|
||||
for (di_ch = 0; di_ch < DI_MAX; di_ch++)
|
||||
{
|
||||
di_state_now[di_ch] = gpio_di_test(di_ch);
|
||||
|
@ -292,11 +291,11 @@ void start_gpio_di_do_task(void const * argument)
|
|||
}
|
||||
if ((send_data_flag_cmd != 0) && (1 == tcp_echo_flags_control))
|
||||
{
|
||||
tx_data[5 + DI_MAX] = xor_compute(tx_data + 1, tx_data_len - 3); // 异或校验
|
||||
tx_data[6 + DI_MAX] = FRAME_TAIL; // 帧尾
|
||||
tx_data[5 + DI_MAX] = xor_compute(tx_data + 1, tx_data_len - 3); // 寮傛垨é<EFBFBD><EFBFBD>ï¿ ç<EFBFBD>™
|
||||
tx_data[6 + DI_MAX] = FRAME_TAIL; // 甯у熬
|
||||
user_send_data_control(tx_data, tx_data_len);
|
||||
send_data_flag_cmd++;
|
||||
if (send_data_flag_cmd > 3) // 连续三次上位机没有回应,则停止发送数据包
|
||||
if (send_data_flag_cmd > 3) // æ<EFBFBD>©ç‚µç”»æ¶“夋涓å©<EFBFBD>ç¶…é<EFBFBD>ˆçƒ˜ç—…é<EFBFBD>ˆå¤Šæ´–æ<EFBFBD>´æ—“ç´<EFBFBD>é<EFBFBD>’æ¬<EFBFBD>ä» å§<EFBFBD>㈠彂閫佹暟鎹寘
|
||||
{
|
||||
send_data_flag_cmd = 0;
|
||||
}
|
||||
|
@ -319,9 +318,116 @@ void start_ec11_task(void const * argument)
|
|||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
direction = __HAL_TIM_IS_TIM_COUNTING_DOWN(&htim1);
|
||||
encode_num = (short)__HAL_TIM_GET_COUNTER(&htim1);
|
||||
vTaskDelay(10);
|
||||
// 旋转编ç <C3A7>器确认按键状æ€<C3A6>,并切æ<E280A1>¢é?šé<C5A1>“和确认电æµ<C3A6>å?¼è¾“å‡?
|
||||
{
|
||||
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) // 确认按键确认电æµ<C3A6>输出
|
||||
{
|
||||
ec11_data.confirm_key_flag_last++;
|
||||
if (ec11_data.confirm_key_flag_last > 10)
|
||||
{
|
||||
current_buff[0] = (float)uart_lcd_state.current_value[0];
|
||||
current_buff[1] = (float)uart_lcd_state.current_value[1];
|
||||
ec11_data.confirm_key_flag_last = 0;
|
||||
ec11_data.confirm_key_flag = 0;
|
||||
}
|
||||
}
|
||||
else if (ec11_data.confirm_key_flag == 2) // 切æ<E280A1>¢é€šé<C5A1>“按键确认状æ??
|
||||
{
|
||||
ec11_data.confirm_key_flag_last++;
|
||||
if (ec11_data.confirm_key_flag_last > 10)
|
||||
{
|
||||
if (uart_lcd_state.key_state[0] == 1)
|
||||
{
|
||||
uart_lcd_state.key_state[0] = 0;
|
||||
uart_lcd_state.key_state[1] = 1;
|
||||
uart_lcd_state.key_state[2] = 0;
|
||||
}
|
||||
else if (uart_lcd_state.key_state[0] == 0)
|
||||
{
|
||||
uart_lcd_state.key_state[0] = 1;
|
||||
uart_lcd_state.key_state[1] = 0;
|
||||
uart_lcd_state.key_state[2] = 1;
|
||||
}
|
||||
ec11_data.confirm_key_flag_last = 0;
|
||||
ec11_data.confirm_key_flag = 0;
|
||||
uart_lcd_channel_switch(uart_lcd_state.key_state[0]);
|
||||
}
|
||||
}
|
||||
else if (ec11_data.confirm_key_flag == 3) // 切æ<E280A1>¢ç•Œé<C592>¢
|
||||
{
|
||||
|
||||
if (uart_lcd_state.page_num == 0)
|
||||
{
|
||||
uart_lcd_state.page_num = 1;
|
||||
}
|
||||
else if (uart_lcd_state.page_num == 1)
|
||||
{
|
||||
uart_lcd_state.page_num = 0;
|
||||
}
|
||||
ec11_data.confirm_key_flag_last = 0;
|
||||
ec11_data.confirm_key_flag = 0;
|
||||
uart_lcd_page_switch(uart_lcd_state.page_num);
|
||||
}
|
||||
}
|
||||
|
||||
// 旋转编ç <C3A7>器调节电æµ<C3A6>å?¼ç”»é<C2BB>¢æ˜¾ç¤?
|
||||
{
|
||||
ec11_data.direction = __HAL_TIM_IS_TIM_COUNTING_DOWN(&htim1);
|
||||
ec11_data.encode_num = (short)__HAL_TIM_GET_COUNTER(&htim1);
|
||||
if ((ec11_data.direction == 0) && (ec11_data.encode_num > ec11_data.encode_num_last))
|
||||
{
|
||||
if (uart_lcd_state.key_state[0] == 0)
|
||||
{
|
||||
uart_lcd_state.current_value[0] += 1;
|
||||
if (uart_lcd_state.current_value[0] > 20)
|
||||
{
|
||||
uart_lcd_state.current_value[0] = 20;
|
||||
}
|
||||
}
|
||||
else if (uart_lcd_state.key_state[0] == 1)
|
||||
{
|
||||
uart_lcd_state.current_value[1] += 1;
|
||||
if (uart_lcd_state.current_value[1] > 20)
|
||||
{
|
||||
uart_lcd_state.current_value[1] = 20;
|
||||
}
|
||||
}
|
||||
uart_lcd_current_out(uart_lcd_state.key_state[0]);
|
||||
}
|
||||
if ((ec11_data.direction == 1) && (ec11_data.encode_num < ec11_data.encode_num_last))
|
||||
{
|
||||
if (uart_lcd_state.key_state[0] == 0)
|
||||
{
|
||||
if (uart_lcd_state.current_value[0] < 2)
|
||||
{
|
||||
uart_lcd_state.current_value[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_lcd_state.current_value[0] -= 1;
|
||||
}
|
||||
}
|
||||
else if (uart_lcd_state.key_state[0] == 1)
|
||||
{
|
||||
if (uart_lcd_state.current_value[1] < 2)
|
||||
{
|
||||
uart_lcd_state.current_value[1] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
uart_lcd_state.current_value[1] -= 1;
|
||||
}
|
||||
}
|
||||
uart_lcd_current_out(uart_lcd_state.key_state[0]);
|
||||
}
|
||||
|
||||
ec11_data.encode_num_last = ec11_data.encode_num;
|
||||
}
|
||||
vTaskDelay(100);
|
||||
}
|
||||
/* USER CODE END start_ec11_task */
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ int main(void)
|
|||
MX_TIM1_Init();
|
||||
MX_USART1_UART_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
/*é…<EFBFBD>ç½®å<EFBFBD>„串å<EFBFBD>£çš„DMA接收*/
|
||||
/*闂佹澘绉堕悿鍡涘触閸曨亣顩柛娆欑悼濞堟厪MA闁规亽鍎查弫锟<EFBFBD>*/
|
||||
// start
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart4, lcd_uart4.rx_data_temp, ARRAY_LEN(lcd_uart4.rx_data_temp));
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart6, ble1_uart6.rx_data_temp, ARRAY_LEN(ble1_uart6.rx_data_temp));
|
||||
|
@ -135,9 +135,9 @@ int main(void)
|
|||
HAL_UARTEx_ReceiveToIdle_DMA(&huart2, hart2_uart2.rx_data_temp, ARRAY_LEN(hart2_uart2.rx_data_temp));
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, usb_uart1.rx_data_temp, ARRAY_LEN(usb_uart1.rx_data_temp));
|
||||
// end
|
||||
hart_ht1200m_reset(); // åˆ<EFBFBD>始化HT1200M模å<EFBFBD>—
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // PWM输出,用于驱动HT1200M模å<EFBFBD>—
|
||||
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL); // 旋转编ç <EFBFBD>器输å…?
|
||||
hart_ht1200m_reset(); // 闁告帗绻傞~鎰板礌閺堟壍1200M婵☆垪鈧櫕鍋<EFBFBD>
|
||||
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1); // PWM閺夊牊鎸搁崵顓㈡晬<EFBFBD>?<3F>€鈧弫銈嗙鎼淬劉鏀抽柛鏂哄墻T1200M婵☆垪鈧櫕鍋<E6AB95>
|
||||
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL); // 闁哄啫顑堝ù鍡欑磽閺嶎偆鍨抽柛锝冨<EFBFBD>?缁额參宕<E58F83>??
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Call init function for freertos objects (in freertos.c) */
|
||||
|
@ -189,8 +189,7 @@ void SystemClock_Config(void)
|
|||
|
||||
/** Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
|
@ -214,7 +213,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
|
|||
memcpy(usb_uart1.rx_data, usb_uart1.rx_data_temp, Size);
|
||||
HAL_UARTEx_ReceiveToIdle_DMA(&huart1, usb_uart1.rx_data_temp, ARRAY_LEN(usb_uart1.rx_data_temp));
|
||||
// dma_usart_send(&huart4, usb_uart1.rx_data_temp, usb_uart1.rx_num);
|
||||
// ip地å<EFBFBD>€ä¿®æ”¹å¤„ç<EFBFBD>†
|
||||
// ip闁革附婢樺鍐╃┍椤旇姤鏆璺哄閹<EFBFBD>?
|
||||
IP4_ADDR(&ipaddr, usb_uart1.rx_data_temp[0], usb_uart1.rx_data_temp[1], usb_uart1.rx_data_temp[2], usb_uart1.rx_data_temp[3]);
|
||||
gnetif.ip_addr = ipaddr;
|
||||
if (flash_write_data(FLASH_USER_START_ADDR, usb_uart1.rx_data_temp, Size) == HAL_OK)
|
||||
|
@ -306,7 +305,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
|||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM4) {
|
||||
if (htim->Instance == TIM4)
|
||||
{
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
|
@ -322,10 +322,10 @@ void Error_Handler(void)
|
|||
{
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
__disable_irq();
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
// __disable_irq();
|
||||
// while (1)
|
||||
// {
|
||||
// }
|
||||
/* USER CODE END Error_Handler_Debug */
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "usart.h"
|
||||
#include "tcpserverc.h"
|
||||
#include "ht1200m.h"
|
||||
#include "uart_lcd.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
@ -321,16 +322,28 @@ 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 == 0)
|
||||
{
|
||||
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3); // 蜂鸣器PWM输出,用于蜂鸣器发声
|
||||
buzzer_flag = 0;
|
||||
ec11_data.confirm_key_flag = 1;
|
||||
}
|
||||
else if (buzzer_flag == 0)
|
||||
else if (ec11_data.confirm_key_flag == 1)
|
||||
{
|
||||
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出,用于关闭蜂鸣器发声
|
||||
buzzer_flag = 1;
|
||||
ec11_data.confirm_key_flag = 2;
|
||||
}
|
||||
else if (ec11_data.confirm_key_flag == 2)
|
||||
{
|
||||
ec11_data.confirm_key_flag = 3;
|
||||
}
|
||||
// if (buzzer_flag == 1)
|
||||
// {
|
||||
// HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3); // 蜂鸣器PWM输出,用于蜂鸣器发声
|
||||
// buzzer_flag = 0;
|
||||
// }
|
||||
// else if (buzzer_flag == 0)
|
||||
// {
|
||||
// HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_3); // 停止蜂鸣器PWM输出,用于关闭蜂鸣器发声
|
||||
// buzzer_flag = 1;
|
||||
// }
|
||||
/* USER CODE END EXTI9_5_IRQn 1 */
|
||||
}
|
||||
|
||||
|
|
|
@ -148,7 +148,24 @@
|
|||
<Name>-U090F00028316303030303032 -O2254 -SF1000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8004 -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/>
|
||||
<Breakpoint>
|
||||
<Bp>
|
||||
<Number>0</Number>
|
||||
<Type>0</Type>
|
||||
<LineNumber>221</LineNumber>
|
||||
<EnabledFlag>1</EnabledFlag>
|
||||
<Address>134232952</Address>
|
||||
<ByteObject>0</ByteObject>
|
||||
<HtxType>0</HtxType>
|
||||
<ManyObjects>0</ManyObjects>
|
||||
<SizeOfObject>0</SizeOfObject>
|
||||
<BreakByAccess>0</BreakByAccess>
|
||||
<BreakIfRCount>1</BreakIfRCount>
|
||||
<Filename>../Core/Src/main.c</Filename>
|
||||
<ExecCommand></ExecCommand>
|
||||
<Expression>\\semi_finished_product_testing\../Core/Src/main.c\221</Expression>
|
||||
</Bp>
|
||||
</Breakpoint>
|
||||
<WatchWindow1>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
|
@ -290,12 +307,32 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ipaddr</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>28</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ec11_data</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>29</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>uart_lcd_state</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>30</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>huart</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>31</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>huart->pTxBuffPtr</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
<SubType>0</SubType>
|
||||
<ItemText>0x080E0000</ItemText>
|
||||
<ItemText>buf</ItemText>
|
||||
<AccSizeX>0</AccSizeX>
|
||||
</Mm>
|
||||
</MemoryWindow1>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,38 @@
|
|||
#include "lwip.h"
|
||||
|
||||
extern ip4_addr_t ipaddr;
|
||||
uint8_t ip_addr[24] = {0};
|
||||
uart_lcd_t uart_lcd_state = {0};
|
||||
|
||||
static void uart_lcd_current_channel1(void);
|
||||
static void uart_lcd_current_channel2(void);
|
||||
|
||||
static void uart_lcd_page1(void);
|
||||
static void uart_lcd_page2(void);
|
||||
|
||||
uint8_t uart_lcd_data1[24] = {0xEE, 0xB1, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
||||
static void uart_lcd_current_channel1(void)
|
||||
{
|
||||
dma_usart_send(&huart4, uart_lcd_data1, ARRAY_LEN(uart_lcd_data1));
|
||||
}
|
||||
|
||||
uint8_t uart_lcd_data2[24] = {0xEE, 0xB1, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x03, 0x00, 0x01, 0x01, 0xFF, 0xFC, 0xFF, 0xFF};
|
||||
static void uart_lcd_current_channel2(void)
|
||||
{
|
||||
dma_usart_send(&huart4, uart_lcd_data2, ARRAY_LEN(uart_lcd_data2));
|
||||
}
|
||||
uint8_t uart_lcd_data3[9] = {0xEE, 0xB1, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
||||
static void uart_lcd_page1(void)
|
||||
{
|
||||
|
||||
dma_usart_send(&huart4, uart_lcd_data3, ARRAY_LEN(uart_lcd_data3));
|
||||
}
|
||||
uint8_t uart_lcd_data4[9] = {0xEE, 0xB1, 0x00, 0x00, 0x01, 0xFF, 0xFC, 0xFF, 0xFF};
|
||||
static void uart_lcd_page2(void)
|
||||
{
|
||||
|
||||
dma_usart_send(&huart4, uart_lcd_data4, ARRAY_LEN(uart_lcd_data4));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 通过UART向LCD屏幕绘制IP地址
|
||||
*
|
||||
|
@ -11,14 +42,16 @@ uint8_t ip_addr[24] = {0};
|
|||
*
|
||||
* @note 此函数假定已经正确初始化了UART接口,并且LCD屏幕已经正确连接到UART接口。
|
||||
*/
|
||||
uint8_t ip_addr[24] = {0};
|
||||
void uart_lcd_draw_ipaddr(void)
|
||||
{
|
||||
|
||||
// 串口发送的固定值为串口屏指令指定的帧头帧尾
|
||||
ip_addr[0] = 0xEE; // 帧头
|
||||
ip_addr[1] = 0xB1;
|
||||
ip_addr[2] = 0x10; // 命令码,此处为文本控件文本设置指令
|
||||
ip_addr[3] = 0x00; // 画面ID高位地址
|
||||
ip_addr[4] = 0x00; // 画面ID低位地址
|
||||
ip_addr[4] = 0x01; // 画面ID低位地址
|
||||
ip_addr[5] = 0x00; // 控件ID高位地址
|
||||
ip_addr[6] = 0x03; // 控件ID低位地址
|
||||
char *ip_addr_str = ipaddr_ntoa(&ipaddr);
|
||||
|
@ -27,5 +60,78 @@ void uart_lcd_draw_ipaddr(void)
|
|||
ip_addr[8 + strlen(ip_addr_str)] = 0xFC;
|
||||
ip_addr[9 + strlen(ip_addr_str)] = 0xFF;
|
||||
ip_addr[10 + strlen(ip_addr_str)] = 0xFF;
|
||||
//uart_lcd_page2();
|
||||
//HAL_Delay(100);
|
||||
dma_usart_send(&huart4, ip_addr, ARRAY_LEN(ip_addr));
|
||||
//HAL_Delay(100);
|
||||
}
|
||||
|
||||
void uart_lcd_init(void)
|
||||
{
|
||||
uart_lcd_state.page_num = 0;
|
||||
uart_lcd_state.key_state[0] = 0;
|
||||
uart_lcd_state.key_state[1] = 1;
|
||||
uart_lcd_state.key_state[2] = 0;
|
||||
uart_lcd_state.current_value[0] = 0;
|
||||
uart_lcd_state.current_value[1] = 0;
|
||||
// uart_lcd_channel_switch(uart_lcd_state.key_state[0]);
|
||||
// HAL_Delay(10);
|
||||
// uart_lcd_current_out(0);
|
||||
// HAL_Delay(10);
|
||||
// uart_lcd_current_out(1);
|
||||
}
|
||||
uint8_t lcd_channel[15] = {0xEE, 0xB1, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFC, 0xFF, 0xFF};
|
||||
|
||||
void uart_lcd_current_out(uint8_t channel)
|
||||
{
|
||||
|
||||
if (channel == 0)
|
||||
{
|
||||
lcd_channel[6] = 0x04;
|
||||
lcd_channel[10] = uart_lcd_state.current_value[0];
|
||||
dma_usart_send(&huart4, lcd_channel, ARRAY_LEN(lcd_channel));
|
||||
}
|
||||
else if (channel == 1)
|
||||
{
|
||||
lcd_channel[6] = 0x05;
|
||||
lcd_channel[10] = uart_lcd_state.current_value[1];
|
||||
dma_usart_send(&huart4, lcd_channel, ARRAY_LEN(lcd_channel));
|
||||
}
|
||||
// HAL_Delay(100);
|
||||
}
|
||||
|
||||
void uart_lcd_channel_switch(uint8_t channel)
|
||||
{
|
||||
|
||||
switch (channel)
|
||||
{
|
||||
case 0:
|
||||
uart_lcd_current_channel1();
|
||||
break;
|
||||
case 1:
|
||||
uart_lcd_current_channel2();
|
||||
break;
|
||||
default:
|
||||
uart_lcd_current_channel1();
|
||||
break;
|
||||
}
|
||||
// HAL_Delay(100);
|
||||
}
|
||||
|
||||
void uart_lcd_page_switch(uint8_t page)
|
||||
{
|
||||
|
||||
switch (page)
|
||||
{
|
||||
case 0:
|
||||
uart_lcd_page1();
|
||||
break;
|
||||
case 1:
|
||||
uart_lcd_page2();
|
||||
break;
|
||||
default:
|
||||
uart_lcd_page1();
|
||||
break;
|
||||
}
|
||||
// HAL_Delay(100);
|
||||
}
|
||||
|
|
|
@ -3,5 +3,27 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t page_num;
|
||||
uint8_t key_state[3];
|
||||
uint8_t current_value[2];
|
||||
uint8_t lcd_flag;
|
||||
} uart_lcd_t;
|
||||
extern uart_lcd_t uart_lcd_state;
|
||||
typedef struct
|
||||
{
|
||||
uint8_t confirm_key_flag;
|
||||
uint8_t confirm_key_flag_last;
|
||||
int direction;
|
||||
int encode_num_last;
|
||||
int encode_num;
|
||||
} ec11_t;
|
||||
extern ec11_t ec11_data;
|
||||
|
||||
void uart_lcd_draw_ipaddr(void);
|
||||
void uart_lcd_init(void);
|
||||
void uart_lcd_current_out(uint8_t channel);
|
||||
void uart_lcd_channel_switch(uint8_t channel);
|
||||
void uart_lcd_page_switch(uint8_t page);
|
||||
#endif
|
||||
|
|
|
@ -139,7 +139,7 @@ ETH.IPParameters=MediaInterface
|
|||
ETH.MediaInterface=HAL_ETH_RMII_MODE
|
||||
FREERTOS.FootprintOK=true
|
||||
FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configENABLE_FPU,configMAX_PRIORITIES,FootprintOK
|
||||
FREERTOS.Tasks01=lwip_task,2,512,start_tcp_task,Default,NULL,Dynamic,NULL,NULL;led_task,-2,128,start_led_toggle_task,Default,NULL,Dynamic,NULL,NULL;dac_task,0,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;adc_task,-1,128,start_adc_task,Default,NULL,Dynamic,NULL,NULL;gpio_di_do_task,0,128,start_gpio_di_do_task,Default,NULL,Dynamic,NULL,NULL;ec11_task,0,128,start_ec11_task,Default,NULL,Dynamic,NULL,NULL
|
||||
FREERTOS.Tasks01=lwip_task,2,512,start_tcp_task,Default,NULL,Dynamic,NULL,NULL;led_task,-2,128,start_led_toggle_task,Default,NULL,Dynamic,NULL,NULL;dac_task,0,512,start_dac_task,Default,NULL,Dynamic,NULL,NULL;adc_task,-1,128,start_adc_task,Default,NULL,Dynamic,NULL,NULL;gpio_di_do_task,0,128,start_gpio_di_do_task,Default,NULL,Dynamic,NULL,NULL;ec11_task,0,512,start_ec11_task,Default,NULL,Dynamic,NULL,NULL
|
||||
FREERTOS.configENABLE_FPU=1
|
||||
FREERTOS.configMAX_PRIORITIES=32
|
||||
FREERTOS.configMAX_TASK_NAME_LEN=24
|
||||
|
|
Loading…
Reference in New Issue