头文件
#ifndef __HEAD_H__
#define __HEAD_H__
#define PHY_LED1_MODER 0X50006000
#define PHY_LED1_ODR 0X50006014
#define PHY_LED2_MODER 0x50007000
#define PHY_LED2_ODR 0x50007014
#define PHY_LED3_MODER 0x50006000
#define PHY_LED3_ODR 0x50006014
#define PHY_RCC 0X50000A28
#endif
demo1.c
#include
#include
#include
#include
#include
#include "head.h"
unsigned int major;
char kbuf[128]={};
//定义指针指向映射后的虚拟内存
unsigned int *vir_moder1;
unsigned int *vir_odr1;
unsigned int *vir_moder2;
unsigned int *vir_odr2;
unsigned int *vir_moder3;
unsigned int *vir_odr3;
unsigned int *vir_rcc;
//封装操作方法
int mycdev_open(struct inode *inode, struct file *file)
{
printk("%s:%s:%dn",__FILE__,__func__,__LINE__);
return 0;
}
ssize_t mycdev_read(struct file *file,服务器托管网 char *ubuf, size_t size, loff_t *lof)
{
printk("%s:%s:%dn",__FILE__,__func__,__LINE__);
int ret;
ret=copy_to_user(ubuf,kbuf,size);
if(ret)
{
printk("copy_to_user filedn");
return -EIO;
}
return 0;
}
ssize_t mycdev_write(struct file *file, const char *ubuf, size_t size, 服务器托管网loff_t *lof)
{
printk("%s:%s:%dn",__FILE__,__func__,__LINE__);
int ret;
ret=copy_from_user(kbuf, ubuf,size);
if(ret)
{
printk("copy_from_user filedn");
return -EIO;
}
if (kbuf[1] == '0')
{
// 关灯逻辑
if (kbuf[0] == '1')
(*vir_odr1) &= (~(0X100
(*vir_moder1) |= (0X101
(*vir_odr1) &= (~(0X100
(*vir_moder2) |= (0X101
(*vir_odr2) &= (~(0X100
(*vir_moder3) |= (0X101
(*vir_odr3) &= (~(0X1
text.c
#include
#include
#include
#include
#include
#include
int main(int argc, char const *argv[])
{
char buf[128] = {0};
int fd = open("/dev/mychrdev", O_RDWR);
if (fd ");
fgets(buf,sizeof(buf),stdin);
buf[strlen(buf)-1] = '';
//调用write
write(fd, buf, sizeof(buf));
//memset(buf, 0, sizeof(buf));
//read(fd, buf, sizeof(buf));
//printf("buf:%sn",buf);
}
//调用close
close(fd);
return 0;
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
使用mysql 将数据迁移到pgsql 1. 直接使用在线的脚本转化器 sqllines online 地址 优点就是快速敏捷,在线编辑;缺点在于,有的转换可能不准,只有学习的意义.且在线工具如果粘贴的文本过大会很卡 且翻译不出来(可以下载它的客户端工…