Add sys_init
This commit is contained in:
1 parent
f7ae8d226b
commit
42d54dc132
3 files changed
+48
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.20.0)
|
||||||
|
|
||||||
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||||
|
|
||||||
|
project(sys_init)
|
||||||
|
|
||||||
|
target_sources(app PRIVATE src/main.c)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Set to -Og
|
||||||
|
CONFIG_DEBUG_OPTIMIZATIONS=y
|
||||||
|
|
||||||
|
# Thread awareness support
|
||||||
|
CONFIG_DEBUG_THREAD_INFO=y
|
||||||
|
|
||||||
|
# Generate stack usage per-function
|
||||||
|
CONFIG_STACK_USAGE=y
|
||||||
|
|
||||||
|
# Other options in case not set by default
|
||||||
|
CONFIG_BUILD_OUTPUT_HEX=y
|
||||||
|
CONFIG_BUILD_OUTPUT_META=y
|
||||||
|
CONFIG_OUTPUT_SYMBOLS=y
|
||||||
|
CONFIG_OUTPUT_STAT=y
|
||||||
|
CONFIG_OUTPUT_DISASSEMBLY=y
|
||||||
|
CONFIG_OUTPUT_PRINT_MEMORY_USAGE=y
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#include <zephyr/kernel.h>
|
||||||
|
|
||||||
|
int post_kernel_cb(void) {
|
||||||
|
printk("[POST_KERNEL:10] Called automatically by the kernel\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int post_kernel_cb2(void) {
|
||||||
|
printk("[POST_KERNEL:20] Called after priority 10\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int application_cb(void) {
|
||||||
|
printk("[APPLICATION] Called automatically before main()\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SYS_INIT(post_kernel_cb, POST_KERNEL, 10);
|
||||||
|
SYS_INIT(post_kernel_cb2, POST_KERNEL, 20);
|
||||||
|
SYS_INIT(application_cb, APPLICATION, 10);
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
printk("[main] running\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user