STM32F429IG 运行 RT-Thread

  •  RT-Thread 运行在STM32F429IG(硬件情况)

  • 代码情况

/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2019-08-015    xp          今天日本投降74周年
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>

/* defined the LED0 pin: PB1 */
#define LED0_PIN    GET_PIN(H, 10)
/**
 * 多线程测试************
 * 1.线程1 打印 这个是现场1
 * 2.线程2 打印 这个是现场2
*/
/*线程1是静态线程*/
#define THREAD_PRIORITY 25
#define THREAD_STACK_SIZE 512
#define THREAD_TIMESLICE 5
static rt_thread_t tid1 = RT_NULL;
/*线程1 入口函数*/
static void thread1_entry(void *hhh)
{
  rt_uint32_t count =6;
  while(count--)
  {
    rt_kprintf("thread1 >>>>>>>>count:%d\n",count);
    rt_thread_mdelay(500);
		
  }
	rt_kprintf("thread 1 die\n");
}
ALIGN(RT_ALIGN_SIZE)
static char thread2_stack[1024];
static struct rt_thread thread2;
static void thread2_entry(void *hhh)
{
  rt_uint32_t count = 0 ;
  for(count=0;count<3;count++)
  {
    rt_kprintf("thread2 >>>>>>>>:count%d\n",count);
  }
  rt_kprintf("thread2 die\n");

}
int main(void)
{
    int count = 0;
    /* set LED0 pin mode to output */
    rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
		rt_pin_write(LED0_PIN,PIN_HIGH);

  //创建线程1  静态线程使用create
    tid1 = rt_thread_create("thread1",thread1_entry,RT_NULL,THREAD_STACK_SIZE,
                            THREAD_PRIORITY,THREAD_TIMESLICE);
    if( tid1 != RT_NULL)
    rt_thread_startup(tid1);

    //创建线程2   动态创建线程 使用init
    rt_thread_init(&thread2,
                    "thread2",
                    thread2_entry,
                    RT_NULL,
                    &thread2_stack,
                    sizeof(thread2_stack),
                    THREAD_PRIORITY-1,
                    THREAD_TIMESLICE);
    rt_thread_startup(&thread2);

    return RT_EOK;
}
  •  运行效果:

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值