树莓派 -- bcm2835 library (1)
bcm2835 library提供了user space 操作IO的代码。
本文不涉及代码分析,先直观的按照user guide完成操作。
1. 在Raspberry中安装bcm2835 library
2. build LED test
3. run led test
- 从http://www.airspayce.com/mikem/bcm2835/ 下载library库,可以直接在树莓派中下载或者宿主机上下载后sftp传给树莓派,
- 解压缩
pi@raspberrypi:~ $ tar zxvf bcm2835-1.56.tar.gz
bcm2835-1.56/
bcm2835-1.56/configure.ac
bcm2835-1.56/COPYING
bcm2835-1.56/examples/
bcm2835-1.56/examples/spi/
bcm2835-1.56/examples/spi/spi.c
bcm2835-1.56/examples/input/
bcm2835-1.56/examples/input/input.c
bcm2835-1.56/examples/event/
bcm2835-1.56/examples/event/event.c
bcm2835-1.56/examples/pwm/
bcm2835-1.56/examples/pwm/pwm.c
bcm2835-1.56/examples/gpio/
bcm2835-1.56/examples/gpio/gpio.c
bcm2835-1.56/examples/blink/
bcm2835-1.56/examples/blink/blink.c
bcm2835-1.56/examples/spin/
bcm2835-1.56/examples/spin/spin.c
bcm2835-1.56/examples/i2c/
bcm2835-1.56/examples/i2c/i2c.c
bcm2835-1.56/config.guess
bcm2835-1.56/NEWS
bcm2835-1.56/depcomp
bcm2835-1.56/configure
bcm2835-1.56/aclocal.m4
bcm2835-1.56/compile
bcm2835-1.56/INSTALL
bcm2835-1.56/Makefile.in
bcm2835-1.56/missing
bcm2835-1.56/config.sub
bcm2835-1.56/Makefile.am
bcm2835-1.56/ChangeLog
bcm2835-1.56/README
bcm2835-1.56/install-sh
bcm2835-1.56/config.h.in
bcm2835-1.56/src/
bcm2835-1.56/src/test.c
bcm2835-1.56/src/bcm2835.h
bcm2835-1.56/src/bcm2835.c
bcm2835-1.56/src/Makefile.in
bcm2835-1.56/src/Makefile.am
bcm2835-1.56/ltmain.sh
bcm2835-1.56/AUTHORS
bcm2835-1.56/doc/
bcm2835-1.56/doc/Doxyfile.in
bcm2835-1.56/doc/Makefile.in
bcm2835-1.56/doc/Makefile.am
bcm2835-1.56/test-driver
- ./configure
pi@raspberrypi:~/bcm2835-1.56 $ ls
aclocal.m4 ChangeLog config.guess config.sub configure.ac depcomp examples install-sh Makefile.am missing README test-driver
AUTHORS compile config.h.in configure COPYING doc INSTALL ltmain.sh Makefile.in NEWS src
pi@raspberrypi:~/bcm2835-1.56 $ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for clock_gettime in -lrt... yes
checking for doxygen... no
configure: WARNING: Doxygen not found - continuing without Doxygen support
checking for ranlib... ranlib
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing depfiles commands
- make
pi@raspberrypi:~/bcm2835-1.56 $ make
make all-recursive
make[1]: Entering directory '/home/pi/bcm2835-1.56'
Making all in src
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT bcm2835.o -MD -MP -MF .deps/bcm2835.Tpo -c -o bcm2835.o bcm2835.c
mv -f .deps/bcm2835.Tpo .deps/bcm2835.Po
rm -f libbcm2835.a
ar cru libbcm2835.a bcm2835.o
ar: `u' modifier ignored since `D' is the default (see `U')
ranlib libbcm2835.a
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
Making all in doc
make[2]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[2]: Entering directory '/home/pi/bcm2835-1.56'
make[2]: Leaving directory '/home/pi/bcm2835-1.56'
make[1]: Leaving directory '/home/pi/bcm2835-1.56'
pi@raspberrypi:~/bcm2835-1.56 $ sudo make check
Making check in src
make[1]: Entering directory '/home/pi/bcm2835-1.56/src'
make test
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT test.o -MD -MP -MF .deps/test.Tpo -c -o test.o test.c
mv -f .deps/test.Tpo .deps/test.Po
gcc -g -O2 -o test test.o ./libbcm2835.a -lrt
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
make check-TESTS
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
make[3]: Entering directory '/home/pi/bcm2835-1.56/src'
PASS: test
============================================================================
Testsuite summary for bcm2835 1.56
============================================================================
# TOTAL: 1
# PASS: 1
# SKIP: 0
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================
make[3]: Leaving directory '/home/pi/bcm2835-1.56/src'
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
make[1]: Leaving directory '/home/pi/bcm2835-1.56/src'
Making check in doc
make[1]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[1]: Nothing to be done for 'check'.
make[1]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[1]: Entering directory '/home/pi/bcm2835-1.56'
make[1]: Leaving directory '/home/pi/bcm2835-1.56'
- sudo make install
pi@raspberrypi:~/bcm2835-1.56 $ sudo make install
Making install in src
make[1]: Entering directory '/home/pi/bcm2835-1.56/src'
make[2]: Entering directory '/home/pi/bcm2835-1.56/src'
/bin/mkdir -p '/usr/local/lib'
/usr/bin/install -c -m 644 libbcm2835.a '/usr/local/lib'
( cd '/usr/local/lib' && ranlib libbcm2835.a )
/bin/mkdir -p '/usr/local/include'
/usr/bin/install -c -m 644 bcm2835.h '/usr/local/include'
make[2]: Leaving directory '/home/pi/bcm2835-1.56/src'
make[1]: Leaving directory '/home/pi/bcm2835-1.56/src'
Making install in doc
make[1]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[2]: Entering directory '/home/pi/bcm2835-1.56/doc'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[1]: Leaving directory '/home/pi/bcm2835-1.56/doc'
make[1]: Entering directory '/home/pi/bcm2835-1.56'
make[2]: Entering directory '/home/pi/bcm2835-1.56'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/pi/bcm2835-1.56'
make[1]: Leaving directory '/home/pi/bcm2835-1.56'
pi@raspberrypi:~/bcm2835-1.56 $
- build LED test 并执行
pi@raspberrypi:~/Pioneer600 $ cd LED/
pi@raspberrypi:~/Pioneer600/LED $ ls
bcm2835 fs python shell wiringPi
pi@raspberrypi:~/Pioneer600/LED $ cd bcm2835/
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ ls
led led.c Makefile
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ make
make: 'led' is up to date.
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ ./led
bcm2835_init: Unable to open /dev/mem: Permission denied
pi@raspberrypi:~/Pioneer600/LED/bcm2835 $ sudo ./led
LED代码
/* LED.c
* you can build this with something like:
* gcc -Wall blink.c -o blink -lbcm2835
* sudo ./blink
*/
#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;
}
可以看到LED blink.
树莓派 -- bcm2835 library (1)的更多相关文章
- 树莓派--bcm2835 library (2) 交叉编译BCM2835
在上文中,按照guide, 在树莓派目标板上install bcm2835. 因为bcm2835是用户空间应用,所以可以在宿主机上交叉编译,生成binary后在树莓派执行 按照guide: Insta ...
- 关于RPi.GPIO、BCM2835 c library、WiringPi、Gertboard
1.RPi.GPIO//RPi.GPIO-0.5.5.tar.gz 开发者:python官网:https://www.python.org/ 官网:https://pypi.python.org/py ...
- 详解树莓派Model B+控制蜂鸣器演奏乐曲
步进电机以及无源蜂鸣器这些都需要脉冲信号才能够驱动,这里将用GPIO的PWM接口驱动无源蜂鸣器弹奏乐曲,本文基于树莓派Mode B+,其他版本树莓派实现时需参照相关资料进行修改! 1 预备知识 1.1 ...
- 树莓派 - wiringPi
wiringPi其实和BCM2835 library类似,也是通过memmap, IOmap来实现在用户空间直接操作底层寄存器 wiringPi http://wiringpi.com/ Wiring ...
- 进监狱全攻略之 Mifare1 Card 破解
补充新闻:程序员黑餐馆系统 给自己饭卡里充钱 ,技术是双刃剑,小心,小心! 前言 从M1卡的验证漏洞被发现到现今,破解设备层出不穷,所以快速傻瓜式一键破解不是本文的重点,年轻司机将从本文中获得如下技能 ...
- PCF8591 AD/DA模块使用详解
I2C PCF8591 8位AD/DA转换 BCM2835 Library 1.PCF8591T简述 PCF8591器件图如下: PCF8591是一个8位的CMOS数据采集器件,具有4个模拟输入(其中 ...
- 树莓派 -- 按键 (key)使用BCM2835 gpio library
BCM2835 GPIO library介绍 This is a C library for Raspberry Pi (RPi). It provides access to GPIO and ot ...
- 树莓派4B的CPU系统里查到为BCM2835而非BCM2711
树莓派4B采用四核64位的ARM Cortex-A72架构CPU,型号为博通BCM2711 SoC.2711是个64位的四核,而2835是多年前的32位单核CPU. 查看当前芯片版本,显示为4核心,但 ...
- 在 树莓派上使用 c++ libsockets library
rpi默认安装的编译器是gcc-4.6.2 而现在最新的c++ libsockets library 需要使用支持c++-11特征的编译器,即需要4.8.2才可以.为此,需要先升级编译器才可以支持编译 ...
随机推荐
- eclipse本地怎么和git相同
1.打开Eclipse后,在左侧的项目窗口空白处右键,选择“Import...”2.打开Import窗口后,选择“Git”->"Projects from Git",点击“N ...
- bzoj 2561: 最小生成树【最小割】
看错题了以为多组询问吓得不行-- 其实还挺好想的,就是数据范围一点都不网络流.把U作为s,V作为t,以最小生成树为例,(U,V,L)要在最小生成树上,就要求所有边权比L小的边不能连通(U,V)所在的联 ...
- springboot(九) Cache缓存和Redis缓存
1. Cache缓存 1.1 缓存的概念&缓存注解 Cache 缓存接口,定义缓存操作.实现有:RedisCache.EhCacheCache.ConcurrentMapCache等 Cach ...
- 洛谷P2384 最短路(dijkstra解法)
题目背景 狗哥做烂了最短路,突然机智的考了Bosh一道,没想到把Bosh考住了...你能帮Bosh解决吗? 他会给你100000000000000000000000000000000000%10金币w ...
- Windows 程序设计 笔记
知识点 双字节字符集和Unicode字符集有何区别?采用双字节字符集有何问题 双字节字符集(DBCS)编码是0-255,DBCS含有1字节代码与2字节代码,而Unicode是统一的16位系统,这样就允 ...
- 32位Oracle10g在64位CentOS下安装失败记录
环境信息:Alibaba Cloud Elastic Compute Service,CentOS Linux release 7.4.1708 (Core),16C/64GB. 使用32位Oracl ...
- VS2010环境下.NET4.0中Tuple<T>的一个小BUG问题
启动一个桌面程序后,发现一个窗体cfdata=null, 执行时发生错误, 但是在初始化的时候,我明明是cfdata=new Cfdata();为什么会出现这个错误呢. 我开始跟踪,发现当执行cfda ...
- 转】在Ubuntu中安装Cassandra
原博文出自于: http://blog.fens.me/category/%E6%95%B0%E6%8D%AE%E5%BA%93/ 感谢! Posted: Mar 22, 2014 Tags: cas ...
- Codeforces Round #235 (Div. 2) D (dp)
以为是组合,后来看着像数位dp,又不知道怎么让它不重复用..然后就没思路 了. 其实状压就可以了 状压是可以确定一个数的使用顺序的 利用01也可以确定所有的数的使用以及不重复 dp[i+1<&l ...
- 组合模式和php实现
组合模式(有时候又叫做部分-整体模式): 将对象组合成树形结构以表示“部分整体”的层次结构.组合模式使得用户对单个对象和组合对象的使用具有一致性.它使我们树型结构的问题中,模糊了简单元素和复杂元素的概 ...