Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use codal pulse #3642

Merged
merged 5 commits into from
Nov 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libs/core/pins.cpp
Original file line number Diff line number Diff line change
@@ -254,6 +254,17 @@ namespace pins {
MicroBitPin* pin = getPin((int)name);
if (!pin) return 0;

#if MICROBIT_CODAL
// set polarity
pin->setPolarity(PulseValue::High == value ? 1 : 0);
// record pulse
int period = pin->getPulseUs(maxDuration);
// timeout
if (DEVICE_CANCELLED == period)
return 0;
// success!
return period;
#else
int pulse = value == PulseValue::High ? 1 : 0;
uint64_t tick = system_timer_current_time_us();
uint64_t maxd = (uint64_t)maxDuration;
@@ -269,6 +280,7 @@ namespace pins {
}
uint64_t end = system_timer_current_time_us();
return end - start;
#endif
}

/**
2 changes: 1 addition & 1 deletion pxtarget.json
Original file line number Diff line number Diff line change
@@ -153,7 +153,7 @@
"codalTarget": {
"name": "codal-microbit-v2",
"url": "https://github.com/lancaster-university/codal-microbit-v2",
"branch": "v0.2.17",
"branch": "v0.2.18",
"type": "git"
},
"codalBinary": "MICROBIT",