⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello_world.c

📁 最新rtlinux内核源码
💻 C
字号:
/** rt_com test module
 *  ==================
 *
 * RT-Linux kernel module for communication across serial lines.
 *
 * Copyright (C) 2000 Jochen K黳per
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file License. if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307, USA.
 *
 * $Id: hello_world.c,v 1.1.1.1 2004/02/28 16:22:23 hofrat Exp $ */


#define __KERNEL__
#define __RT__
#define MODULE

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/version.h>

#include <rt_com.h>


/** Init module.
 *
 * Initialize and write to the serial port */
int init_module(void)
{
    char hello[] = "Hello World";
    
/*     if( 0 > rt_com_set_param( 0, 0, 0 ) ) */
/* 	return( -1 ); */
    if( 0 > rt_com_setup( 0, 9600, RT_COM_PARITY_NONE, 1, 8 ) )
	return( -1 );
    rt_com_write( 0, hello, sizeof( hello ) );
    printk( KERN_INFO "rt_com test: >>%s<< sent.\n", hello );
    return( 0 );
}



/** free all allocated resources */
void cleanup_module(void)
{
    rt_com_setup( 0, -1, 0, 0, 0 );
/*     rt_com_set_param( 0, -1, 0 ); */
    printk( KERN_INFO "rt_com test: finished\n");
}




/**
 * Local Variables:
 * mode: C
 * c-file-style: "Stroustrup"
 * End:
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -