• 大小: 459KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: 其他
  • 标签: rt-thread  嵌入式  

资源简介

RT-Thread 是一款主要由中国开源社区主导开发的开源实时操作系统。实时线程操作系统不仅仅是一个单一的实时操作系统内核,它也是一个完整的应用系统,包含了实时、嵌入式系统相关的各个组件:TCP/IP协议栈,文件系统,libc接口,图形用户界面等。性能优于一般的ucos-ii系统。

资源截图

代码片段和文件信息

/*
 * File      : app.c
 * This file is part of RT-Thread RTOS
 * COPYRIGHT (C) 2006 RT-Thread Development Team
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://openlab.rt-thread.com/license/LICENSE
 *
 * Change Logs:
 * Date           Author       Notes
 * 2009-01-05     Bernard      the first version
 */

/**
 * @addtogroup STM32
 */
/*@{*/

#include 
#include 

char thread1_stack[0x120];
char thread2_stack[0x120];

struct rt_thread thread1;
struct rt_thread thread2;

void thread1_entry(void* parameter)
{
rt_uint32_t i = 0;

while (1)
{
rt_kprintf(“thread1 --> %d\n“ ++i);
rt_thread_delay(100);
}
}

/* UART received msg structure */
struct rx_msg
{
rt_device_t dev;
rt_size_t size;
};

/* message queue for Rx */
static rt_mq_t rx_mq;
static char uart_rx_buffer[64];

rt_err_t uart_input(rt_device_t dev rt_size_t size)
{
struct rx_msg msg;
msg.dev  = dev;
msg.size = size;

/* send message to message queue */
rt_mq_send(rx_mq &msg sizeof(struct rx_msg));

return RT_EOK;
}

void thread2_entry(void* parameter)
{
struct rx_msg msg;
int count = 0;

rt_device_t device write_device;
rt_err_t result = RT_EOK;

device = rt_device_find(“uart3“);
if (device != RT_NULL)
{
rt_device_set_rx_indicate(device uart_input);
rt_device_open(device RT_DEVICE_OFLAG_RDWR);
}

/* set write device */
write_device = device;

device = rt_device_find(“uart2“);
if (device != RT_NULL)
{
rt_device_set_rx_indicate(device uart_input);
rt_device_open(device RT_DEVICE_OFLAG_RDWR);
}

while (1)
{
result = rt_mq_recv(rx_mq &msg sizeof(struct rx_msg) 50);
if (result == -RT_ETIMEOUT)
{
/* rx timeout */
rt_kprintf(“Thread2 count:%d\n“ ++count);
// rt_device_write(device 0 &test_str[0] sizeof(test_str) - 1);
}

if (result == RT_EOK)
{
rt_uint32_t rx_length;

rx_length = (sizeof(uart_rx_buffer) - 1) > msg.size ?
msg.size : sizeof(uart_rx_buffer) - 1;

rx_length = rt_device_read(msg.dev 0 &uart_rx_buffer[0] rx_length);
uart_rx_buffer[rx_length] = ‘\0‘;

rt_kprintf(“%s“ &uart_rx_buffer[0]);
rt_device_write(msg.dev 0 &uart_rx_buffer[0] rx_length);

/* write to device:uart3 too */
if (write_device != RT_NULL)
rt_device_write(write_device 0 &uart_rx_buffer[0] rx_length);
}
}
}

#ifdef RT_USING_DFS
/* dfs init */
#include 
/* dfs filesystem:EFS filesystem init */
#include 
/* dfs Filesystem APIs */
#include 
#endif

/* thread phase init */
void rt_init_thread_entry(void *parameter)
{
/* Filesystem Initialization */
#ifdef RT_USING_DFS
{
/* init the device filesystem */
dfs_init();
/* init the efsl filesystam*/
efsl_init();

/* mount sd card fat partition 1 as root directory */
if (dfs_mount(“sd0“ 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2009-05-05 10:29  rt-thread 0.3.0\
     文件         721  2009-03-22 18:49  rt-thread 0.3.0\AUTHORS
     目录           0  2009-05-05 10:29  rt-thread 0.3.0\bsp\
     目录           0  2009-05-05 10:29  rt-thread 0.3.0\bsp\stm32f103vb\
     文件        3869  2009-05-05 10:29  rt-thread 0.3.0\bsp\stm32f103vb\application.c
     文件        6091  2009-04-29 20:14  rt-thread 0.3.0\bsp\stm32f103vb\board.c
     文件         566  2009-04-12 14:19  rt-thread 0.3.0\bsp\stm32f103vb\board.h
     文件        9403  2009-05-04 07:01  rt-thread 0.3.0\bsp\stm32f103vb\cortexm3_macro.s
     目录           0  2009-05-05 10:29  rt-thread 0.3.0\bsp\stm32f103vb\library\
     目录           0  2009-05-05 10:29  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\
     文件        2225  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\cortexm3_macro.h
     文件       18854  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_adc.h
     文件        6911  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_bkp.h
     文件       12279  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_can.h
     文件        1881  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_crc.h
     文件        9598  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_dac.h
     文件        2865  2009-05-04 20:17  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_dbgmcu.h
     文件       17974  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_dma.h
     文件        5776  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_exti.h
     文件       13996  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_flash.h
     文件       18005  2009-05-04 20:17  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_fsmc.h
     文件       14820  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_gpio.h
     文件       15693  2009-05-04 20:17  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_i2c.h
     文件        3414  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_iwdg.h
     文件        3200  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_lib.h
     文件      500262  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_map.h
     文件       19198  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_nvic.h
     文件        3865  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_pwr.h
     文件       14783  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_rcc.h
     文件        3619  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_rtc.h
     文件       18326  2008-09-21 15:16  rt-thread 0.3.0\bsp\stm32f103vb\library\inc\stm32f10x_sdio.h
............此处省略166个文件信息

评论

共有 条评论