Skip to content

Commit f7504ff

Browse files
committed
Tweaks based on review comments
1 parent 255e997 commit f7504ff

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

ports/raspberrypi/common-hal/analogbufio/BufferedIn.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *s
7979

8080
// sample_rate is forced to be >= 1 in shared-bindings
8181
float clk_div = (float)ADC_CLOCK_INPUT / (float)sample_rate;
82-
mp_printf(&mp_plat_print, "clk_div %f for %d\n", (double)clk_div, sample_rate);
8382
adc_set_clkdiv(clk_div);
8483

8584
// 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
122121
// RP2040 Implementation Detail
123122
// Fills the supplied buffer with ADC values using DMA transfer.
124123
// If the buffer is 8-bit, then values are 8-bit shifted and error bit is off.
125-
// If buffer is 16-bit, then values are not shifted and error bit is present.
124+
// If buffer is 16-bit, then values are 12-bit and error bit is present. We
125+
// stretch the 12-bit value to 16-bits and truncate the number of valid
126+
// samples at the first sample with the error bit set.
126127
// Number of transfers is always the number of samples which is the array
127128
// byte length divided by the bytes_per_sample.
128129
uint dma_size = DMA_SIZE_8;

shared-bindings/analogbufio/BufferedIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
//| import array
4848
//|
4949
//| length = 1000
50-
//| mybuffer = array.array("H", 0x0000 for i in range(length))
50+
//| mybuffer = array.array("H", [0x0000] * length)
5151
//| rate = 500000
5252
//| adcbuf = analogbufio.BufferedIn(board.GP26, sample_rate=rate)
5353
//| adcbuf.readinto(mybuffer)

0 commit comments

Comments
 (0)