/********************************
名称:vuart.c
作者:杨华碧
********************************/
//*********************宏定义*************************
//***************************************************
梦见钓了好多鱼是什么意思#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/fs.h>
#include<linux/init.h>
#include<linux/delay.h>
#include<asm/irq.h>
#include<mach/regs-gpio.h>
#include<mach/hardware.h>
#include<linux/device.h>
#define DEVICE_NAME "EmbedSky-vuart"
#define VUART_MAJOR 234//231
#define IOCTL_VUART_ON 1
#define IOCTL_VUART_OFF 0
#define BaudRate 115200 //波特率
//***************************************************
//***********************变量定义*********************
/
/***************************************************
static unsigned int baudrate_temp;
static unsigned long vuart_table[]=
{
S3C2410_GPB5,
S3C2410_GPB6,
S3C2410_GPB7,
S3C2410_GPB8,
S3C2410_GPG13,
S3C2410_GPG14,
};
static unsigned int vuart_cfg_table[]=
{
S3C2410_GPB5_OUTP,
S3C2410_GPB6_OUTP,
S3C2410_GPB7_OUTP,
S3C2410_GPB8_OUTP,
S3C2410_GPG13_OUTP, 胖子烧饼
管理学名词解释
S3C2410_GPG14_OUTP,
};
//***************************************************
//********************功能函数*************************
/
/***************************************************
//延时函数
static void vuart_delay(unsigned int t)
{
非洲纬度位置 volatile unsigned int t1,t2;
for(t1=0;t1<t;t1++)
for(t2=0;t2<35;t2++);
}
//打开文件函数
static int EmbedSky_vuart_open(struct inode *inode,struct file *file)
{
int i;
for(i=0;i<6;i++)
{
s3c2410_gpio_cfgpin(vuart_table[i],vuart_cfg_table[i]);
}
return 0;
}
//模拟串口读写函数:cmd 0为发送,1为接收,arg 要发送的数
static int EmbedSky_vuart_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned char arg)
{
int k=0;
unsigned char da;
//发送
if(cmd == 0)
{
da = arg;
资本公积用途 s3c2410_gpio_tpin(vuart_table[5],1);
vuart_delay(1000000/BaudRate);
s3c2410_gpio_tpin(vuart_table[5],0);中央空调家用优缺点
vuart_delay(1000000/BaudRate);
for(k=0;k<8;k++)
{
if(da & 0x01)
{
s3c2410_gpio_tpin(vuart_table[5],1);
}
el
{
s3c2410_gpio_tpin(vuart_table[5],0);
}
vuart_delay(1000000/BaudRate);
da = da>>1;
}
s3c2410_gpio_tpin(vuart_table[5],1);
}
}
//***************************************************
//***********************注册处理*********************
//***************************************************
static struct file_operations EmbedSky_vuart_fops=
{
.owner = THIS_MODULE,
.open = EmbedSky_vuart_open,
.ioctl = EmbedSky_vuart_ioctl,
};
static char __initdata banner[]="TQ2440/SKY2440 VUART,(c)2008,bedsky\n";
static struct class *vuart_class;
static int __init EmbedSky_vuart_init(void)
{
int ret;
printk(banner);
ret = register_chrdev(VUART_MAJOR,DEVICE_NAME,&EmbedSky_vuart_fops);
if(ret<0)
{
printk(DEVICE_NAME" can't register major number\n");
return ret;
}
vuart_class = class_create(THIS_MODULE,DEVICE_NAME);
if(IS_ERR(vuart_class))
{
printk("Err: failed in EmbedSky-vuart class.\n");
return -1;
}
device_create(vuart_class,NULL,MKDEV(VUART_MAJOR,0),NULL,DEVICE_NAME);
printk(DEVICE_NAME" initialized\n");
return 0;
}
static void __exit EmbedSky_vuart_exit(void)
{
unregister_chrdev(VUART_MAJOR,DEVICE_NAME);
device_destroy(vuart_class,MKDEV(VUART_MAJOR,0));
白马非马的故事 class_destroy(vuart_class);
printk(DEVICE_NAME" EmbedSky_vuart_exit\n");
}
module_init(EmbedSky_vuart_init);
module_exit(EmbedSky_vuart_exit);
//***************************************************
4月20号是什么星座的
MODULE_AUTHOR("bedsky");
MODULE_DESCRIPTION("TQ2440/SKY2440 VUART Driver");
MODULE_LICENSE("GPL");