summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-05-02 14:38:54 +1000
committerDamien George <damien.p.george@gmail.com>2020-05-08 23:40:22 +1000
commite12de1fd9d6016e75eec6ebde2b4a50093a8bc78 (patch)
tree2e07b29527ce878df40b2af9b911cfaac9e277df
parentf792e6c283e90067919e083c5ce6db156c0cd0e2 (diff)
esp8266: Clean up Pin intr handler by moving all code to machine_pin.c.
The macro MP_FASTCODE is used to explicitly place required functions in iRAM, instead of needing a separate .c file.
-rw-r--r--ports/esp8266/Makefile1
-rw-r--r--ports/esp8266/intr.c37
-rw-r--r--ports/esp8266/machine_pin.c15
-rw-r--r--ports/esp8266/modmachine.h2
4 files changed, 12 insertions, 43 deletions
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile
index 7fb1bc43c..38b91a545 100644
--- a/ports/esp8266/Makefile
+++ b/ports/esp8266/Makefile
@@ -93,7 +93,6 @@ SRC_C = \
esppwm.c \
espneopixel.c \
espapa102.c \
- intr.c \
modpyb.c \
modmachine.c \
machine_pin.c \
diff --git a/ports/esp8266/intr.c b/ports/esp8266/intr.c
deleted file mode 100644
index 456d6cb04..000000000
--- a/ports/esp8266/intr.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2016 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#include "etshal.h"
-#include "ets_alt_task.h"
-
-#include "modmachine.h"
-
-// this is in a separate file so it can go in iRAM
-void pin_intr_handler_iram(void *arg) {
- uint32_t status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
- GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, status);
- pin_intr_handler(status);
-}
diff --git a/ports/esp8266/machine_pin.c b/ports/esp8266/machine_pin.c
index 4e74ad652..419ee87a7 100644
--- a/ports/esp8266/machine_pin.c
+++ b/ports/esp8266/machine_pin.c
@@ -59,6 +59,9 @@ typedef struct _pin_irq_obj_t {
uint16_t phys_port;
} pin_irq_obj_t;
+STATIC void pin_intr_handler_part1(void *arg);
+STATIC void pin_intr_handler_part2(uint32_t status);
+
const pyb_pin_obj_t pyb_pin_obj[16 + 1] = {
{{&pyb_pin_type}, 0, FUNC_GPIO0, PERIPHS_IO_MUX_GPIO0_U},
{{&pyb_pin_type}, 1, FUNC_GPIO1, PERIPHS_IO_MUX_U0TXD_U},
@@ -88,7 +91,7 @@ STATIC const pin_irq_obj_t pin_irq_obj[16];
void pin_init0(void) {
ETS_GPIO_INTR_DISABLE();
- ETS_GPIO_INTR_ATTACH(pin_intr_handler_iram, NULL);
+ ETS_GPIO_INTR_ATTACH(pin_intr_handler_part1, NULL);
// disable all interrupts
memset(&MP_STATE_PORT(pin_irq_handler)[0], 0, 16 * sizeof(mp_obj_t));
for (int p = 0; p < 16; ++p) {
@@ -98,7 +101,13 @@ void pin_init0(void) {
ETS_GPIO_INTR_ENABLE();
}
-void MP_FASTCODE(pin_intr_handler)(uint32_t status) {
+void MP_FASTCODE(pin_intr_handler_part1)(void *arg) {
+ uint32_t status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);
+ GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, status);
+ pin_intr_handler_part2(status);
+}
+
+void MP_FASTCODE(pin_intr_handler_part2)(uint32_t status) {
status &= 0xffff;
for (int p = 0; status; ++p, status >>= 1) {
if (status & 1) {
@@ -478,7 +487,7 @@ STATIC const pin_irq_obj_t pin_irq_obj[16] = {
STATIC mp_obj_t pin_irq_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
pin_irq_obj_t *self = self_in;
mp_arg_check_num(n_args, n_kw, 0, 0, false);
- pin_intr_handler(1 << self->phys_port);
+ pin_intr_handler_part2(1 << self->phys_port);
return mp_const_none;
}
diff --git a/ports/esp8266/modmachine.h b/ports/esp8266/modmachine.h
index cea382d24..f5cfc0fa2 100644
--- a/ports/esp8266/modmachine.h
+++ b/ports/esp8266/modmachine.h
@@ -23,8 +23,6 @@ typedef struct _pyb_pin_obj_t {
const pyb_pin_obj_t pyb_pin_obj[16 + 1];
void pin_init0(void);
-void pin_intr_handler_iram(void *arg);
-void pin_intr_handler(uint32_t);
uint mp_obj_get_pin(mp_obj_t pin_in);
pyb_pin_obj_t *mp_obj_get_pin_obj(mp_obj_t pin_in);