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>
41 lines
957 B
C
41 lines
957 B
C
/*
|
|
* Copyright (c) 2020 Matija Tudan
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/device.h>
|
|
#include <zephyr/devicetree.h>
|
|
#include <zephyr/drivers/sensor.h>
|
|
|
|
int main(void)
|
|
{
|
|
const struct device *const dev = DEVICE_DT_GET_ONE(maxim_max17262);
|
|
|
|
if (!device_is_ready(dev)) {
|
|
printk("sensor: device not ready.\n");
|
|
return 0;
|
|
}
|
|
|
|
while (1) {
|
|
struct sensor_value voltage, avg_current, temperature;
|
|
float i_avg;
|
|
|
|
sensor_sample_fetch(dev);
|
|
sensor_channel_get(dev, SENSOR_CHAN_GAUGE_VOLTAGE, &voltage);
|
|
sensor_channel_get(dev, SENSOR_CHAN_GAUGE_AVG_CURRENT,
|
|
&avg_current);
|
|
sensor_channel_get(dev, SENSOR_CHAN_GAUGE_TEMP, &temperature);
|
|
|
|
i_avg = avg_current.val1 + (avg_current.val2 / 1000000.0);
|
|
|
|
printk("V: %d.%06d V; I: %f mA; T: %d.%06d °C\n",
|
|
voltage.val1, voltage.val2, (double)i_avg,
|
|
temperature.val1, temperature.val2);
|
|
|
|
k_sleep(K_MSEC(1000));
|
|
}
|
|
return 0;
|
|
}
|