⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 基于STM32F107的UDP服务器程序
💻 C
字号:
/**
  ******************************************************************************
  * @file    main.c
  * @author  ARMJISHU Team
  * @version V1.0.0
  * @date    11/20/2009
  * @brief   Main program body
  ******************************************************************************
  *
  * <h2><center>&copy; COPYRIGHT 2009 ARMJISHU</center></h2>
  */

/* Includes ------------------------------------------------------------------*/
#include "stm32_eth.h"
#include "netconf.h"
#include "main.h"
#include <stdio.h>
#include "Udp_Api.h"
#include "spi_flash.h"
#include "GData.h"
/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/
#define SYSTEMTICK_PERIOD_MS  10


const u8 SizeOfInfor=9;
const u16 NumInfor=150; //150*9Bytes=1350Bytes;
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
__IO uint32_t LocalTime = 0; /* this variable is used to create a time reference incremented by 10ms */

extern __IO uint32_t TimingDelay;
volatile TestStatus TransferStatus1 = FAILED;
__IO uint32_t FlashID = 0;
__IO uint32_t DeviceID = 0;
u8 Tx_infor[9]={0,1,7,13,3,14,23,49,30}; 
u8 Rx_infor[1500]; 

/* Private function prototypes -----------------------------------------------*/
void System_Periodic_Handle(void);
TestStatus Buffercmp(u8* pBuffer1, u8* pBuffer2, u16 BufferLength);

void Delay_ARMJISHU(__IO uint32_t nCount)
{
  for (; nCount != 0; nCount--);
}


/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  u16 i=0;												 
  /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC) 
        and STM3210C-EVAL resources */
  System_Setup();	
             
  /* Initilaize the LwIP satck */
  LwIP_Init();
  Udp_Api_init();

  SPI_FLASH_Init();	   
   
  SPI_FLASH_SectorErase(FLASH_Sector1ToErase);
  for(;i<NumInfor;i++)
  {
      SPI_FLASH_BufferWrite(Tx_infor, FLASH_WriteAddress+SizeOfInfor*i, SizeOfInfor);
	  Delay_ARMJISHU(0xfff);
  }	    
  SPI_FLASH_BufferRead(Rx_infor, FLASH_ReadAddress,NumInfor*SizeOfInfor);

  while (1)
  {    
    /* Periodic tasks */
   System_Periodic_Handle(); 
  }
}

/**
  * @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)
{
  /* Update the LCD display and the LEDs status */
  /* Manage the IP address setting */
  Display_Periodic_Handle(LocalTime);  //显示新的IP地址,留着调试用
  
  /* LwIP periodic services are done here */
  LwIP_Periodic_Handle(LocalTime);
}
/*******************************************************************************
* Function Name  : Buffercmp
* Description    : Compares two buffers.
* Input          : - pBuffer1, pBuffer2: buffers to be compared.
*                : - BufferLength: buffer's length
* Output         : None
* Return         : PASSED: pBuffer1 identical to pBuffer2
*                  FAILED: pBuffer1 differs from pBuffer2
*******************************************************************************/
//TestStatus Buffercmp(u8* pBuffer1, u8* pBuffer2, u16 BufferLength)
//{
//  while(BufferLength--)
//  {
//    if(*pBuffer1 != *pBuffer2)
//    {
//      return FAILED;
//    }
//
//    pBuffer1++;
//    pBuffer2++;
//  }
//
//  return PASSED;
//}

#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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -