From abea5f8353c233586a42ae34a7769b2e2f2ac481 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 31 Jul 2023 14:15:59 +1000 Subject: [PATCH] AP_Bootloader: added custom LED reset for Here4AP --- Tools/AP_Bootloader/AP_Bootloader.cpp | 2 ++ Tools/AP_Bootloader/custom.cpp | 52 +++++++++++++++++++++++++++ Tools/AP_Bootloader/support.cpp | 1 + Tools/AP_Bootloader/support.h | 2 ++ 4 files changed, 57 insertions(+) create mode 100644 Tools/AP_Bootloader/custom.cpp diff --git a/Tools/AP_Bootloader/AP_Bootloader.cpp b/Tools/AP_Bootloader/AP_Bootloader.cpp index 4f3edcfe69..f422712080 100644 --- a/Tools/AP_Bootloader/AP_Bootloader.cpp +++ b/Tools/AP_Bootloader/AP_Bootloader.cpp @@ -63,6 +63,8 @@ AP_FlashIface_JEDEC ext_flash; int main(void) { + custom_startup(); + #ifdef STM32F427xx if (BOARD_FLASH_SIZE > 1024 && check_limit_flash_1M()) { board_info.fw_size = (1024 - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024; diff --git a/Tools/AP_Bootloader/custom.cpp b/Tools/AP_Bootloader/custom.cpp new file mode 100644 index 0000000000..ef5f7ef434 --- /dev/null +++ b/Tools/AP_Bootloader/custom.cpp @@ -0,0 +1,52 @@ +/* + custom code for specific boards + */ +#include +#include "ch.h" +#include "hal.h" +#include "support.h" + +#ifdef AP_BOOTLOADER_CUSTOM_HERE4 +/* + reset here4 LEDs +*/ +static void bootloader_custom_Here4(void) +{ + for (uint8_t n=0; n<10; n++) { + const uint8_t num_leds = 4; + const uint32_t min_bits = num_leds*25+50; + const uint8_t num_leading_zeros = 8-min_bits%8 + 50; + const uint32_t output_stream_byte_length = (min_bits+7)/8; + palSetLineMode(HAL_GPIO_PIN_LED_DI, PAL_MODE_OUTPUT_PUSHPULL); + palSetLineMode(HAL_GPIO_PIN_LED_SCK, PAL_MODE_OUTPUT_PUSHPULL); + int l = 100; + while (l--) { + for (uint32_t i=0; i