AP_Bootloader: added custom LED reset for Here4AP

This commit is contained in:
Andrew Tridgell 2023-07-31 14:15:59 +10:00
parent 865be0df64
commit abea5f8353
4 changed files with 57 additions and 0 deletions

View File

@ -63,6 +63,8 @@ AP_FlashIface_JEDEC ext_flash;
int main(void) int main(void)
{ {
custom_startup();
#ifdef STM32F427xx #ifdef STM32F427xx
if (BOARD_FLASH_SIZE > 1024 && check_limit_flash_1M()) { if (BOARD_FLASH_SIZE > 1024 && check_limit_flash_1M()) {
board_info.fw_size = (1024 - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024; board_info.fw_size = (1024 - (FLASH_BOOTLOADER_LOAD_KB + APP_START_OFFSET_KB))*1024;

View File

@ -0,0 +1,52 @@
/*
custom code for specific boards
*/
#include <AP_HAL/AP_HAL.h>
#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<output_stream_byte_length; i++) {
for (uint8_t bit = 0; bit < 8; bit++) {
uint32_t out_bit_idx = i*8+bit;
uint8_t bit_val;
if (out_bit_idx < num_leading_zeros) {
bit_val = 0;
} else if ((out_bit_idx-num_leading_zeros) % 25 == 0) {
bit_val = 1;
} else {
bit_val = 0;
}
palClearLine(HAL_GPIO_PIN_LED_SCK);
palWriteLine(HAL_GPIO_PIN_LED_DI, bit_val);
palSetLine(HAL_GPIO_PIN_LED_SCK);
}
}
}
chThdSleepMilliseconds(10);
}
}
#endif // AP_BOOTLOADER_CUSTOM_HERE4
void custom_startup(void)
{
#ifdef AP_BOOTLOADER_CUSTOM_HERE4
bootloader_custom_Here4();
#endif
}

View File

@ -469,3 +469,4 @@ void port_setbaud(uint32_t baudrate)
#endif #endif
} }
#endif // BOOTLOADER_DEV_LIST #endif // BOOTLOADER_DEV_LIST

View File

@ -44,6 +44,8 @@ void led_on(unsigned led);
void led_off(unsigned led); void led_off(unsigned led);
void led_toggle(unsigned led); void led_toggle(unsigned led);
void custom_startup(void);
// printf to debug uart (or USB) // printf to debug uart (or USB)
extern "C" { extern "C" {
void uprintf(const char *fmt, ...) FMT_PRINTF(1,2); void uprintf(const char *fmt, ...) FMT_PRINTF(1,2);