-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
50 lines (40 loc) · 1.04 KB
/
Copy pathmain.cpp
File metadata and controls
50 lines (40 loc) · 1.04 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
#include "pico/stdlib.h"
#include "FreeRTOS.h"
#include "task.h"
// Define the stack overflow hook
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName) {
// Handle the stack overflow
for(;;);
}
// Define the malloc failed hook
void vApplicationMallocFailedHook(void) {
// Handle the malloc failure
for(;;);
}
// Define the LED pin
#define LED_PIN 25
// Task to blink the LED
void vBlinkTask(void *pvParameters) {
const TickType_t xDelay = 500 / portTICK_PERIOD_MS; // 500 ms delay
// Initialize the GPIO for the LED
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
while (true) {
// Toggle the LED
gpio_put(LED_PIN, 1);
vTaskDelay(xDelay);
gpio_put(LED_PIN, 0);
vTaskDelay(xDelay);
}
}
int main() {
// Initialize stdio
stdio_init_all();
// Create the blink task
xTaskCreate(vBlinkTask, "Blink Task", 256, NULL, 1, NULL);
// Start the scheduler
vTaskStartScheduler();
// Will never reach here
while (true) {
}
}