diff --git a/Core/Inc/gpio.h b/Core/Inc/gpio.h
index adda4ed..387f35c 100644
--- a/Core/Inc/gpio.h
+++ b/Core/Inc/gpio.h
@@ -1,7 +1,7 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
- * @file gpio.h
+ * @file gpio.h
* @brief This file contains all the function prototypes for
* the gpio.c file
******************************************************************************
@@ -40,13 +40,19 @@ extern "C"
DI_2,
DI_3,
DI_4,
+ DI_5,
+ DI_6,
+ DI_MAX,
+ } gpio_di_e;
+ typedef enum
+ {
DO_1,
DO_2,
DO_3,
DO_4,
DO_EN,
- DI_DO_MAX,
- } gpio_e;
+ DO_MAX,
+ } gpio_do_e;
/* USER CODE END Private defines */
void MX_GPIO_Init(void);
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index eb4bd98..b829f00 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -23,8 +23,7 @@
#define __MAIN_H
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
@@ -72,26 +71,30 @@ extern uart_t hart2_uart2;
#define LOCAL_PORT 5001
- /* USER CODE END ET */
+/* USER CODE END ET */
- /* Exported constants --------------------------------------------------------*/
- /* USER CODE BEGIN EC */
+/* Exported constants --------------------------------------------------------*/
+/* USER CODE BEGIN EC */
- /* USER CODE END EC */
+/* USER CODE END EC */
- /* Exported macro ------------------------------------------------------------*/
- /* USER CODE BEGIN EM */
+/* Exported macro ------------------------------------------------------------*/
+/* USER CODE BEGIN EM */
- /* USER CODE END EM */
+/* USER CODE END EM */
- /* Exported functions prototypes ---------------------------------------------*/
- void Error_Handler(void);
+/* Exported functions prototypes ---------------------------------------------*/
+void Error_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
+#define DI_CH5_Pin GPIO_PIN_2
+#define DI_CH5_GPIO_Port GPIOE
+#define DI_CH6_Pin GPIO_PIN_3
+#define DI_CH6_GPIO_Port GPIOE
#define ETH_RESET_Pin GPIO_PIN_0
#define ETH_RESET_GPIO_Port GPIOC
#define LED3_R_Pin GPIO_PIN_1
@@ -172,7 +175,7 @@ extern uart_t hart2_uart2;
/* USER CODE BEGIN Private defines */
#define TRUE 0
#define FAIL -1
- /* USER CODE END Private defines */
+/* USER CODE END Private defines */
#ifdef __cplusplus
}
diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c
index e2e598b..c05f5f1 100644
--- a/Core/Src/freertos.c
+++ b/Core/Src/freertos.c
@@ -54,6 +54,7 @@ osThreadId lwip_taskHandle;
osThreadId led_taskHandle;
osThreadId dac_taskHandle;
osThreadId adc_taskHandle;
+osThreadId gpio_di_do_taskHandle;
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
@@ -64,6 +65,7 @@ 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);
extern void MX_LWIP_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
@@ -128,6 +130,10 @@ void MX_FREERTOS_Init(void)
osThreadDef(adc_task, start_adc_task, osPriorityBelowNormal, 0, 128);
adc_taskHandle = osThreadCreate(osThread(adc_task), NULL);
+ /* definition and creation of gpio_di_do_task */
+ osThreadDef(gpio_di_do_task, start_gpio_di_do_task, osPriorityNormal, 0, 128);
+ gpio_di_do_taskHandle = osThreadCreate(osThread(gpio_di_do_task), NULL);
+
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
@@ -240,6 +246,24 @@ void start_adc_task(void const *argument)
/* USER CODE END start_adc_task */
}
+/* USER CODE BEGIN Header_start_gpio_di_do_task */
+/**
+ * @brief Function implementing the gpio_di_do_task thread.
+ * @param argument: Not used
+ * @retval None
+ */
+/* USER CODE END Header_start_gpio_di_do_task */
+void start_gpio_di_do_task(void const *argument)
+{
+ /* USER CODE BEGIN start_gpio_di_do_task */
+ /* Infinite loop */
+ for (;;)
+ {
+ osDelay(1);
+ }
+ /* USER CODE END start_gpio_di_do_task */
+}
+
/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c
index 57c3a2e..4732642 100644
--- a/Core/Src/gpio.c
+++ b/Core/Src/gpio.c
@@ -45,11 +45,11 @@ void MX_GPIO_Init(void)
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
+ __HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
- __HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
@@ -70,6 +70,12 @@ void MX_GPIO_Init(void)
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(HART2_RST_GPIO_Port, HART2_RST_Pin, GPIO_PIN_RESET);
+ /*Configure GPIO pins : PEPin PEPin */
+ GPIO_InitStruct.Pin = DI_CH5_Pin | DI_CH6_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
+
/*Configure GPIO pin : PtPin */
GPIO_InitStruct.Pin = ETH_RESET_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
@@ -199,6 +205,12 @@ GPIO_PinState gpio_di_test(uint8_t gpio_num)
case DI_4:
state = HAL_GPIO_ReadPin(DI_CH4_GPIO_Port, DI_CH4_Pin);
break;
+ case DI_5:
+ state = HAL_GPIO_ReadPin(DI_CH5_GPIO_Port, DI_CH5_Pin);
+ break;
+ case DI_6:
+ state = HAL_GPIO_ReadPin(DI_CH6_GPIO_Port, DI_CH6_Pin);
+ break;
default:
state = GPIO_PIN_RESET;
break;
diff --git a/Core/Src/main.c b/Core/Src/main.c
index b4a2a31..c33f82f 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -80,9 +80,9 @@ uint8_t tcp_echo_flags_control = 0;
/* USER CODE END 0 */
/**
- * @brief The application entry point.
- * @retval int
- */
+ * @brief The application entry point.
+ * @retval int
+ */
int main(void)
{
/* USER CODE BEGIN 1 */
@@ -146,22 +146,22 @@ int main(void)
}
/**
- * @brief System Clock Configuration
- * @retval None
- */
+ * @brief System Clock Configuration
+ * @retval None
+ */
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
- */
+ */
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
- * in the RCC_OscInitTypeDef structure.
- */
+ * in the RCC_OscInitTypeDef structure.
+ */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
@@ -176,8 +176,9 @@ 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;
@@ -256,20 +257,19 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
/* USER CODE END 4 */
/**
- * @brief Period elapsed callback in non blocking mode
- * @note This function is called when TIM1 interrupt took place, inside
- * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
- * a global variable "uwTick" used as application time base.
- * @param htim : TIM handle
- * @retval None
- */
+ * @brief Period elapsed callback in non blocking mode
+ * @note This function is called when TIM1 interrupt took place, inside
+ * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
+ * a global variable "uwTick" used as application time base.
+ * @param htim : TIM handle
+ * @retval None
+ */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
- if (htim->Instance == TIM1)
- {
+ if (htim->Instance == TIM1) {
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
@@ -278,9 +278,9 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
/**
- * @brief This function is executed in case of error occurrence.
- * @retval None
- */
+ * @brief This function is executed in case of error occurrence.
+ * @retval None
+ */
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
@@ -292,14 +292,14 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */
}
-#ifdef USE_FULL_ASSERT
+#ifdef USE_FULL_ASSERT
/**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
+ * @brief Reports the name of the source file and the source line number
+ * where the assert_param error has occurred.
+ * @param file: pointer to the source file name
+ * @param line: assert_param error line source number
+ * @retval None
+ */
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
diff --git a/Core/Src/stm32f4xx_it.c b/Core/Src/stm32f4xx_it.c
index bfe6b03..4718c0d 100644
--- a/Core/Src/stm32f4xx_it.c
+++ b/Core/Src/stm32f4xx_it.c
@@ -88,8 +88,8 @@ extern TIM_HandleTypeDef htim1;
/* 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 */
@@ -103,8 +103,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 */
@@ -118,8 +118,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 */
@@ -133,8 +133,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 */
@@ -148,8 +148,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 */
@@ -163,8 +163,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 */
@@ -183,8 +183,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 */
@@ -197,8 +197,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 */
@@ -211,8 +211,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 */
@@ -225,8 +225,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 */
@@ -239,8 +239,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 */
@@ -253,8 +253,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 */
@@ -267,8 +267,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 */
@@ -281,8 +281,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 */
@@ -295,8 +295,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 */
@@ -309,8 +309,8 @@ void DMA1_Stream6_IRQHandler(void)
}
/**
- * @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
- */
+ * @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
+ */
void TIM1_UP_TIM10_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
@@ -323,8 +323,8 @@ void TIM1_UP_TIM10_IRQHandler(void)
}
/**
- * @brief This function handles TIM3 global interrupt.
- */
+ * @brief This function handles TIM3 global interrupt.
+ */
void TIM3_IRQHandler(void)
{
/* USER CODE BEGIN TIM3_IRQn 0 */
@@ -337,8 +337,8 @@ void TIM3_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 */
@@ -368,8 +368,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 */
@@ -382,8 +382,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 +404,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 +417,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 */
@@ -447,8 +447,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 */
@@ -461,8 +461,8 @@ void DMA2_Stream1_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 */
@@ -475,8 +475,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 */
@@ -489,8 +489,8 @@ void DMA2_Stream6_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 */
diff --git a/Core/Src/usart.c b/Core/Src/usart.c
index 81529ee..984d66c 100644
--- a/Core/Src/usart.c
+++ b/Core/Src/usart.c
@@ -65,6 +65,7 @@ void MX_UART4_Init(void)
/* USER CODE BEGIN UART4_Init 2 */
//__HAL_UART_ENABLE_IT(&huart4, UART_IT_IDLE); // 使能IDLE中断
/* USER CODE END UART4_Init 2 */
+
}
/* UART5 init function */
void MX_UART5_Init(void)
@@ -93,6 +94,7 @@ void MX_UART5_Init(void)
// __HAL_UART_ENABLE_IT(&huart5, UART_IT_RXNE); // 接收中断
// __HAL_UART_ENABLE_IT(&huart5, UART_IT_IDLE); // 空闲中断
/* USER CODE END UART5_Init 2 */
+
}
/* USART2 init function */
@@ -122,6 +124,7 @@ void MX_USART2_UART_Init(void)
// __HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE); // 接收中断
// __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE); // 使能IDLE中断
/* USER CODE END USART2_Init 2 */
+
}
/* USART3 init function */
@@ -150,6 +153,7 @@ void MX_USART3_UART_Init(void)
/* USER CODE BEGIN USART3_Init 2 */
/* USER CODE END USART3_Init 2 */
+
}
/* USART6 init function */
@@ -178,17 +182,18 @@ void MX_USART6_UART_Init(void)
/* USER CODE BEGIN USART6_Init 2 */
/* USER CODE END USART6_Init 2 */
+
}
-void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
+void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
- if (uartHandle->Instance == UART4)
+ if(uartHandle->Instance==UART4)
{
- /* USER CODE BEGIN UART4_MspInit 0 */
+ /* USER CODE BEGIN UART4_MspInit 0 */
- /* USER CODE END UART4_MspInit 0 */
+ /* USER CODE END UART4_MspInit 0 */
/* UART4 clock enable */
__HAL_RCC_UART4_CLK_ENABLE();
@@ -197,7 +202,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
PC10 ------> UART4_TX
PC11 ------> UART4_RX
*/
- GPIO_InitStruct.Pin = LCD_TX_Pin | LCD_RX_Pin;
+ GPIO_InitStruct.Pin = LCD_TX_Pin|LCD_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@@ -221,7 +226,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmarx, hdma_uart4_rx);
+ __HAL_LINKDMA(uartHandle,hdmarx,hdma_uart4_rx);
/* UART4_TX Init */
hdma_uart4_tx.Instance = DMA1_Stream4;
@@ -239,20 +244,20 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmatx, hdma_uart4_tx);
+ __HAL_LINKDMA(uartHandle,hdmatx,hdma_uart4_tx);
/* UART4 interrupt Init */
HAL_NVIC_SetPriority(UART4_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(UART4_IRQn);
- /* USER CODE BEGIN UART4_MspInit 1 */
+ /* USER CODE BEGIN UART4_MspInit 1 */
- /* USER CODE END UART4_MspInit 1 */
+ /* USER CODE END UART4_MspInit 1 */
}
- else if (uartHandle->Instance == UART5)
+ else if(uartHandle->Instance==UART5)
{
- /* USER CODE BEGIN UART5_MspInit 0 */
+ /* USER CODE BEGIN UART5_MspInit 0 */
- /* USER CODE END UART5_MspInit 0 */
+ /* USER CODE END UART5_MspInit 0 */
/* UART5 clock enable */
__HAL_RCC_UART5_CLK_ENABLE();
@@ -293,7 +298,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmatx, hdma_uart5_tx);
+ __HAL_LINKDMA(uartHandle,hdmatx,hdma_uart5_tx);
/* UART5_RX Init */
hdma_uart5_rx.Instance = DMA1_Stream0;
@@ -311,20 +316,20 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmarx, hdma_uart5_rx);
+ __HAL_LINKDMA(uartHandle,hdmarx,hdma_uart5_rx);
/* UART5 interrupt Init */
HAL_NVIC_SetPriority(UART5_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(UART5_IRQn);
- /* USER CODE BEGIN UART5_MspInit 1 */
+ /* USER CODE BEGIN UART5_MspInit 1 */
- /* USER CODE END UART5_MspInit 1 */
+ /* USER CODE END UART5_MspInit 1 */
}
- else if (uartHandle->Instance == USART2)
+ else if(uartHandle->Instance==USART2)
{
- /* USER CODE BEGIN USART2_MspInit 0 */
+ /* USER CODE BEGIN USART2_MspInit 0 */
- /* USER CODE END USART2_MspInit 0 */
+ /* USER CODE END USART2_MspInit 0 */
/* USART2 clock enable */
__HAL_RCC_USART2_CLK_ENABLE();
@@ -333,7 +338,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
PD5 ------> USART2_TX
PD6 ------> USART2_RX
*/
- GPIO_InitStruct.Pin = HART2_TX_Pin | HART2_RX_Pin;
+ GPIO_InitStruct.Pin = HART2_TX_Pin|HART2_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@@ -357,7 +362,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmarx, hdma_usart2_rx);
+ __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx);
/* USART2_TX Init */
hdma_usart2_tx.Instance = DMA1_Stream6;
@@ -375,20 +380,20 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmatx, hdma_usart2_tx);
+ __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
/* USART2 interrupt Init */
HAL_NVIC_SetPriority(USART2_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USART2_IRQn);
- /* USER CODE BEGIN USART2_MspInit 1 */
+ /* USER CODE BEGIN USART2_MspInit 1 */
- /* USER CODE END USART2_MspInit 1 */
+ /* USER CODE END USART2_MspInit 1 */
}
- else if (uartHandle->Instance == USART3)
+ else if(uartHandle->Instance==USART3)
{
- /* USER CODE BEGIN USART3_MspInit 0 */
+ /* USER CODE BEGIN USART3_MspInit 0 */
- /* USER CODE END USART3_MspInit 0 */
+ /* USER CODE END USART3_MspInit 0 */
/* USART3 clock enable */
__HAL_RCC_USART3_CLK_ENABLE();
@@ -397,7 +402,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
PD8 ------> USART3_TX
PD9 ------> USART3_RX
*/
- GPIO_InitStruct.Pin = BLE2_TX_Pin | BLE2_RX_Pin;
+ GPIO_InitStruct.Pin = BLE2_TX_Pin|BLE2_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@@ -421,7 +426,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmarx, hdma_usart3_rx);
+ __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart3_rx);
/* USART3_TX Init */
hdma_usart3_tx.Instance = DMA1_Stream3;
@@ -439,20 +444,20 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmatx, hdma_usart3_tx);
+ __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart3_tx);
/* USART3 interrupt Init */
HAL_NVIC_SetPriority(USART3_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USART3_IRQn);
- /* USER CODE BEGIN USART3_MspInit 1 */
+ /* USER CODE BEGIN USART3_MspInit 1 */
- /* USER CODE END USART3_MspInit 1 */
+ /* USER CODE END USART3_MspInit 1 */
}
- else if (uartHandle->Instance == USART6)
+ else if(uartHandle->Instance==USART6)
{
- /* USER CODE BEGIN USART6_MspInit 0 */
+ /* USER CODE BEGIN USART6_MspInit 0 */
- /* USER CODE END USART6_MspInit 0 */
+ /* USER CODE END USART6_MspInit 0 */
/* USART6 clock enable */
__HAL_RCC_USART6_CLK_ENABLE();
@@ -461,7 +466,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
PC6 ------> USART6_TX
PC7 ------> USART6_RX
*/
- GPIO_InitStruct.Pin = BLE1_TX_Pin | BLE1_RX_Pin;
+ GPIO_InitStruct.Pin = BLE1_TX_Pin|BLE1_RX_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@@ -485,7 +490,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmarx, hdma_usart6_rx);
+ __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart6_rx);
/* USART6_TX Init */
hdma_usart6_tx.Instance = DMA2_Stream6;
@@ -503,25 +508,25 @@ void HAL_UART_MspInit(UART_HandleTypeDef *uartHandle)
Error_Handler();
}
- __HAL_LINKDMA(uartHandle, hdmatx, hdma_usart6_tx);
+ __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart6_tx);
/* USART6 interrupt Init */
HAL_NVIC_SetPriority(USART6_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(USART6_IRQn);
- /* USER CODE BEGIN USART6_MspInit 1 */
+ /* USER CODE BEGIN USART6_MspInit 1 */
- /* USER CODE END USART6_MspInit 1 */
+ /* USER CODE END USART6_MspInit 1 */
}
}
-void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
+void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
{
- if (uartHandle->Instance == UART4)
+ if(uartHandle->Instance==UART4)
{
- /* USER CODE BEGIN UART4_MspDeInit 0 */
+ /* USER CODE BEGIN UART4_MspDeInit 0 */
- /* USER CODE END UART4_MspDeInit 0 */
+ /* USER CODE END UART4_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_UART4_CLK_DISABLE();
@@ -529,7 +534,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
PC10 ------> UART4_TX
PC11 ------> UART4_RX
*/
- HAL_GPIO_DeInit(GPIOC, LCD_TX_Pin | LCD_RX_Pin);
+ HAL_GPIO_DeInit(GPIOC, LCD_TX_Pin|LCD_RX_Pin);
/* UART4 DMA DeInit */
HAL_DMA_DeInit(uartHandle->hdmarx);
@@ -537,15 +542,15 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
/* UART4 interrupt Deinit */
HAL_NVIC_DisableIRQ(UART4_IRQn);
- /* USER CODE BEGIN UART4_MspDeInit 1 */
+ /* USER CODE BEGIN UART4_MspDeInit 1 */
- /* USER CODE END UART4_MspDeInit 1 */
+ /* USER CODE END UART4_MspDeInit 1 */
}
- else if (uartHandle->Instance == UART5)
+ else if(uartHandle->Instance==UART5)
{
- /* USER CODE BEGIN UART5_MspDeInit 0 */
+ /* USER CODE BEGIN UART5_MspDeInit 0 */
- /* USER CODE END UART5_MspDeInit 0 */
+ /* USER CODE END UART5_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_UART5_CLK_DISABLE();
@@ -563,15 +568,15 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
/* UART5 interrupt Deinit */
HAL_NVIC_DisableIRQ(UART5_IRQn);
- /* USER CODE BEGIN UART5_MspDeInit 1 */
+ /* USER CODE BEGIN UART5_MspDeInit 1 */
- /* USER CODE END UART5_MspDeInit 1 */
+ /* USER CODE END UART5_MspDeInit 1 */
}
- else if (uartHandle->Instance == USART2)
+ else if(uartHandle->Instance==USART2)
{
- /* USER CODE BEGIN USART2_MspDeInit 0 */
+ /* USER CODE BEGIN USART2_MspDeInit 0 */
- /* USER CODE END USART2_MspDeInit 0 */
+ /* USER CODE END USART2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART2_CLK_DISABLE();
@@ -579,7 +584,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
PD5 ------> USART2_TX
PD6 ------> USART2_RX
*/
- HAL_GPIO_DeInit(GPIOD, HART2_TX_Pin | HART2_RX_Pin);
+ HAL_GPIO_DeInit(GPIOD, HART2_TX_Pin|HART2_RX_Pin);
/* USART2 DMA DeInit */
HAL_DMA_DeInit(uartHandle->hdmarx);
@@ -587,15 +592,15 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
/* USART2 interrupt Deinit */
HAL_NVIC_DisableIRQ(USART2_IRQn);
- /* USER CODE BEGIN USART2_MspDeInit 1 */
+ /* USER CODE BEGIN USART2_MspDeInit 1 */
- /* USER CODE END USART2_MspDeInit 1 */
+ /* USER CODE END USART2_MspDeInit 1 */
}
- else if (uartHandle->Instance == USART3)
+ else if(uartHandle->Instance==USART3)
{
- /* USER CODE BEGIN USART3_MspDeInit 0 */
+ /* USER CODE BEGIN USART3_MspDeInit 0 */
- /* USER CODE END USART3_MspDeInit 0 */
+ /* USER CODE END USART3_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART3_CLK_DISABLE();
@@ -603,7 +608,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
PD8 ------> USART3_TX
PD9 ------> USART3_RX
*/
- HAL_GPIO_DeInit(GPIOD, BLE2_TX_Pin | BLE2_RX_Pin);
+ HAL_GPIO_DeInit(GPIOD, BLE2_TX_Pin|BLE2_RX_Pin);
/* USART3 DMA DeInit */
HAL_DMA_DeInit(uartHandle->hdmarx);
@@ -611,15 +616,15 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
/* USART3 interrupt Deinit */
HAL_NVIC_DisableIRQ(USART3_IRQn);
- /* USER CODE BEGIN USART3_MspDeInit 1 */
+ /* USER CODE BEGIN USART3_MspDeInit 1 */
- /* USER CODE END USART3_MspDeInit 1 */
+ /* USER CODE END USART3_MspDeInit 1 */
}
- else if (uartHandle->Instance == USART6)
+ else if(uartHandle->Instance==USART6)
{
- /* USER CODE BEGIN USART6_MspDeInit 0 */
+ /* USER CODE BEGIN USART6_MspDeInit 0 */
- /* USER CODE END USART6_MspDeInit 0 */
+ /* USER CODE END USART6_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_USART6_CLK_DISABLE();
@@ -627,7 +632,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
PC6 ------> USART6_TX
PC7 ------> USART6_RX
*/
- HAL_GPIO_DeInit(GPIOC, BLE1_TX_Pin | BLE1_RX_Pin);
+ HAL_GPIO_DeInit(GPIOC, BLE1_TX_Pin|BLE1_RX_Pin);
/* USART6 DMA DeInit */
HAL_DMA_DeInit(uartHandle->hdmarx);
@@ -635,30 +640,30 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef *uartHandle)
/* USART6 interrupt Deinit */
HAL_NVIC_DisableIRQ(USART6_IRQn);
- /* USER CODE BEGIN USART6_MspDeInit 1 */
+ /* USER CODE BEGIN USART6_MspDeInit 1 */
- /* USER CODE END USART6_MspDeInit 1 */
+ /* USER CODE END USART6_MspDeInit 1 */
}
}
/* USER CODE BEGIN 1 */
/**
- * @brief 使用DMA方式通过串口发送数据
+ * @brief 使用DMA方式通过串口发?数?
*
- * 该函数使用DMA方式通过指定的串口发送指定长度的数据。
+ * 该函数使用DMA方式通过指定的串口发送指定长度的数据?
*
- * @param huart UART_HandleTypeDef结构体指针,指向需要使用的串口句柄
- * @param buf 指向需要发送的数据缓冲区的指针
- * @param len 需要发送的数据长度
+ * @param huart UART_HandleTypeDef结构体指针,指向?要使用的串口句柄
+ * @param buf 指向?要发送的数据缓冲区的指针
+ * @param len ?要发送的数据长度
*
- * @return 无返回值
+ * @return 无返回??
*
- * @note 如果发送过程中出现错误,会调用Error_Handler函数处理错误
+ * @note 如果发?过程中出现错误,会调用Error_Handler函数处理错误
*/
void dma_usart_send(UART_HandleTypeDef *huart, uint8_t *buf, uint8_t len)
{
- if (HAL_UART_Transmit_DMA(huart, buf, len) != HAL_OK) // 判断是否发送正常,如果出现异常则进入异常中断函数
+ if (HAL_UART_Transmit_DMA(huart, buf, len) != HAL_OK) // 判断是否发?正常,如果出现异常则进入异常中断函?
{
Error_Handler();
}
diff --git a/Documents/project documents/~$测试&半成品测试协议.docx b/Documents/project documents/~$测试&半成品测试协议.docx
new file mode 100644
index 0000000..097e4ed
Binary files /dev/null and b/Documents/project documents/~$测试&半成品测试协议.docx differ
diff --git a/Documents/project documents/本体功能测试台系统设计方案-20250210.docx b/Documents/project documents/本体功能测试台系统设计方案-20250210.docx
new file mode 100644
index 0000000..4f7fa8a
Binary files /dev/null and b/Documents/project documents/本体功能测试台系统设计方案-20250210.docx differ
diff --git a/Documents/project documents/老化测试&半成品测试协议.docx b/Documents/project documents/老化测试&半成品测试协议.docx
new file mode 100644
index 0000000..09b56a7
Binary files /dev/null and b/Documents/project documents/老化测试&半成品测试协议.docx differ
diff --git a/MDK-ARM/TEST2.uvoptx b/MDK-ARM/TEST2.uvoptx
index 2eb454a..95523fe 100644
--- a/MDK-ARM/TEST2.uvoptx
+++ b/MDK-ARM/TEST2.uvoptx
@@ -148,24 +148,7 @@
-UB -O2254 -SF1800 -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 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407VGTx$CMSIS\Flash\STM32F4xx_1024.FLM)
-
-
- 0
- 0
- 4
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- ../User/application/inc/communication_protocol.h
-
-
-
-
+
0
diff --git a/TEST2.ioc b/TEST2.ioc
index cd7bd74..358794b 100644
--- a/TEST2.ioc
+++ b/TEST2.ioc
@@ -117,7 +117,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
+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
FREERTOS.configENABLE_FPU=1
FREERTOS.configMAX_PRIORITIES=32
FREERTOS.configMAX_TASK_NAME_LEN=24
@@ -163,65 +163,67 @@ Mcu.IP9=TIM3
Mcu.IPNb=15
Mcu.Name=STM32F407V(E-G)Tx
Mcu.Package=LQFP100
-Mcu.Pin0=PH0-OSC_IN
-Mcu.Pin1=PH1-OSC_OUT
-Mcu.Pin10=PB2
-Mcu.Pin11=PE7
-Mcu.Pin12=PE12
-Mcu.Pin13=PE13
-Mcu.Pin14=PE14
-Mcu.Pin15=PB11
-Mcu.Pin16=PB12
-Mcu.Pin17=PB13
-Mcu.Pin18=PD8
-Mcu.Pin19=PD9
-Mcu.Pin2=PC0
-Mcu.Pin20=PD11
-Mcu.Pin21=PD12
-Mcu.Pin22=PD13
-Mcu.Pin23=PD14
-Mcu.Pin24=PD15
-Mcu.Pin25=PC6
-Mcu.Pin26=PC7
-Mcu.Pin27=PC8
-Mcu.Pin28=PC9
-Mcu.Pin29=PA8
-Mcu.Pin3=PC1
-Mcu.Pin30=PA11
-Mcu.Pin31=PA12
-Mcu.Pin32=PA13
-Mcu.Pin33=PA14
-Mcu.Pin34=PA15
-Mcu.Pin35=PC10
-Mcu.Pin36=PC11
-Mcu.Pin37=PC12
-Mcu.Pin38=PD0
-Mcu.Pin39=PD1
-Mcu.Pin4=PA1
-Mcu.Pin40=PD2
-Mcu.Pin41=PD3
-Mcu.Pin42=PD4
-Mcu.Pin43=PD5
-Mcu.Pin44=PD6
-Mcu.Pin45=PD7
-Mcu.Pin46=PB3
-Mcu.Pin47=PB4
-Mcu.Pin48=PB5
-Mcu.Pin49=PB6
-Mcu.Pin5=PA2
-Mcu.Pin50=PB7
-Mcu.Pin51=PE0
-Mcu.Pin52=PE1
-Mcu.Pin53=VP_FREERTOS_VS_CMSIS_V1
-Mcu.Pin54=VP_LWIP_VS_Enabled
-Mcu.Pin55=VP_SYS_VS_tim1
-Mcu.Pin56=VP_TIM2_VS_ClockSourceINT
-Mcu.Pin57=VP_TIM3_VS_ClockSourceINT
-Mcu.Pin6=PA7
-Mcu.Pin7=PC4
-Mcu.Pin8=PC5
-Mcu.Pin9=PB1
-Mcu.PinsNb=58
+Mcu.Pin0=PE2
+Mcu.Pin1=PE3
+Mcu.Pin10=PC5
+Mcu.Pin11=PB1
+Mcu.Pin12=PB2
+Mcu.Pin13=PE7
+Mcu.Pin14=PE12
+Mcu.Pin15=PE13
+Mcu.Pin16=PE14
+Mcu.Pin17=PB11
+Mcu.Pin18=PB12
+Mcu.Pin19=PB13
+Mcu.Pin2=PH0-OSC_IN
+Mcu.Pin20=PD8
+Mcu.Pin21=PD9
+Mcu.Pin22=PD11
+Mcu.Pin23=PD12
+Mcu.Pin24=PD13
+Mcu.Pin25=PD14
+Mcu.Pin26=PD15
+Mcu.Pin27=PC6
+Mcu.Pin28=PC7
+Mcu.Pin29=PC8
+Mcu.Pin3=PH1-OSC_OUT
+Mcu.Pin30=PC9
+Mcu.Pin31=PA8
+Mcu.Pin32=PA11
+Mcu.Pin33=PA12
+Mcu.Pin34=PA13
+Mcu.Pin35=PA14
+Mcu.Pin36=PA15
+Mcu.Pin37=PC10
+Mcu.Pin38=PC11
+Mcu.Pin39=PC12
+Mcu.Pin4=PC0
+Mcu.Pin40=PD0
+Mcu.Pin41=PD1
+Mcu.Pin42=PD2
+Mcu.Pin43=PD3
+Mcu.Pin44=PD4
+Mcu.Pin45=PD5
+Mcu.Pin46=PD6
+Mcu.Pin47=PD7
+Mcu.Pin48=PB3
+Mcu.Pin49=PB4
+Mcu.Pin5=PC1
+Mcu.Pin50=PB5
+Mcu.Pin51=PB6
+Mcu.Pin52=PB7
+Mcu.Pin53=PE0
+Mcu.Pin54=PE1
+Mcu.Pin55=VP_FREERTOS_VS_CMSIS_V1
+Mcu.Pin56=VP_LWIP_VS_Enabled
+Mcu.Pin57=VP_SYS_VS_tim1
+Mcu.Pin58=VP_TIM2_VS_ClockSourceINT
+Mcu.Pin59=VP_TIM3_VS_ClockSourceINT
+Mcu.Pin6=PA1
+Mcu.Pin7=PA2
+Mcu.Pin8=PA7
+Mcu.Pin9=PC4
+Mcu.PinsNb=60
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F407VGTx
@@ -508,6 +510,16 @@ PE14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PE14.Locked=true
PE14.PinState=GPIO_PIN_SET
PE14.Signal=GPIO_Output
+PE2.GPIOParameters=GPIO_PuPd,GPIO_Label
+PE2.GPIO_Label=DI_CH5
+PE2.GPIO_PuPd=GPIO_PULLUP
+PE2.Locked=true
+PE2.Signal=GPIO_Input
+PE3.GPIOParameters=GPIO_PuPd,GPIO_Label
+PE3.GPIO_Label=DI_CH6
+PE3.GPIO_PuPd=GPIO_PULLUP
+PE3.Locked=true
+PE3.Signal=GPIO_Input
PE7.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label
PE7.GPIO_Label=LED3_Y
PE7.GPIO_PuPd=GPIO_PULLUP
diff --git a/User/application/inc/tcpserverc.h b/User/application/inc/tcpserverc.h
index 980cbca..cbf9e4b 100644
--- a/User/application/inc/tcpserverc.h
+++ b/User/application/inc/tcpserverc.h
@@ -5,9 +5,9 @@
#define TCP_PORT_HART1 5001
#define TCP_PORT_HART2 5002
-#define TCP_PORT_BLE1 5003
-#define TCP_PORT_BLE2 5004
-#define TCP_PORT_CONTROL 5005
+#define TCP_PORT_BLE1 6001
+#define TCP_PORT_BLE2 6002
+#define TCP_PORT_CONTROL 5003
extern void tcp_echo_init(void);
extern void user_send_data_hart1(uint8_t *data, uint16_t len);
diff --git a/User/application/src/tcpserverc.c b/User/application/src/tcpserverc.c
index b79fb50..0d33074 100644
--- a/User/application/src/tcpserverc.c
+++ b/User/application/src/tcpserverc.c
@@ -175,6 +175,11 @@ static err_t tcpecho_recv_control(void *arg, struct tcp_pcb *tpcb, struct pbuf *
}
else if (tcp_rx_data[3] == 0x02) // 读数字量指令
{
+ /*读操作,从寄存器读取数据,组包返回*/
+ tx_data_len = 7 + user_communication_di->num;
+ user_communication_di = &communication_data.di_data;
+ user_read_gpio(user_communication_di, tcp_tx_data, tcp_rx_data);
+ tcp_write(tpcb, tcp_tx_data, tx_data_len, 1);
}
else if (tcp_rx_data[3] == 0x03) // 写数字量指令
{
diff --git a/User/system/user_gpio.c b/User/system/user_gpio.c
index 2e09505..28a80b7 100644
--- a/User/system/user_gpio.c
+++ b/User/system/user_gpio.c
@@ -17,13 +17,21 @@ void user_write_gpio(communication_do_t *do_data)
}
}
}
-void user_read_gpio(uint8_t *const tx_data, uint8_t *const rx_data, uint16_t length)
+void user_read_gpio(communication_di_t *di_data, uint8_t *tx_data, const uint8_t *const rx_data)
{
uint8_t i = 0;
- uint8_t start_addr = rx_data[0]; // 读输入的起始地址
- uint8_t leng = rx_data[1]; // 读输入的数量
- for (i = 0; i < leng; i++)
+ uint8_t start_addr = di_data->start_addr; // 读输入的起始地址
+ uint8_t length = di_data->num; // 读输入的数量
+ uint8_t tx_data_len = 7 + length; // 数据长度
+ tx_data[0] = FRAME_HEAD; // 帧头
+ tx_data[1] = COM_OK; // 状态
+ tx_data[2] = rx_data[2]; // 设备号
+ tx_data[3] = rx_data[3]; // 命令号
+ tx_data[4] = length; // 数据长度
+ for (i = 0; i < length; i++)
{
- tx_data[i] = gpio_di_test(DI_1 + start_addr + i);
+ tx_data[5 + i] = gpio_di_test(DI_1 + i + start_addr);
}
+ tx_data[5 + length] = xor_compute(tx_data + 1, tx_data_len - 3); // 异或校验
+ tx_data[6 + length] = FRAME_TAIL; // 帧尾
}
diff --git a/User/system/user_gpio.h b/User/system/user_gpio.h
index ffc3fa3..77c9792 100644
--- a/User/system/user_gpio.h
+++ b/User/system/user_gpio.h
@@ -5,6 +5,6 @@
#include "communication_protocol.h"
void user_write_gpio(communication_do_t *do_data);
-void user_read_gpio(uint8_t *const tx_data, uint8_t *const rx_data, uint16_t length);
+void user_read_gpio(communication_di_t *di_data, uint8_t *tx_data, const uint8_t *const rx_data);
#endif