【GD32L233C-START Review】3. Porting an operating system
[Copy link]
This post was last edited by ddllxxrr on 2022-1-22 22:13
Porting an operating system, this topic seems a bit strange. I hate porting anything. My ideal porting is to port it with just a click like RTX.
But this time the RTX chip is gray. I can't tick it at all.
I turned my attention to OSAL. Last time I worked hard on the timer interrupt for this purpose, but I found it very troublesome to migrate it online. It’s not that I can’t migrate it, but I’m afraid it will be unpleasant to use after I migrate it.
So I turned my attention to FREERTOS, which I felt was not too bad either, so I took several tests.
Suddenly I saw a netizen transplanting RT-THREAD NANO and I thought it was good, so I did it again. I specially recorded it.
1. Download PACK
https://www.rt-thread.org/download/mdk/RealThread.RT-Thread.3.1.5.pack
2. Double-click the downloaded file to install it on MDK.
3. At the green diamond, check the rt-thread core.
Fourth, shield and modify the interrupt it.h file:
//void HardFault_Handler(void)
//void PendSV_Handler(void)
5. Compile it and the error message is a section of EORR raw name, which is also blocked.
//#error "TODO 1: OS Tick Configuration."
At this time, the compilation is successful. In fact, the migration has been successful.
The following program is used to test whether it can be run:
#include "gd32l23x.h"
#include "systick.h"
#include "rtthread.h"
static rt_thread_t led1_thr = RT_NULL;
static void thread_led1_entry(void *parameter);
/*!
\brief main function
\param[in] none
\param[out] none
\retval none
*/
int main(void)
{
systick_config();
/* enable the LED GPIO clock */
rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_GPIOC);
/* configure LED GPIO pin */
gpio_mode_set(GPIOA, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_7 | GPIO_PIN_8);
gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_7 | GPIO_PIN_8);
gpio_mode_set(GPIOC, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, GPIO_PIN_6 | GPIO_PIN_7);
gpio_output_options_set(GPIOC, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_6 | GPIO_PIN_7);
/* reset LED GPIO pin */
gpio_bit_reset(GPIOA, GPIO_PIN_7 | GPIO_PIN_8);
gpio_bit_reset(GPIOC, GPIO_PIN_6 | GPIO_PIN_7);
led1_thr = rt_thread_create( "led1", /*????*/
thread_led1_entry,/*??????*/
RT_NULL,/*????????*/
256, /*?????*/
4 , /*?????*/
20); /*?????*/
rt_thread_startup(led1_thr);
while(1) {
// /* turn on LED1, turn off LED4 */
// gpio_bit_set(GPIOA, GPIO_PIN_7);
// gpio_bit_reset(GPIOC, GPIO_PIN_7);
// delay_1ms(500);
// /* turn on LED2, turn off LED1 */
// gpio_bit_set(GPIOA, GPIO_PIN_8);
// gpio_bit_reset(GPIOA, GPIO_PIN_7);
// delay_1ms(500);
// /* turn on LED3, turn off LED2 */
// gpio_bit_set(GPIOC, GPIO_PIN_6);
// gpio_bit_reset(GPIOA, GPIO_PIN_8);
// delay_1ms(500);
// /* turn on LED4, turn off LED3 */
// gpio_bit_set(GPIOC, GPIO_PIN_7);
// gpio_bit_reset(GPIOC, GPIO_PIN_6);
// delay_1ms(500);
rt_thread_mdelay(100);
}
}
static void thread_led1_entry(void *parameter)
{
while(1)
{
gpio_bit_toggle(GPIOC,GPIO_PIN_7);
rt_thread_mdelay(1000);
}
}
Just a light flashes, compiles and downloads, and the program runs normally.
|