Add espidf module.
This commit is contained in:
parent
b3a449c276
commit
1034cc1217
@ -166,6 +166,7 @@ SRC_C += \
|
||||
background.c \
|
||||
fatfs_port.c \
|
||||
mphalport.c \
|
||||
bindings/espidf/__init__.c \
|
||||
boards/$(BOARD)/board.c \
|
||||
boards/$(BOARD)/pins.c \
|
||||
modules/$(CIRCUITPY_MODULE).c \
|
||||
|
79
ports/esp32s2/bindings/espidf/__init__.c
Normal file
79
ports/esp32s2/bindings/espidf/__init__.c
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* This file is part of the MicroPython project, http://micropython.org/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 Scott Shawcroft for Adafruit Industries
|
||||
*
|
||||
* 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 "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "esp-idf/components/heap/include/esp_heap_caps.h"
|
||||
|
||||
//| """Direct access to a few ESP-IDF details. This module *should not* include any functionality
|
||||
//| that could be implemented by other frameworks. It should only include ESP-IDF specific
|
||||
//| things."""
|
||||
|
||||
//| def heap_caps_get_total_size() -> int:
|
||||
//| """Return the total size of the ESP-IDF, which includes the CircuitPython heap."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t espidf_heap_caps_get_total_size(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(heap_caps_get_total_size(MALLOC_CAP_8BIT));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_total_size_obj, espidf_heap_caps_get_total_size);
|
||||
|
||||
//| def heap_caps_get_free_size() -> int:
|
||||
//| """Return total free memory in the ESP-IDF heap."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t espidf_heap_caps_get_free_size(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(heap_caps_get_free_size(MALLOC_CAP_8BIT));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_free_size_obj, espidf_heap_caps_get_free_size);
|
||||
|
||||
//| def heap_caps_get_largest_free_block() -> int:
|
||||
//| """Return the size of largest free memory block in the ESP-IDF heap."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t espidf_heap_caps_get_largest_free_block(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(espidf_heap_caps_get_largest_free_block_obj, espidf_heap_caps_get_largest_free_block);
|
||||
|
||||
STATIC const mp_rom_map_elem_t espidf_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_espidf) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_heap_caps_get_total_size), MP_ROM_PTR(&espidf_heap_caps_get_total_size_obj)},
|
||||
{ MP_ROM_QSTR(MP_QSTR_heap_caps_get_free_size), MP_ROM_PTR(&espidf_heap_caps_get_free_size_obj)},
|
||||
{ MP_ROM_QSTR(MP_QSTR_heap_caps_get_largest_free_block), MP_ROM_PTR(&espidf_heap_caps_get_largest_free_block_obj)},
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(espidf_module_globals, espidf_module_globals_table);
|
||||
|
||||
const mp_obj_module_t espidf_module = {
|
||||
.base = { &mp_type_module },
|
||||
.globals = (mp_obj_dict_t*)&espidf_module_globals,
|
||||
};
|
@ -25,5 +25,6 @@ CIRCUITPY_RTC = 0
|
||||
CIRCUITPY_NVM = 0
|
||||
CIRCUITPY_USB_MIDI = 0 # We don't have enough endpoints to include MIDI.
|
||||
CIRCUITPY_WIFI = 1
|
||||
CIRCUITPY_ESPIDF = 1
|
||||
|
||||
CIRCUITPY_MODULE ?= none
|
||||
|
@ -363,6 +363,13 @@ extern const struct _mp_obj_module_t terminalio_module;
|
||||
#define TERMINALIO_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_ESPIDF
|
||||
extern const struct _mp_obj_module_t espidf_module;
|
||||
#define ESPIDF_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_espidf),(mp_obj_t)&espidf_module },
|
||||
#else
|
||||
#define ESPIDF_MODULE
|
||||
#endif
|
||||
|
||||
#if CIRCUITPY_FRAMEBUFFERIO
|
||||
extern const struct _mp_obj_module_t framebufferio_module;
|
||||
#define FRAMEBUFFERIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_framebufferio), (mp_obj_t)&framebufferio_module },
|
||||
@ -750,6 +757,7 @@ extern const struct _mp_obj_module_t wifi_module;
|
||||
TERMINALIO_MODULE \
|
||||
VECTORIO_MODULE \
|
||||
ERRNO_MODULE \
|
||||
ESPIDF_MODULE \
|
||||
FRAMEBUFFERIO_MODULE \
|
||||
FREQUENCYIO_MODULE \
|
||||
GAMEPAD_MODULE \
|
||||
|
@ -95,6 +95,12 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO)
|
||||
CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD)
|
||||
CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO)
|
||||
|
||||
# CIRCUITPY_ESPIDF is handled in the atmel-samd tree.
|
||||
# Only for ESP32S chips.
|
||||
# Assume not a ESP build.
|
||||
CIRCUITPY_ESPIDF ?= 0
|
||||
CFLAGS += -DCIRCUITPY_ESPIDF=$(CIRCUITPY_ESPIDF)
|
||||
|
||||
ifeq ($(CIRCUITPY_DISPLAYIO),1)
|
||||
CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD)
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user