Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffpeng3 committed Aug 21, 2024
1 parent 87373aa commit a5853e9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
4 changes: 2 additions & 2 deletions driver/linux/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions driver/linux/include/lib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* SPDX-License-Identifier: <SPDX License Expression> */
#include <linux/module.h>

void i2c_info(const char *format, ...);
1 change: 1 addition & 0 deletions driver/linux/include/spi_engine.h
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/* SPDX-License-Identifier: <SPDX License Expression> */
#include <linux/spi/spi.h>
17 changes: 17 additions & 0 deletions driver/linux/src/lib.c
Original file line number Diff line number Diff line change
@@ -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);
}
6 changes: 2 additions & 4 deletions driver/linux/src/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/init.h>
#include <linux/module.h>

#include "lib.h"
#include "i2c_engine.h"
#include "spi_engine.h"
#include "uart_engine.h"
Expand All @@ -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;
}
Expand Down

0 comments on commit a5853e9

Please sign in to comment.