附IAP遠程更新源代碼和說明文件
0.png (42.73 KB, 下載次數: 63)
下載附件
2018-3-13 02:11 上傳
0.jpg (44.69 KB, 下載次數: 76)
下載附件
2018-3-13 02:11 上傳
0.png (278.96 KB, 下載次數: 64)
下載附件
2018-3-13 02:12 上傳
單片機源程序如下:
- /* Includes ------------------------------------------------------------------*/
- #include "stm32_eth.h"
- #include "netconf.h"
- #include "main.h"
- #include "helloworld.h"
- #include "httpd.h"
- #include "tftpserver.h"
- #include "KEY.H"
- #include "stdio.h"
- #include "bkp.h"
- #include "LED.H"
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- #define SYSTEMTICK_PERIOD_MS 10
- #ifdef __GNUC__
- /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
- set to 'Yes') calls __io_putchar() */
- #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
- #else
- #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
- #endif /* __GNUC__ */
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- __IO uint32_t LocalTime = 0; /* this variable is used to create a time reference incremented by 10ms */
- uint32_t timingdelay;
- typedef void (*pFunction)(void);
- pFunction Jump_To_User_Application;
- uint32_t Jump_User_Address;
- /* Private function prototypes -----------------------------------------------*/
- void System_Periodic_Handle(void);
- void IAP_httpd_init(void);
- void IAP_tftpd_init(void);
- void MY_NVIC_Configuration(void);
- void NVIC_DeInit(void);
- void BKP_Configuration(void);
- void MCU_Reset(void);
- void EARES_SRAM(void);
- void NVIC_Configuration(void);
- /* Private functions ---------------------------------------------------------*/
- /**
- * @brief Main program.
- * @param None
- * @retval None
- */
-
- int main(void)
- {
- unsigned int g_bUpdateFlag = 0;
- NVIC_DeInit();
- RCC_DeInit();
- SystemInit();
- BKP_Configuration();
- NVIC_Configuration();
- SEI(); //開全局中斷
- g_bUpdateFlag = BKP_ReadBackupRegister(BKP_DR9); //讀取更新標志
- //if(!(KEY1 | KEY2 | KEY3 | KEY4)
- if(g_bUpdateFlag == 0x0) //不需要升級,
- {
- /* Check if valid stack address (RAM address) then jump to user application */
- if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
- {
- CLI(); //關閉總中斷,必須有、
- NVIC_DeInit();
- RCC_DeInit();
- /* Jump to user application */
- Jump_User_Address = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
- Jump_To_User_Application = (pFunction) Jump_User_Address;
- /* Initialize user application's Stack Pointer */
- __set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
- Jump_To_User_Application();
- while (1);
- }
- else
- {
- //printf("非法SRAM\n");
- }
- }
-
- else //初始化網絡模塊,等待用戶遠程登錄,更新固件
- {
- /* Setup STM32 system (clocks, Ethernet, GPIO, NVIC) and STM3210C-EVAL resources */
- BKP_WriteBackupRegister(BKP_DR9,0x00);// 標志已經下載了程序了
- System_Setup();
- /* Initilaize the LwIP satck ip地址設置,mac設置,*/
- LwIP_Init();
-
- IAP_httpd_init();
- /* Infinite loop */
- while (1)
- {
- /* Periodic tasks */
- System_Periodic_Handle();
- }
- }
- }
- void MCU_Reset(void)
- {
- __disable_fault_irq(); // STM32 軟復位
- NVIC_SystemReset();
- }
- PUTCHAR_PROTOTYPE
- {
- /* Place your implementation of fputc here */
- /* e.g. write a character to the USART */
- USART_SendData(USART2, (uint8_t) ch);
- /* Loop until the end of transmission */
- while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET)
- {}
- return ch;
- }
- /**
- * @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)
- {
- /* Update the LCD display and the LEDs status */
- /* Manage the IP address setting */
- Display_Periodic_Handle(LocalTime);
-
- /* LwIP periodic services are done here */
- LwIP_Periodic_Handle(LocalTime);
- }
- #ifdef USE_FULL_ASSERT
- ……………………
- …………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
智嵌以太網遠程更新.7z
(6.42 MB, 下載次數: 176)
2018-3-12 19:04 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|