树莓派系列教程汇总 树莓派系列教程汇总 目录 目录... 1 树莓派系列教程 1: 人生若只如初见... 3 树莓派系列教程 2: 树莓派烧写镜像... 5 树莓派系列教程 3: 访问树莓派 树莓派系列教程 4: 树莓派 raspi-config 配置 树莓派系列教程 5:l

Size: px
Start display at page:

Download "树莓派系列教程汇总 树莓派系列教程汇总 目录 目录... 1 树莓派系列教程 1: 人生若只如初见... 3 树莓派系列教程 2: 树莓派烧写镜像... 5 树莓派系列教程 3: 访问树莓派 树莓派系列教程 4: 树莓派 raspi-config 配置 树莓派系列教程 5:l"

Transcription

1 目录 目录... 1 树莓派系列教程 1: 人生若只如初见... 3 树莓派系列教程 2: 树莓派烧写镜像... 5 树莓派系列教程 3: 访问树莓派 树莓派系列教程 4: 树莓派 raspi-config 配置 树莓派系列教程 5:linux 常用命令以及 vi/vim 编辑器 树莓派教程系列 6: 文件共享 (samba) 树莓派系列教程 7: 如何点亮一个 LED 灯 ( 上 ) 树莓派系列教程 8 : 如何点亮一个 LED 灯 ( 下 ) wiringpi bcm python 树莓派系列教程 9: 按键 bcm wiringpi python 树莓派系列教程 10:I2C 启动 I2C i2c-tools

2 使用 i2c-tools 控制 PCF8574 IO 树莓派系列教程 11:I2C 编程 bcm wiringpi python 树莓派系列教程 12:I2C 总线控制 BMP 树莓派系列教程 13:Serial 串口 释放串口 使用 minicom 调试串口 串口编程 python 树莓派系列教程 14: 单总线控制 DS18B 树莓派系列教程 15: 红外遥控 树莓派系列教程 16:RTC 树莓派系列教程 17:PCF8591 AD/DA DAC ADC 树莓派系列教程 18:SPI

3 树莓派系列教程 1: 人生若只如初见 Raspberry Pi( 中文名为 树莓派, 简写为 RPi, 或者 RasPi/RPi) 是为学生计算机编程教育 而设计, 只有信用卡大小的卡片式电脑, 其系统基于 Linux 第一次接触树莓派的时候也是刚学 linux 系统 抱着玩玩的心态买了一块树莓派 B+, 刚拿到手的是有点和想象的不一样, 就只有一个盒子装在, 真的只有一张信用卡大小, 真的很吃惊 自己动手刷了一个系统启动起来的时候真的很神奇, 这小小的身板真的是五脏俱全, 一个便携的 mini pc. 然后就一发不可收拾, 玩得不亦乐乎 SSH 登陆,xrdp 远程桌面, 家庭影院,LAMP 服务器, SAMBA 服务器等等, 它不但是一个卡式电脑, 更重要的是它引出 40 个管脚 这就可以做更多的事情了 就让我们一起走进树莓派的世界 项目 A+ 型 B 型 B+ 型 2 代 B 型 SoC( 系统 Broadcom BCM2835(CPU,GPU DSP 和 SDRAM) Broadcom BCM2836 级芯片 ) CPU ARM1176JZF-S 核心 (ARM11 系列 )700MHz 单核 ARM Cortex-A7 900MHz 4 核 GPU( 图形处理器 ) Broadcom VideoCore IV, OpenGL ES 2.0, 1080p 30 h.264/mpeg-4 AVC 高清解码器 内存 256MB 512MB 1GB USB 2.0 1( 支持 USB hub 扩展 ) 2( 支持 USB hub 扩展 ) 4( 支持 USB hub 扩展 ) 视频输出 RCA 视频接口输出 ( 仅 1 代 B 型有此接口 ), 支持 PAL 和 NTSC 制式, 支持 HDMI (1.3 和 1.4), 分辨率为 640 x 350 至 1920 x 1200 支持 PAL 和 NTSC 制式 音频输出 3.5mm 插孔, HDMI( 高清晰度多音频 / 视频接口 ) SD 卡接口 Micro SD 卡接口标准 SD 卡接口 Micro SD 卡接口 网络介入 没有 ( 需通过 USB) 10/100 以太网接口 (RJ45 接口 ) 扩展接口 额定功率 未知, 但更低 700 毫安 ( 为 3.5 W) 600 毫安 ( 为 3.0 W) 1000 毫安 ( 为 5.0 W) 电源输入 5v, 通过 MicroUSB 或 GPIO 引脚 总体尺寸 mm mm 85 x 56 x 17 mm 操作系统 Debian GNU/Linux Fedora Arch Linux RISC OS 2 代 B 型还支持 Windows10 和 Snappy Ubuntu Core, 官方会持续更新以支持更多 操作系统, 敬请期待! 3

4 4

5 树莓派系列教程 2: 树莓派烧写镜像 树莓派没有硬盘, 取而代之的是 TF 卡 只需一个电源一张 TF 卡即可启动树莓派 1) 下载树莓派系统树莓派官网下载地址 : ( 可下载最新的 Raspbian 树莓派系统也可以在我们公司 wiki 上面下载我们配置过的系统 ) 2) 格式化 SD 卡插上 SD 卡到电脑, 使用 SDFormatter.exe 软件格式化 SD 卡 5

6 6

7 7

8 3) 烧写树莓系统 用 Win32DiskImager.exe 烧写镜像 选择要烧写的镜像, 点击 Write 进行烧写 4) 启动树莓派烧写完后把 SD 卡插入树莓派即可运行 树莓派 raspbian 系统 pi 用户密码默认为 raspberry ;root 权限密码为 raspberry 启动图形界面命令 startx 重启 sudo reboot 关机 sudo poweroff 5) 备份树莓派系统有的时候想装 win10 ubuntu kodi 等等系统玩玩, 但是只有一张卡, 又想保留现在的系统, 那么现在教你一个方法, 就是备份现在的系统 其实很简单, 看到这个图像必大家都明白了 先新建一个空白的.img 后缀的文件, 然后选择直接 read 就可以备份系统了, 到 8

9 时再重装就可以恢复了 9

10 树莓派系列教程 3: 访问树莓派 1) 外接 HDMI 显示器, 鼠标键盘如果把树莓派当作一个小电脑, 那么可以外接鼠标键盘操作树莓派, 通过 HDMI 连接显示器显示界面 2) 外接 LCD 显示屏如果你觉得抱着鼠标键盘麻烦, 那么你可以接 LCD 触摸屏, 触摸控制树莓派, 像平板一样玩 3) SSH 更常用的方式是通过 ssh 控制树莓派,putty,SecureCRT,SSH Secure Shell Client 等 SSH 软件 10

11 我个人更加喜欢用 xshell 软件 11

12 当然你也可以用手机安装 juicessh 这个软件通过 SSH 控制树莓派 4) 串口终端 如果树莓派没有连接网络, 又没有显示设备 你可以用串口登陆树莓派 你需要串口转 USB 模块将树莓派连接到电脑 本公司的 Pioneer 600 扩展板板载 UART TO USB 功能 通过 12

13 putty,xshell 等软件通过串口登陆树莓派 5) 通过远程桌面连接树莓派 在树莓派命令行下输入以下命令安装 xrdp sudo apt-get install xrdp 在 windows 附件中打开远程桌面连接树莓派 IP, 输入用户名密码, 就可以看到树莓派的界面了 13

14 14

15 树莓派系列教程 4: 树莓派 raspi-config 配置 1) 树莓派 raspi-config 设置 第一次使用树莓派的时候需要进行一些简单的配置, 在终端运行以下命令进入配置界面 sudo raspi-config 1 Expand Filesystem 扩展文件系统, 扩展整张 SD 卡空间作为根分区 2 Change User Password 改变默认 pi 用户的密码, 按回车后输入 pi 用户的新密码 3 Enable Boot to Desktop/Scratch 启动时进入的环境选择 1 Console Text console, requiring login(default) 启动时进入字符控制台, 需要进行登录 ( 默认项 ) 2 Desktop log in as user 'pi' at the graphical desktop 启动时进入 LXDE 图形界面的桌面 3 Scratch Start the Scratch programming environment upon boot 启动时进入 Scratch 编程环境 4 Internationalisation Options 国际化选项, 可以更改默认语言 I1 Change Locale 语言和区域设置 选中 zh-cn 然后回车 I2 Change Timezone 设置时区, 如果不进行设置,Pi 的时间就显示不正常 I3 Change Keyboard Layout 改变键盘布局 5 Enable Camera 启动 PI 的摄像头模块, 如果想启用, 选择 Enable, 禁用选择 Disable 就行了 6 Add to Rastrack 把你的 PI 的地理位置添加到一个全世界开启此选项的地图 7 Overclock 15

16 None 不超频, 运行在 700Mhz, 核心频率 250Mhz, 内存频率 400Mhz, 不增加电压 Modest 适度超频, 运行在 800Mhz, 核心频率 250Mhz, 内存频率 400Mhz, 不增加电压 Medium 中度超频, 运行在 900Mhz, 核心频率 250Mhz, 内存频率 450Mhz, 增加电压 2 High 高度超频, 运行在 950Mhz, 核心频率 250Mhz, 内存频率 450Mhz, 增加电压 6 Turbo 终极超频, 运行在 1000Mhz, 核心频率 500Mhz, 内存频率 600Mhz, 增加电压 6 8 Advanced Options 高级设置 A1 Overscan 是否让屏幕内容全屏显示 A2 Hostname 在网上邻居或者路由器能看到的主机名称 A3 Memory Split 内存分配, 选择给 GPU 多少内存 A4 SSH 是否运行 SSH 登录, 建议开户此选项, 以后操作 PI 方便, 有网络就行, 不用开屏幕了 A5 Device Tree 时候默认启动设备树 A6 SPI 是否默认启动 SPI 内核驱动 A7 I2C 是否默认启动 I2C 内核驱动 A8 Serial 是否默认启动串口调试 A9 Audio 选择声音默认输出到模拟口还是 HDMI 口 i 0 Auto 自动选 1 Force 3.5mm ('headphone') jack 强制输出到 3.5mm 模拟口 2 Force HDMI 强制输出到 HDMI A0 update 把 raspi-config 这个工具自动升级到最新版本 9 About raspi-config 关于 raspi-config 的信息 初次启动树莓派要设置 Internationalisation Options 选项 I1 Change Locale 设置语言, 默认为英文, 若想改中文, 须安装中文字体, 命令如下 : sudo apt-get update sudo apt-get install ttf-wqy-zenhei ttf-wqy-microhei 移动到屏幕底部, 用空格键选中 zh-cn.gbk GBK 和 zh_cn.utf-8 UTF-8 两项, 然后按回车, 然后默认语言选中 zh-cn.utf-8, 然后回车 安装拼音输入法 sudo apt-get install scim-pinyin I2 change Timezone 设置时区, 选择 Asia( 亚洲 ) 再选择 shanghai( 上海 ) I3 Change Keyboard Layout 改变键盘布局 2) wifi 设置有线什么的都 OUT 了, 无线才是王道, 有 wifi 的日子才是好日子 本人从来是都一个电源加一个无线网卡玩转树莓派 运行以下命令查看网卡信息, 若有 wlan0 则已经识别无线网卡 ifconfig 打开配置文件并修改 16

17 sudo vi /etc/network/interfaces 注释掉 wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf 添加下面两句 wpa-ssid waveshare_1013 # 你要链接的 wifi ssid wpa-psk waveshare #wpa 连接密码 若要设置静态 IP 地址则修改如下 重启网卡使设置生效 sudo service networking restart 17

18 树莓派系列教程 5: linux 常用命令以及 vi/vim 编辑器 1) linux 常用命令 树莓派系统多都是基于 Linux, 而 Linux 多数情况下都是在命令行下输入命令操作 上图为 linux 常用命令 这里我就不一一介绍了, 只是简单介绍几条命令 18

19 查看操作系统版本 cat /proc/version 查看主板版本 cat /proc/cpuinfo 查看 SD 存储卡剩余空间 df -h 查看 ip 地址 ifconfig 压缩 :tar -zcvf filename.tar.gz dirname 解压 :tar -zxvf filename.tar.gz linux 系统常用 apt(advanced Package Tool) 高级软件工具来安装软件 sudo apt-get install xxx # 安装软件 sudo apt-get update # 更新软件列表 sudo apt-get upgrade # 更新已安装软件 sudo apt-get remove xxx # 删除软件 例如 : 运行以下两个命令安装 sl,cmatrix sudo apt-get install sl sudo apt-get install cmatrix 安装完成后运行以下两个命令 sl cmatrix ( 别问我这两个软件有什么用, 我是不会告诉你的 试一下你就知道了 ) sudo 是增加用户权限, 在命令行前面添加 sudo 相当于以 root 用户运行这条命令 可以运行 sudo su 直接切换到 root 用户操作 我个人喜欢在普通用户登陆 "$" 为普通用户,"#" 为超级用户 pi@raspberrypi ~ $ sudo su root@raspberrypi:/home/pi# su pi pi@raspberrypi ~ $ 2) vi/vim 编辑器 linux 常用的编辑工具有 nano,vi/vim(vim 是 vi 的增强版 ) 等 新手建议使用 nano 编辑器, 简单易用 我个人则更加喜欢使用 vi/vim 编辑器, 如果要使用 vi 编辑器首先得重新安装 vi 编辑器, 因为树莓派自带的编辑器比较坑, 谁用谁知道 首先删除默认 vi 编辑器 sudo apt-get remove vim-common 然后重装 vim sudo apt-get install vim 19

20 为方便使用还得在 /etc/vim/vimrc 文件后面添加下面三句 set nu # 显示行号 syntax on # 语法高亮 set tabstop=4 #tab 退四格效果如下 vi 有 3 个模式 : 插入模式 命令模式 低行模式 插入模式 : 在此模式下可以输入字符, 按 ESC 将回到命令模式 命令模式 : 可以移动光标 删除字符等 低行模式 : 可以保存文件 退出 vi 设置 vi 查找等功能( 低行模式也可以看作是命令模式里 20

21 的 ) 打开文件 保存 关闭文件 (vi 命令模式下使用 ): vi filename // 打开 filename 文件 :w // 保存文件 :q // 退出编辑器, 如果文件已修改请使用下面的命令 :q! // 退出编辑器, 且不保存 :wq // 退出编辑器, 且保存文件插入文本或行 (vi 命令模式下使用, 执行下面命令后将进入插入模式, 按 ESC 键可退出插入模式 ): a // 在当前光标位置的右边添加文本 i // 在当前光标位置的左边添加文本 A // 在当前行的末尾位置添加文本 I // 在当前行的开始处添加文本 ( 非空字符的行首 ) O // 在当前行的上面新建一行 o // 在当前行的下面新建一行 R // 替换 ( 覆盖 ) 当前光标位置及后面的若干文本 J // 合并光标所在行及下一行为一行 ( 依然在命令模式 ) 删除 恢复字符或行 (vi 命令模式下使用 ): x // 删除当前字符 nx // 删除从光标开始的 n 个字符 dd // 删除当前行 ndd // 向下删除当前行在内的 n 行 u // 撤销上一步操作 U // 撤销对当前行的所有操作复制 粘贴 (vi 命令模式下使用 ): yy // 将当前行复制到缓存区 nyy // 将当前行向下 n 行复制到缓冲区 yw // 复制从光标开始到词尾的字符 nyw // 复制从光标开始的 n 个单词 y^ // 复制从光标到行首的内容 y$ // 复制从光标到行尾的内容 21

22 p // 粘贴剪切板里的内容在光标后 P // 粘贴剪切板里的内容在光标前 设置行号 (vi 命令模式下使用 ) :set nu // 显示行号 :set nonu // 取消显示行号新手使用 vi 可能不习惯, 慢慢的被虐多了就觉习惯了 顺便提醒一句,linux 系统是区分大小写的 另附 vi/vim 键盘图一张 22

23 树莓派教程系列 6: 文件共享 (samba) 我们使用树莓派的时候经常要在 windows 和树莓派之间进行文件传输, 使用 samba 服务可实现文件共享 在 windows 的网上邻居即可访问树莓派文件系统, 非常方便 1) 运行以下命令安装 samba 软件 sudo apt-get install samba samba-common-bin 2) 安装完成后, 修改配置文件 /etc/samba/smb.conf sudo vi /etc/samba/smb.conf 下面的配置是让用户可以访问自己的 home 目录 a) 开启用户认证, 找到 ##### Authentication #####, 将 # security = user 的 # 号去掉 b) 配置每个用户可以读写自己的 home 目录, 在 [homes] 节中, 把 read only = yes 改为 read only = no 3) 重启 samba 服务 sudo /etc/init.d/samba restart 或 sudo service samba restart 4) 添加默认用户 pi 到 samba sudo smbpasswd -a pi 输入密码确定即可 5) 访问树莓派文件使用文件浏览器打开 ip 地址 \\ \pi (ip 地址改为树莓派 IP 地址 ), 输入用户密码, 则可以访问树莓派 home 目录 在 windows 网络中你会发现多了台电脑 RASPBERRYPI, 以后直接点击即可访问树莓派存储器, 或在 windows 开始菜单中运行打开 \\RASPBERRYPI. ( 提示 : 如果树莓派开机启动 Samba 服务器, 而又不知道树莓派 IP, 可以在 windows 命令 23

24 行中 ping RASPBERRYPI 返回树莓派的 ip 地址 ) 24

25 树莓派系列教程 7: 如何点亮一个 LED 灯 ( 上 ) 树莓派的强大之处不单单是因为它是一个卡式电脑, 更重要的是个引出 GPIO, 可以通过编程控制 GPIO 管脚输出高低电平 学过 51 单片机的孩童第一个程序就是点亮一个 LED 灯, 从此就点亮我们的人生, 从此 code 奸我千百遍, 我待 code 如初见 今天我们就来探讨一下树莓派点亮一个 LED 灯的 n 种方法 从这一章开始我们将教大家如何在树莓派编程, 在学习树莓派编程前, 你需要一块树莓扩展板 本教程是 WaveShare 设计的 Pioneer600 扩展板为例 Pioneer600 扩展板包括了 GPIO,I2C,SPI,Serial 等接口的器件, 是学习树莓派编程很好的扩展板 关于 Pioneer600 扩展的详细资料看网站 1) 通过 shell 脚本操作 GPIO # 进入 GPIO 目录 cd /sys/class/gpio # 运行 ls 命令查看 gpio 目录中的内容, 可以查看到 export gpiochip0 unexport 三个文件 sudo ls # GPIO 操作接口从内核空间暴露到用户空间 # 执行该操作之后, 该目录下会增加一个 gpio26 文件 echo 26 > export # 进入 GPIO26 目录, 该目录由上一步操作产生 cd gpio26 # 运行 ls 查看 gpio26 目录中的内容, 可查看到的内容如下 # active_low direction edge power subsystem uevent value sudo ls # 设置 GPIO26 为输出方向 echo out > direction # BCM_GPIO26 输出逻辑高电平,LED 点亮 echo 1 > value # BCM_GPIO26 输出逻辑低电平,LED 熄灭 echo 0 > value # 返回上一级目录 cd.. # 注销 GPIO20 接口 echo 20> unexport 注 :echo 命令为打印输出, 相当于 C 语言的 printf 函数的功能,> 符号为 IO 重定向符号, IO 重定向是指改变 linux 标准输入和输出的默认设备, 指向一个用户定义的设备 例如 echo 20 > export 便是把 20 写入到 export 文件中 25

26 我们可以编写成 shell 脚本的形式运行 vi led.sh 用 vi 新建 led.sh 文件, 添加以下程序并保存退出 #! /bin/bash echo Exporting pin $1 echo $1 > /sys/class/gpio/export echo Setting direction to out. echo out > /sys/class/gpio/gpio$1/direction echo Setting pin $2 echo $2 > /sys/class/gpio/gpio$1/value 修改文件属性, 使文件可执行 chmod +x led.sh 程序第一句注销表明这个是一个 bash shell 文件, 通过 /bin/bash 程序执行 $1 代表第一个参数,$2 代表第二个参数, 执行以下两个命令可点亮和熄灭 LED(Pioneer600 扩展板 LED1 接到树莓派 BCM 编码的 26 号管脚 ) sudo./led.sh 26 1 sudo./led.sh ) 通过 sysfs 方式操作 GPIO 通过上面的操作, 我们可以发现在 linux 系统中, 读写设备文件即可操作对应的设备 所以说在 linux 的世界, 一切的都是文件 下面我们可以通过 C 语言读写文件的方式操作 GPIO. vi led.c 使用 vi 新建 led.c 文件, 添加以下程序并保存退出 #include &ls;sys stat.h> #include <sys types.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #define IN 0 #define OUT 1 #define LOW 0 #define HIGH 1 #define POUT 26 #define BUFFER_MAX 3 26

27 #define DIRECTION_MAX 48 static int GPIOExport(int pin) char buffer[buffer_max]; int len; int fd; fd = open("/sys/class/gpio/export", O_WRONLY); if (fd < 0) fprintf(stderr, "Failed to open export for writing!\n"); return(-1); len = snprintf(buffer, BUFFER_MAX, "%d", pin); write(fd, buffer, len); close(fd); return(0); static int GPIOUnexport(int pin) char buffer[buffer_max]; int len; int fd; fd = open("/sys/class/gpio/unexport", O_WRONLY); if (fd < 0) fprintf(stderr, "Failed to open unexport for writing!\n"); return(-1); len = snprintf(buffer, BUFFER_MAX, "%d", pin); write(fd, buffer, len); close(fd); return(0); static int GPIODirection(int pin, int dir) 27

28 static const char dir_str[] = "in\0out"; char path[direction_max]; int fd; snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/direction", pin); fd = open(path, O_WRONLY); if (fd < 0) fprintf(stderr, "failed to open gpio direction for writing!\n"); return(-1); if (write(fd, &dir_str[dir == IN? 0 : 3], dir == IN? 2 : 3) < 0) fprintf(stderr, "failed to set direction!\n"); return(-1); close(fd); return(0); static int GPIORead(int pin) char path[direction_max]; char value_str[3]; int fd; snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/value", pin); fd = open(path, O_RDONLY); if (fd < 0) fprintf(stderr, "failed to open gpio value for reading!\n"); return(-1); if (read(fd, value_str, 3) < 0) fprintf(stderr, "failed to read value!\n"); return(-1); close(fd); return(atoi(value_str)); 28

29 static int GPIOWrite(int pin, int value) static const char s_values_str[] = "01"; char path[direction_max]; int fd; snprintf(path, DIRECTION_MAX, "/sys/class/gpio/gpio%d/value", pin); fd = open(path, O_WRONLY); if (fd < 0) fprintf(stderr, "failed to open gpio value for writing!\n"); return(-1); if (write(fd, &s_values_str[value == LOW? 0 : 1], 1) < 0) fprintf(stderr, "failed to write value!\n"); return(-1); close(fd); return(0); int main(int argc, char *argv[]) int i = 0; GPIOExport(POUT); GPIODirection(POUT, OUT); for (i = 0; i < 20; i++) GPIOWrite(POUT, i % 2); usleep(500 * 1000); GPIOUnexport(POUT); return(0); </unistd.h></string.h></stdlib.h></stdio.h></fcntl.h></sys types.h> 编译并执行程序 gcc led.c -o led sudo./led 29

30 如果没有意外, 我们可以看到接到 BCM 编码的 26 号管脚的 LED, 闪烁 10 次后自动退出程序 以上第一条命令是使用 gcc 编译器将 led.c 源文件, 编译成 led 可执行文件, 在目录下面我们可以发现编程后生产的 led 可执行文件 我们也可以编写 Makefile 文件, 下次直接运行 make 命令即可编译程序 vi Makefile 使用 vi 新建 Makefile 文件, 添加以下代码并保存退出 led:led.c gcc led.c -o led clean: rm led 运行以下命令即可编译 led.c 程序 make 运行以下命令即可删除编译产生的可执行文件 led make clean 余下教程都为方便解说都是运行 gcc 命令编译程序, 如果想编写 Makefile 文件可查看 Pioneer600 示例程序 关于 sysfs 操作 GPIO 方式, 详情请参考以下网站 : 30

31 树莓派系列教程 8 : 如何点亮一个 LED 灯 ( 下 ) 上一章我们讲解了在 linux 系统下如何通过读写设备文件的方式控制 GPIO 点亮 LED 灯, 本章 我们继续讲解如果通过使用中间层库函数编程控制 GPIO. WIRINGPI WiringPi 是应用于树莓派平台的 GPIO 控制库函数,WiringPi 中的函数类似于 Arduino 的 wiring 系统 官网 : 1 wiringpi 安装 (1) 方案 1- 使用 GIT 工具通过 GIT 获得 wiringpi 的源码 git clone git://git.drogon.net/wiringpi cd wiringpi./build build 脚本会帮助你编译和安装 wiringpi (2) 方案 1- 使用 GIT 工具 我们可以在网站上直接下载最新版本编译使 用, 在 windows 上下载 wiringpi 库, 并复制到树莓派中, 运行如下命令解压安装 (xxx 代表版本 号 ) tar -zxvf wiringpi-xxx.tar.gz cd wiringpi-xxx./build 31

32 详细安装教程请参考 wiringpi 官网 : 2 测试 wiringpi 包括一套 gpio 命令, 使用 gpio 命令可以控制树莓派上的各种接口, 通过以下指令可以测试 wiringpi 是否安装成功 <div style="text-align: left;"><span style="font-size: 9pt; line-height: 1.8em;">gpio -v</span></div>gpio readall 从上图可以知道树莓派管脚有三种编号方式, 下面以 Pioneer600 扩展板的 LED1 为例, 第一种为板上编号 (37), 即中间两列, 表示第几号插针 第二中为 wiringpi 编码 (25), 使用 wiringpi 库编程时是用 wiringpi 编号, 第三种为 BCM 编号, 这个是更加 BCM 管脚来编号的, 使用 bcm2835 库或 python 的 RPi.GPIO 编程时使用 BCM 编号 我们可以使用 gpio 命令操作树莓派 GPIO, 下面我们可以 gpio 命令控制 Pioneer600 扩展的 LED1. gpio -g mode 26 out 32

33 设置管脚为输出模式,-g 参数表示是以 BCM 编号方式, 如果去掉这个参数测以 wiringpi 编号方式, 即为 25 gpio -g write 26 1 设置管脚为高电平, 点亮 LED. gpio -g write 26 0 设置管脚为低电平, 熄灭 LED, gpio -g read 26 读取管脚当前状态更多 gpio 命令请查看 : 3 wiringpi 程序 : #include<wiringpi.h> char LED = 25; int main(void) if(wiringpisetup() < 0)return 1; pinmode (LED,OUTPUT) ; while(1) digitalwrite(led, 1) ; delay (200); digitalwrite(led, 0) ; delay (200); 使用 vi 将代码添加到 led.c 文件中, 运行如下命令编译并执行程序 按 Ctrl+C 终止程序 gcc -Wall led.c o led -lwiringpi sudo./led 注 :(1)-Wall 表示编译时显示所有警告,-lwringPi 表示编译时动态加载 wringpi 库 (2) 终止程序后,LED 的状态为不确定, 这和 python 程序相比显得有点不足 关于更多 wiringpi 的库函数, 可参看 wiringpi 官网, 也可参考 wiringpi 用户手册 ZzoLywa0-QpElYNT2yHvNV0P7BbqTZCgG0ctaqZLi_ovkAGXREBOE6h68eTt-Q3y 33

34 BCM2835 bcm2835 库是树莓派 cpu 芯片的库函数, 相当于 stm32 的固件库一样, 底层是直接操作寄存器 而 wiringpi 库和 python 的 RPi.GPIO 库其底层都是通过读写 linux 系统的设备文件操作设备 1 安装 bcm2835 库从 bcm22835 官网 ( 下载最新版本的库, 然后解压安装 tar -zxvf bcm xx.tar.gz cd bcm xx./configure make sudo make check sudo make install 2 示例程序新建名为 led.c 的文件, 添加以下程序 #include <bcm2835.h> #define PIN 26 int main(int argc, char **argv) if (!bcm2835_init())return 1; bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP); while (1) bcm2835_gpio_write(pin, HIGH); bcm2835_delay(500); bcm2835_gpio_write(pin, LOW); bcm2835_delay(500); bcm2835_close(); return 0; 编译并执行程序, 按 Ctrl+C 可结束程序 gcc Wall led.c o led lbcm2835 sudo./led 34

35 注 :(1)-lbcm2835 表示动态加载 bcm2835 库 (2) 注意 bcm2835 程序管脚使用 bcm 编号, 和 wiringpi 编号不一样 (3) 和 wiringpi 一样, 程序结束时 GPIO 的状态不确定 PYTHON 1 安装 RPi.GPIO (1) 先安装 python-dev, 输入以下指令 sudo apt-get install python-dev (2) 安装 RPi.GPIO <span style="font-size: 9pt; line-height: 1.8em;"># 下载 wget # 解压 : tar -zxvf RPi.GPIO tar.gz # 进入解压之后的目录 : cd RPi.GPIO-0.5.3a # 启动安装 : sudo python setup.py install</span> 2. 示例程序新建 led.py 文件, 添加如下代码并保存 #!/usr/bin/python # -*- coding:utf-8 -*- import RPi.GPIO as GPIO import time LED = 26 GPIO.setmode(GPIO.BCM) GPIO.setup(LED,GPIO.OUT) try: while True: GPIO.output(LED,GPIO.HIGH) time.sleep(1) GPIO.output(LED,GPIO.LOW) time.sleep(1) except: print("except") 35

36 <span style="font-size: 9pt; line-height: px;"> </span>gpio.cleanup() 执行程序, 按 Ctrl+C 结束程序 sudo python led.py 注 :(1)#!/usr/bin/env python, 定义 python 解析脚本的绝对路径 (2)# -*- coding: utf-8 -*-,python 文件为 utf-8 格式, 否则无法写入中文注释 (3) GPIO.setmode(GPIO.BCM), 采用 bcm 编号方式 (4) python 程序使用 try except 语言, 当按下 Ctrl+C 结束程序是会触发异常, 程序执行 gpio.cleanup() 语句清楚 GPIO 管脚状态 对 python 语言不是很熟悉的孩童, 可以查看 Python 基础教程 : 这里有一个 python 语言的 wiringpi 库, 有兴趣的可以参考 : 36

37 树莓派系列教程 9: 按键 上两章我们讲解了在树莓派上如何点亮一个 LED 灯, 这一章我们讲解一下按键以及事件中断 BCM2835 #include <bcm2835.h> #include <stdio.h> #define KEY 20 int main(int argc, char **argv) if (!bcm2835_init())return 1; bcm2835_gpio_fsel(key, BCM2835_GPIO_FSEL_INPT); bcm2835_gpio_set_pud(key, BCM2835_GPIO_PUD_UP); printf("key Test Program!!!!\n"); while (1) if(bcm2835_gpio_lev(key) == 0) printf ("KEY PRESS\n") ; while(bcm2835_gpio_lev(key) == 0) bcm2835_delay(100); bcm2835_delay(100); bcm2835_close(); return 0; </stdio.h></bcm2835.h> 编译并执行, 按下按键会看到窗口显示 KEY PRESS, 按 Ctrl+C 结束程序 gcc Wall key.c o key lbcm2835 sudo./key 注 :(1)bcm2835_gpio_fsel(KEY, BCM2835_GPIO_FSEL_INPT); 设置管脚为输入模式 (2)bcm2835_gpio_set_pud(KEY, BCM2835_GPIO_PUD_UP); 设置为上拉模式 (3) bcm2835_gpio_lev(key); 读取管脚状态 37

38 WIRINGPI #include <stdio.h> #include<wiringpi.h> char KEY = 29; int main() if (wiringpisetup() < 0)return 1 ; pinmode (KEY,INPUT); pullupdncontrol(key, PUD_UP); printf("key Test Program!!!\n"); while(1) if (digitalread(key) == 0) printf ("KEY PRESS\n") ; while(digitalread(key) == 0) delay(100); delay(100); </wiringpi.h></stdio.h> 编译并执行, 按下按键会看到窗口显示 KEY PRESS, 按 Ctrl+C 结束程序 gcc Wall key.c o key wiringpi sudo./key 注 :(1)pinMode (KEY,INPUT); 设置管脚为输入模式 (2)pullUpDnControl(KEY, PUD_UP); 设置为上拉模式 (3) digitalread(key); 读取管脚状态 通过中断的方式编程 #include <stdio.h> #include <wiringpi.h> 38

39 #define button 29 char flag = 0; void myinterrupt() flag ++; int main() if(wiringpisetup() < 0)return 1; if(wiringpiisr(button,int_edge_falling,&myinterrupt) < 0) printf("unable to setup ISR \n"); printf("interrupt test program\n"); while(1) if(flag) while(digitalread(button) ==0); printf("button press\n"); flag = 0; </wiringpi.h></stdio.h> 编译并执行 gcc Wall Interrupt.c o Interrupt -lwirngpi sudo./interrupt 注 :(1)wiringPiISR(button,INT_EDGE_FALLING,&myInterrupt); 设置中断下降沿触发, myinterrupt 为中断处理函数 PYTHON #!/usr/bin/python # -*- coding:utf-8 -*- import RPi.GPIO as GPIO 39

40 import time KEY = 26 GPIO.setmode(GPIO.BCM) GPIO.setup(KEY,GPIO.IN,GPIO.PUD_UP) while True: time.sleep(0.05) if GPIO.input(KEY) == 0: print("key PRESS") while GPIO.input(KEY) == 0: time.sleep(0.01) 执行程序, 按下按键会看到窗口显示 KEY PRESS, 按 Ctrl+C 结束程序 sudo python key.py 注 :(1)GPIO.setup(KEY,GPIO.IN,GPIO.PUD_UP) 设置管脚为上拉输入模式 (2)GPIO.input(KEY) 读取管脚值 通过中断模式编程 #!/usr/bin/python # -*- coding:utf-8 -*- import RPi.GPIO as GPIO import time KEY = 26 def MyInterrupt(KEY): <span style="font-size: 9pt; line-height: px;"> </span>print("key PRESS") GPIO.setmode(GPIO.BCM) GPIO.setup(KEY,GPIO.IN,GPIO.PUD_UP) GPIO.add_event_detect(KEY,GPIO.FALLING,MyInterrupt,200) while True: <span style="font-size: 9pt; line-height: px;"> </span>time.sleep(1) 注 :(1)def MyInterrupt(KEY): 定义中断处理函数 40

41 (2) GPIO.add_event_detect(KEY,GPIO.FALLING,MyInterrupt,200) 增加事件检测, 下降沿触发, 忽略由于开关抖动引起的小于 200ms 的边缘操作 关于树莓派事件中断编程请参考 : 41

42 树莓派系列教程 10: I2C 启动 I2C 执行如下命令进行树莓派配置 sudo raspi-config 选择 Advanced Options -> I2C ->yes 启动 i2c 内核驱动 除了启动 i2c 内核驱动外, 还需修改配置文件, 运行如下命令打开配置文件 sudo nano /etc/modules 增加以下两行并保存退出 i2c-bcm2708 i2c-dev 运行 lsmod 命令查看 i2c 时候启动 I2C-TOOLS 安装 i2c-tools, 这个工具在 I2c 硬件监控设备识别和故障诊断是非常重要 sudo apt-get install i2c-tools i2c-tools 官网 I2c-tools 仅有四条命令, 下面逐条介绍 1 i2c-tool 查询 i2c 设备 : i2cdetect -y 1 -y 代表取消用户交互过程, 直接执行指令 ; 1 代表 I2C 总线编号 ; 上图是树莓派接上 Pioneer 600 扩展板检测到的 i2c 设备, 42

43 0x20 是 PCF8974 IO 扩展芯片的地址, 0x48 是 PCF8591 AD/DA 转换芯片的地址 0x68 是 DS3231 RTC 时钟芯片的地址 0x77 是 BMP180 压强传感器的地址 2 扫描寄存器内容 : i2cdump -y 1 0x68 -y 代表取消用户交互过程, 直接执行指令 ; 1 代表 I2C 总线编号 ; 0x68 代表 I2C 设备从机地址, 此处表示 DS3231 RTC 时钟芯片 3 寄存器内容写入 : i2cset -y 1 0x68 0x00 0x13 -y 代表曲线用户交互过程, 直接执行指令 1 代表 I2C 总线编号 0x68 代表 I2C 设备地址, 此处表示 DS3231 RTC 时钟芯片 0x00 代表存储器地址, 0x13 代表存储器地址中的具体内容 4 寄存器内容读出 : i2cget -y 1 0x68 0x00 -y 代表曲线用户交互过程, 直接执行指令 1 代表 I2C 总线编号 0x68 0x00 代表 I2C 设备地址, 此处表示 DS3231 RTC 时钟芯片 代表存储器地址 43

44 使用 I2C-TOOLS 控制 PCF8574 IO PCF8574 是 I2C 总线 8 位 IO 扩展芯片, 初始状态 IO 为高电平. PCF8574 和其他 I2C 芯片不同, 该芯片没有寄存器, 直接传输一个字节即控制 IO 输出状态 Pioneer 600 扩展板,LED2 接到 PCF8574 的 p4 管脚 低电平点亮 LED. 写 IO 管脚 : i2cset y 1 0x20 0xEF 0x20 代表 I2C 设备地址, 此处表示 PCF8574 芯片 0xEF 传输的内容, 此处表示 PCF8574 的 P4 管脚输出低电平, 其他管脚输出高电平 可以看到 Pioneer 600 扩展板的 LED2 点亮 读 IO 管脚 : i2cget -y 1 0x20 运行这条命令即可读取 PCF8574 IO 管脚状态 熄灭 LED2 i2cset y 1 0x20 0xFF 同理,Pionerr 600 扩展板, 蜂鸣器接到 PCF8574 的 P7 管脚, 可以用 i2c-tool 控制蜂鸣器 蜂鸣器响 : i2cset y 1 0x20 0xEF 蜂鸣器停 : i2cset y 1 0x20 0xFF 44

45 树莓派系列教程 11: I2C 编程 例程是通过 i2c 控制 pcf8574 IO, 使 Pioneer 600 扩展板的 LED2 闪烁 BCM2835 #include <bcm2835.h> int main(int argc, char **argv) char buf[1]; if (!bcm2835_init())return 1; bcm2835_i2c_begin(); bcm2835_i2c_setslaveaddress(0x20); //i2c address bcm2835_i2c_set_baudrate(10000); //1M baudrate while(1) buf[0] = 0xEF; //LED ON bcm2835_i2c_write(buf,1); bcm2835_delay(500); buf[0] = 0xFF; //LED OFF bcm2835_i2c_write(buf,1); bcm2835_delay(500); bcm2835_i2c_end(); bcm2835_close(); return 0; </bcm2835.h> 编译并执行, 扩展板上的 LED2 灯开始闪烁了,Ctrl +C 结束程序 gcc Wall pcf8574 o pfc8574 lbcm2835 sudo./pcf8574 注 :(1)bcm2835_i2c_begin(); 启动 i2c 操作, 设置 I2C 相关引脚为复用功能 (2)bcm2835_i2c_setSlaveAddress(0x20); 设置 I2C 从机设备的地址, 此处为 0x20 即 PCF8574 的地址 45

46 (3)bcm2835_i2c_write(buf,1); 传输字节到 i2c 从设备,buf 为要传输的数据,1 表示传输一个字节更多 bcm2835 库 i2c 操作函数请查看 : i2c.html#ga f f3040b1553ea64 WIRINGPI #include <wiringpi.h> #include <wiringpii2c.h> int main (void) int fd; wiringpisetup(); fd = wiringpii2csetup(0x20); while (1) wiringpii2cwrite(fd,0xef); //LED ON delay(500); wiringpii2cwrite(fd,0xff); //LED OFF delay(500); return 0; </wiringpii2c.h></wiringpi.h> 编译并执行, 扩展板上的 LED2 灯开始闪烁了,Ctrl +C 结束程序 gcc Wall pcf8574 o pfc8574 lbcm2835 sudo./pcf8574 注 :(1)fd = wiringpii2csetup(0x20); 初始化 I2C 设备,0x20 为 PCF8574 的 I2C 地址, 返回值是标准的 Linux 文件句柄, 如果错误则返回 -1. 由此可知,wiringPi 底层也是通过 sysfs 方式操作 I2C 设备 /dev/i2c-1 wiringpi 还有 pcf8574 的扩展库, 也可以调用 pcf8574 的库操作 IO. #include <wiringpi.h #include="" <pcf8574.h=""> #define EXTEND_BASE 64 46

47 #define LED EXTEND_BASE + 4 int main (void) wiringpisetup(); pcf8574setup(extend_base,0x20); pinmode(led,output); while (1) digitalwrite(led,low); //LED ON delay(500); digitalwrite(led,high); //LED OFF delay(500); return 0; </wiringpi.h> 编译并执行 gcc Wall pcf8574.c o pcf8474 lwiringpi sudo./pcf8574 更多 bcm2835 库 i2c 操作函数请查看 : PYTHON 首先执行如下命令安装 smbus 库 sudo apt-get install python-smbus 编辑程序 #!/usr/bin/python # -*- coding:utf-8 -*- import smbus import time address = 0x20 bus = smbus.smbus(1) 47

48 while True: bus.write_byte(address,0xef) time.sleep(0.5) bus.write_byte(address,0xff) time.sleep(0.5) 执行程序 : sudo python pcf8574.py 注 :(1) import smbus 导入 smbus 模块 的编号为 1 (2)bus = smbus.smbus(1) 在树莓派版本 2 中,I2C 设备位于 /dev/i2c-1, 所以此处 python 封装 SMBUS 操作函数具体代码请查看 : 四 sysfs 从上面编程, 我们可以发现,wiring,python 程序都是通过读写 i2c 设备文件 /dev/i2c-1 操作 i2c 设备 故我们也可以用 c 语言读写文件的形式操作 i2c 设备 #include <linux i2c-dev.h=""> #include <errno.h> #define I2C_ADDR 0x20 #define LED_ON 0xEF #define LED_OFF 0xFF int main (void) int value; int fd; fd = open("/dev/i2c-1", O_RDWR); if (fd < 0) printf("error opening file: %s\n", strerror(errno)); return 1; if (ioctl(fd, I2C_SLAVE, I2C_ADDR) < 0) printf("ioctl error: %s\n", strerror(errno)); return 1; while(1) if(value == LED_ON)value = LED_OFF; 48

49 else value = LED_ON; if( write( fd, &value, 1 )!= 1) printf("error writing file: %s\n", strerror(errno)); usleep( ); return 0; </errno.h></linux> 编译并执行 gcc Wall pcf8574.c o pcf8574 sudo./pcf8574 注 :(1)fd = open("/dev/i2c-1", O_RDWR); 打开设备, 树莓派版本 2 的 I2C 设备位于 /dev/i2c-1 (2)ioctl(fd, I2C_SLAVE, I2C_ADDR) ; 设置 I2C 从设备地址, 此时 PCF8574 的从机地址为 0x20 (3) write( fd, &value, 1 ); 向 PCF8574 写入一个字节,value 便是写入的内容, 写入的长度为 1. 49

50 树莓派系列教程 12: I2C 总线控制 BMP180 通过上一章, 相信各位对树莓派 I2C 编程有一定的了解了, 今天我们继续使用 I2C 来控制 BMP180 压强传感器 BMP180 压强传感器操作原理比较简单, 开机先通过 I2C 读取出 AC1,AC2,AC3,AC4,AC5,AC6,B1,B2,MB,MC,MD 等寄存器的值, 这些寄存器的值作为校准时使用 如何读取温度寄存器, 压强寄存器的值, 根据下图公式算出测得的当前温度和压强 50

51 本章主要讲解 python 程序, 使大家熟悉 python 编程 关于 bcm2835,wiringpi 程序具体可参 看 Pioneer600 示例程序 驱动文件 bmp180.py import time import smbus # BMP085 default address. BMP180_I2CADDR = 0x77 # Operating Modes BMP180_ULTRALOWPOWER = 0 BMP180_STANDARD = 1 BMP180_HIGHRES = 2 BMP180_ULTRAHIGHRES = 3 # BMP085 Registers BMP180_CAL_AC1 = 0xAA # R Calibration data (16 bits) BMP180_CAL_AC2 = 0xAC # R Calibration data (16 bits) BMP180_CAL_AC3 = 0xAE # R Calibration data (16 bits) BMP180_CAL_AC4 = 0xB0 # R Calibration data (16 bits) BMP180_CAL_AC5 = 0xB2 # R Calibration data (16 bits) BMP180_CAL_AC6 = 0xB4 # R Calibration data (16 bits) BMP180_CAL_B1 = 0xB6 # R Calibration data (16 bits) BMP180_CAL_B2 = 0xB8 # R Calibration data (16 bits) BMP180_CAL_MB = 0xBA # R Calibration data (16 bits) BMP180_CAL_MC = 0xBC # R Calibration data (16 bits) BMP180_CAL_MD = 0xBE # R Calibration data (16 bits) BMP180_CONTROL = 0xF4 BMP180_TEMPDATA = 0xF6 BMP180_PRESSUREDATA = 0xF6 # Commands BMP180_READTEMPCMD BMP180_READPRESSURECMD = 0x2E = 0x34 class BMP180(object): def init (self, address=bmp180_i2caddr, mode=bmp180_standard): self._mode = mode self._address = address 51

52 self._bus = smbus.smbus(1) # Load calibration values. self._load_calibration() def _read_byte(self,cmd): return self._bus.read_byte_data(self._address,cmd) def _read_u16(self,cmd): MSB = self._bus.read_byte_data(self._address,cmd) LSB = self._bus.read_byte_data(self._address,cmd+1) return (MSB << 8) + LSB def _read_s16(self,cmd): result = self._read_u16(cmd) if result > 32767:result -= return result def _write_byte(self,cmd,val): self._bus.write_byte_data(self._address,cmd,val) def _load_calibration(self): "load calibration" self.cal_ac1 = self._read_s16(bmp180_cal_ac1) self.cal_ac2 = self._read_s16(bmp180_cal_ac2) self.cal_ac3 = self._read_s16(bmp180_cal_ac3) self.cal_ac4 = self._read_u16(bmp180_cal_ac4) self.cal_ac5 = self._read_u16(bmp180_cal_ac5) self.cal_ac6 = self._read_u16(bmp180_cal_ac6) self.cal_b1 = self._read_s16(bmp180_cal_b1) self.cal_b2 = self._read_s16(bmp180_cal_b2) self.cal_mb = self._read_s16(bmp180_cal_mb) self.cal_mc = self._read_s16(bmp180_cal_mc) self.cal_md = self._read_s16(bmp180_cal_md) # INT16 # INT16 # INT16 # UINT16 # UINT16 # UINT16 # INT16 # INT16 # INT16 # INT16 # INT16 def read_raw_temp(self): """Reads the raw (uncompensated) temperature from the sensor.""" self._write_byte(bmp180_control, BMP180_READTEMPCMD) time.sleep(0.005) # Wait 5ms MSB = self._read_byte(bmp180_tempdata) LSB = self._read_byte(bmp180_tempdata+1) raw = (MSB << 8) + LSB return raw 52

53 def read_raw_pressure(self): """Reads the raw (uncompensated) pressure level from the sensor.""" self._write_byte(bmp180_control, BMP180_READPRESSURECMD + (self._mode << 6)) if self._mode == BMP180_ULTRALOWPOWER: time.sleep(0.005) elif self._mode == BMP180_HIGHRES: time.sleep(0.014) elif self._mode == BMP180_ULTRAHIGHRES: time.sleep(0.026) else: time.sleep(0.008) MSB = self._read_byte(bmp180_pressuredata) LSB = self._read_byte(bmp180_pressuredata+1) XLSB = self._read_byte(bmp180_pressuredata+2) raw = ((MSB << 16) + (LSB << 8) + XLSB) >> (8 - self._mode) return raw def read_temperature(self): """Gets the compensated temperature in degrees celsius.""" UT = self.read_raw_temp() X1 = ((UT - self.cal_ac6) * self.cal_ac5) >> 15 X2 = (self.cal_mc << 11) / (X1 + self.cal_md) B5 = X1 + X2 temp = ((B5 + 8) >> 4) / 10.0 return temp def read_pressure(self): """Gets the compensated pressure in Pascals.""" UT = self.read_raw_temp() UP = self.read_raw_pressure() X1 = ((UT - self.cal_ac6) * self.cal_ac5) >> 15 X2 = (self.cal_mc << 11) / (X1 + self.cal_md) B5 = X1 + X2 # Pressure Calculations B6 = B X1 = (self.cal_b2 * (B6 * B6) >> 12) >> 11 X2 = (self.cal_ac2 * B6) >> 11 53

54 X3 = X1 + X2 B3 = (((self.cal_ac1 * 4 + X3) << self._mode) + 2) / 4 X1 = (self.cal_ac3 * B6) >> 13 X2 = (self.cal_b1 * ((B6 * B6) >> 12)) >> 16 X3 = ((X1 + X2) + 2) >> 2 B4 = (self.cal_ac4 * (X )) >> 15 B7 = (UP - B3) * (50000 >> self._mode) if B7 < 0x : p = (B7 * 2) / B4 else: p = (B7 / B4) * 2 X1 = (p >> 8) * (p >> 8) X1 = (X1 * 3038) >> 16 X2 = (-7357 * p) >> 16 p = p + ((X1 + X ) >> 4) return p def read_altitude(self, sealevel_pa= ): """Calculates the altitude in meters.""" # Calculation taken straight from section 3.6 of the datasheet. pressure = float(self.read_pressure()) altitude = * (1.0 - pow(pressure / sealevel_pa, (1.0/5.255))) return altitude def read_sealevel_pressure(self, altitude_m=0.0): """Calculates the pressure at sealevel when given a known altitude in meters. Returns a value in Pascals.""" pressure = float(self.read_pressure()) p0 = pressure / pow(1.0 - altitude_m/ , 5.255) return p0 主文件 bmp180_example.py #!/usr/bin/python import time from BMP180 import BMP180 # Initialise the BMP085 and use STANDARD mode (default value) # bmp = BMP085(0x77, debug=true) 54

55 bmp = BMP180() # To specify a different operating mode, uncomment one of the following: # bmp = BMP085(0x77, 0) # ULTRALOWPOWER Mode # bmp = BMP085(0x77, 1) # STANDARD Mode # bmp = BMP085(0x77, 2) # HIRES Mode # bmp = BMP085(0x77, 3) # ULTRAHIRES Mode while True: temp = bmp.read_temperature() # Read the current barometric pressure level pressure = bmp.read_pressure() # To calculate altitude based on an estimated mean sea level pressure # ( hpa) call the function as follows, but this won't be very accurate altitude = bmp.read_altitude() # To specify a more accurate altitude, enter the correct mean sea level # pressure level. For example, if the current pressure level is hpa # enter since we include two decimal places in the integer value # altitude = bmp.readaltitude(102350) print "Temperature: %.2f C" % temp print "Pressure: %.2f hpa" % (pressure / 100.0) print "Altitude: %.2f\n" % altitude time.sleep(1) 55

56 树莓派系列教程 13: SERIAL 串口 树莓派的串口默认为串口终端调试使用, 如要正常使用串口则需要修改树莓派设置 关闭串口终 端调试功能后则不能再通过串口登陆访问树莓派, 需从新开启后才能通过串口控制树莓派 释放串口 执行如下命令进入树莓派配置 sudo raspi-config 选择 Advanced Options ->Serial ->no 关闭串口调试功能 使用 MINICOM 调试串口 设置完之后串口便可以正常使用了, 便可测试一下树莓派的 UART 是否正常工作,Pioneer600 扩展板带有 USB 转 UART 功能, 用 USB 线连接到电脑 minicom 便是一个简单好用的工具 minicom 是 linux 平台串口调试工具, 相当于 windows 上的串口调试助手 1 minicom 安装 sudo apt-get install minicom 2 minicom 启动 minicom -D /dev/ttyama0 默认波特率为 , 如需设置波特率为 9600 加参数 -b 9600,-D 代表端口,/dev/ttyAMA0 类似于 windows 中的 COM1, 56

57 同时在 windows 也打开串口助手 设置波特率为 , 选择对应的串口号 57

58 3 串口数据传输 直接在 minicom 控制台中输入内容即可通过串口发送数据, 在 windows 串口助手中会接到到输入的内容 同理, 在 windows 串口助手中发送数据会在 minicom 控制台上显示 如果 minicom 打开了回显 ( 先 Ctrl+A, 再 E) 可在控制台中观察到输出内容, 如果回显关闭 minicom 控制台不会显示你输入的内容 先 Ctrl+A, 再 Q, 退出 minicom 串口编程 1 wiringpi #include <stdio.h> #include <wiringpi.h> #include <wiringserial.h> int main() int fd; if(wiringpisetup() < 0)return 1; if((fd = serialopen("/dev/ttyama0",115200)) < 0)return 1; printf("serial test start...\n"); serialprintf(fd,"hello World!!!\n"); while(1) serialputchar(fd,serialgetchar(fd)); serialclose(fd); return 0; </wiringserial.h></wiringpi.h></stdio.h> 编译并执行, 在 window 下打开串口助手会接收到 Hello World!!!, 发送数据会返回到显示窗口 gcc Wall uart.c o uart lwiringpi sudo./uart PYTHON 首先运行如下命令安装 python serial 扩展库 sudo apt-get install python-serial 编写程序 58

59 #!/usr/bin/python # -*- coding:utf-8 -*-import serial ser = serial.serial("/dev/ttyama0",115200) print('serial test start...') ser.write("hello Wrold!!!\n") try: while True: ser.write(ser.read()) except KeyboardInterrupt: if ser!= None: ser.close() 执行程序, 实验结果和上面一样 sudo python uart.py 注 :(1) ser = serial.serial("/dev/ttyama0",115200) 打开串口, 波特率为 (2) ser.write(ser.read()) 接收字符并回传 (3) ser.close() 关闭串口 总结 : 通过上面两个程序我们可以发现和 i2c 一样,wiringPi,python 程序都是读写串口设备 文件 /dev/ttyama0 操作串口, 故我们也可以通过 sysfs 的形式编程操作串口, 在这里我就不 详细介绍了 59

60 树莓派系列教程 14: 单总线控制 DS18B20 DS18B20 是一个比较常用的温度传感器, 采用单总线控制, 以前用单片机编程控制时严格按照单总线的时序控制, 今天来看看在 linux 系统下如何控制 DS18B20, 体验一下在 linux 世界, 一切都是文件 一 修改配置文件 sudo vi /boot/config.txt ( 注 : 运行 sudo raspi-config 实际上也是修改这个文件, 例如设置 Advanced Options -> I2C 启动 i2c 内核驱动, 就是修个 dtparam=i2c_arm=on 这一行 ) 在 /boot/config.txt 文件后面添加下面这一句, 这一句就是树莓派添加 Device Tree 设备, dtoverlay=w1-gpio-pull 表示添加单总线设备,gpioin=4 默认管脚为 4, 如果 DS18B20 接到其他管脚则需要修改这个值,Pioneer 600 扩展板 DS18B20 默认接到 4, 故不用修改 ( 注 : 管脚为 BCM 编号 ) dtoverlay=w1-gpio-pull,gpioin=4 在 /boot/overlays/readme 中有关于树莓派 Device Tree 的详细介绍, 在其中我们找到下面 关于 w1-gpio-pullup 设备的介绍如下图 二 查看模块是否启动 重启树莓派是设置生效, 运行 lsmod 命令, 如果发现红色方框的两个模块说明模块已启动 如果没有发现, 也可以运行如下命令加载模块 sudo modprobe w1_gpio 60

61 sudo modprobe w1_therm 三 读取温度 如果没有问题, 在 /sys/bus/w1/devices 中发现一个 28-XXXX 开头的文件夹, 这个就是 DS18B20 的 ROM, 每个 DS18B20 都一样, 在这个文件夹中读取 w1_slave 文件则会返回当前温度值 操作如下图 : sudo modprobe w1-gpio sudo modprobe w1-therm cd /sys/bus/w1/devices cd xxx cat w1_slave 返回数据中, 第一行最后的 YRS 表示 CRC 校验成功, 数据有效 第二行最后 t=30500 表示当前 温度为 30.5 摄氏度 如果接多个 DS18B20, 将会看到多个 28-xxxx 的文件, 分别对应各个 DS18B20 61

62 四 软件编程 1 sysfs #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <dirent.h> #include <string.h> #include <time.h> int main(int argc, char *argv[]) char path[50] = "/sys/bus/w1/devices/"; char rom[20]; char buf[100]; DIR *dirp; struct dirent *direntp; int fd =-1; char *temp; float value; system("sudo modprobe w1-gpio"); system("sudo modprobe w1-therm"); if((dirp = opendir(path)) == NULL) printf("opendir error\n"); return 1; while((direntp = readdir(dirp))!= NULL) if(strstr(direntp->d_name," ")) strcpy(rom,direntp->d_name); printf(" rom: %s\n",rom); closedir(dirp); strcat(path,rom); 62

63 strcat(path,"/w1_slave"); while(1) if((fd = open(path,o_rdonly)) < 0) printf("open error\n"); return 1; if(read(fd,buf,sizeof(buf)) < 0) printf("read error\n"); return 1; temp = strchr(buf,'t'); sscanf(temp,"t=%s",temp); value = atof(temp)/1000; printf(" temp : %3.3f C\n",value); sleep(1); return 0; </time.h></string.h></dirent.h></fcntl.h></unistd.h></stdlib.h></stdio.h> 编译并执行, 结果如图 gcc Wall ds18b20.c o ds18b20 sudo ds18b20 注 :(1)system("sudo modprobe w1-gpio");system("sudo modprobe w1-therm"); 在 程序的开头运行了一下 modprobe 命令 (2) dirp = opendir(path) 打开 /sys/bus/w1/devices/ 文件路径 63

64 (3)direntp = readdir(dirp) 读取当前路径下的文件或文件夹 (4)strstr(direntp->d_name," ") 查找 开头的文件,strstr 为字符串操作函数, 上面这条语句表示文件名字是否包含字符串 , 如果匹配则返回第一次匹配的地址, 没有搜索到则返回 NULL. (5)strcpy(rom,direntp->d_name); strcpy 为字符串复制函数, 将包含 的文件名复制到 rom 字符串 (6)strcat(path,rom);strcat(path,"/w1_slave"); strcat 为字符串连接函数, 此时 path 的值为 /sys/bus/w1/devices/ xxxx/w1_slave (7)fd = open(path,o_rdonly); read(fd,buf,sizeof(buf)) 打开文件并读取数据 (8)temp = strchr(buf,'t'); 查找字符 t 第一次出现的位置, (9)sscanf(temp,"t=%s",temp); sscanf 函数是从一个字符串中读进与指定格式相符的数 据, 此处为从第二行数据中扫描出温度值 (10) value = atof(temp)/1000; atof 函数把字符串转化为浮点数 2 python import os import glob import time os.system('modprobe w1-gpio') os.system('modprobe w1-therm') base_dir = '/sys/bus/w1/devices/' device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' def read_rom(): name_file=device_folder+'/name' f = open(name_file,'r') return f.readline() def read_temp_raw(): f = open(device_file, 'r') lines = f.readlines() f.close() 64

65 return lines def read_temp(): lines = read_temp_raw() while lines[0].strip()[-3:]!= 'YES': time.sleep(0.2) lines = read_temp_raw() equals_pos = lines[1].find('t=') if equals_pos!= -1: temp_string = lines[1][equals_pos+2:] temp_c = float(temp_string) / temp_f = temp_c * 9.0 / return temp_c, temp_f print(' rom: '+ read_rom()) while True: print(' C=%3.3f F=%3.3f'% read_temp()) time.sleep(1) 运行程序, 运行结果如图 sudo python ds18b20.py 注 :(1) 程序的开头运行了一下 modprobe 命令 (2) device_folder = glob.glob(base_dir + '28*')[0] device_file = device_folder + '/w1_slave' 定义设备文件夹和设备文件,glob.glob(base_dir + '28*')) 函数为获得 base_dir 路径下所有 28 开头的文件 (3)while lines[0].strip()[-3:]!= 'YES': 是否为 YES 判断 w1-value 第一行的最后三个字符 (4)equals_pos = lines[1].find('t=') 查找第二行中 t= 出现的位置 65

66 (5) temp_string = lines[1][equals_pos+2:] 取温度数据 总结 : 对比上面两个两个程序, 我们可以发现 python 程序更加简单方便 66

67 树莓派系列教程 15: 红外遥控 上一章我们介绍了如果通过树莓派 device tree, 将在 ds18b20 添加到 linux 系统中, 并通过命令行读取温度数据, 这一章我们也通过 device tree 添加红外接收 lirc 为 linux 系统中红外遥控的软件, 树莓派系统已经有这个模块, 我们只需设置一下就而已使用 sudo vi /boot/config.txt 在文件后面添加下面这一行 doverlay=lirc-rpi,gpio_in_pin=18 红外默认输出是 18 管脚, 如果红外接收头接到其他管脚则需修改对应管脚,( 管脚为 BCM 编码 ), Pioneer 600 接收头默认接到 18 管脚故只需要添加 doverlay=lirc-rpi 在 /boot/overlay/readme 文件中我们可以找到详细说明 安装 lirc 软件 sudo apt-get install lirc 运行 lsmod 命令查看设备是否已启动, 如若没有找到可运行 sudo modprobe lirc_rpi 加载驱 动 67

68 运行 sudo mode2 d /dev/lirc0, 按遥控上任何键, 查看是否接到到类似脉冲 如有接到到脉冲测 lirc 正常使用 采用脉宽调制的串行码, 以脉宽为 0.565ms 间隔 0.56ms 周期为 1.125ms 的组合表示二进制 的 "0"; 以脉宽为 0.565ms 间隔 1.685ms 周期为 2.25ms 的组合表示二进制的 "1 68

69 协议 : 上述 0 和 1 组成的 32 位二进制码经 38kHz 的载频进行二次调制以提高发射效率, 达到降低 电源功耗的目的 然后再通过红外发射二极管产生红外线向空间发射, 如下图 引导码 用户识别码 用户识别码反码 操作码 操作码反码 一个命令只发送一次, 即使遥控器上的按键一直按着 但是会每 110mS 发送一次代码, 直到遥 控器按键释放 重复码比较简单 : 一个 9mS 的 AGC 脉冲 2.25mS 间隔 560uS 脉冲 bcm2835 程序 : [ 代码 ]php 代码 : 69

70 #include <bcm2835.h> #include <stdio.h> #define PIN 18 #define IO bcm2835_gpio_lev(pin) unsigned char i,idx,cnt; unsigned char count; unsigned char data[4]; int main(int argc, char **argv) if (!bcm2835_init())return 1; bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_INPT); bcm2835_gpio_set_pud(pin, BCM2835_GPIO_PUD_UP); printf("irm Test Program... \n"); while (1) if(io == 0) count = 0; while(io == 0 && count++ < 200) delaymicroseconds(60); //9ms count = 0; while(io == 1 && count++ < 80) delaymicroseconds(60); //4.5ms idx = 0; cnt = 0; data[0]=0; data[1]=0; data[2]=0; data[3]=0; for(i =0;i<32;i++) count = 0; while(io == 0 && count++ < 15) //0.56ms delaymicroseconds(60); count = 0; while(io == 1 && count++ < 40) //0: 0.56ms; 1: 1.69ms delaymicroseconds(60); 70

71 if (count > 25)data[idx] = (1<<cnt); if(cnt="=" 7)="" ="" cnt="0;" idx++;="" ="" else="" cnt++;="" if(data[0]+data[1]="=" 0xff="" &&="" data[2]+data[3]="=0xff)" check="" printf("get="" the="" key:="" 0x%02x\n",data[2]);="" bcm2835_close();="" return="" 0;="" <="" pre=""></cnt);></stdio.h></bcm2835.h><cnt); if(cnt="=" 7)="" ="" cnt="0;" idx++;="" ="" else="" cnt++;="" if(data[0]+data[1]="=" 0xff="" &&="" data[2]+data[3]="=0xff)" check="" printf("get="" the="" key:="" 0x%02x\n",data[2]);="" bcm2835_close();="" return="" 0;="" <="" pre=""></cnt);> 编译并执行, 按下遥控按键, 终端会显示接到到按键的键值 gcc Wall irm.c o irm lbcm2835 sudo./irm python 程序 v #!/usr/bin/python # -*- coding:utf-8 -*- import RPi.GPIO as GPIO import time PIN = 18; GPIO.setmode(GPIO.BCM) GPIO.setup(PIN,GPIO.IN,GPIO.PUD_UP) print('irm Test Start...') try: while True: if GPIO.input(PIN) == 0: count = 0 while GPIO.input(PIN) == 0 and count < 200: #9ms count += 1 time.sleep( ) count = 0 71

72 while GPIO.input(PIN) == 1 and count < 80: #4.5ms count += 1 time.sleep( ) idx = 0 cnt = 0 data = [0,0,0,0] for i in range(0,32): count = 0 while GPIO.input(PIN) == 0 and count < 15: count += 1 time.sleep( ) #0.56ms count = 0 while GPIO.input(PIN) == 1 and count < 40: #0: 0.56mx count += 1 #1: 1.69ms time.sleep( ) if count > 8: data[idx] = 1>>cnt if cnt == 7: cnt = 0 idx += 1 else: cnt += 1 if data[0]+data[1] == 0xFF and data[2]+data[3] == 0xFF: #check print("get the key: 0x%02x" %data[2]) except KeyboardInterrupt: GPIO.cleanup(); 执行, 按下遥控按键, 终端会显示接到到按键的键值 sudo python irm.py 72

73 树莓派系列教程 16: RTC 树莓派本身没有 RTC 功能, 若树莓派不联网则无法从网络获取正确时间,Pioneer 600 扩展板 上面带有高精度 RTC 时钟 DS3231 芯片, 可解决这个问题 一 配置 RTC 1 修改配置文件 sudo vi /boot/config.txt 添加 RTC 设备 ds3231 dtoverlay=i2c-rtc,ds3231 重启树莓派生效设置, 开机后可以运行 lsmod 命令查看时候有 rtc-1307 模块 ( 注 :ds3231 为 i2c 控制, 故应打开树莓派 I2C 功能 ) 2 读取 RTC 时钟, sudo hwclock r 读取系统时间 date 3 设置 RTC 时间 sudo hwclock set date= 2015/08/12 18:00:00 4 更新 RTC 时间到系统 sudo hwclock -s 5 读取 RTC 时间及系统时间 sudo hwclock r;date 73

74 二 编程控制 我们也可以通过 I2C 编程读写 RTC 时间, 运行 i2cdetect y 1 命令我们可以看到下图, 我们发现 ds3231 的 i2c 地址 0x68 的位置显示 UU, 此时 ds3231 作为树莓派的硬件时钟, 不能 通过 i2c 编程控制, 必须将刚才配置文件中的设置注释掉才能用 sudo vi /boot/config.txt 找到刚才的设置, 在前面加 # 注释掉 #dtoverlay=i2c-rtc,ds3231 重启后再运行 i2cdetect y 1 此时发现 ds3231 可以通过 i2c 编程控制 1 bcm

75 #include <bcm2835.h> #include <stdio.h> #include <unistd.h> //regaddr,seconds,minutes,hours,weekdays,days,months,yeas char buf[]=0x00,0x00,0x00,0x18,0x04,0x12,0x08,0x15; char *str[] ="SUN","Mon","Tues","Wed","Thur","Fri","Sat"; void pcf8563settime() bcm2835_i2c_write(buf,8); void pcf8563readtime() buf[0] = 0x00; bcm2835_i2c_write_read_rs(buf,1, buf,7); int main(int argc, char **argv) if (!bcm2835_init())return 1; bcm2835_i2c_begin(); bcm2835_i2c_setslaveaddress(0x68); bcm2835_i2c_set_baudrate(10000); printf("start...\n"); pcf8563settime(); while(1) pcf8563readtime(); buf[0] = buf[0]&0x7f; //sec buf[1] = buf[1]&0x7f; //min buf[2] = buf[2]&0x3f; //hour buf[3] = buf[3]&0x07; //week buf[4] = buf[4]&0x3f; //day buf[5] = buf[5]&0x1f; //mouth 75

76 //year/month/day printf("20%02x/%02x/%02x ",buf[6],buf[5],buf[4]); //hour:minute/second printf("%02x:%02x:%02x ",buf[2],buf[1],buf[0]); //weekday printf("%s\n",str[(unsigned char)buf[3]-1]); bcm2835_delay(1000); bcm2835_i2c_end(); bcm2835_close(); return 0; </unistd.h></stdio.h></bcm2835.h> 编译并执行 gcc Wall ds3231.c o ds3231 lbcm2835 sudo./ds python #!/usr/bin/python # -*- coding: utf-8 -*- import smbus import time address = 0x68 register = 0x00 76

77 #sec min hour week day mout year NowTime = [0x00,0x00,0x18,0x04,0x12,0x08,0x15] w = ["SUN","Mon","Tues","Wed","Thur","Fri","Sat"]; #/dev/i2c-1 bus = smbus.smbus(1) def ds3231settime(): bus.write_i2c_block_data(address,register,nowtime) def ds3231readtime(): return bus.read_i2c_block_data(address,register,7); ds3231settime() while 1: t = ds3231readtime() t[0] = t[0]&0x7f #sec t[1] = t[1]&0x7f #min t[2] = t[2]&0x3f #hour t[3] = t[3]&0x07 #week t[4] = t[4]&0x3f #day t[5] = t[5]&0x1f #mouth print("20%x/%x/%x %x:%x:%x %s" %(t[6],t[5],t[4],t[2],t[1],t[0],w[t[3]-1])) time.sleep(1) 执行程序 sudo python ds3231.py 77

78 树莓派系列教程 17: PCF8591 AD/DA 树莓派本身没有 AD/DA 功能, 如果树莓派外接模拟传感器, 则必须外接 AD/DA 功能扩展板才能 用 Pioneer 600 扩展带有 AD/DA 芯片 PCF8591,pcf8591 带 1 通道 8 位 DA,4 通道 8 位 AD, 通过 I2C 控制 DAC 1 bcm2835 程序 #include <bcm2835.h> #include <stdio.h> #include <unistd.h> int main(int argc, char **argv) char Buf[]=0,0; unsigned char value=0; if (!bcm2835_init())return 1; bcm2835_i2c_begin(); bcm2835_i2c_setslaveaddress(0x48); bcm2835_i2c_set_baudrate(10000); printf("start...\n"); while(1) Buf[0] = 0x40; Buf[1] = value++; bcm2835_i2c_write(buf,2); printf("aout: %d\n",value); bcm2835_delay(20); bcm2835_i2c_end(); bcm2835_close(); return 0; </unistd.h></stdio.h></bcm2835.h> 编译并执行 78

79 gcc Wall pcf8591.c o pcf8591 lbcm2835 sudo./ pcf Python 程序 #!/usr/bin/python # -*- coding:utf-8 -*- import smbus import time address = 0x48 cmd = 0x40 value = 0 bus = smbus.smbus(1) while True: bus.write_byte_data(address,cmd,value) value += 1 if value == 256: value =0 print("aout:%3d" %value) time.sleep(0.01) 执行程序 sudo python pcf wiringpi 程序 #include <wiringpi.h> #include <pcf8591.h> #include <stdio.h> #define Address 0x48 #define BASE 64 #define A0 BASE+0 #define A1 BASE+1 #define A2 BASE+2 #define A3 BASE+3 int main(void) unsigned char value; 79

80 wiringpisetup(); pcf8591setup(base,address); while(1) analogwrite(a0,value); printf("aout: %d\n",value++); delay(20); </stdio.h></pcf8591.h></wiringpi.h> 编译并执行程序 gcc Wall pcf8591.c o pcf8591 lbcm2835 -lwiringpi sudo./ pcf8591 ADC 1 bcm2835 程序 #include <bcm2835.h> #include <stdio.h> #include <unistd.h> int main(int argc, char **argv) char Buf[]=0; unsigned char i; if (!bcm2835_init())return 1; bcm2835_i2c_begin(); bcm2835_i2c_setslaveaddress(0x48); bcm2835_i2c_set_baudrate(10000); printf("start...\n"); while(1) for(i = 0;i < 4;i++) Buf[0] = i; bcm2835_i2c_write_read_rs(buf,1,buf,1); 80

81 bcm2835_i2c_read (Buf,1); printf("ain%d:%5.2f ",i,(double)buf[0]*3.3/255); printf("\n"); bcm2835_delay(100); bcm2835_i2c_end(); bcm2835_close(); return 0; </unistd.h></stdio.h></bcm2835.h> 编译并执行 gcc Wall pcf8591.c o pcf8591 lbcm2835 sudo./ pcf Python 程序 #!/usr/bin/python # -*- coding:utf-8 -*- import smbus import time address = 0x48 A0 = 0x40 A1 = 0x41 A2 = 0x42 A3 = 0x43 bus = smbus.smbus(1) while True: bus.write_byte(address,a0) value = bus.read_byte(address) print("aout:%1.3f " %(value*3.3/255)) time.sleep(0.1) 执行程序 sudo python pcf wiringpi 程序 #include <wiringpi.h> #include <pcf8591.h> #include <stdio.h> 81

82 #define Address 0x48 #define BASE 64 #define A0 BASE+0 #define A1 BASE+1 #define A2 BASE+2 #define A3 BASE+3 int main(void) int value; wiringpisetup(); pcf8591setup(base,address); while(1) value = analogread(a0); printf("analoge: %dmv\n",value*3300/255); delay(1000); </stdio.h></pcf8591.h></wiringpi.h> 编译并执行程序 gcc Wall pcf8591.c o pcf8591 -lwiringpi sudo./ pcf

83 树莓派系列教程 18: SPI 一 开启树莓派 spi 功能 sudo raspi-config 选择 Advanced Options -> SPI -> yes 启动 SPI 内核驱动 运行 lsmod 命令, 可以看到 spi 模块已启动 在 /dev 路径下面, 我们可以发现两个 spi 设备 83

84 spi 管脚如下图红框所示, 左边方框的管脚分别为 MOSI MISO SCLK, 左边 CE0,CE1 为两个片选 管脚, 分别对应上图中的 spidev0.0,spidev0.1 两个设备 对这两个文件读写操作即可控制 spi 设备 二 SPI 编程 Pioneer 600 扩展板配备一款 0.96inch, 分辨率的 oled 显示屏, 通过 SPI 控制, 先上显示效果图 由于程序过长, 在这里我就不把代码全部贴出来了, 只是简单讲解一下 spi 的操作函数 如果各位有兴趣可以下载程序, 研究一下 如果程序有什么写得不好的地方, 还望各位指正 1 bcm2835 bcm2835_spi_begin(); // 启动 spi 接口, 设置 spi 对应管脚为复用功能 bcm2835_spi_setbitorder(bcm2835_spi_bit_order_msbfirst); // 高位先传输 bcm2835_spi_setdatamode(bcm2835_spi_mode0); //spi 模式 0 bcm2835_spi_setclockdivider(bcm2835_spi_clock_divider_128); // 分频, bcm2835_spi_chipselect(bcm2835_spi_cs0); // 设置片选 bcm2835_spi_setchipselectpolarity(bcm2835_spi_cs0, LOW); // 设置片选低电平有效 84

85 uint8_t bcm2835_spi_transfer(uint_t value) 传输一个字节 void bcm2835_spi_transfernb(char *tbuf,char *rbuf,uint32_t len) 传输 n 字节 2 python 安装 spi 库 下载 spidev 库, 复制到树莓派, 并行运行如下命令解压安装 tar zxvf spidev-3.1.tar.gz cd spidev sudo python setup.py install 安装 imaging 库 sudo apt-get install python-imaging python-spidev 的使用方法 : import spidev 导入库 bus=0 device=0 spi=spi.spidev(bus,device) 打开 spi 设备, 此处设备为 /dev/spi-decv0.0 spi.readbytes(n) 从 SPI 设备读取 n 字节 spi.writebytes(list of value) 将列表的数据写到 SPI 设备 spi.xfer(list of values[, speed_hz, delay_usec, bits_per_word]) 执行 SPI 传输 85

DVK530/531扩展板

DVK530/531扩展板 DVK512 树莓派扩展版 用户手册 DVK512 是一款 Raspberry Pi A+/B+/2 代 B 的外扩板, 带有丰富的资源及扩展接口, 支持各类外围 模块的接入 特点 : 板载 USB TO UART, 方便进行串口调试 板载 4 个按键和 4 个 LED 板载 RTC 板载 LCD1602 接口 板载 UART SPI I2C 8I/Os 接口, 兼容 Waveshare 标准, 方便接入各种外围

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

static struct file_operations gpio_ctl_fops={ ioctl: gpio_ctl_ioctl, open : gpio_open, release: gpio_release, ; #defineled1_on() (GPBDAT &= ~0x1) #def

static struct file_operations gpio_ctl_fops={ ioctl: gpio_ctl_ioctl, open : gpio_open, release: gpio_release, ; #defineled1_on() (GPBDAT &= ~0x1) #def Kaise s 2410 Board setting [1]. Device Driver Device Driver Linux s Kernel ARM s kernel s3c2410_kernel2.4.18_r1.1_change.tar.bz2 /usr/src (1) #cd /usr/src (2) #tar xfj s3c2410_kernel2.4.18_r1.1_change.tar.bz2

More information

Microsoft Word - PS2_linux_guide_cn.doc

Microsoft Word - PS2_linux_guide_cn.doc Linux For $ONY PlayStatioin2 Unofficall General Guide Language: Simplified Chinese First Write By Beter Hans v0.1 Mail: hansb@citiz.net Version: 0.1 本 人 是 菜 鸟 + 小 白 欢 迎 指 正 错 误 之 处, 如 果 您 有 其 他 使 用 心 得

More information

华恒家庭网关方案

华恒家庭网关方案 LINUX V1.5 1 2 1 2 LINUX WINDOWS PC VC LINUX WINDOWS LINUX 90% GUI LINUX C 3 REDHAT 9 LINUX PC TFTP/NFS http://www.hhcn.com/chinese/embedlinux-res.html minicom NFS mount C HHARM9-EDU 1 LINUX HHARM9-EDU

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

ICD ICD ICD ICD ICD

ICD ICD ICD ICD ICD MPLAB ICD2 MPLAB ICD2 PIC MPLAB-IDE V6.0 ICD2 usb PC RS232 MPLAB IDE PC PC 2.0 5.5V LED EEDATA MPLAB ICD2 Microchip MPLAB-IDE v6.0 Windows 95/98 Windows NT Windows 2000 www.elc-mcu.com 1 ICD2...4 1.1 ICD2...4

More information

P4i45GL_GV-R50-CN.p65

P4i45GL_GV-R50-CN.p65 1 Main Advanced Security Power Boot Exit System Date System Time Floppy Drives IDE Devices BIOS Version Processor Type Processor Speed Cache Size Microcode Update Total Memory DDR1 DDR2 Dec 18 2003 Thu

More information

DVK530/531扩展板

DVK530/531扩展板 DVK720 扩展板 驱动移植手册 2014.04.03 V1.0 版权声明 本手册所有权由深圳市微雪电子有限公司独家持有 未经本公司的书 面许可, 不得以任何方式或形式进行修改 分发或复制本文档的任何 部分, 否则一切后果由违者自负 版本更新记录 版本日期说明 V1.0 2014.04.03 初始发布 深圳市微雪电子有限公司 www.waveshare.net I 目录 版权声明... I 版本更新记录...

More information

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco Windows RTEMS 1 Danilliu MMI TCP/IP 80486 QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos ecos Email www.rtems.com RTEMS ecos RTEMS RTEMS Windows

More information

T1028_Manual_KO_V3 0.pdf

T1028_Manual_KO_V3 0.pdf 2009 : 2009/09 PC Microsoft, MS-DOS, Windows, Windows Sound System Microsoft Corporation Intel, Atom Intel Corporation Sound Blaster, Sound Blaster ProCreative Technology I AC AC AC AC AC - 115 V/60 Hz

More information

.. 3 N

.. 3 N 1 .. 3 N9.. 4 5.. 6 7.. 8 20.. 21 23.. 24.. 25 26.. 27.. 28.. 29 2 (Cyber Café) Linux (LAN) Linux Public Home 3 K12LTSP K12LTSPFedora Core 4 (Linux)LTSP Linux (command line interface) (Graphical User Interface,

More information

目录

目录 ALTERA_CPLD... 3 11SY_03091... 3 12SY_03091...4....5 21 5 22...8 23..10 24..12 25..13..17 3 1EPM7128SLC.......17 3 2EPM7032SLC.......18 33HT46R47......19..20 41..20 42. 43..26..27 5151DEMO I/O...27 52A/D89C51...28

More information

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

1

1 1 2 3 4 5 GNUDebugger 6 7 void main(int argc, char **argv){ vulncpy(argv[1]); return; } void vulncpy(char *a){ char buf[30]; strcpy(buf, a); return; } *argv[1] buf Shellcode *argv[1]... &buf &buf 8 strcpy

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10 Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10 Ác Åé å Serial ATA ( Silicon Image SiI3114) S A T A (1) SATA (2)

More information

Abstract arm linux tool-chain root NET-Start! 2

Abstract arm linux tool-chain root NET-Start! 2 Lab III - Embedding Linux 1 Abstract arm linux tool-chain root NET-Start! 2 Part 1.4 Step1. tool-chain 4 Step2. PATH 4 Part 2 kernel 5 Step1. 5 Step2... 6 Step3...8 Part 3 root. 8 Step1. 8 Step2. 8 Part

More information

PTS7_Manual.PDF

PTS7_Manual.PDF User Manual Soliton Technologies CO., LTD www.soliton.com.tw - PCI V2.2. - PCI 32-bit / 33MHz * 2 - Zero Skew CLK Signal Generator. - (each Slot). -. - PCI. - Hot-Swap - DOS, Windows 98/2000/XP, Linux

More information

AL-M200 Series

AL-M200 Series NPD4754-00 TC ( ) Windows 7 1. [Start ( )] [Control Panel ()] [Network and Internet ( )] 2. [Network and Sharing Center ( )] 3. [Change adapter settings ( )] 4. 3 Windows XP 1. [Start ( )] [Control Panel

More information

Linux 操作系统课程社区创作

Linux 操作系统课程社区创作 学 号 14284060xx 等 第 苏 州 大 学 实 验 报 告 Linux 操 作 系 统 课 程 社 区 创 作 院 ( 系 ) 名 称 : 电 子 信 息 学 院 专 业 名 称 : 14 通 信 工 程 ( 嵌 入 式 培 养 ) 学 生 姓 名 : 某 某 某 课 程 名 称 : Linux 操 作 系 统 2015-2016 学 年 第 一 学 期 1 摘 要 这 是 摘 要 主 要

More information

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor

(Load Project) (Save Project) (OffLine Mode) (Help) Intel Hex Motor 1 4.1.1.1 (Load) 14 1.1 1 4.1.1.2 (Save) 14 1.1.1 1 4.1.2 (Buffer) 16 1.1.2 1 4.1.3 (Device) 16 1.1.3 1 4.1.3.1 (Select Device) 16 2 4.1.3.2 (Device Info) 16 2.1 2 4.1.3.3 (Adapter) 17 2.1.1 CD-ROM 2 4.1.4

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

+01-10_M5A_C1955.p65

+01-10_M5A_C1955.p65 Notebook PC User s Manual C1955 1.01 2005 4 2 50 70 3 (0 30 ) (50 122 ) 4 pre-load Fn+F7 5 ...2...3...6 1-1...12...12...13...14...15...16...17 1-2...18 1-3...20...20...21...21...21...21...22...22...22...22...23...23

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

Microsoft Word - 实用案例.doc

Microsoft Word - 实用案例.doc 计 算 机 系 统 应 用 2009 年 第 12 期 嵌 入 式 Linux 下 温 湿 度 传 感 器 的 设 计 与 实 现 1 Design and Implementation of Temperature and Humidity Sensor Based on Embedded Linux 陈 博 刘 锦 高 ( 华 东 师 范 大 学 电 子 科 学 技 术 系 上 海 200241)

More information

bingdian001.com

bingdian001.com TSM12M TSM12 STM8L152C6, STM8L152R8 MSP430F5325 whym1987@126.com! /******************************************************************************* * : TSM12.c * : * : 2013/10/21 * : TSM12, STM8L f(sysclk)

More information

Microsoft Word - linux命令及建议.doc

Microsoft Word - linux命令及建议.doc Linux 操 作 系 统 命 令 集 1 基 本 命 令 查 看 系 统 信 息 : uname -a 修 改 密 码 : passwd 退 出 : logout(exit) 获 取 帮 助 : man commands 2 文 件 和 目 录 命 令 显 示 当 前 工 作 目 录 : pwd 改 变 所 在 目 录 : cd cd - 切 换 到 上 一 次 使 用 的 目 录 cd 切 换

More information

Microsoft Word - 在VMWare-5.5+RedHat-9下建立本机QTopia-2.1.1虚拟平台a.doc

Microsoft Word - 在VMWare-5.5+RedHat-9下建立本机QTopia-2.1.1虚拟平台a.doc 在 VMWare-5.5+RedHat-9 下建立 本机 QTopia-2.1.1 虚拟平台 张大海 2008-5-9 一 资源下载 1. 需要以下安装包 : tmake-1.13.tar.gz qtopia-free-source-2.1.1.tar.gz qt-embedded-2.3.10-free.tar.gz qt-x11-2.3.2.tar.gz qt-x11-free-3.3.4.tar.gz

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

手册 doc

手册 doc 1. 2. 3. 3.1 3.2 3.3 SD 3.4 3.5 SD 3.6 3.7 4. 4.1 4.2 4.3 SD 4.4 5. 5.1 5.2 5.3 SD 6. 1. 1~3 ( ) 320x240~704x288 66 (2G SD 320x2401FPS ) 32M~2G SD SD SD SD 24V DC 3W( ) -10~70 10~90% 154x44x144mm 2. DVR106

More information

本文由筱驀釹贡献

本文由筱驀釹贡献 本 文 由 筱 驀 釹 贡 献 ppt 文 档 可 能 在 WAP 端 浏 览 体 验 不 佳 建 议 您 优 先 选 择 TXT, 或 下 载 源 文 件 到 本 机 查 看 Linux 操 作 系 统 Linux 操 作 系 统 第 一 部 分 介 绍 与 安 装 Linux 的 由 来 : Linux 的 由 来 : 的 由 来 Linus Torvalds 1.Linux 的 版 本 1.Linux

More information

ebook140-9

ebook140-9 9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I

More information

Compute Module IO Board Plus 用户手册 Compute Module IO Board Plus 用户手册 产品概述 本品是一块基于树莓派计算模块的外扩板, 与树莓派基金会提供的 Compute Module IO Board V3 兼容, 并扩展了多种常用的资源 支持树

Compute Module IO Board Plus 用户手册 Compute Module IO Board Plus 用户手册 产品概述 本品是一块基于树莓派计算模块的外扩板, 与树莓派基金会提供的 Compute Module IO Board V3 兼容, 并扩展了多种常用的资源 支持树 Compute Module IO Board Plus 用户手册 产品概述 本品是一块基于树莓派计算模块的外扩板, 与树莓派基金会提供的 Compute Module IO Board V3 兼容, 并扩展了多种常用的资源 支持树莓派官方的 Compute Module 3 Lite, Compute Module 3, Compute Module 3+ Lite, Compute Module

More information

F515_CS_Book.book

F515_CS_Book.book /USB , ( ) / L R 1 > > > 2, / 3 L 1 > > > 2 + - 3, 4 L 1 了解显示屏上显示的图标 Wap 信箱收到一条 Wap push 信息 ( ) GSM 手机已连接到 GSM 网络 指示条越多, 接收质量越好 2 ...........................4.............................. 4 Micro SD (

More information

Serial ATA ( Nvidia nforce430)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Microsoft Win

Serial ATA ( Nvidia nforce430)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A (6) Microsoft Win Serial ATA ( Nvidia nforce430)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 9 (5) S A T A... 11 (6) Microsoft Windows 2000... 14 Ác Åé å Serial ATA ( Nvidia nforce430)

More information

HD ( ) 18 HD ( ) 18 PC 19 PC 19 PC 20 Leica MC170 HD Leica MC190 HD 22 Leica MC170 HD Leica MC190 HD Leica MC170 HD

HD ( ) 18 HD ( ) 18 PC 19 PC 19 PC 20 Leica MC170 HD Leica MC190 HD 22 Leica MC170 HD Leica MC190 HD Leica MC170 HD Leica MC170 HD Leica MC190 HD 5 6 7 8 11 12 13 14 16 HD ( ) 18 HD ( ) 18 PC 19 PC 19 PC 20 Leica MC170 HD Leica MC190 HD 22 Leica MC170 HD Leica MC190 HD 22 23 24 26 Leica MC170 HD Leica MC190 HD ( ) 28

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Microsoft Word - InoTouch Editor编程软件手册2012.2.10.doc

Microsoft Word - InoTouch Editor编程软件手册2012.2.10.doc 目 录 第 一 章 关 于 InoTouch Editor 编 程 软 件 的 安 装... - 6-1.1 InoTouch 系 列 HMI 和 InoTouch Editor 软 件 的 简 介... - 6-1.2 安 装 InoTouch Editor 编 程 软 件... - 10-1.3 系 统 连 接 图... - 12-1.4 InoTouch 系 列 人 机 界 面 的 系 统 设

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

775i65PE_BIOS_CN.p65

775i65PE_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 14:00:09] [Wed 10/20/2004] BIOS Version : 775i65PE BIOS P1.00 Processor Type : Intel (R) CPU 3.20 GHz Processor Speed : 3200

More information

68369 (ppp quickstart guide)

68369 (ppp quickstart guide) Printed in USA 04/02 P/N 68369 rev. B PresencePLUS Pro PC PresencePLUS Pro PresencePLUS Pro CD Pass/Fails page 2 1 1. C-PPCAM 2. PPC.. PPCAMPPCTL 3. DB9D.. STPX.. STP.. 01 Trigger Ready Power 02 03 TRIGGER

More information

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 月 3 日 1 1 INPUTOUTPUT 1 InputOutput 题目描述 用 cin 输入你的姓名 ( 没有空格 ) 和年龄 ( 整数 ), 并用 cout 输出 输入输出符合以下范例 输入 master 999 输出 I am master, 999 years old. 注意 "," 后面有一个空格,"." 结束,

More information

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING 前言 - Andrew Payne 目录 1 2 Firefly Basics 3 COMPONENT TOOLBOX 目录 4 RESOURCES 致谢

More information

像 客 样 使 命令行 徐 东

像 客 样 使 命令行 徐 东 像 客 样 使 命令行 徐 东 1 1.1................................ 1 1.2................................. 3 1.3............................. 4 1.3.1 Linux............................ 5 1.3.2 macos............................

More information

DVK530/531扩展板

DVK530/531扩展板 DVK710 扩展板 驱动移植手册 2014.06.03 V1.0 版权声明 本手册所有权由深圳市微雪电子有限公司独家持有 未经本公司的书 面许可, 不得以任何方式或形式进行修改 分发或复制本文档的任何 部分, 否则一切后果由违者自负 版本更新记录 版本日期说明 V1.0 2014.06.03 初始发布 深圳市微雪电子有限公司 www.waveshare.netii I 目录版权声明... I 版本更新记录...

More information

Ch03_嵌入式作業系統建置_01

Ch03_嵌入式作業系統建置_01 Chapter 3 CPU Motorola DragonBall ( Palm PDA) MIPS ( CPU) Hitachi SH (Sega DreamCast CPU) ARM StrongARM CPU CPU RISC (reduced instruction set computer ) CISC (complex instruction set computer ) DSP(digital

More information

AXIS M7014/M7010

AXIS M7014/M7010 安 装 指 南 AXIS M7014 视 频 编 码 器 中 文 AXIS M7010 视 频 编 码 器 关 于 本 文 档 本 文 档 包 含 网 络 安 装 AXIS M7014/M7010 说 明 安 装 该 产 品 时, 拥 有 网 络 经 验 将 会 有 一 定 的 帮 助 法 律 考 虑 事 项 视 频 和 音 频 监 视 可 能 会 受 法 律 限 制, 各 个 国 家 / 地 区

More information

untitled

untitled IP Video 9100B-RS IP VIDEO 9100(B) 說 IP Video 9100B-RS 說 : 2.39-RS : 2007.1-1 - FCC CE 1. IP Video 9100B-RS. 2. IP Video 9100B-RS. 3. 4. 9100B-RS 5. 9100B-RS - 2 - IP VIDEO 9100(B) 說 1.... 4... 2.... 5

More information

ESP-Jumpstart

ESP-Jumpstart 2016-2019 2019 08 08 Contents 1 3 1.1 ESP32.............................. 3 1.2.................................................. 5 2 7 2.1............................................. 7 2.2 ESP-IDF............................................

More information

K7VT2_QIG_v3

K7VT2_QIG_v3 ............ 1 2 3 4 5 [R] : Enter Raid setup utility 6 Press[A]keytocreateRAID RAID Type: JBOD RAID 0 RAID 1: 2 7 RAID 0 Auto Create Manual Create: 2 RAID 0 Block Size: 16K 32K

More information

P4Dual-915GL_BIOS_CN.p65

P4Dual-915GL_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date Total Memory DIMM 1 DIMM 2 [ 14:00:09] [Wed 01/05/2005] BIOS Version : P4Dual-915GL BIOS P1.00 Processor Type : Intel (R) Pentium

More information

0 配置 Host MIB 设备 V ( 简体版 ) 0 Update: 2016/1/30

0 配置 Host MIB 设备 V ( 简体版 ) 0 Update: 2016/1/30 0 配置 Host MIB 设备 V 1.1.2 ( 简体版 ) 0 Update: 2016/1/30 前言 N-Reporter 支持 Host Resource MIB 监控主机 (Host) 状态, 本文件描述 N-Reporter 用户如何配置 Host MIB 设备 文件章节如下 : 1. 配置 Windows Server 2003... 2 1-1.Windows Server 2003

More information

Compute Module IO Board Plus 用户手册 Compute Module IO Board Plus 用户手册 产品概述 本产品是一块基于 Compute Module 3/3 Lite/3+/3+ Lite 外扩板, 与树莓派基金会提供的 Compute Module IO

Compute Module IO Board Plus 用户手册 Compute Module IO Board Plus 用户手册 产品概述 本产品是一块基于 Compute Module 3/3 Lite/3+/3+ Lite 外扩板, 与树莓派基金会提供的 Compute Module IO Compute Module IO Board Plus 用户手册 产品概述 本产品是一块基于 Compute Module 3/3 Lite/3+/3+ Lite 外扩板, 与树莓派基金会提供的 Compute Module IO Board V3 兼容, 并扩展了多种常用的资源 特点 兼容树莓派基金会提供的 Compute Module IO Board V3 带有 Raspberry Pi GPIO

More information

Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Windows XP

Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS RAID (4) SATA (5) SATA (a) S A T A ( S A T A R A I D ) (b) (c) Windows XP Serial ATA ( Sil3132)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 6 (4) S A T A... 10 (5) S A T A... 12 Ác Åé å Serial ATA ( Sil3132) S A T A (1) SATA (2) BIOS SATA (3)* RAID BIOS

More information

EK-STM32F

EK-STM32F STMEVKIT-STM32F10xx8 软 件 开 发 入 门 指 南 目 录 1 EWARM 安 装... 1 1.1 第 一 步 : 在 线 注 册... 1 1.2 第 二 步 : 下 载 软 件... 2 1.3 第 三 步 : 安 装 EWARM... 3 2 基 于 STMEVKIT-STM32F10xx8 的 示 例 代 码 运 行... 6 2.1 GPIO Demo... 6 2.2

More information

1.ai

1.ai HDMI camera ARTRAY CO,. LTD Introduction Thank you for purchasing the ARTCAM HDMI camera series. This manual shows the direction how to use the viewer software. Please refer other instructions or contact

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

P4VM800_BIOS_CN.p65

P4VM800_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 17:00:09] [Fri 02/25/2005] BIOS Version : P4VM800 BIOS P1.00 Processor Type : Intel (R) Pentium (R) 4 CPU 2.40 GHz Processor

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 Linux 操 作 系 统 基 础 介 绍 课 程 目 标 及 要 求 了 解 Linux 操 作 系 统 的 登 入 方 式 掌 握 常 用 命 令 的 基 本 用 法 能 够 熟 练 在 各 个 目 录 转 换 Outline 1. Linux 操 作 系 统 简 介 2. Linux 操 作 系 统 的 登 录 3. Linux 操 作 系 统 的 目 录 结 构 4. 常 用 命 令 5.

More information

P4V88+_BIOS_CN.p65

P4V88+_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 17:00:09] [Wed 12/22/2004] BIOS Version : P4V88+ BIOS P1.00 Processor Type : Intel (R) Pentium (R) 4 CPU 2.40 GHz Processor

More information

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2

(Guangzhou) AIT Co, Ltd V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn Xi III Zebra XI III 1 (Guangzhou) AIT Co, Ltd 020-84106666 020-84106688 http://wwwlenxcn 230V 110V [ ]! 2 (Guangzhou) AIT Co, Ltd 020-84106666

More information

MarsBoard AM335X 用户手册 微雪电子 WAVESHARE ELECTRONICS MarsBoard AM335X 用户手册 产品概述 MarsBoard AM335X 是基于 TI AM335X 系列处理器的卡片式电脑 工业级别的芯片, 广泛的应用 在工业, 医疗, 消费类电子等行

MarsBoard AM335X 用户手册 微雪电子 WAVESHARE ELECTRONICS MarsBoard AM335X 用户手册 产品概述 MarsBoard AM335X 是基于 TI AM335X 系列处理器的卡片式电脑 工业级别的芯片, 广泛的应用 在工业, 医疗, 消费类电子等行 MarsBoard AM335X 用户手册 产品概述 MarsBoard AM335X 是基于 TI AM335X 系列处理器的卡片式电脑 工业级别的芯片, 广泛的应用 在工业, 医疗, 消费类电子等行业 1 目录 产品概述... 1 目录... 2 1. 板载资源... 3 2. 使用操作... 5 2.1. 系统固件的下载... 5 2.2. TF 卡系统的烧写... 5 2.3. TF 卡系统的启动...

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

DR2010.doc

DR2010.doc DR/2010 HACH 11-8-96-2 HACH. DR/2010, / UL E79852 CSA C22.223 LR 58275 VDE GS 1015-92 FCC"A" 15 : AMADOR CORP, HACH. EN50 011/CISPR 11 "B" (EMI)/89/336/EEC/EMC: AMADOR CORP, HACH.. EN50 082-1( )/89/226/EEC

More information

典型自编教材

典型自编教材 河 南 科 技 大 学 计 算 机 实 验 教 学 中 心 1. 计 算 机 文 化 基 础 实 验 指 导 书 2. 数 据 结 构 实 验 指 导 书 3. 操 作 系 统 实 验 指 导 书 4. 面 向 对 象 程 序 设 计 实 验 指 导 书 5. 数 据 库 原 理 实 验 指 导 书 6. 编 译 原 理 实 验 指 导 书 7. JAVA 程 序 设 计 实 验 指 导 书 8.

More information

bingdian001.com

bingdian001.com (AVA PROPRE 6HD) ... 5 1.1 1.2 1.3 1.4 1.5 1.6... 5... 6... 6... 9... 9... 10... 12 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9... 12... 12... 13... 13... 14... 15... 16... 17... 18 2.10... 18 2.11... 19 2.12...

More information

0.96inch LCD Module 用户手册 0.96inch LCD Module 用户手册 产品概述 本产品是 0.96 寸 IPS 显示屏模块, 分辨率为 160*80, 使用 SPI 接口通信,LCD 带有 内部控制器, 已封装好基本函数, 可以实现图片旋转 画点 线 圆 矩形, 显示英

0.96inch LCD Module 用户手册 0.96inch LCD Module 用户手册 产品概述 本产品是 0.96 寸 IPS 显示屏模块, 分辨率为 160*80, 使用 SPI 接口通信,LCD 带有 内部控制器, 已封装好基本函数, 可以实现图片旋转 画点 线 圆 矩形, 显示英 0.96inch LCD Module 用户手册 产品概述 本产品是 0.96 寸 IPS 显示屏模块, 分辨率为 160*80, 使用 SPI 接口通信,LCD 带有 内部控制器, 已封装好基本函数, 可以实现图片旋转 画点 线 圆 矩形, 显示英文字符和 中文字符, 显示图片 提供完善的配套树莓派例程 (BCM2835 库,WiringPi 库, 以及 python 例程 ), STM32 例程,Arduino

More information

JLX

JLX PRODUCT:LCD MODULE. Model No.: JLX177-006 Product Type: 1.77 inch QVGA TFT Modoule. 产品规格书 晶联讯研发研发部 : Written By Checked By Approved By 客户名称 : 结构电子核准 地址 : 深圳市宝安区西乡宝安大道东华工业区 A3 栋 6 楼电话 :0755-29784961 Http://www.jlxlcd.cn

More information

Microsoft Word - 正文.doc

Microsoft Word - 正文.doc 1 2 1 2 3 4 5 6 7 8 9 10 3 1 150 2 150 1 1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.4 1.4.1 CPU 1.4.2 I/O 1.4.3 I/O 1.5 1.5.1 CISC RISC 1.5.2 1.5.3 1.6 1.6.1 1.6.2 N 1.6.3 2 2.1 2.1.1 2.1.2 2.1.3

More information

KL DSC DEMO 使用说明

KL DSC DEMO 使用说明 :0755-82556825 83239613 : (0755)83239613 : http://www.kingbirdnet.com EMAIL Good989@163.com 1 1 KB3000 DTU... 3 1.1... 3 1.2... 3 1.3... 3 1.4... 3 2... 4 2.1 GSM/GPRS... 4 2.2... 4 2.3... 5 2.4... 6 2.5...

More information

MarsBoard AM335X 用户手册 微雪电子 WAVESHARE ELECTRONICS MarsBoard AM335X 用户手册 产品概述 MarsBoard AM335X 是基于 TI AM335X 系列处理器的卡片式电脑 工业级别的芯片, 广泛的应用 在工业, 医疗, 消费类电子等行

MarsBoard AM335X 用户手册 微雪电子 WAVESHARE ELECTRONICS MarsBoard AM335X 用户手册 产品概述 MarsBoard AM335X 是基于 TI AM335X 系列处理器的卡片式电脑 工业级别的芯片, 广泛的应用 在工业, 医疗, 消费类电子等行 MarsBoard AM335X 用户手册 产品概述 MarsBoard AM335X 是基于 TI AM335X 系列处理器的卡片式电脑 工业级别的芯片, 广泛的应用 在工业, 医疗, 消费类电子等行业 1 目录 产品概述... 1 目录... 2 1. 板载资源... 3 2. 使用操作... 5 2.1. 系统固件的下载... 5 2.2. TF 卡系统的烧写... 5 2.3. TF 卡系统的启动...

More information

快 速 入 门 (Linux) 概 述 文 档 目 的 本 文 档 介 绍 了 如 何 快 速 创 建 Linux 系 统 实 例 远 程 连 接 实 例 部 署 环 境 等 旨 在 引 导 您 一 站 式 完 成 实 例 的 创 建 登 录 和 快 速 环 境 部 署 云 服 务 器 ECS 实

快 速 入 门 (Linux) 概 述 文 档 目 的 本 文 档 介 绍 了 如 何 快 速 创 建 Linux 系 统 实 例 远 程 连 接 实 例 部 署 环 境 等 旨 在 引 导 您 一 站 式 完 成 实 例 的 创 建 登 录 和 快 速 环 境 部 署 云 服 务 器 ECS 实 云 服 务 器 ECS 快 速 入 门 (Linux) 快 速 入 门 (Linux) 概 述 文 档 目 的 本 文 档 介 绍 了 如 何 快 速 创 建 Linux 系 统 实 例 远 程 连 接 实 例 部 署 环 境 等 旨 在 引 导 您 一 站 式 完 成 实 例 的 创 建 登 录 和 快 速 环 境 部 署 云 服 务 器 ECS 实 例, 有 时 候 也 被 称 为 阿 里 云

More information

Tel: Fax: TTP-344M/246M /

Tel: Fax: TTP-344M/246M / TTP-344M/246M / True Type font David Turner, Robert Wilhelm Werner Lemberg The Free Type Project 235 16 8 2 i- TTP-344M/246M...1 1.1...1 1.2...1 1.2.1...1 1.2.2 /...2 1.2.3...2 1.2.4...2 1.3...3 1.4...3

More information

第7章-并行计算.ppt

第7章-并行计算.ppt EFEP90 10CDMP3 CD t 0 t 0 To pull a bigger wagon, it is easier to add more oxen than to grow a gigantic ox 10t 0 t 0 n p Ts Tp if E(n, p) < 1 p, then T (n) < T (n, p) s p S(n,p) = p : f(x)=sin(cos(x))

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

1500XA Daniel Danalyzer 1500XA Rosemount Analytical 1500XA P/N 3-9000-757 A 2010 5 ii 1500XA 1500XA iii iv 1500XA : 1-2 1500XA - 1500XA 1-3 1-4 1500XA 1500XA 1-5 1-6 1500XA 1500XA 1-7 1-8 1500XA

More information

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1 Cadence SPB 15.2 VOICE 2005-05-07 Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1 1 1.1 Cadence SPB 15.2 2 Microsoft 1.1.1 Windows 2000 1.1.2 Windows XP Pro Windows

More information

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

エスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP: ******************* * 关于 Java 测试试题 ******

エスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP:  ******************* * 关于 Java 测试试题 ****** ******************* * 关于 Java 测试试题 ******************* 問 1 运行下面的程序, 选出一个正确的运行结果 public class Sample { public static void main(string[] args) { int[] test = { 1, 2, 3, 4, 5 ; for(int i = 1 ; i System.out.print(test[i]);

More information

untitled

untitled V3041A-J/V3042A-J IP-SAN/NAS Infinova Infinova Infinova Infinova www.infinova.com.cn Infinova Infinova Infinova 1 2 1 2 V3041A-16R-J V3041A-24R-J V3042A-16R-J V3042A-24R-J V3049-EXD-R16 V3049-EXD-R24 ...

More information

Microsoft Word - MSP430 Launchpad 指导书.docx

Microsoft Word - MSP430 Launchpad 指导书.docx Contents 3... 9... 14 MSP430 LAUNCHPAD 指导书 3 第一部分第一个工程 New Project File > New > CCS Project Project name: ButtonLED Device>Family: MSP430 Variant: MSP430G2553 Project templates and examples : Empty Project

More information

目 录

目 录 1 Quick51...1 1.1 SmartSOPC Quick51...1 1.2 Quick51...1 1.3 Quick51...2 2 Keil C51 Quick51...4 2.1 Keil C51...4 2.2 Keil C51...4 2.3 1 Keil C51...4 2.4 Flash Magic...9 2.5 ISP...9 2.6...10 2.7 Keil C51...12

More information

Microsoft Word - Sable User's Manual.doc

Microsoft Word - Sable User's Manual.doc SABLE 刻 字 机 使 用 手 册 1 注 意 GCC 星 云 保 留 在 不 事 先 通 知 的 情 况 下, 修 改 该 使 用 手 册 任 何 内 容 的 权 利! 禁 止 任 何 未 经 允 许 的 修 改 复 制 分 发 或 公 布! 关 于 此 手 册 有 任 何 问 题 或 意 见 请 联 系 您 的 当 地 经 销 商 2 目 录 安 全 操 作 注 意 事 项...5 第 一

More information

<4D F736F F D20B5DAC8FDCBC4D5C2D7F7D2B5B4F0B0B82E646F63>

<4D F736F F D20B5DAC8FDCBC4D5C2D7F7D2B5B4F0B0B82E646F63> 第三章 Q3 1 1. 省略了 I/O 操作的复杂逻辑, 易实现, 耗费低 ; 2. 可以利用丰富的内存寻址模式实现灵活的 I/O 操作 Q3 2 假设存储单元 ds1 处寄存器地址为 0x2000, 代码如下 #define ds1 0x2000 while ( *ds1 == 0 ) ; Q3 3 假设设备 (dev1) 中有两个寄存器 ds1 和 dd1,dev1 的地址为 0x1000,ds1

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

untitled

untitled V3049A-EXD IP-SAN/NAS Infinova Infinova Infinova Infinova www.infinova.com.cn Infinova Infinova Infinova 1 2 1 2 V3049A-EXD-R16 V3049A-EXD-R24 ... 1 1.1... 1 1.2... 1 1.3... 1... 2 2.1... 2 2.2... 3...

More information

CA-C750К

CA-C750К 1 3 3 4 PC 4 USB 5 5 6 8 9 11 mediasync Manager?...13 mediasync Manager 15 25 38 39 41 41 DRM...44 Image Manager...44 47 49 49 50 50 51 51 51 52 / 52 A-B 53 MP3 53 /FM 54 FM 55 FM 55 BMP56 56 57 57 58

More information

Linux Ubuntu Part Linux Ubuntu Linux UNIX...19 Linux...19 Linux Linux...21 Linux GNU FSF Open So urce.

Linux Ubuntu Part Linux Ubuntu Linux UNIX...19 Linux...19 Linux Linux...21 Linux GNU FSF Open So urce. Linux Ubuntu 10.04 Part 1 17 1 Linux Ubuntu... 18 1-1 Linux... 19 UNIX...19 Linux...19 Linux...20...20 Linux...21 Linux...21 1-2 GNU FSF Open So urce...22 GNU...22 GPL...23...24 1-3 GNU/Linux V.S. Linux...25

More information

Microsoft PowerPoint - os_4.ppt

Microsoft PowerPoint - os_4.ppt 行 程 資 科 系 林 偉 川 行 程 概 念 行 程 與 程 式 主 要 的 不 同 點 : 程 式 是 被 放 在 外 部 的 儲 存 裝 置 如 磁 碟 上, 而 行 程 則 被 放 在 記 憶 體 中 程 式 在 儲 存 裝 置 中 是 靜 態 的, 而 行 程 在 記 憶 體 中 是 動 態 的, 它 會 隨 著 一 些 事 件 的 發 生 而 產 生 相 對 的 改 變 行 程, 就 是

More information

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha CYPOK CYPOK 1 UltraEdit Project-->Install Language Tool: Language Suite----->hi-tech picc Tool Name ---->PICC Compiler Executable ---->c:hi-picinpicc.exe ( Command-line Project-->New Project-->File Name--->myc

More information