muyichuan2012 发表于 2021-2-1 13:40

AT32F407+freertos+lwip example

AT32F407+freertos+lwip example

/**
******************************************************************************
* File   : ETH/Telent/main.c
* Version: V1.1.9
* Date   : 2020-05-29
* Brief: ethernet function test.
******************************************************************************
*/

/* Includes -----------------------------------------------------------------*/
#include "at32_board.h"
#include "main.h"
#include "eth_config.h"
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "semphr.h"
#include "arch/sys_arch.h"
#include "api.h"
#include "apps/httpd.h"
/** @addtogroup AT32F407_StdPeriph_Examples
* @{
*/

/** @addtogroup ETH_Telnet
* @{
*/

/* Gloable variables ---------------------------------------------------------*/
__IO uint32_t LocalTime = 0; /* this variable is used to create a time reference incremented by 10ms */
uint32_t timingdelay;

/* task1 priority */
#define Task1_PRIO                3
/* task1 stack size*/
#define Task1_STK_SIZE                 256
/* task1 handler */
TaskHandle_t Task1_Handler;
/* task1 function */
void task1(void *pvParameters);

/* task2 Priority */
#define Task2_PRIO                3
/* task2 stack size*/
#define Task2_STK_SIZE                 256
/* task2 handler */
TaskHandle_t Task2_Handler;
/* task2 function */
void task2(void *pvParameters);

#if LWIP_DHCP
/* task3 Priority */
#define Task3_PRIO                4
/* task3 stack size*/
#define Task3_STK_SIZE                 256
/* task3 handler */
TaskHandle_t Task3_Handler;
/* task3 function */
void task3(void *pvParameters);
#endif
/* Gloable functions ---------------------------------------------------------*/
/**
* @briefMain Function.
* @paramNone
* @retval None
*/
int main(void)
{
/* --------BSP Init ------------------------------------------------*/
AT32_Board_Init();
UART_Print_Init(115200);
/* Setup AT32 system (clocks, Ethernet, GPIO, NVIC)*/




/* 进入临界区保护 */
taskENTER_CRITICAL();
/* Initilaize LwIP satck, IP configuration and MAC configuration*/


/* 创建task1 */
xTaskCreate((TaskFunction_t )task1,   
            (const char*    )"task1",   
            (uint16_t       )Task1_STK_SIZE,
            (void*          )NULL,
            (UBaseType_t    )Task1_PRIO,
            (TaskHandle_t*)&Task1_Handler);

/* 创建task2 */
xTaskCreate((TaskFunction_t )task2,   
            (const char*    )"task2",   
            (uint16_t       )Task2_STK_SIZE,
            (void*          )NULL,
            (UBaseType_t    )Task2_PRIO,
            (TaskHandle_t*)&Task2_Handler);
                                                       
        #if LWIP_DHCP
        xTaskCreate((TaskFunction_t )task3,   
            (const char*    )"task3",   
            (uint16_t       )Task3_STK_SIZE,
            (void*          )NULL,
            (UBaseType_t    )Task3_PRIO,
            (TaskHandle_t*)&Task3_Handler);
        #endif

/* 退出临界区保护 */
taskEXIT_CRITICAL();            

/* 开启任务调度器 */
vTaskStartScheduler();

while(1);
}

/* task1 */
void task1(void *pvParameters)
{
        if(System_Setup() == ETH_DRIVER_FAIL) {
    while(1);
}
        LwIP_Init();
        httpd_init();
while(1)
        {       
    printf("This is task1!\r\n");
    vTaskDelay(500);
    #if LWIP_DHCP
    /* Necessary */
    dhcp_fine_tmr();
    printf("0x%08x\n\r", netif.ip_addr.addr);
    #endif
        }
}

/* task2???? */
void task2(void *pvParameters)
{
while(1)
        {       
    printf("This is task2!\r\n");
    vTaskDelay(1100);
        }
}

#if LWIP_DHCP
void task3(void *pvParameters)
{
int i;
while(1)
        {       
    printf("This is task3!\r\n");   
    /* Necessary */
    for(i=0;j<60;i++)
      vTaskDelay(1000);
    dhcp_coarse_tmr();
    printf("dhcp_coarse_tmr() call!\r\n");   
    vTaskDelay(1000);
        }
}
#endif

/**
* @briefInserts a delay time.
* @paramnCount: number of 10ms periods to wait for.
* @retval None
*/
void Delay(uint32_t nCount)
{
/* Capture the current local time */
timingdelay = LocalTime + nCount;

/* wait until the desired delay finish */
while(timingdelay > LocalTime)
{   
}
}

/**
* @briefUpdates the system local time
* @paramNone
* @retval None
*/
void Time_Update(void)
{
LocalTime += SYSTEMTICK_PERIOD_MS;
}

/**
* @briefHandles the periodic tasks of the system
* @paramNone
* @retval None
*/
void System_Periodic_Handle(void)
{
/* LwIP periodic services are done here */
LwIP_Periodic_Handle(LocalTime);
}

#ifdefUSE_FULL_ASSERT

/**
* @briefReports the name of the source file and the source line number
*   where the assert_param error has occurred.
* @paramfile: pointer to the source file name
* @paramline: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
   ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

/* Infinite loop */
while (1)
{}
}
#endif

/**
* @}
*/

/**
* @}
*/

/******************* (C) COPYRIGHT 2019 ArteryTek *****END OF FILE****/

Xavier977 发表于 2021-6-4 16:43

sdfgsdfgs

Xavier977 发表于 2021-6-4 16:45

下载不了吗

huquanz711 发表于 2021-6-8 18:52

参考一下,感谢分享。

骑蚂蚁追飞机 发表于 2021-7-23 08:54

版主,能加个好友吗??

18210528758 发表于 2021-9-3 15:49

lwip+freertos有IAR版本的吗

勇敢的大白菜 发表于 2021-9-3 18:28

现在的freertos很火的。

jimmhu 发表于 2021-9-4 14:53

为什么不使用RT-Therad呢   

xiaoyaozt 发表于 2021-9-4 14:53

freertos占用多大的内存呢   

lihuami 发表于 2021-9-4 14:53

AT32F407这么牛呢   

10299823 发表于 2021-9-4 14:54

这个是官网的程序吗   

primojones 发表于 2021-9-4 14:54

这个是基于哪块开发板   

alvpeg 发表于 2021-9-4 14:54

用conmark跑个分试试

earlmax 发表于 2021-9-4 14:55

lwip用的是什么?   

sesefadou 发表于 2021-9-4 14:55

能够移植lvgl吗?   

cehuafan 发表于 2021-9-4 14:55

下载学习一下了。         

uptown 发表于 2021-9-4 14:55

freertos+lwip的绝配芯片。   

勇敢的大白菜 发表于 2021-9-6 09:20

感谢楼主的分享,lwip是什么?可以详细的介绍一下吗?

asmine 发表于 2021-9-6 10:18

勇敢的大白菜 发表于 2021-9-6 09:20
感谢楼主的分享,lwip是什么?可以详细的介绍一下吗?

网路

自己造声卡 发表于 2021-9-10 10:16

单片机上操作系统,我一直没有看好的,不知道楼主是怎么做到的。
页: [1] 2
查看完整版本: AT32F407+freertos+lwip example