diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index 6b67e014a3..2119605878 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -146,7 +146,8 @@ void frequencyin_reference_tc_init() { return; } #ifdef SAMD21 - turn_on_clocks(true, reference_tc, 0, TC_HANDLER_FREQUENCYIN); + set_timer_handler(reference_tc, dpll_gclk, TC_HANDLER_FREQUENCYIN); + turn_on_clocks(true, reference_tc, 0); #endif // use the DPLL we setup so that the reference_tc and freqin_tc(s) // are using the same clock frequency. @@ -384,7 +385,7 @@ void common_hal_frequencyio_frequencyin_deinit(frequencyio_frequencyin_obj_t* se if (common_hal_frequencyio_frequencyin_deinited(self)) { return; } - reset_pin(self->pin); + reset_pin_number(self->pin); // turn off EIC & EVSYS utilized by this TC disable_event_channel(self->event_channel); @@ -480,11 +481,11 @@ void common_hal_frequencyio_frequencyin_pause(frequencyio_frequencyin_obj_t* sel #ifdef SAMD21 uint32_t masked_value = EIC->EVCTRL.vec.EXTINTEO; - EIC->EVCTRL.vec.EXTINTEO = masked_value | (0 << self->channel); + EIC->EVCTRL.vec.EXTINTEO = masked_value ^ (1 << self->channel); #endif #ifdef SAMD51 uint32_t masked_value = EIC->EVCTRL.bit.EXTINTEO; - EIC->EVCTRL.bit.EXTINTEO = masked_value | (0 << self->channel); + EIC->EVCTRL.bit.EXTINTEO = masked_value ^ (1 << self->channel); #endif return; } diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 0e666d718e..fb1698fa2e 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -71,20 +71,18 @@ //| frequency.clear() //| STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, - size_t n_kw, const mp_obj_t *pos_args) { - mp_arg_check_num(n_args, n_kw, 1, 2, true); + const mp_obj_t *pos_args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 1, 1, true); frequencyio_frequencyin_obj_t *self = m_new_obj(frequencyio_frequencyin_obj_t); self->base.type = &frequencyio_frequencyin_type; - mp_map_t kw_args; - mp_map_init_fixed_table(&kw_args, n_kw, pos_args + n_args); enum { ARG_pin, ARG_capture_period }; static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_capture_period, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 10} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - mp_arg_parse_all(n_args, pos_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); assert_pin(args[ARG_pin].u_obj, false); mcu_pin_obj_t* pin = MP_OBJ_TO_PTR(args[ARG_pin].u_obj); diff --git a/shared-bindings/frequencyio/FrequencyIn.h b/shared-bindings/frequencyio/FrequencyIn.h index 4718075ece..dba6c3a661 100644 --- a/shared-bindings/frequencyio/FrequencyIn.h +++ b/shared-bindings/frequencyio/FrequencyIn.h @@ -1,4 +1,4 @@ -frequencyio/* +/* * This file is part of the Micro Python project, http://micropython.org/ * * The MIT License (MIT)