Add initial sensor sampler and processing components
This commit is contained in:
+8
-1
@@ -9,7 +9,14 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(app LANGUAGES C)
|
||||
|
||||
target_sources(app PRIVATE src/main.cpp)
|
||||
target_sources(app
|
||||
PRIVATE
|
||||
src/main.cpp
|
||||
src/SensorDataProcessor.cpp
|
||||
src/SensorDataProcessor.hpp
|
||||
src/SensorSampler.cpp
|
||||
src/SensorSampler.hpp
|
||||
)
|
||||
|
||||
# The code below locates the git index file for this repository and adds it as a dependency for
|
||||
# the application VERSION file so that if the repo has a new commit added, even if no files in
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "SensorDataProcessor.hpp"
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
void app::SensorDataProcessor::entryPoint(void *, void *, void *) {
|
||||
while (true) {
|
||||
printk("app::SensorDataProcessor::entryPoint - Running...\n");
|
||||
k_sleep(K_SECONDS(5));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SENSOR_DATA_PROCESSOR_HPP
|
||||
#define SENSOR_DATA_PROCESSOR_HPP
|
||||
|
||||
namespace app {
|
||||
|
||||
class SensorDataProcessor {
|
||||
public:
|
||||
SensorDataProcessor() = default;
|
||||
~SensorDataProcessor() = default;
|
||||
|
||||
// Thread entry
|
||||
static void entryPoint(void *, void *, void *);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,9 @@
|
||||
#include "SensorSampler.hpp"
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
void app::SensorSampler::entryPoint(void *, void *, void *) {
|
||||
while (true) {
|
||||
printk("app::SensorSampler::entryPoint - Running...\n");
|
||||
k_sleep(K_SECONDS(5));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef SENSOR_SAMPLER_HPP
|
||||
#define SENSOR_SAMPLER_HPP
|
||||
|
||||
namespace app {
|
||||
|
||||
class SensorSampler {
|
||||
public:
|
||||
SensorSampler() = default;
|
||||
~SensorSampler() = default;
|
||||
|
||||
// Thread entry
|
||||
static void entryPoint(void *, void *, void *);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
||||
+18
-3
@@ -3,19 +3,34 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "SensorDataProcessor.hpp"
|
||||
#include "SensorSampler.hpp"
|
||||
#include <app_version.h>
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/logging/log.h>
|
||||
|
||||
#include <app_version.h>
|
||||
|
||||
LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
|
||||
|
||||
// Sensor Data Processor
|
||||
static constexpr size_t SensorDataProcessorStackSize = 1024;
|
||||
static constexpr size_t SensorDataProcessorPriority = 5;
|
||||
K_THREAD_DEFINE(SensorDataProcessorThreadId, SensorDataProcessorStackSize,
|
||||
app::SensorDataProcessor::entryPoint, NULL, NULL, NULL,
|
||||
SensorDataProcessorPriority, 0, 0);
|
||||
|
||||
// Sensor Sampler
|
||||
static constexpr size_t SensorSamplerStackSize = 1024;
|
||||
static constexpr size_t SensorSamplerPriority = 5;
|
||||
K_THREAD_DEFINE(SensorSamplerThreadId, SensorSamplerStackSize,
|
||||
app::SensorSampler::entryPoint, NULL, NULL, NULL,
|
||||
SensorSamplerPriority, 0, 0);
|
||||
|
||||
int main() {
|
||||
printk("Zephyr Example Application %s\n", APP_VERSION_STRING);
|
||||
printk("Build with C++ standard: %ldL\n", __cplusplus);
|
||||
|
||||
while (true) {
|
||||
printk("Running...\n");
|
||||
printk("main - Running...\n");
|
||||
k_sleep(K_SECONDS(5));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user