|
diff --git a/apps/blinky/src/main.c b/apps/blinky/src/main.c
|
| ... |
| 4 |
|
4 |
|
| 5 |
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios); |
5 |
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios); |
| 6 |
|
6 |
|
| 7 |
int main(void) { |
7 |
#define STACKSIZE 1024 |
| 8 |
int ret; |
8 |
#define PRIORITY 7 |
| 9 |
|
9 |
|
| 10 |
printk("Blinky starting (main thread)...\n"); |
10 |
void blink_thread(void *p1, void *p2, void *p3) { |
|
|
11 |
int ret; |
| 11 |
|
12 |
|
| 12 |
if (!gpio_is_ready_dt(&led)) { |
13 |
if (!gpio_is_ready_dt(&led)) { |
| 13 |
printk("Error: LED device %s is not ready\n", led.port->name); |
14 |
printk("Error: LED device %s is not ready\n", led.port->name); |
| 14 |
return 0; |
15 |
return; |
| 15 |
} |
16 |
} |
| 16 |
|
17 |
|
| 17 |
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE); |
18 |
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE); |
| 18 |
if (ret < 0) { |
19 |
if (ret < 0) { |
| 19 |
printk("Error %d: failed to configure LED pin\n", ret); |
20 |
printk("Error %d: failed to configure LED pin\n", ret); |
| 20 |
return 0; |
21 |
return; |
| 21 |
} |
22 |
} |
| 22 |
|
23 |
|
| 23 |
while (1) { |
24 |
while (1) { |
| ... |
| 29 |
gpio_pin_set_dt(&led, 0); |
30 |
gpio_pin_set_dt(&led, 0); |
| 30 |
k_msleep(500); |
31 |
k_msleep(500); |
| 31 |
} |
32 |
} |
|
|
33 |
} |
| 32 |
|
34 |
|
|
|
35 |
K_THREAD_DEFINE(blink_thread_id, STACKSIZE, blink_thread, NULL, NULL, NULL, PRIORITY, 0, 0); |
|
|
36 |
|
|
|
37 |
int main(void) { |
|
|
38 |
printk("Blinky starting (main thread)...\n"); |
| 33 |
return 0; |
39 |
return 0; |
| 34 |
} |
40 |
} |