samples: blinky: add verbose printf output
Add console output to the sample, with the LED status upon a GPIO toggle. Signed-off-by: Patryk Koscik <pkoscik@antmicro.com>
This commit is contained in:
parent
7e253ff937
commit
b22bb172f2
2 changed files with 8 additions and 2 deletions
|
@ -40,8 +40,9 @@ Build and flash Blinky as follows, changing ``reel_board`` for your board:
|
||||||
:goals: build flash
|
:goals: build flash
|
||||||
:compact:
|
:compact:
|
||||||
|
|
||||||
After flashing, the LED starts to blink. If a runtime error occurs, the sample
|
After flashing, the LED starts to blink and messages with the current LED state
|
||||||
exits without printing to the console.
|
are printed on the console. If a runtime error occurs, the sample exits without
|
||||||
|
printing to the console.
|
||||||
|
|
||||||
Build errors
|
Build errors
|
||||||
************
|
************
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <zephyr/kernel.h>
|
#include <zephyr/kernel.h>
|
||||||
#include <zephyr/drivers/gpio.h>
|
#include <zephyr/drivers/gpio.h>
|
||||||
|
|
||||||
|
@ -22,6 +23,7 @@ static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
bool led_state = true;
|
||||||
|
|
||||||
if (!gpio_is_ready_dt(&led)) {
|
if (!gpio_is_ready_dt(&led)) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -37,6 +39,9 @@ int main(void)
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
led_state = !led_state;
|
||||||
|
printf("LED state: %s\n", led_state ? "ON" : "OFF");
|
||||||
k_msleep(SLEEP_TIME_MS);
|
k_msleep(SLEEP_TIME_MS);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue