Pin Validation fixed/readmultiple return fixed
This commit is contained in:
parent
7cd969e236
commit
04af01a672
@ -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) {
|
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
|
// 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();
|
raise_ValueError_invalid_pins();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,6 @@ void common_hal_adcbuffer_bufferedinput_construct(adcbuffer_bufferedinput_obj_t
|
|||||||
// clear any previous activity
|
// clear any previous activity
|
||||||
adc_fifo_drain();
|
adc_fifo_drain();
|
||||||
adc_run(false);
|
adc_run(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool common_hal_adcbuffer_bufferedinput_deinited(adcbuffer_bufferedinput_obj_t *self) {
|
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);
|
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;
|
uint32_t cdl = self->len / self->bytes_per_sample;
|
||||||
|
|
||||||
@ -163,6 +162,4 @@ bool common_hal_adcbuffer_bufferedinput_readmultiple(adcbuffer_bufferedinput_obj
|
|||||||
// Clean up
|
// Clean up
|
||||||
adc_run(false);
|
adc_run(false);
|
||||||
adc_fifo_drain();
|
adc_fifo_drain();
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
STATIC mp_obj_t adcbuffer_bufferedinput_obj_readmultiple(mp_obj_t self_in) {
|
||||||
adcbuffer_bufferedinput_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
adcbuffer_bufferedinput_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
check_for_deinit(self);
|
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);
|
MP_DEFINE_CONST_FUN_OBJ_1(adcbuffer_bufferedinput_readmultiple_obj, adcbuffer_bufferedinput_obj_readmultiple);
|
||||||
|
|
||||||
|
@ -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_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);
|
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_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__
|
#endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ADCBUFFER_BUFFEREDINPUT_H__
|
||||||
|
@ -69,7 +69,6 @@
|
|||||||
STATIC const mp_rom_map_elem_t adcbuffer_module_globals_table[] = {
|
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___name__), MP_ROM_QSTR(MP_QSTR_adcbuffer) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_BufferedInput), MP_ROM_PTR(&adcbuffer_bufferedinput_type) },
|
{ 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);
|
STATIC MP_DEFINE_CONST_DICT(adcbuffer_module_globals, adcbuffer_module_globals_table);
|
||||||
|
Loading…
Reference in New Issue
Block a user