zephyr/samples/subsys/edac/src/main.c
Gerard Marull-Paretas c7b5b3c419 samples: migrate includes to contain <zephyr/...> prefix
In order to bring consistency in-tree, migrate all samples to the use
the new prefix <zephyr/...>. Note that the conversion has been scripted:

```python
from pathlib import Path
import re

EXTENSIONS = ("c", "h", "cpp", "rst")

for p in Path(".").glob("samples/**/*"):
    if not p.is_file() or p.suffix and p.suffix[1:] not in EXTENSIONS:
        continue

    content = ""
    with open(p) as f:
        for line in f:
            m = re.match(r"^(.*)#include <(.*)>(.*)$", line)
            if (m and
                not m.group(2).startswith("zephyr/") and
                (Path(".") / "include" / "zephyr" / m.group(2)).exists()):
                content += (
                    m.group(1) +
                    "#include <zephyr/" + m.group(2) +">" +
                    m.group(3) + "\n"
                )
            else:
                content += line

    with open(p, "w") as f:
        f.write(content)
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 11:29:59 +02:00

67 lines
1.3 KiB
C

/*
* Copyright (c) 2020 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/zephyr.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/edac.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
#define STACKSIZE 1024
#define PRIORITY 7
static atomic_t handled;
/**
* Callback called from ISR. Runs in supervisor mode
*/
static void notification_callback(const struct device *dev, void *data)
{
/* Special care need to be taken for NMI callback:
* delayed_work, mutex and semaphores are not working stable
* here, using integer increment for now
*/
atomic_set(&handled, true);
}
#define DEVICE_NAME DT_LABEL(DT_NODELABEL(ibecc))
void main(void)
{
const struct device *dev;
dev = device_get_binding(DEVICE_NAME);
if (!dev) {
LOG_ERR("Cannot open EDAC device: %s", DEVICE_NAME);
return;
}
if (edac_notify_callback_set(dev, notification_callback)) {
LOG_ERR("Cannot set notification callback");
return;
}
LOG_INF("EDAC shell application initialized");
}
void thread_function(void)
{
LOG_DBG("Thread started");
while (true) {
if (atomic_cas(&handled, true, false)) {
printk("Got notification about IBECC event\n");
k_sleep(K_MSEC(300));
}
}
}
K_THREAD_DEFINE(thread_id, STACKSIZE, thread_function, NULL, NULL, NULL,
PRIORITY, 0, 0);