From f7504ff857f597a4b18502d759a2a31159b3bc30 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Fri, 2 Dec 2022 10:19:31 -0800 Subject: [PATCH] Tweaks based on review comments --- ports/raspberrypi/common-hal/analogbufio/BufferedIn.c | 5 +++-- shared-bindings/analogbufio/BufferedIn.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c b/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c index 1b0a0d684a..bc5f9028b7 100644 --- a/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c +++ b/ports/raspberrypi/common-hal/analogbufio/BufferedIn.c @@ -79,7 +79,6 @@ void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *s // sample_rate is forced to be >= 1 in shared-bindings float clk_div = (float)ADC_CLOCK_INPUT / (float)sample_rate; - mp_printf(&mp_plat_print, "clk_div %f for %d\n", (double)clk_div, sample_rate); adc_set_clkdiv(clk_div); // Set up the DMA to start transferring data as soon as it appears in FIFO @@ -122,7 +121,9 @@ uint32_t common_hal_analogbufio_bufferedin_readinto(analogbufio_bufferedin_obj_t // RP2040 Implementation Detail // Fills the supplied buffer with ADC values using DMA transfer. // If the buffer is 8-bit, then values are 8-bit shifted and error bit is off. - // If buffer is 16-bit, then values are not shifted and error bit is present. + // If buffer is 16-bit, then values are 12-bit and error bit is present. We + // stretch the 12-bit value to 16-bits and truncate the number of valid + // samples at the first sample with the error bit set. // Number of transfers is always the number of samples which is the array // byte length divided by the bytes_per_sample. uint dma_size = DMA_SIZE_8; diff --git a/shared-bindings/analogbufio/BufferedIn.c b/shared-bindings/analogbufio/BufferedIn.c index d6c6b4a46e..193552c313 100644 --- a/shared-bindings/analogbufio/BufferedIn.c +++ b/shared-bindings/analogbufio/BufferedIn.c @@ -47,7 +47,7 @@ //| import array //| //| length = 1000 -//| mybuffer = array.array("H", 0x0000 for i in range(length)) +//| mybuffer = array.array("H", [0x0000] * length) //| rate = 500000 //| adcbuf = analogbufio.BufferedIn(board.GP26, sample_rate=rate) //| adcbuf.readinto(mybuffer)