找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3020|回复: 2
收起左侧

FreeRTOS+lwip for GD32450单片机源码下载

[复制链接]
ID:433495 发表于 2018-11-26 16:08 | 显示全部楼层 |阅读模式
FreeRTOS+lwip for GD32450
  This demo is based on the GD32450I-EVAL board. On the board,the Tamper key
connected to PC13 and the LED1 connected to PE2. It provides a description to
use the key to control the LED by the polling mode. The user can toggle the output
state of LED1 by pressing the Tamper key.
0.png

单片机源程序如下:
  1. /*!
  2.     \file  main.c
  3.     \brief GPIO keyboard polling demo
  4. */

  5. /*
  6.     Copyright (C) 2016 GigaDevice

  7.     2016-10-19, V1.0.0, demo for GD32F4xx
  8. */

  9. #include "gd32f4xx.h"
  10. #include "gd32f450i_eval.h"
  11. #include "systick.h"
  12. #include "stdio.h"
  13. #include "gd25qxx.h"
  14. #include "ff.h"
  15. #include "mylog.h"
  16. #include "stdlib.h"

  17. uint32_t flash_id = 0;
  18. #define SFLASH_ID                0xC84013 //0xC84015
  19. #define FLASH_WRITE_ADDRESS      0x000000
  20. #define FLASH_READ_ADDRESS       FLASH_WRITE_ADDRESS

  21. char *gpBuff = NULL;
  22. int main(void)
  23. {
  24.         int32_t i, j, is_successful;
  25.         char szItem[256];
  26.         
  27.         //gpBuff = (char *)malloc(1000);
  28.         
  29.     //gd_eval_key_init(KEY_TAMPER,KEY_MODE_GPIO);
  30.         gd_eval_key_init(KEY_TAMPER, KEY_MODE_EXTI);
  31.     systick_config();
  32.     gd_eval_gpio_init(LED1);
  33.         //gd_eval_gpio_init(BUZZER1);
  34.         //gd_eval_gpio_init(RELAY1);
  35.         gd_eval_gpio_init(WTN6170);
  36.         
  37.         gd_eval_gpio_on(LED1);
  38.         //gd_eval_gpio_off(BUZZER1);
  39.         //gd_eval_gpio_off(RELAY1);
  40.         delay_1ms(300);
  41.         //gd_eval_gpio_on(BUZZER1);
  42.         //gd_eval_gpio_on(RELAY1);
  43.         
  44.     /* USART interrupt configuration */
  45.     //nvic_irq_enable(USART0_IRQn, 0, 0);        
  46.         nvic_irq_enable(UART3_IRQn, 0, 0);        
  47.     /* configure EVAL_COM1 */
  48.         //gd_eval_com_init(EVAL_COM0);
  49.     gd_eval_com_init2(com3);
  50.     /* enable USART0 receive interrupt */
  51.     usart_interrupt_enable(EVAL_COM3, USART_INTEN_RBNEIE);
  52.     /* enable USART0 transmit interrupt */
  53.     //usart_interrupt_enable(EVAL_COM3, USART_INTEN_TBEIE);
  54.         
  55.         get_chip_serial_num();
  56.         /* output a message on hyperterminal using printf function */
  57.     LogInfo("\r\n Application start! chipID:%X%X%X SHORT:%d, INT:%d, LONG:%d, QWORD:%d\r\n", _gChipID[2], _gChipID[1], _gChipID[0],
  58.                 sizeof(short), sizeof(int), sizeof(long), sizeof(long long));
  59.         sprintf(szItem, "chipID:%X-%X-%X\r\n", _gChipID[2], _gChipID[1], _gChipID[0]);
  60.         LogInfo("%s", szItem);
  61.         
  62.     //configure SPI4 GPIO and parameter
  63.     spi_flash_init();
  64. //    /* get flash id */
  65. //    flash_id = spi_flash_read_id();
  66. //    LogInfo("\r\nThe Flash_ID:0x%X,%d\r\n\r\n", flash_id, sizeof(FATFS));

  67. //    //flash id is correct
  68. //    if(SFLASH_ID == flash_id) {
  69. //        LogInfo("\r\nWrite to tx_buffer:\r\n\r\n");

  70. //        /* printf tx_buffer value */
  71. //        for(i = 0; i < BUFFER_SIZE; i++){
  72. //            tx_buffer[i] = i;
  73. //            LogInfo("0x%02X ",tx_buffer[i]);

  74. //            if(15 == i%16)
  75. //                LogInfo("\r\n");
  76. //        }

  77. //        LogInfo("\r\nrRead from rx_buffer:\r\n\r\n");
  78. //        /* erase the specified flash sector */
  79. //        spi_flash_sector_erase(FLASH_WRITE_ADDRESS);

  80. //        /* write tx_buffer data to the flash */
  81. //        //qspi_flash_buffer_write(tx_buffer,FLASH_WRITE_ADDRESS,256);
  82. //                spi_flash_buffer_write(tx_buffer,FLASH_WRITE_ADDRESS,256);               
  83. //        delay_1ms(10);
  84. //               
  85. //        /* read a block of data from the flash to rx_buffer */
  86. //        //qspi_flash_buffer_read(rx_buffer,FLASH_READ_ADDRESS,256);
  87. //                spi_flash_buffer_read(rx_buffer,FLASH_READ_ADDRESS,256);

  88. //        /* printf rx_buffer value */
  89. //        for(i = 0; i < BUFFER_SIZE; i ++){
  90. //            LogInfo("0x%02X ", rx_buffer[i]);
  91. //            if(15 == i%16)
  92. //                LogInfo("\r\n");
  93. //        }

  94. //        if(ERROR == memory_compare(tx_buffer,rx_buffer,256)){
  95. //            LogInfo("\r\nErr:Data Read and Write aren't Matching.\r\n");
  96. //            is_successful = 1;
  97. //        }
  98. //    }else{
  99. //        /* spi flash read id fail */
  100. //        LogInfo("\r\nSPI Flash: Read ID Fail!\r\n");
  101. //    }
  102.         
  103.         //spi_flash_bulk_erase();
  104.         delay_1ms(100);
  105.         testFatfs_ram();
  106.         testFatfs_flash();
  107.         
  108.     while(1){
  109.                 gd_eval_gpio_off(UART3_CTRL);
  110. //        if(RESET == gd_eval_key_state_get(KEY_TAMPER)){
  111. //            /* delay 100ms for software removing jitter */
  112. //            delay_1ms(100);
  113. //            if(RESET == gd_eval_key_state_get(KEY_TAMPER)){
  114. //                gpio_bit_write(LED1_GPIO_PORT, LED1_PIN, (bit_status)((1 - gpio_output_bit_get(LED1_GPIO_PORT, LED1_PIN))));
  115. //            }
  116. //        }
  117.     }
  118. }

  119. /* retarget the C library printf function to the USART */
  120. int fputc(int ch, FILE *f)
  121. {
  122.         gd_eval_gpio_on(UART3_CTRL);
  123.     usart_data_transmit(EVAL_COM3, (uint8_t)ch);
  124.     while(RESET == usart_flag_get(EVAL_COM3, USART_FLAG_TBE));
  125.         //gd_eval_gpio_off(UART3_CTRL);
  126.         
  127.     return ch;
  128. }
复制代码

所有资料51hei提供下载:
GD32450i-EVAL(20180913).rar (2.19 MB, 下载次数: 89)
回复

使用道具 举报

ID:439931 发表于 2018-12-5 12:36 | 显示全部楼层
systick.c应该是移植一定要修改的一个文件。
回复

使用道具 举报

ID:169559 发表于 2024-2-3 15:40 | 显示全部楼层
已下载,谢谢分享!!!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表