Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of DigitalSw by
Diff: DigitalSw.cpp
- Revision:
- 5:9198c5c0afcb
- Parent:
- 0:45e3ec3004a6
- Child:
- 6:55845c4ef887
diff -r cd8bb4f0b08d -r 9198c5c0afcb DigitalSw.cpp
--- a/DigitalSw.cpp Sun Oct 23 09:46:01 2016 +0000
+++ b/DigitalSw.cpp Sat Oct 29 01:46:17 2016 +0000
@@ -7,8 +7,8 @@
/**
*
*/
-DigitalSw::DigitalSw(PinName sw
- ) : _sw(sw)
+DigitalSw::DigitalSw(PinName sw, uint8_t pull
+ ) : _sw(sw), _pull(pull)
{
_onEdge = 0;
@@ -16,8 +16,12 @@
_levelNow = 1;
_levelOld = 1;
- _sw.mode(PullUp);
-
+ if(_pull == 1) {
+ _sw.mode(PullUp);
+ } else {
+ _sw.mode(PullDown);
+ }
+
_sw.rise(this, &DigitalSw::swLevelUp);
_sw.fall(this, &DigitalSw::swLevelDown);
@@ -60,6 +64,7 @@
uint8_t levelCheck = 0xaa;
while((levelCheck != 0x00) && (levelCheck != 0xff)) {
+ wait_us(100);
levelCheck = (levelCheck << 1) | _sw.read();
}
@@ -79,6 +84,7 @@
uint8_t levelCheck = 0xaa;
while((levelCheck != 0x00) && (levelCheck != 0xff)) {
+ wait_us(100);
levelCheck = (levelCheck << 1) | _sw.read();
}
