From 2cca96f691ab3b57b981babd84eb8c0499df90dd Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 21 Aug 2024 13:01:30 +0800 Subject: [PATCH] temp --- .vscode/settings.json | 10 +++++++++- driver/linux/Makefile | 4 ++-- driver/linux/include/lib.h | 4 ++++ driver/linux/include/spi_engine.h | 1 + driver/linux/src/lib.c | 17 +++++++++++++++++ driver/linux/src/main.c | 6 ++---- 6 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 driver/linux/include/lib.h create mode 100644 driver/linux/src/lib.c diff --git a/.vscode/settings.json b/.vscode/settings.json index 7fae5bd..d8fdb06 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,15 @@ "kernel.h": "c", "slab.h": "c", "i2c.h": "c", - "i2c_engine.h": "c" + "i2c_engine.h": "c", + "module.h": "c", + "spi_engine.h": "c", + "spi.h": "c", + "i2c-smbus.h": "c", + "i2c-dev.h": "c", + "compiler.h": "c", + "input.h": "c", + "init.h": "c" }, "C_Cpp.clang_format_style": "{ BasedOnStyle: Google, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: true, IndentCaseLabels: false, ColumnLimit: 120}" } \ No newline at end of file diff --git a/driver/linux/Makefile b/driver/linux/Makefile index 6f6816b..e19272f 100644 --- a/driver/linux/Makefile +++ b/driver/linux/Makefile @@ -1,8 +1,8 @@ obj-m += UniversalIO.o -UniversalIO-objs += ./src/main.o ./src/i2c_engine.o ./src/spi_engine.o ./src/uart_engine.o +UniversalIO-objs += ./src/main.o ./src/i2c_engine.o ./src/spi_engine.o ./src/uart_engine.o ./src/lib.o CONFIG_MODULE_SIG=n EXTRA_CFLAGS := -I$(src)/include -I2C_BUS = 8 +I2C_BUS = 4 reload: build -sudo rmmod UniversalIO.ko diff --git a/driver/linux/include/lib.h b/driver/linux/include/lib.h new file mode 100644 index 0000000..bf1d7ab --- /dev/null +++ b/driver/linux/include/lib.h @@ -0,0 +1,4 @@ +/* SPDX-License-Identifier: */ +#include + +void i2c_info(const char *format, ...); \ No newline at end of file diff --git a/driver/linux/include/spi_engine.h b/driver/linux/include/spi_engine.h index 4ff96e1..ce269e2 100644 --- a/driver/linux/include/spi_engine.h +++ b/driver/linux/include/spi_engine.h @@ -1 +1,2 @@ /* SPDX-License-Identifier: */ +#include \ No newline at end of file diff --git a/driver/linux/src/lib.c b/driver/linux/src/lib.c new file mode 100644 index 0000000..4dd263d --- /dev/null +++ b/driver/linux/src/lib.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include "lib.h" +void i2c_info(const char *format, ...) +{ + struct va_format vaf; + va_list args; + + va_start(args, format); + + vaf.fmt = format; + vaf.va = &args; + + pr_info("%pV", &vaf); + + va_end(args); +} \ No newline at end of file diff --git a/driver/linux/src/main.c b/driver/linux/src/main.c index 737e875..316582a 100644 --- a/driver/linux/src/main.c +++ b/driver/linux/src/main.c @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -#include -#include - +#include "lib.h" #include "i2c_engine.h" #include "spi_engine.h" #include "uart_engine.h" @@ -14,7 +12,7 @@ static int __init my_i2c_init(void) // i2c_put_adapter(&adapter); return -ENODEV; } - pr_info("hello i2c-%d!\n", adapter.nr); + i2c_info("hello i2c-%d!\n", adapter.nr); return 0; }