From 04af01a672879f58623c3696abb5f68842b03311 Mon Sep 17 00:00:00 2001 From: Lee Atkinson Date: Sat, 27 Aug 2022 14:47:12 -0400 Subject: [PATCH] Pin Validation fixed/readmultiple return fixed --- ports/raspberrypi/common-hal/adcbuffer/BufferedInput.c | 7 ++----- shared-bindings/adcbuffer/BufferedInput.c | 3 ++- shared-bindings/adcbuffer/BufferedInput.h | 2 +- shared-bindings/adcbuffer/__init__.c | 1 - 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ports/raspberrypi/common-hal/adcbuffer/BufferedInput.c b/ports/raspberrypi/common-hal/adcbuffer/BufferedInput.c index 50f2dc5d1a..b42bed2c0c 100644 --- a/ports/raspberrypi/common-hal/adcbuffer/BufferedInput.c +++ b/ports/raspberrypi/common-hal/adcbuffer/BufferedInput.c @@ -47,7 +47,7 @@ void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t *self, const mcu_pin_obj_t *pin, uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint32_t sample_rate) { // Make sure pin number is in range for ADC - if (pin->number < ADC_FIRST_PIN_NUMBER && pin->number >= (ADC_FIRST_PIN_NUMBER + ADC_PIN_COUNT)) { + if (pin->number < ADC_FIRST_PIN_NUMBER || pin->number >= (ADC_FIRST_PIN_NUMBER + ADC_PIN_COUNT)) { raise_ValueError_invalid_pins(); } @@ -122,7 +122,6 @@ void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t // clear any previous activity adc_fifo_drain(); adc_run(false); - } bool common_hal_adcbuffer_bufferedinput_deinited(adcbuffer_bufferedinput_obj_t *self) { @@ -142,7 +141,7 @@ void common_hal_adcbuffer_bufferedinput_deinit(adcbuffer_bufferedinput_obj_t *se dma_channel_unclaim(self->dma_chan); } -bool common_hal_adcbuffer_bufferedinput_readmultiple(adcbuffer_bufferedinput_obj_t *self) { +void common_hal_adcbuffer_bufferedinput_readmultiple(adcbuffer_bufferedinput_obj_t *self) { uint32_t cdl = self->len / self->bytes_per_sample; @@ -163,6 +162,4 @@ bool common_hal_adcbuffer_bufferedinput_readmultiple(adcbuffer_bufferedinput_obj // Clean up adc_run(false); adc_fifo_drain(); - - return true; } diff --git a/shared-bindings/adcbuffer/BufferedInput.c b/shared-bindings/adcbuffer/BufferedInput.c index 25e1b75cd7..da7cb9525a 100644 --- a/shared-bindings/adcbuffer/BufferedInput.c +++ b/shared-bindings/adcbuffer/BufferedInput.c @@ -157,7 +157,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adcbuffer_bufferedinput___exit___obj, STATIC mp_obj_t adcbuffer_bufferedinput_obj_readmultiple(mp_obj_t self_in) { adcbuffer_bufferedinput_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - return MP_OBJ_NEW_SMALL_INT(common_hal_adcbuffer_bufferedinput_readmultiple(self)); + common_hal_adcbuffer_bufferedinput_readmultiple(self); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(adcbuffer_bufferedinput_readmultiple_obj, adcbuffer_bufferedinput_obj_readmultiple); diff --git a/shared-bindings/adcbuffer/BufferedInput.h b/shared-bindings/adcbuffer/BufferedInput.h index 42b9f94558..25411a3d7c 100644 --- a/shared-bindings/adcbuffer/BufferedInput.h +++ b/shared-bindings/adcbuffer/BufferedInput.h @@ -35,6 +35,6 @@ extern const mp_obj_type_t adcbuffer_bufferedinput_type; void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t *self, const mcu_pin_obj_t *pin, uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint32_t sample_rate); void common_hal_adcbuffer_bufferedinput_deinit(adcbuffer_bufferedinput_obj_t *self); bool common_hal_adcbuffer_bufferedinput_deinited(adcbuffer_bufferedinput_obj_t *self); -bool common_hal_adcbuffer_bufferedinput_readmultiple(adcbuffer_bufferedinput_obj_t *self); +void common_hal_adcbuffer_bufferedinput_readmultiple(adcbuffer_bufferedinput_obj_t *self); #endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER_BUFFEREDINPUT_H__ diff --git a/shared-bindings/adcbuffer/__init__.c b/shared-bindings/adcbuffer/__init__.c index 4d5fefc26e..447f01ea15 100644 --- a/shared-bindings/adcbuffer/__init__.c +++ b/shared-bindings/adcbuffer/__init__.c @@ -69,7 +69,6 @@ STATIC const mp_rom_map_elem_t adcbuffer_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_adcbuffer) }, { MP_ROM_QSTR(MP_QSTR_BufferedInput), MP_ROM_PTR(&adcbuffer_bufferedinput_type) }, - // #ifdef CIRCUITPY_BUFFEREDINPUT #endif }; STATIC MP_DEFINE_CONST_DICT(adcbuffer_module_globals, adcbuffer_module_globals_table);