As both C and C++ standards require applications running under an OS to
return 'int', adapt that for Zephyr to align with those standard. This also
eliminates errors when building with clang when not using -ffreestanding,
and reduces the need for compiler flags to silence warnings for both clang
and gcc.
Most of these changes were automated using coccinelle with the following
script:
@@
@@
- void
+ int
main(...) {
...
- return;
+ return 0;
...
}
Approximately 40 files had to be edited by hand as coccinelle was unable to
fix them.
Signed-off-by: Keith Packard <keithp@keithp.com>
44 lines
800 B
C
44 lines
800 B
C
/*
|
|
* Copyright (c) 2016 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/drivers/gpio.h>
|
|
|
|
/* 1000 msec = 1 sec */
|
|
#define SLEEP_TIME_MS 1000
|
|
|
|
/* The devicetree node identifier for the "led0" alias. */
|
|
#define LED0_NODE DT_ALIAS(led0)
|
|
|
|
/*
|
|
* A build error on this line means your board is unsupported.
|
|
* See the sample documentation for information on how to fix this.
|
|
*/
|
|
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
|
|
|
|
int main(void)
|
|
{
|
|
int ret;
|
|
|
|
if (!gpio_is_ready_dt(&led)) {
|
|
return 0;
|
|
}
|
|
|
|
ret = gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);
|
|
if (ret < 0) {
|
|
return 0;
|
|
}
|
|
|
|
while (1) {
|
|
ret = gpio_pin_toggle_dt(&led);
|
|
if (ret < 0) {
|
|
return 0;
|
|
}
|
|
k_msleep(SLEEP_TIME_MS);
|
|
}
|
|
return 0;
|
|
}
|