diff --git a/Tools/AP_Periph/AP_Periph.cpp b/Tools/AP_Periph/AP_Periph.cpp index 65e722c49c..ef2025415a 100644 --- a/Tools/AP_Periph/AP_Periph.cpp +++ b/Tools/AP_Periph/AP_Periph.cpp @@ -306,7 +306,9 @@ void AP_Periph_FW::update() if (now - last_led_ms > 1000) { last_led_ms = now; #ifdef HAL_GPIO_PIN_LED - palToggleLine(HAL_GPIO_PIN_LED); + if (!no_iface_finished_dna) { + palToggleLine(HAL_GPIO_PIN_LED); + } #endif #if 0 #ifdef HAL_PERIPH_ENABLE_GPS diff --git a/Tools/AP_Periph/AP_Periph.h b/Tools/AP_Periph/AP_Periph.h index 3808d4ba0d..e8e0e6da34 100644 --- a/Tools/AP_Periph/AP_Periph.h +++ b/Tools/AP_Periph/AP_Periph.h @@ -231,6 +231,8 @@ public: // show stack as DEBUG msgs void show_stack_free(); + + static bool no_iface_finished_dna; }; namespace AP diff --git a/Tools/AP_Periph/can.cpp b/Tools/AP_Periph/can.cpp index 8a894685ef..9b887911ba 100644 --- a/Tools/AP_Periph/can.cpp +++ b/Tools/AP_Periph/can.cpp @@ -486,7 +486,7 @@ static void handle_allocation_response(CanardInstance* ins, CanardRxTransfer* tr (void) canardDecodeScalar(transfer, 0, 7, false, &allocated_node_id); canardSetLocalNodeID(ins, allocated_node_id); - printf("Node ID allocated: %d\n", allocated_node_id); + printf("IF%d Node ID allocated: %d\n", can_ins->index, allocated_node_id); } } @@ -1214,22 +1214,41 @@ static void process1HzTasks(uint64_t timestamp_usec) /* wait for dynamic allocation of node ID */ -static bool no_iface_finished_dna = true; +bool AP_Periph_FW::no_iface_finished_dna = true; static bool can_do_dna(instance_t &ins) { if (canardGetLocalNodeID(&ins.canard) != CANARD_BROADCAST_NODE_ID) { - no_iface_finished_dna = false; + AP_Periph_FW::no_iface_finished_dna = false; return true; } + const uint32_t now = AP_HAL::native_millis(); + const uint32_t led_pattern = 0xAAAA; + const uint32_t led_change_period = 50; + static uint8_t led_idx = 0; + static uint32_t last_led_change; + + if ((now - last_led_change > led_change_period) && AP_Periph_FW::no_iface_finished_dna) { + // blink LED in recognisable pattern while waiting for DNA +#ifdef HAL_GPIO_PIN_LED + palWriteLine(HAL_GPIO_PIN_LED, (led_pattern & (1U< led_change_period) { - // blink LED in recognisable pattern while waiting for DNA -#ifdef HAL_GPIO_PIN_LED - palWriteLine(HAL_GPIO_PIN_LED, (led_pattern & (1U< ins.send_next_node_id_allocation_request_at_ms) { + can_do_dna(ins); + } } static uint32_t last_1Hz_ms;