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.
pull/5999/head
Damien George 2020-05-02 14:38:54 +10:00
rodzic f792e6c283
commit e12de1fd9d
4 zmienionych plików z 12 dodań i 43 usunięć

Wyświetl plik

@ -93,7 +93,6 @@ SRC_C = \
esppwm.c \
espneopixel.c \
espapa102.c \
intr.c \
modpyb.c \
modmachine.c \
machine_pin.c \

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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);