CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/AP_Bootloader/custom.cpp
Views: 1798
1
/*
2
custom code for specific boards
3
*/
4
#include <AP_HAL/AP_HAL.h>
5
#include "ch.h"
6
#include "hal.h"
7
#include "support.h"
8
9
#ifdef AP_BOOTLOADER_CUSTOM_HERE4
10
/*
11
reset here4 LEDs
12
*/
13
static void bootloader_custom_Here4(void)
14
{
15
for (uint8_t n=0; n<10; n++) {
16
const uint8_t num_leds = 4;
17
const uint32_t min_bits = num_leds*25+50;
18
const uint8_t num_leading_zeros = 8-min_bits%8 + 50;
19
const uint32_t output_stream_byte_length = (min_bits+7)/8;
20
palSetLineMode(HAL_GPIO_PIN_LED_DI, PAL_MODE_OUTPUT_PUSHPULL);
21
palSetLineMode(HAL_GPIO_PIN_LED_SCK, PAL_MODE_OUTPUT_PUSHPULL);
22
int l = 100;
23
while (l--) {
24
for (uint32_t i=0; i<output_stream_byte_length; i++) {
25
for (uint8_t bit = 0; bit < 8; bit++) {
26
uint32_t out_bit_idx = i*8+bit;
27
uint8_t bit_val;
28
if (out_bit_idx < num_leading_zeros) {
29
bit_val = 0;
30
} else if ((out_bit_idx-num_leading_zeros) % 25 == 0) {
31
bit_val = 1;
32
} else {
33
bit_val = 0;
34
}
35
36
palClearLine(HAL_GPIO_PIN_LED_SCK);
37
palWriteLine(HAL_GPIO_PIN_LED_DI, bit_val);
38
palSetLine(HAL_GPIO_PIN_LED_SCK);
39
}
40
}
41
}
42
chThdSleepMilliseconds(10);
43
}
44
}
45
#endif // AP_BOOTLOADER_CUSTOM_HERE4
46
47
void custom_startup(void)
48
{
49
#ifdef AP_BOOTLOADER_CUSTOM_HERE4
50
bootloader_custom_Here4();
51
#endif
52
}
53
54