打开freertos.c里的加上
#include “gpio.h”
#include “sys.h”
#include “pcf8574.h”
#include “tcp_echoserver.h”,并在主线程将PCF8574初的P7管脚使能
PCF8574_WriteBit(ETH_RESET_IO,0);代码如下
/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "main.h"
#include "cmsis_os.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "gpio.h"
#include "sys.h"
#include "pcf8574.h"
#include "tcp_echoserver.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */
/* USER CODE END Variables */
osThreadId defaultTaskHandle;
osThreadId myTaskLEDHandle;
osThreadId myTaskTCPHandle;
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */
extern void tcp_echoserver_init(void);
/* USER CODE END FunctionPrototypes */
void StartDefaultTask(void const * argument);
void LEDTask(void const * argument);
void TCPTask(void const * argument);
extern void MX_LWIP_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
/**
* @brief FreeRTOS initialization
* @param None
* @retval None
*/
void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */
/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */
/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */
/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* definition and creation of myTaskLED */
osThreadDef(myTaskLED, LEDTask, osPriorityIdle, 0, 128);
myTaskLEDHandle = osThreadCreate(osThread(myTaskLED), NULL);
/* definition and creation of myTaskTCP */
osThreadDef(myTaskTCP, TCPTask, osPriorityIdle, 0, 1024);
myTaskTCPHandle = osThreadCreate(osThread(myTaskTCP), NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */
}
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* @brief Function implementing the defaultTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void const * argument)
{
/* init code for LWIP */
MX_LWIP_Init();
/* USER CODE BEGIN StartDefaultTask */
PCF8574_WriteBit(ETH_RESET_IO,0); //Æô¶¯PHYоƬ
Tcp_Server_Init();
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END StartDefaultTask */
}
/* USER CODE BEGIN Header_LEDTask */
/**
* @brief Function implementing the myTaskLED thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_LEDTask */
void LEDTask(void const * argument)
{
/* USER CODE BEGIN LEDTask */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END LEDTask */
}
/* USER CODE BEGIN Header_TCPTask */
/**
* @brief Function implementing the myTaskTCP thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_TCPTask */
void TCPTask(void const * argument)
{
/* USER CODE BEGIN TCPTask */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
/* USER CODE END TCPTask */
}
接下来我们的开发板连上电脑,保证电脑IP地址和开发板IP地址在同一网段后按Windows+R后输入cmd回车打开CMD,在界面输入ping xxx.xxx.xxx.xxx(xxx代表开发板IP地址),可以得到
这样开发板就ping通了,这个时候就可以引入服务器或是客户端的代码,实现对应功能。
|