Skip to content
Snippets Groups Projects
Commit cf5671b1 authored by Dzulfikar Ahmad  Samhan's avatar Dzulfikar Ahmad Samhan
Browse files

Initial commit

parent 3615e81b
Branches
1 merge request!1Initial commit
Showing
with 447 additions and 5 deletions
.build*
.ccache
pythonenv*
sample*
\ No newline at end of file
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build app posix",
"type": "shell",
"command": "./scripts/docker_run.sh west build -b native_sim debug-app/app --build-dir .build-debug-app-native",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
}
},
{
"label": "Build app evk",
"type": "shell",
"command": "./scripts/docker_run.sh west build -b stm32f4_disco debug-app/app --build-dir .build-debug-app-evk",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
}
},
// {
// "label": "Flash app only",
// "type": "shell",
// "command": "./scripts/docker_run.sh west flash --build-dir .build-mtp-lpmcu-lpc55s28-app-only",
// "problemMatcher": [
// "$gcc"
// ],
// "group": {
// "kind": "build",
// "isDefault": true
// },
// "presentation": {
// "clear": true
// }
// },
// {
// "label": "Run Posix",
// "type": "shell",
// "command": " ./scripts/docker_run.sh west build -t run --build-dir .build-debug-app-qemu",
// "problemMatcher": [
// "$gcc"
// ],
// "group": {
// "kind": "build",
// "isDefault": true
// },
// "presentation": {
// "clear": true
// }
// },
{
"label": "Clean",
"type": "shell",
"command": "./scripts/docker_run.sh rm -rf .build-debug-app*",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
}
},
{
"label": "Update",
"type": "shell",
"command": "./scripts/docker_run.sh west update",
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"clear": true
}
}
]
}
\ No newline at end of file
[manifest]
path = debug-app
file = west.yml
[zephyr]
base = zephyr
[manifest]
path = zephyr
[zephyr]
base = zephyr
[manifest]
path = debug-app
file = west.yml
[zephyr]
base = zephyr
......@@ -4,11 +4,12 @@
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
- update SDK for the first time after clone.
- build `ctrl+shift+b` choose `build for evk`
- run on native `./scripts/docker_run.sh ./.build-debug-app-native/zephyr/zephyr.exe`
- run on evk `ctrl+shift+b` choose `Flash app evk`
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
<!-- ## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
......@@ -90,4 +91,4 @@ Show your appreciation to those who have contributed to the project.
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. -->
zephyr_include_directories(include)
add_subdirectory(module)
# add_subdirectory(drivers)
\ No newline at end of file
cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(debug-tracing LANGUAGES C CXX)
target_sources(app PRIVATE src/main.cpp)
# CONFIG_BOOTLOADER_MCUBOOT=y
# CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="mtp-lpmcu/app/rsa-2048-priv.pem"
# CONFIG_MCUBOOT_EXTRA_IMGTOOL_ARGS="--align 4 --header-size 0x400 --pad-header --slot-size 0x30000 --max-sectors 32"
# CONFIG_ROM_START_OFFSET=0x400
# CONFIG_USE_DT_CODE_PARTITION=y
\ No newline at end of file
# C++
CONFIG_CPP=y
CONFIG_CPP_MAIN=y
CONFIG_STD_CPP17=y
CONFIG_MINIMAL_LIBCPP=y
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y
CONFIG_NEWLIB_LIBC=y
# Zephyr
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=512
CONFIG_THREAD_NAME=y
CONFIG_ASSERT=y
CONFIG_NO_OPTIMIZATIONS=y
# Peripheral
# CONFIG_ADC=y
# CONFIG_ADC_ASYNC=y
# CONFIG_SPI=y
# CONFIG_SPI_ASYNC=y
# CONFIG_GPIO=y
# CONFIG_I2C=y
# CONFIG_SERIAL=y
# CONFIG_UART_ASYNC_API=y
# CONFIG_UART_INTERRUPT_DRIVEN=y
#bus
CONFIG_ZBUS=y
CONFIG_ZBUS_LOG_LEVEL_INF=y
CONFIG_ZBUS_RUNTIME_OBSERVERS=y
CONFIG_ZBUS_CHANNEL_NAME=y
# PM
# CONFIG_PM=y
# CONFIG_PM_DEVICE=y
# CONFIG_PM_DEVICE_RUNTIME=y
# Log
CONFIG_LOG=y
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCjicog4G1DPSIL
8hwIulmBSmRV7wxoIUePokMa0O1XAhLiQwepYQsgAJ0S8B+M9XduDeNJ3JZY8hEA
3RmrKw5m2OcLJ7Aix09DKAectRu9O9JFUyxoCdxRz6sjtL4XKNdBD+f19ez0cxHK
JptJEPxUjskFvfeN5BQXQXUsZoT/G/xvMDu0PpkZ2W2KxrAOzYjr07+AT7N73nOw
HB/SYb4qgycGI8sPfYr1OVZaKCM51Q4gl/qy2zsjCaKiZ6DiOm0IfSfxSy5qIe0Y
s/yuxvo3i6lGR299c+p2xBb/q4imnXjfnM5aikSBFBtyAS3dN2+eV1nqgqpS4WZG
qzAFfHZpAgMBAAECggEAITYaHaeeIN3RJH5oWZBonWRbcIUx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xFMHttMcyPgMg4BAVdr/012tqmlwOS3vvankblECrR8e2ZCH
AfpGOcEPktCphYHFKY5+UmN06YQ2HdwIN7sNkpH+cYr7OX98f3NdO5pP30KLgPgO
zyPvjQG1+bSvH/bUpB1MluY=
-----END PRIVATE KEY-----
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/zbus/zbus.h>
#include "main-handler.h"
#include "debug-handler.h"
#include "driver-hook.h"
#include "utilities.h"
LOG_MODULE_REGISTER(main);
DriverMessage_t defaultDriverMsg;
StateMessage_t defaultStateMsg;
ZBUS_CHAN_DEFINE(driverRequestChannel, /* Name */
DriverMessage_t, /* Message type */
NULL, /* Validator */
NULL, /* User data */
ZBUS_OBSERVERS_EMPTY, /* observers */
ZBUS_MSG_INIT(defaultDriverMsg)
);
ZBUS_CHAN_DEFINE(driverResponseChannel, /* Name */
DriverMessage_t, /* Message type */
NULL, /* Validator */
NULL, /* User data */
ZBUS_OBSERVERS_EMPTY, /* observers */
ZBUS_MSG_INIT(defaultDriverMsg)
);
ZBUS_CHAN_DEFINE(stateChannel, /* Name */
StateMessage_t, /* Message type */
NULL, /* Validator */
NULL, /* User data */
ZBUS_OBSERVERS_EMPTY, /* observers */
ZBUS_MSG_INIT(defaultStateMsg)
);
int main()
{
MainHandler mainHandler;
DriverHook DriverHook;
DebugHandler debugHanddler;
while(true) {
// LOG_INF("Hello World! run app\n");
k_sleep(K_SECONDS(5));
}
}
\ No newline at end of file
#include <zephyr/kernel.h>
class DebugHandler {
public:
/** Constructor.
*
**/
DebugHandler();
/** Destructor.
*
**/
~DebugHandler();
void Init();
int Deinit();
static void DriverResponseListener(const struct zbus_channel *chan);
static void StateListener(const struct zbus_channel *chan);
private:
static void DebugThread(DebugHandler *context);
};
\ No newline at end of file
#pragma once
#include <zephyr/kernel.h>
class DriverHook {
public:
/** Constructor.
*
**/
DriverHook();
/** Destructor.
*
**/
~DriverHook();
void Init();
int Deinit();
static void DriverRequestListener(const struct zbus_channel *chan);
private:
};
\ No newline at end of file
#include <zephyr/kernel.h>
#include "utilities.h"
class MainHandler {
public:
/** Constructor.
*
**/
MainHandler();
/** Destructor.
*
**/
~MainHandler();
void Init();
int Deinit();
static void DriverResponseListener(const struct zbus_channel *chan);
private:
DriverNumb_e requestedResponse;
DriverMessage_t driverResponse_g;
static void MainThread(MainHandler *context);
bool DriverRequest(DriverMessage_t *sentMessage, DriverMessage_t *driverResponse, k_timeout_t timeout);
};
\ No newline at end of file
#pragma once
#include <vector>
#include <string>
typedef enum DriverNumb{
SENSOR_1,
SENSOR_2,
SENSOR_3,
ACTUATOR_1,
} DriverNumb_e;
typedef enum StateFlag{
STATE,
DATA_1,
DATA_2
} StateFlag_e;
typedef struct DriverMessage {
DriverNumb_e number;
std::vector<uint8_t> value;
} DriverMessage_t;
typedef struct StateMessage {
StateFlag_e flag;
std::vector<uint8_t> value;
} StateMessage_t;
\ No newline at end of file
add_subdirectory(driver-hook)
add_subdirectory(handler)
\ No newline at end of file
zephyr_library_sources(src/driver-hook.cpp)
\ No newline at end of file
#include <zephyr/logging/log.h>
#include <zephyr/zbus/zbus.h>
#include <stdio.h>
#include <string.h>
#include "driver-hook.h"
#include "utilities.h"
LOG_MODULE_REGISTER(Driver_Hook);
ZBUS_CHAN_DECLARE(driverRequestChannel, driverResponseChannel);
static DriverHook *context;
ZBUS_LISTENER_DEFINE(driverHookListener, context->DriverRequestListener);
DriverHook::DriverHook(){
context = this;
zbus_chan_add_obs(&driverRequestChannel, &driverHookListener, K_NO_WAIT);
}
DriverHook::~DriverHook(){
}
void DriverHook::Init(){
}
int DriverHook::Deinit(){
return 0;
}
void DriverHook::DriverRequestListener(const struct zbus_channel *chan){
const DriverMessage_t *msg;
if (&driverRequestChannel == chan) {
msg = (DriverMessage_t *)zbus_chan_const_msg(chan); // Direct message access
LOG_DBG("From listener -> driver =%d, value 0=%d", msg->number, msg->value[0]);
}
else{
return;
}
std::vector<uint8_t> data;
data.push_back(msg->number);
DriverMessage_t sentMessage = {
.number = msg->number,
.value = data
};
switch (msg->number)
{
case SENSOR_1:
LOG_INF("Sensor %d", msg->number);
break;
case SENSOR_2:
LOG_INF("Sensor %d", msg->number);
break;
case SENSOR_3:
LOG_INF("Sensor %d", msg->number);
break;
default:
LOG_ERR("Invalid Sensor %d", msg->number);
break;
}
int status = zbus_chan_pub(&driverResponseChannel, &sentMessage, K_MSEC(200));
LOG_INF("Status pub %d", status);
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment