extmod: Add and reorganise compilation guards and includes.

To reduce dependencies on header files when extmod components are disabled.

Signed-off-by: Damien George <damien.p.george@gmail.com>
This commit is contained in:
Damien George
2022-11-11 15:43:55 +11:00
parent 2f05653673
commit a513558e3a
8 changed files with 26 additions and 10 deletions

View File

@@ -28,6 +28,9 @@
#include <string.h>
#include "py/runtime.h"
#if MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_SOFTSPI
#include "extmod/machine_spi.h"
// if a port didn't define MSB/LSB constants then provide them
@@ -39,8 +42,6 @@
/******************************************************************************/
// MicroPython bindings for generic machine.SPI
#if MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_SOFTSPI
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_obj_base_t *s = (mp_obj_base_t *)MP_OBJ_TO_PTR(args[0]);
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t *)MP_OBJ_TYPE_GET_SLOT(s->type, protocol);