資源簡介
orangpi zero的gpio接口wiringOP_zero,親測點亮LED成功,香橙派的gpio資料太少了,靠大家一起分享。

代碼片段和文件信息
/*
?*?ds1302.c:
?* Real?Time?clock
?*
?*?Copyright?(c)?2013?Gordon?Henderson.
?***********************************************************************
?*?This?file?is?part?of?wiringPi:
?* https://projects.drogon.net/raspberry-pi/wiringpi/
?*
?*????wiringPi?is?free?software:?you?can?redistribute?it?and/or?modify
?*????it?under?the?terms?of?the?GNU?Lesser?General?Public?License?as?published?by
?*????the?Free?Software?Foundation?either?version?3?of?the?License?or
?*????(at?your?option)?any?later?version.
?*
?*????wiringPi?is?distributed?in?the?hope?that?it?will?be?useful
?*????but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*????MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
?*????GNU?Lesser?General?Public?License?for?more?details.
?*
?*????You?should?have?received?a?copy?of?the?GNU?Lesser?General?Public?License
?*????along?with?wiringPi.??If?not?see? .
?***********************************************************************
?*/
#include?
#include?
#include?
#include?
#include?
#include?“ds1302.h“
//?Register?defines
#define RTC_SECS ?0
#define RTC_MINS ?1
#define RTC_HOURS ?2
#define RTC_DATE ?3
#define RTC_MONTH ?4
#define RTC_DAY ?5
#define RTC_YEAR ?6
#define RTC_WP ?7
#define RTC_TC ?8
#define RTC_BM 31
//?Locals
static?int?dPin?cPin?sPin?;
/*
?*?dsShiftIn:
?* Shift?a?number?in?from?the?chip?LSB?first.?Note?that?the?data?is
?* sampled?on?the?trailing?edge?of?the?last?clock?so?it‘s?valid?immediately.
?*********************************************************************************
?*/
static?unsigned?int?dsShiftIn?(void)
{
??uint8_t?value?=?0?;
??int?i?;
??pinMode?(dPin?INPUT)?; delayMicroseconds?(1)?;
??for?(i?=?0?;?i?8?;?++i)
??{
????value?|=?(digitalRead?(dPin)?<????digitalWrite?(cPin?HIGH)?;?delayMicroseconds?(1)?;
????digitalWrite?(cPin?LOW)?; delayMicroseconds?(1)?;
??}
??return?value;
}
/*
?*?dsShiftOut:
?* A?normal?LSB-first?shift-out?just?slowed?down?a?bit?-?the?Pi?is
?* a?bit?faster?than?the?chip?can?handle.
?*********************************************************************************
?*/
static?void?dsShiftOut?(unsigned?int?data)
{
??int?i?;
??pinMode?(dPin?OUTPUT)?;
??for?(i?=?0?;?i?8?;?++i)
??{
????digitalWrite?(dPin?data?&?(1?<????digitalWrite?(cPin?HIGH)?; delayMicroseconds?(1)?;
????digitalWrite?(cPin?LOW)?; delayMicroseconds?(1)?;
??}
}
/*
?*?ds1302regRead:?ds1302regWrite:
?* Read/Write?a?value?to?an?RTC?Register?or?RAM?location?on?the?chip
?*********************************************************************************
?*/
static?unsigned?int?ds1302regRead?(const?int?reg)
{
??unsigned?int?data?;
??digitalWrite?(sPin?HIGH)?;?delayMicroseconds?(1)?;
????dsShiftOut?(reg)?;
????data?=?dsShiftIn?()?;
??digitalWrite?(sPin?LOW)??;?delayMicroseconds?(1)?;
??return?data?;
}
static?void?ds1302regWrite?(const?int?reg?const?unsign
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-01-17?14:46??WiringOP-zero\
?????文件??????????52??2017-01-04?10:11??WiringOP-zero\.gitignore
?????文件????????2136??2017-01-04?10:11??WiringOP-zero\build
?????文件????????7651??2017-01-04?10:11??WiringOP-zero\COPYING.LESSER
?????目錄???????????0??2017-01-04?10:11??WiringOP-zero\debian\
?????文件?????????154??2017-01-04?10:11??WiringOP-zero\debian\changelog
?????文件???????????2??2017-01-04?10:11??WiringOP-zero\debian\compat
?????文件????????2457??2017-01-04?10:11??WiringOP-zero\debian\control
?????文件????????1405??2017-01-04?10:11??WiringOP-zero\debian\copyright
?????文件??????????10??2017-01-04?10:11??WiringOP-zero\debian\docs
?????文件??????????20??2017-01-04?10:11??WiringOP-zero\debian\gpio.install
?????文件??????????12??2017-01-04?10:11??WiringOP-zero\debian\libwiringop-dev.dirs
?????文件??????????14??2017-01-04?10:11??WiringOP-zero\debian\libwiringop-dev.install
?????文件???????????8??2017-01-04?10:11??WiringOP-zero\debian\libwiringop2.dirs
?????文件??????????52??2017-01-04?10:11??WiringOP-zero\debian\libwiringop2.install
?????文件????????3968??2017-01-04?10:11??WiringOP-zero\debian\libwiringop2.symbols
?????文件??????????58??2017-01-04?10:11??WiringOP-zero\debian\libwiringopdev2.install
?????文件????????1046??2017-01-04?10:11??WiringOP-zero\debian\rules
?????目錄???????????0??2017-01-04?10:11??WiringOP-zero\debian\source\
?????文件??????????13??2017-01-04?10:11??WiringOP-zero\debian\source\format
?????目錄???????????0??2017-01-04?10:11??WiringOP-zero\devLib\
?????文件????????5866??2017-01-04?10:11??WiringOP-zero\devLib\ds1302.c
?????文件????????1673??2017-01-04?10:11??WiringOP-zero\devLib\ds1302.h
?????文件????????2568??2017-01-04?10:11??WiringOP-zero\devLib\ds1302.o
?????文件???????55558??2017-01-04?10:11??WiringOP-zero\devLib\font.h
?????文件????????4119??2017-01-04?10:11??WiringOP-zero\devLib\gertboard.c
?????文件????????1484??2017-01-04?10:11??WiringOP-zero\devLib\gertboard.h
?????文件????????1440??2017-01-04?10:11??WiringOP-zero\devLib\gertboard.o
?????文件???????11549??2017-01-04?10:11??WiringOP-zero\devLib\lcd.c
?????文件????????2095??2017-01-04?10:11??WiringOP-zero\devLib\lcd.h
?????文件????????3884??2017-01-04?10:11??WiringOP-zero\devLib\lcd.o
............此處省略199個文件信息
- 上一篇:MSP430簡單計算器的實現
- 下一篇:存儲器讀寫程序代碼及實驗要求
評論
共有 條評論