[RTOS] AT32F407+freertos+lwip example

[复制链接]
8356|37
 楼主| muyichuan2012 发表于 2021-2-1 13:40 | 显示全部楼层 |阅读模式
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 ---------------------------------------------------------*/
/**
  * @brief  Main Function.
  * @param  None
  * @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

/**
  * @brief  Inserts a delay time.
  * @param  nCount: 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)
  {     
  }
}

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

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

#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
  */
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****/

AT32F407_FreeRTOS_ETH_20201102_0x0.zip

17.2 MB, 下载次数: 847

Xavier977 发表于 2021-6-4 16:43 | 显示全部楼层
sdfgsdfgs
Xavier977 发表于 2021-6-4 16:45 | 显示全部楼层
下载不了吗

评论

换一个浏览器再试试呢  发表于 2021-6-8 09:19
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 | 显示全部楼层
单片机上操作系统,我一直没有看好的,不知道楼主是怎么做到的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

215

主题

2077

帖子

37

粉丝
快速回复 在线客服 返回列表 返回顶部