3399 views|2 replies

266

Posts

0

Resources
The OP
 

【GD32E503 Review 03】 Porting FreeRTOS to GD32E503 in 5 minutes [Copy link]

 This post was last edited by caizhiwei on 2021-1-19 22:17

1. By utilizing the powerful functions of MDK5, FreeRTOS can be quickly ported.

First, open the Pack toolkit of MDK and check the FreeRTOS middleware:

After this, there will definitely be 3 errors in the compilation, and the three functions have been defined repeatedly:

The following three interfaces are defined in FreeRTOSConfig.h:

/* Map the FreeRTOS port interrupt handlers to their CMSIS standard names. */
#define xPortPendSVHandler                    PendSV_Handler
#define vPortSVCHandler                       SVC_Handler
#define xPortSysTickHandler                   SysTick_Handler

In gd32e50x_it.c, you just need to block these functions.

/*!
    \brief      this function handles SVC exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
//void SVC_Handler(void)
//{
//}

/*!
    \brief      this function handles DebugMon exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
void DebugMon_Handler(void)
{
}

/*!
    \brief      this function handles PendSV exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
//void PendSV_Handler(void)
//{
//}

/*!
    \brief      this function handles SysTick exception
    \param[in]  none
    \param[out] none
    \retval     none
*/
//void SysTick_Handler(void)
//{
//    delay_decrement();
//}

In the third step, we add our task creation function:

#include "systick.h"

#include "gd32e503v_eval.h"
#include "gd32e503v_lcd_eval.h"

#include "bsp_touch.h"
#include "picture.h"

#include <stdio.h>

#include "FreeRTOS.h"
#include "task.h"


#define LED1_TASK_PRIO    ( tskIDLE_PRIORITY + 2 )

void LED1_task(void * pvParameters);



static void led_init(void)
{
    /* initialize the leds */
    gd_eval_led_init(LED1);
    gd_eval_led_init(LED2);
    gd_eval_led_init(LED3);
    gd_eval_led_init(LED4);

    /* close all of leds */
    gd_eval_led_off(LED1);
    gd_eval_led_off(LED2);
    gd_eval_led_off(LED3);
    gd_eval_led_off(LED4);
}


/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    //systick_config();

	led_init();
	
	 /* configure EVAL_COM0 */
    gd_eval_com_init(EVAL_COM0);

    /* configure TAMPER key */
    gd_eval_key_init(KEY_B, KEY_MODE_GPIO);
	
	printf("\r\nHello,eeworld!");
	

    /* configure the GPIO of SPI touch panel */
    touch_panel_gpio_configure();

    //delay_1ms(50);  

	/* configure the EXMC access mode */
    exmc_lcd_init();	
    /* initialize the LCD */
    lcd_init();

    /* clear the LCD screen */
    lcd_clear(LCD_COLOR_WHITE);

	uint8_t len_s;
	char *str;
	uint16_t i;
	
	char_format_struct char_format;
	
	char error_string[]="Hello,EEWORLD!";
	
    /* draw character on LCD screen */
    len_s = sizeof(error_string)-1;
    str = error_string;
    
 
// 	/* configure char format */
//    char_format.char_color = LCD_COLOR_RED;
//    char_format.bk_color = LCD_COLOR_WHITE;
//    char_format.direction = CHAR_DIRECTION_VERTICAL;
//    char_format.font = CHAR_FONT_8_16; 
//	
//    for (i = 0; i < len_s; i++)
//	{
//        lcd_char_display((8*i), 100 + 24, *str++, char_format);
//    }
	

	
	 /* configure char format */
    char_format.char_color = LCD_COLOR_BLUE;
    char_format.bk_color = LCD_COLOR_WHITE;
    char_format.direction = CHAR_DIRECTION_VERTICAL;
    char_format.font = CHAR_FONT_16_24; 
	
    for (i = 0; i < len_s; i++)
	{
        lcd_char_display((16*i), 10, *str++, char_format);
    }
	

	/* 设置优先级分组为4,16个优先级全是抢占优先级 */
    nvic_priority_group_set(NVIC_PRIGROUP_PRE4_SUB0);
	
	
	xTaskCreate(LED1_task, "LED1", configMINIMAL_STACK_SIZE, NULL, LED1_TASK_PRIO, NULL);
	
	/* start scheduler */
    vTaskStartScheduler();
	
    while(1){
    }
	
}





void LED1_task(void * pvParameters)
{  
    for( ;; ){
        /* toggle LED2 each 500ms */
        gd_eval_led_toggle(LED1);;
        vTaskDelay(100);
    }
}


Finally, the compilation is OK, the download is run, the LED starts flashing, and the OS is running!

Isn’t it very simple? There is no complicated adding of various files to the project and so on.

Welcome to communicate more~

This post is from Domestic Chip Exchange

Latest reply

Awesome! The transplant is really fast, Liu Pi Liu Pi, I will try it when the time comes! Hehe   Details Published on 2021-1-20 15:19

赞赏

1

查看全部赞赏

Personal signature

gitee/casy

 
 

1942

Posts

2

Resources
2
 

Awesome! The transplant is really fast, Liu Pi Liu Pi, I will try it when the time comes! Hehe

This post is from Domestic Chip Exchange

Comments

Communicate more and learn and improve together  Details Published on 2021-1-21 08:56
 
 
 

266

Posts

0

Resources
3
 
w494143467 posted on 2021-1-20 15:19 Awesome! The transplant is really fast, Liu Pi Liu Pi, I will try it when the time comes! Hehehe

Communicate more and learn and improve together

This post is from Domestic Chip Exchange
Personal signature

gitee/casy

 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list