summaryrefslogtreecommitdiff
path: root/ports
diff options
context:
space:
mode:
authorScott Shawcroft <scott.shawcroft@gmail.com>2018-06-01 13:11:40 -0700
committerScott Shawcroft <scott.shawcroft@gmail.com>2018-06-01 15:08:52 -0700
commit717199018bcb43dd50af9011e2259f3caf3290f8 (patch)
tree366dd7e8759bf43472807b2c0822280967eead56 /ports
parentf386144428b8ad4fab29e0df6657856141e7f96b (diff)
Adapt for feedback and hack around pIRkey size constraint.
Diffstat (limited to 'ports')
-rw-r--r--ports/atmel-samd/common-hal/busio/I2C.c4
-rw-r--r--ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c5
-rw-r--r--ports/atmel-samd/peripherals/samd21/events.c12
3 files changed, 15 insertions, 6 deletions
diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c
index 66929beff..c14b2d68f 100644
--- a/ports/atmel-samd/common-hal/busio/I2C.c
+++ b/ports/atmel-samd/common-hal/busio/I2C.c
@@ -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;
diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
index 9f378f169..ddc545295 100644
--- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
+++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c
@@ -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);
diff --git a/ports/atmel-samd/peripherals/samd21/events.c b/ports/atmel-samd/peripherals/samd21/events.c
index 70dfa249d..08b82c91f 100644
--- a/ports/atmel-samd/peripherals/samd21/events.c
+++ b/ports/atmel-samd/peripherals/samd21/events.c
@@ -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;