Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/AP_Bootloader/custom.cpp
Views: 1798
/*1custom code for specific boards2*/3#include <AP_HAL/AP_HAL.h>4#include "ch.h"5#include "hal.h"6#include "support.h"78#ifdef AP_BOOTLOADER_CUSTOM_HERE49/*10reset here4 LEDs11*/12static void bootloader_custom_Here4(void)13{14for (uint8_t n=0; n<10; n++) {15const uint8_t num_leds = 4;16const uint32_t min_bits = num_leds*25+50;17const uint8_t num_leading_zeros = 8-min_bits%8 + 50;18const uint32_t output_stream_byte_length = (min_bits+7)/8;19palSetLineMode(HAL_GPIO_PIN_LED_DI, PAL_MODE_OUTPUT_PUSHPULL);20palSetLineMode(HAL_GPIO_PIN_LED_SCK, PAL_MODE_OUTPUT_PUSHPULL);21int l = 100;22while (l--) {23for (uint32_t i=0; i<output_stream_byte_length; i++) {24for (uint8_t bit = 0; bit < 8; bit++) {25uint32_t out_bit_idx = i*8+bit;26uint8_t bit_val;27if (out_bit_idx < num_leading_zeros) {28bit_val = 0;29} else if ((out_bit_idx-num_leading_zeros) % 25 == 0) {30bit_val = 1;31} else {32bit_val = 0;33}3435palClearLine(HAL_GPIO_PIN_LED_SCK);36palWriteLine(HAL_GPIO_PIN_LED_DI, bit_val);37palSetLine(HAL_GPIO_PIN_LED_SCK);38}39}40}41chThdSleepMilliseconds(10);42}43}44#endif // AP_BOOTLOADER_CUSTOM_HERE44546void custom_startup(void)47{48#ifdef AP_BOOTLOADER_CUSTOM_HERE449bootloader_custom_Here4();50#endif51}525354