Adapt for feedback and hack around pIRkey size constraint.
This commit is contained in:
parent
f386144428
commit
717199018b
|
@ -41,6 +41,10 @@
|
|||
|
||||
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
|
||||
const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, uint32_t frequency, uint32_t timeout) {
|
||||
#ifdef PIRKEY_M0
|
||||
mp_raise_NotImplementedError("Not enough pins available");
|
||||
return;
|
||||
#endif
|
||||
Sercom* sercom = NULL;
|
||||
uint8_t sercom_index;
|
||||
uint32_t sda_pinmux = 0;
|
||||
|
|
|
@ -96,6 +96,11 @@ mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementa
|
|||
return self->position;
|
||||
}
|
||||
|
||||
void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t* self,
|
||||
mp_int_t new_position) {
|
||||
self->position = new_position;
|
||||
}
|
||||
|
||||
void incrementalencoder_interrupt_handler(uint8_t channel) {
|
||||
rotaryio_incrementalencoder_obj_t* self = get_eic_channel_data(channel);
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ void init_event_channel_interrupt(uint8_t channel, uint8_t gclk, uint8_t generat
|
|||
EVSYS_CHANNEL_EVGEN(generator) |
|
||||
EVSYS_CHANNEL_PATH_RESYNCHRONIZED |
|
||||
EVSYS_CHANNEL_EDGSEL_RISING_EDGE;
|
||||
if (channel > 7) {
|
||||
uint8_t value = 1 << (channel - 7);
|
||||
if (channel >= 8) {
|
||||
uint8_t value = 1 << (channel - 8);
|
||||
EVSYS->INTFLAG.reg = EVSYS_INTFLAG_EVDp8(value) | EVSYS_INTFLAG_OVRp8(value);
|
||||
EVSYS->INTENSET.reg = EVSYS_INTENSET_EVDp8(value) | EVSYS_INTENSET_OVRp8(value);
|
||||
} else {
|
||||
|
@ -87,8 +87,8 @@ void init_event_channel_interrupt(uint8_t channel, uint8_t gclk, uint8_t generat
|
|||
|
||||
bool event_interrupt_active(uint8_t channel) {
|
||||
bool active = false;
|
||||
if (channel > 7) {
|
||||
uint8_t value = 1 << (channel - 7);
|
||||
if (channel >= 8) {
|
||||
uint8_t value = 1 << (channel - 8);
|
||||
active = (EVSYS->INTFLAG.reg & EVSYS_INTFLAG_EVDp8(value)) != 0;
|
||||
// Only clear if we know its active, otherwise there is the possibility it becomes active
|
||||
// after we check but before we clear.
|
||||
|
@ -107,8 +107,8 @@ bool event_interrupt_active(uint8_t channel) {
|
|||
|
||||
bool event_interrupt_overflow(uint8_t channel) {
|
||||
bool overflow = false;
|
||||
if (channel > 7) {
|
||||
uint8_t value = 1 << (channel - 7);
|
||||
if (channel >= 8) {
|
||||
uint8_t value = 1 << (channel - 8);
|
||||
overflow = (EVSYS->INTFLAG.reg & EVSYS_INTFLAG_OVRp8(value)) != 0;
|
||||
} else {
|
||||
uint8_t value = 1 << channel;
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
|
||||
//| .. currentmodule:: rotaryio
|
||||
//|
|
||||
//| :class:`IncrementalEncoder` -- Read the position of the incremental encoder
|
||||
//| ============================================================================
|
||||
//| :class:`IncrementalEncoder` -- Track the relative position of an incremental encoder
|
||||
//| ====================================================================================
|
||||
//|
|
||||
//| IncrementalEncoder determines the relative rotational position based on two series of pulses.
|
||||
//|
|
||||
|
@ -47,8 +47,8 @@
|
|||
//| state of an incremental rotary encoder (also known as a quadrature encoder.) Position is
|
||||
//| relative to the position when the object is contructed.
|
||||
//|
|
||||
//| :param ~microcontroller.Pin pin: First pin to read pulses from.
|
||||
//| :param ~microcontroller.Pin pin: Second pin to read pulses from.
|
||||
//| :param ~microcontroller.Pin pin_a: First pin to read pulses from.
|
||||
//| :param ~microcontroller.Pin pin_b: Second pin to read pulses from.
|
||||
//|
|
||||
//| For example::
|
||||
//|
|
||||
|
@ -94,7 +94,7 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type,
|
|||
|
||||
//| .. method:: deinit()
|
||||
//|
|
||||
//| Deinitialises the IncrementalEncoder and releases any hardware resources for reuse.
|
||||
//| Deinitializes the IncrementalEncoder and releases any hardware resources for reuse.
|
||||
//|
|
||||
STATIC mp_obj_t rotaryio_incrementalencoder_deinit(mp_obj_t self_in) {
|
||||
rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
@ -135,10 +135,19 @@ STATIC mp_obj_t rotaryio_incrementalencoder_obj_get_position(mp_obj_t self_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(rotaryio_incrementalencoder_get_position_obj, rotaryio_incrementalencoder_obj_get_position);
|
||||
|
||||
STATIC mp_obj_t rotaryio_incrementalencoder_obj_set_position(mp_obj_t self_in, mp_obj_t new_position) {
|
||||
rotaryio_incrementalencoder_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
raise_error_if_deinited(common_hal_rotaryio_incrementalencoder_deinited(self));
|
||||
|
||||
common_hal_rotaryio_incrementalencoder_set_position(self, mp_obj_get_int(new_position));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(rotaryio_incrementalencoder_set_position_obj, rotaryio_incrementalencoder_obj_set_position);
|
||||
|
||||
const mp_obj_property_t rotaryio_incrementalencoder_position_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = {(mp_obj_t)&rotaryio_incrementalencoder_get_position_obj,
|
||||
(mp_obj_t)&mp_const_none_obj,
|
||||
(mp_obj_t)&rotaryio_incrementalencoder_set_position_obj,
|
||||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
|
|
|
@ -37,5 +37,7 @@ extern void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementa
|
|||
extern void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_obj_t* self);
|
||||
extern bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incrementalencoder_obj_t* self);
|
||||
extern mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementalencoder_obj_t* self);
|
||||
extern void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t* self,
|
||||
mp_int_t new_position);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_ROTARYIO_INCREMENTALENCODER_H
|
||||
|
|
Loading…
Reference in New Issue