Having an input-only pin is rare, save a string on other ports

This commit is contained in:
Jeff Epler 2022-11-08 15:46:48 -06:00
parent 4158ddfc17
commit c46e219795
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
5 changed files with 14 additions and 0 deletions

View File

@ -99,4 +99,6 @@
#define CIRCUITPY_PORT_NUM_SUPERVISOR_ALLOCATIONS (1)
#endif
#define CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY (1)
#endif // MICROPY_INCLUDED_ESPRESSIF_MPCONFIGPORT_H

View File

@ -582,6 +582,10 @@ void supervisor_run_background_tasks_if_tick(void);
#define MICROPY_WRAP_MP_EXECUTE_BYTECODE PLACE_IN_ITCM
#endif
#ifndef CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY
#define CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY (0)
#endif
#ifndef CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL
#define CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL (0)
#endif

View File

@ -105,9 +105,13 @@ STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type
if (args[ARG_chip_select].u_obj != MP_OBJ_NULL) {
digitalinout_result_t result = common_hal_digitalio_digitalinout_switch_to_output(MP_OBJ_TO_PTR(args[ARG_chip_select].u_obj),
true, DRIVE_MODE_PUSH_PULL);
#if CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY
if (result == DIGITALINOUT_INPUT_ONLY) {
mp_raise_NotImplementedError(translate("Pin is input only"));
}
#else
(void)result;
#endif
}
return (mp_obj_t)self;

View File

@ -53,8 +53,10 @@ STATIC void check_result(digitalinout_result_t result) {
return;
case DIGITALINOUT_PIN_BUSY:
mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_Pin);
#if CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY
case DIGITALINOUT_INPUT_ONLY:
mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_direction);
#endif
#if CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL
case DIGITALINOUT_INVALID_PULL:
mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_pull);

View File

@ -38,7 +38,9 @@ extern const mp_obj_type_t digitalio_digitalinout_type;
typedef enum {
DIGITALINOUT_OK,
DIGITALINOUT_PIN_BUSY,
#if CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY
DIGITALINOUT_INPUT_ONLY,
#endif
#if CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL
DIGITALINOUT_INVALID_PULL,
#endif