summaryrefslogtreecommitdiff
path: root/shared-module/_pew
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2019-03-01 14:59:21 +0100
committerRadomir Dopieralski <openstack@sheep.art.pl>2019-03-01 14:59:21 +0100
commit45fea86554d42d07360ec16574908bc96c5e37ec (patch)
treedc975ed9cfa9a8532fffbfdd80004d6302a17dfc /shared-module/_pew
parent48f0a5163e6a3a5e44e6df231867b9bc90ce933b (diff)
Rebase on top of CircuitPython 4.x
Diffstat (limited to 'shared-module/_pew')
-rw-r--r--shared-module/_pew/PewPew.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/shared-module/_pew/PewPew.c b/shared-module/_pew/PewPew.c
index cbe7164bc..2900f2ac7 100644
--- a/shared-module/_pew/PewPew.c
+++ b/shared-module/_pew/PewPew.c
@@ -35,6 +35,8 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "shared-bindings/util.h"
#include "samd/timers.h"
+#include "supervisor/shared/translate.h"
+#include "timer_handler.h"
static uint8_t pewpew_tc_index = 0xff;
@@ -77,10 +79,11 @@ void pew_init() {
}
}
if (tc == NULL) {
- mp_raise_RuntimeError("All timers in use");
+ mp_raise_RuntimeError(translate(""));
}
pewpew_tc_index = index;
+ set_timer_handler(true, index, TC_HANDLER_PEW);
// We use GCLK0 for SAMD21 and GCLK1 for SAMD51 because they both run
// at 48mhz making our math the same across the boards.
@@ -106,7 +109,6 @@ void pew_init() {
#endif
tc_set_enable(tc, true);
- //tc->COUNT16.CTRLBSET.reg = TC_CTRLBSET_CMD_STOP;
tc->COUNT16.CC[0].reg = 160;
// Clear our interrupt in case it was set earlier
@@ -117,7 +119,9 @@ void pew_init() {
}
void pew_reset(void) {
- tc_insts[pewpew_tc_index]->COUNT16.CTRLA.bit.ENABLE = 0;
- pewpew_tc_index = 0xff;
+ if (pewpew_tc_index != 0xff) {
+ tc_reset(tc_insts[pewpew_tc_index]);
+ pewpew_tc_index = 0xff;
+ }
MP_STATE_VM(pew_singleton) = NULL;
}