-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapplication1.c
More file actions
58 lines (45 loc) · 1.64 KB
/
application1.c
File metadata and controls
58 lines (45 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include "pico/stdlib.h"
#include <string.h> // for memcmp
#include "hardware/structs/scb.h" // Für Zugriff auf SCB->VTOR
#include "hardware/sync.h"
#include "flash.h"
#define GATE_PIN 22 //GATE PIN, MOSFET for power supply control
void hold_power(void) {
gpio_init(GATE_PIN);
gpio_set_dir(GATE_PIN, GPIO_OUT);
gpio_put(GATE_PIN, 1); // Drive the gate pin high to keep power on
printf("Gate Pin on -> Power switch on\n");
}
void switch_off(void) {
printf("Gate Pin off -> Power switch off\n");
gpio_put(GATE_PIN, 0); // Drive the gate pin high to keep power on
}
__attribute__((section(".firmware_header")))
const firmware_header_t firmware_header = {
.magic = FIRMWARE_MAGIC,
.valid_flag = 1,
.build_date = "250719",
.git_version = "v1.2.0-6-gcddef-dirty",
.firmware_size = 23252, //
.slot = 0,
.crc32 = 0 // not implemented
};
_Static_assert(sizeof(firmware_header_t) == 256, "Firmware header must be exactly 256 bytes - check size of header! (arm-none-eabi-size -A application1.elf | grep firmware_header)");
void main(void) {
// hold_power();
sleep_ms(10); // Allow debug interface to initialize
stdio_init_all(); // Enable UART output for debug_log
// Wait until USB-CDC is ready
while (!stdio_usb_connected()) {
sleep_ms(10);
}
printf("\n\n=== Hello Application 1 !===\n");
while (1) {
sleep_ms(500); // Idle loop, could blink LED or enter USB recovery
// printf("\n\n=== looping...===\n");
// stdio_flush();
// sleep_ms(50);
// switch_off();
}
}