-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathled.c
More file actions
32 lines (23 loc) · 866 Bytes
/
led.c
File metadata and controls
32 lines (23 loc) · 866 Bytes
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
#include "hardware/gpio.h"
#include "FreeRTOS.h"
#include "task.h"
#include "jconfig.h"
//--------------------------------------------------------------------+
// BLINKING TASK
//--------------------------------------------------------------------+
extern uint32_t blink_interval_ms;
static void led_init(int pin) {
gpio_init(pin);
gpio_set_dir(pin, GPIO_OUT); // Set as output
gpio_put(pin, false); // Start with the LED off
}
void led_task(void* pvParameters) {
config_t* config = (config_t*)pvParameters; // Cast parameter to config_t pointer
led_init(config->led_pin);
bool led_state = false; // Initial LED state
while (1) {
gpio_put(config->led_pin, led_state); // Set LED state
led_state = !led_state; // Toggle state
vTaskDelay(pdMS_TO_TICKS(blink_interval_ms));
}
}