Skip to content

Commit

Permalink
use codal pulse (#3642)
Browse files Browse the repository at this point in the history
* use codal pulse

* updated pins

* updated for next codal

* updated api

Co-authored-by: Peli de Halleux <peli@Pelis-MacBook-Pro.local>
  • Loading branch information
pelikhan and Peli de Halleux authored Nov 10, 2020
1 parent 31d6106 commit f76c3f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions libs/core/pins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -269,6 +280,7 @@ namespace pins {
}
uint64_t end = system_timer_current_time_us();
return end - start;
#endif
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pxtarget.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f76c3f7

Please sign in to comment.