Exploring Raspberry Pi by Derek Molloy
Author:Derek Molloy
Language: eng
Format: mobi, epub
ISBN: 9781119188698
Published: 2016-05-31T00:00:00+00:00
I2C AND WIRINGPi
The wiringPi library that is installed in Chapter 6 has a library of C functions for interacting with I2C bus devices. This short code example reads the first three registers from the DS3231 RTC and displays the current time:
pi@erpi ~/exploringrpi/chp08/i2c/wiringPi $ more DS3231.c #include<wiringPiI2C.h> #include<stdio.h> int main(){ int fd = wiringPiI2CSetup(0x68); int secs = wiringPiI2CReadReg8(fd, 0x00); int mins = wiringPiI2CReadReg8(fd, 0x01); int hours = wiringPiI2CReadReg8(fd, 0x02); printf("The RTC time is %2d:%02d:%02d\n", hours, mins, secs); return 0; } pi@erpi ~/exploringrpi/chp08/i2c/wiringPi $ gcc DS3231.c -o rtc -lwiringPi pi@erpi ~/exploringrpi/chp08/i2c/wiringPi $ ./rtc The RTC time is 10:08:83
There is more information on this library at tiny.cc/erpi804. Be aware that this library is written specifically for the RPi platform; it will not work on other embedded Linux devices that do not contain the same SoC.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7742)
Filmora Efficient Editing by Alexander Zacharias(5453)
The Infinite Retina by Robert Scoble Irena Cronin(4900)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3906)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(3791)
Edit Like a Pro with iMovie by Regit(3243)
Linux Administration Best Practices by Scott Alan Miller(2844)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2821)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2509)
Docker on Windows by Stoneman Elton(2308)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2297)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2221)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2096)
Creative Projects for Rust Programmers by Carlo Milanesi(2050)
Hands-On Linux for Architects by Denis Salamanca(2031)
Computers For Seniors For Dummies by Nancy C. Muir(1985)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(1975)
The Old New Thing by Raymond Chen(1929)
Linux Kernel Debugging by Kaiwan N Billimoria(1754)
