From d545eecd61a298903d4d944a2a6246a50a843426 Mon Sep 17 00:00:00 2001 From: johnny9 <985648+johnny9@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:10:53 -0500 Subject: [PATCH] bm1366: count number of chips on the chain --- components/bm1397/bm1366.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/bm1397/bm1366.c b/components/bm1397/bm1366.c index 3ac10bf6..830e4276 100644 --- a/components/bm1397/bm1366.c +++ b/components/bm1397/bm1366.c @@ -445,6 +445,16 @@ static void _send_init(uint64_t frequency) unsigned char init3[7] = {0x55, 0xAA, 0x52, 0x05, 0x00, 0x00, 0x0A}; _send_simple(init3, 7); + int chip_counter = 0; + while (true) { + if(SERIAL_rx(asic_response_buffer, 11, 1000) > 0) { + chip_counter++; + } else { + break; + } + } + ESP_LOGI(TAG, "%i chip(s) detected on the chain", chip_counter); + unsigned char init4[11] = {0x55, 0xAA, 0x51, 0x09, 0x00, 0xA8, 0x00, 0x07, 0x00, 0x00, 0x03}; _send_simple(init4, 11);