久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2722|回復: 0
打印 上一主題 下一主題
收起左側

神舟IV號開發板以太網IAP固件升級功能演示及源代碼

[復制鏈接]
跳轉到指定樓層
樓主


單片機源程序如下:
  1. /**
  2.   ******************************************************************************
  3.   * @file    main.c
  4.   * @author  MCD Application Team
  5.   * @version V1.0.0
  6.   * @date    07/16/2010
  7.   * @brief   Main program body
  8.   ******************************************************************************
  9.   * @copy
  10.   *
  11.   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12.   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13.   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14.   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15.   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16.   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17.   *
  18.   * <h2><center>© COPYRIGHT 2010 STMicroelectronics</center></h2>
  19.   */

  20. /* Includes ------------------------------------------------------------------*/
  21. #include "stm32_eth.h"
  22. #include "ethernetif.h"
  23. #include "netconf.h"
  24. #include "main.h"
  25. #include "httpserver.h"
  26. #include "tftpserver.h"
  27. #include "flash_if.h"
  28. #include <stdio.h>
  29. #include <usart.h>

  30. /* Private typedef -----------------------------------------------------------*/
  31. typedef  void (*pFunction)(void);

  32. /* Private define ------------------------------------------------------------*/
  33. #define SYSTEMTICK_PERIOD_MS  10

  34. #define ERR_MESSAGE1   " no user application"
  35. #define ERR_MESSAGE2   " Detected, Pls Press"
  36. #define ERR_MESSAGE3   " Key2 while reset to"
  37. #define ERR_MESSAGE4   " Upload application."
  38. /* Private macro -------------------------------------------------------------*/
  39. /* Private variables ---------------------------------------------------------*/
  40. __IO uint32_t LocalTime = 0; /* this variable is used to create a time reference incremented by 10ms */
  41. uint32_t timingdelay;
  42. pFunction Jump_To_Application;
  43. uint32_t JumpAddress;

  44. /* Private function prototypes -----------------------------------------------*/
  45. void System_Periodic_Handle(void);

  46. /* Private functions ---------------------------------------------------------*/

  47. void Show_Msg(void)
  48. {
  49.     printf("\r\n\n\n ================JISHU  %s configured ==============", EVAL_COM1_STR);
  50.     printf("\n\r STM32 Connectivity Line Device\n\r");
  51.     printf("\n\r In-Application Programming (IAP) over Ethernet....\n\r");
  52.     printf("\n\r User Application will be store at addr 0x%x\n\r", USER_FLASH_FIRST_PAGE_ADDRESS);
  53.     //printf("\n\r IP address is: 192.168.1.6\n\r");
  54. }

  55. u16 Show_ETH_PHY(u16 PHYRegAddr)
  56. {
  57.   u16 PHYRegData;
  58.   PHYRegData = ETH_ReadPHYRegister(0,PHYRegAddr);
  59.   printf("\n\rETH_ReadPHYRegister(0,%d):0x%X", PHYRegAddr, PHYRegData);
  60.   return PHYRegData;
  61. }

  62. void Check_ETH_PHY(void)
  63. {
  64.     if(Show_ETH_PHY(17) & 0x3000)
  65.     {  
  66.       /* Set Ethernet speed to 10M following the autonegotiation */   
  67.       printf("\n\r==>ETH_Speed_10M!");
  68.     }
  69.     else
  70.     {   
  71.       /* Set Ethernet speed to 100M following the autonegotiation */
  72.       printf("\n\r==>ETH_Speed_100M!");     
  73.     }
  74.     /* Configure the MAC with the Duplex Mode fixed by the autonegotiation process */
  75.     if((Show_ETH_PHY(17) & 0xA000) != (uint32_t)RESET)
  76.     {
  77.       /* Set Ethernet duplex mode to FullDuplex following the autonegotiation */
  78.       printf("\n\r==>ETH_Mode_FullDuplex!");
  79.             
  80.     }
  81.     else
  82.     {
  83.       /* Set Ethernet duplex mode to HalfDuplex following the autonegotiation */
  84.       printf("\n\r==>ETH_Mode_HalfDuplex!");
  85.     }
  86. }


  87. void Delay_ARMJISHU(__IO uint32_t nCount)
  88. {
  89.   for (; nCount != 0; nCount--);
  90. }


  91. /**
  92.   * @brief  Main program.
  93.   * @param  None
  94.   * @retval None
  95.   */
  96. int main(void)
  97. {
  98.   static uint32_t addr32;
  99.   /* Initialize Key Button mounted on STM3210C-EVAL board */      
  100.   STM_EVAL_PBInit(Button_KEY, Mode_GPIO);   
  101.   
  102.   /* Test if Key push-button on STM3210C-EVAL Board is not pressed */
  103.   if (STM_EVAL_PBGetState(Button_KEY) != 0x00)
  104.   { /* Key push-button not pressed: jump to user application */
  105.   
  106.     /* Check if valid stack address (RAM address) then jump to user application */
  107.     if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
  108.     {
  109.       STM_EVAL_LEDInit(LED1);
  110.       STM_EVAL_LEDOn(LED1);
  111.       
  112.       addr32 = USER_FLASH_FIRST_PAGE_ADDRESS;
  113.       
  114.       /* Jump to user application */
  115.       JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
  116.       Jump_To_Application = (pFunction) JumpAddress;
  117.       /* Initialize user application's Stack Pointer */
  118.       __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
  119.       Jump_To_Application();
  120.     }
  121.     else
  122.     {/* Otherwise, do nothing */
  123.       /* LED3 (RED) ON to indicate bad software (when not valid stack address) */
  124.       STM_EVAL_LEDInit(LED3);
  125.       STM_EVAL_LEDOn(LED3);

  126.       USART_COM1_Init();
  127.       printf("\n\r ==>" ERR_MESSAGE1 ERR_MESSAGE2 ERR_MESSAGE3 ERR_MESSAGE4"<==\n\r");
  128.       #ifdef USE_LCD
  129.         /* Initialize the STM3210C-EVAL's LCD */
  130.         STM3210C_LCD_Init();
  131.       #endif
  132.       LCD_DisplayWelcomeStr(Line2);
  133.       LCD_DisplayStringLine(Line4, ERR_MESSAGE1);   
  134.       LCD_DisplayStringLine(Line5, ERR_MESSAGE2);
  135.       LCD_DisplayStringLine(Line6, ERR_MESSAGE3);
  136.       LCD_DisplayStringLine(Line7, ERR_MESSAGE4);
  137.       /* do nothing */
  138.       while(1);
  139.     }
  140.   }
  141.   /* enter in IAP mode */
  142.   else
  143.   {
  144.     /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC)
  145.                             and STM3210C-EVAL resources */
  146.     System_Setup();

  147.     Show_Msg();
  148.     Check_ETH_PHY();
  149.   
  150.     /* Initilaize the LwIP stack */
  151.     LwIP_Init();
  152.    
  153. #ifdef USE_IAP_HTTP
  154.     /* Initilaize the webserver module */
  155.     IAP_httpd_init();
  156. #endif
  157.   
  158. #ifdef USE_IAP_TFTP   
  159.     /* Initialize the TFTP server */
  160.     IAP_tftpd_init();
  161. #endif   
  162.    
  163.     /* Infinite loop */
  164.     while (1)
  165.     {
  166.       /* check if any packet received */
  167.       if (ETH_GetRxPktSize()!=0)
  168.       {
  169.         /* process received eth packet */
  170.         LwIP_Pkt_Handle();
  171.       }
  172.       /* Periodic tasks */
  173.       System_Periodic_Handle();
  174.     }
  175.   }
  176.   return 0;
  177. }

  178. /**
  179.   * @brief  Inserts a delay time.
  180.   * @param  nCount: number of 10ms periods to wait for.
  181.   * @retval None
  182.   */
  183. void Delay(uint32_t nCount)
  184. {
  185.   /* Capture the current local time */
  186.   timingdelay = LocalTime + nCount;  

  187.   /* wait until the desired delay finish */  
  188.   while(timingdelay > LocalTime)
  189.   {     
  190.   }
  191. }

  192. /**
  193.   * @brief  Updates the system local time
  194.   * @param  None
  195.   * @retval None
  196.   */
  197. void Time_Update(void)
  198. {
  199.   LocalTime += SYSTEMTICK_PERIOD_MS;
  200. }

  201. /**
  202.   * @brief  Handles the periodic tasks of the system
  203.   * @param  None
  204.   * @retval None
  205.   */
  206. void System_Periodic_Handle(void)
  207. {
  208. #ifdef USE_LCD
  209.   
  210.   /* Update the LCD display and the LEDs status */
  211.   /* Manage the IP address setting */
  212.   Display_Periodic_Handle(LocalTime);
  213.   
  214. #endif
  215. ……………………

  216. …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼

所有資料51hei提供下載:
HTTP-TFTP-V1.1.rar (2.9 MB, 下載次數: 14)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日本精品免费 | 亚洲精品一区中文字幕乱码 | 美女国内精品自产拍在线播放 | 欧美一区二区三区在线观看视频 | 日本特黄a级高清免费大片 成年人黄色小视频 | 日韩精品网站 | 亚洲精品99 | 日本激情视频中文字幕 | 国产精品久久久久久久久免费高清 | 国产精品久久久久久久模特 | 午夜伦理影院 | 中文字幕成人免费视频 | 伊人亚洲| 99免费精品视频 | 欧美1—12sexvideos | 中文字幕免费视频 | 亚洲国产精品一区二区久久 | 午夜久久av | 国产精品一区二区精品 | 欧美中文字幕一区二区三区 | 亚洲一区高清 | 午夜影院在线观看 | 久久久夜夜夜 | 欧美日韩一区二区在线 | 男人天堂网址 | 黄视频免费在线 | 一区二区三区在线 | 欧 | 97超碰站 | 国产免费一区二区三区 | 夜操| 极品销魂美女一区二区 | 欧美一a一片一级一片 | h视频在线免费看 | 成人综合视频在线 | 国产精品永久免费 | 欧美精品一区二区三区在线 | 欧美日韩精品综合 | 久久在线 | 日日操视频 | 国产午夜高清 | 天天久久|