User C module

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Keja
Posts: 4
Joined: Sat Dec 19, 2020 9:56 am

User C module

Post by Keja » Tue Dec 22, 2020 7:57 am

hello all,

I've started investigating how to add some C modules , I want to do this because I have some drivers in C that I would like to use (though I'm still considering rewritting the drivers in Python, can't be a bad excersise ...)

So I started reading the documentation and followed the example to include the simplefunction.c in my unix port. It works fine as long as I use the same folder structure as the example and compiling with the command :

Code: Select all

make USER_C_MODULES=../../../usermod/snippets all
I was curious to understand better how if all works but was unable to do the same using another directory and pointing to that directory in the make command.

I figured I don't understand enough the make files and was hopping to get some explanation on those lines :

Code: Select all

USERMODULES_DIR := $(USERMOD_DIR)

# Add all C files to SRC_USERMOD.
SRC_USERMOD += $(USERMODULES_DIR)/simplefunction.c

CFLAGS_USERMOD += -I$(USERMODULES_DIR)
How does the pre compiler know the value of USERMOD_DIR ?
What do I need to modifiy to point to a different directory for my customs C modules?

Thanks for reading

Post Reply