打印
[RTOS]

AT32F407+freertos+lwip example

[复制链接]
6593|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

使用特权

评论回复
沙发
Xavier977| | 2021-6-4 16:43 | 只看该作者
sdfgsdfgs

使用特权

评论回复
板凳
Xavier977| | 2021-6-4 16:45 | 只看该作者
下载不了吗

使用特权

评论回复
评论
muyichuan2012 2021-6-8 09:19 回复TA
换一个浏览器再试试呢 
地板
huquanz711| | 2021-6-8 18:52 | 只看该作者
参考一下,感谢分享。

使用特权

评论回复
5
骑蚂蚁追飞机| | 2021-7-23 08:54 | 只看该作者
版主,能加个好友吗??

使用特权

评论回复
6
18210528758| | 2021-9-3 15:49 | 只看该作者
lwip+freertos有IAR版本的吗

使用特权

评论回复
7
勇敢的大白菜| | 2021-9-3 18:28 | 只看该作者
现在的freertos很火的。

使用特权

评论回复
8
jimmhu| | 2021-9-4 14:53 | 只看该作者
为什么不使用RT-Therad呢   

使用特权

评论回复
9
xiaoyaozt| | 2021-9-4 14:53 | 只看该作者
freertos占用多大的内存呢   

使用特权

评论回复
10
lihuami| | 2021-9-4 14:53 | 只看该作者
AT32F407这么牛呢   

使用特权

评论回复
11
10299823| | 2021-9-4 14:54 | 只看该作者
这个是官网的程序吗   

使用特权

评论回复
12
primojones| | 2021-9-4 14:54 | 只看该作者
这个是基于哪块开发板   

使用特权

评论回复
13
alvpeg| | 2021-9-4 14:54 | 只看该作者
用conmark跑个分试试  

使用特权

评论回复
14
earlmax| | 2021-9-4 14:55 | 只看该作者
lwip用的是什么?   

使用特权

评论回复
15
sesefadou| | 2021-9-4 14:55 | 只看该作者
能够移植lvgl吗?   

使用特权

评论回复
16
cehuafan| | 2021-9-4 14:55 | 只看该作者
下载学习一下了。         

使用特权

评论回复
17
uptown| | 2021-9-4 14:55 | 只看该作者
freertos+lwip的绝配芯片。   

使用特权

评论回复
18
勇敢的大白菜| | 2021-9-6 09:20 | 只看该作者
感谢楼主的分享,lwip是什么?可以详细的介绍一下吗?

使用特权

评论回复
19
asmine| | 2021-9-6 10:18 | 只看该作者
勇敢的大白菜 发表于 2021-9-6 09:20
感谢楼主的分享,lwip是什么?可以详细的介绍一下吗?

网路

使用特权

评论回复
20
自己造声卡| | 2021-9-10 10:16 | 只看该作者
单片机上操作系统,我一直没有看好的,不知道楼主是怎么做到的。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

174

主题

1798

帖子

25

粉丝