Correctly reset the PTC

This commit is contained in:
Scott Shawcroft 2018-05-22 14:20:35 -07:00
parent 31bcd1c45c
commit 3607d3ba2c
2 changed files with 12 additions and 2 deletions

View File

@ -114,7 +114,14 @@ void common_hal_touchio_touchin_deinit(touchio_touchin_obj_t* self) {
}
void touchin_reset() {
// TODO(tannewt): Reset the PTC.
Ptc* ptc = ((Ptc *) PTC);
if (ptc->CTRLA.bit.ENABLE == 1) {
ptc->CTRLA.bit.ENABLE = 0;
while (ptc->CTRLA.bit.ENABLE == 1) {}
ptc->CTRLA.bit.SWRESET = 1;
while (ptc->CTRLA.bit.SWRESET == 1) {}
}
}
bool common_hal_touchio_touchin_get_value(touchio_touchin_obj_t *self) {

View File

@ -53,6 +53,7 @@
#include "common-hal/pulseio/PulseOut.h"
#include "common-hal/pulseio/PWMOut.h"
#include "common-hal/rtc/RTC.h"
#include "common-hal/touchio/TouchIn.h"
#include "common-hal/usb_hid/Device.h"
#include "shared-bindings/rtc/__init__.h"
#include "clocks.h"
@ -240,8 +241,10 @@ void reset_port(void) {
i2sout_reset();
#endif
audio_dma_reset();
// touchin_reset();
//pdmin_reset();
#endif
#ifdef SAMD21
touchin_reset();
#endif
pulsein_reset();
pulseout_reset();