Hello, I intend to create some libraries to connect to read and write an external eeprom and another to display text on a tft screen, I have some experience in C, I have been looking at the code with which micropython was written and there are some things I understand, but not others, in this case the micropython documentation I have been reviewing but I understood a little more with the source code, could you recommend me some part of the source code in which I can understand a little more about the structure of an external library in C and the coding standard that is used.
Thank you very much for your answers.
Create a native C library for use in micropython for stm32
Re: Create a native C library for use in micropython for stm32
When you say 'library', is it possible you actually just mean 'code'? Or do you really mean 'library' as used in C lingo i.e. a 'static library' or a 'dynamic library'?
Can you provide some more focus for the question: what exactly do you want to know? Have you read http://docs.micropython.org/en/latest/d ... dules.html? Also see the .c files in the extmod/ directories, they are good examples of how to integrate external code into MicroPython.
Can you provide some more focus for the question: what exactly do you want to know? Have you read http://docs.micropython.org/en/latest/d ... dules.html? Also see the .c files in the extmod/ directories, they are good examples of how to integrate external code into MicroPython.
Re: Create a native C library for use in micropython for stm32
to see if I can understand, it would be a static library written in C that can be used in micropython with the import statement, so that the functions contained within these can be used in micropython.stijn wrote: ↑Wed Feb 24, 2021 7:04 amWhen you say 'library', is it possible you actually just mean 'code'? Or do you really mean 'library' as used in C lingo i.e. a 'static library' or a 'dynamic library'?
Can you provide some more focus for the question: what exactly do you want to know? Have you read http://docs.micropython.org/en/latest/d ... dules.html? Also see the .c files in the extmod/ directories, they are good examples of how to integrate external code into MicroPython.
I have also reviewed the documentation, only that the language barrier has made me a little difficult.
Thank you
Re: Create a native C library for use in micropython for stm32
The link about user C modules can do that exactly.
However wanting a static library only makes things more complicated than needed (need a separate build step in which you manually provide all correct include paths, qstr processing, ....): unless you have very good reasons for it, I suggest you just add the code to MicroPython directly.
Copy examples/usercmodule/cexample, add your .c files in that directory and in micropython.mk and you're settled.
However wanting a static library only makes things more complicated than needed (need a separate build step in which you manually provide all correct include paths, qstr processing, ....): unless you have very good reasons for it, I suggest you just add the code to MicroPython directly.
Copy examples/usercmodule/cexample, add your .c files in that directory and in micropython.mk and you're settled.
Re: Create a native C library for use in micropython for stm32
Thank you.stijn wrote: ↑Wed Feb 24, 2021 7:42 amThe link about user C modules can do that exactly.
However wanting a static library only makes things more complicated than needed (need a separate build step in which you manually provide all correct include paths, qstr processing, ....): unless you have very good reasons for it, I suggest you just add the code to MicroPython directly.
Copy examples/usercmodule/cexample, add your .c files in that directory and in micropython.mk and you're settled.
Now that you have cleared my doubts very well and I read the documentation you sent me a little more carefully, the C module can be created specifically for the stm32 port in this case as the specific pins of a stm32f407xx mcu are manipulated, do you think it is possible?
Re: Create a native C library for use in micropython for stm32
I think so, but I don't really know the stm port so not sure. But if it exposes C methods, i.e. there are .h files which allow to manipulate pins, then yes you can just use them in your code.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Create a native C library for use in micropython for stm32
Do you actually need to code this in C? There are MicroPython libraries for accessing EEPROM chips and for displaying text on TFT screens which work fast enough for most purposes, except maybe gaming.
For example micropython_eeprom and nano-gui along with other micro GUIs for touch displays. And those are just my efforts - there are others if you look e.g. in the wiki.
For example micropython_eeprom and nano-gui along with other micro GUIs for touch displays. And those are just my efforts - there are others if you look e.g. in the wiki.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Create a native C library for use in micropython for stm32
The library for the tft screen is specifically for the ST7735 model, the library that exists in uPython has problems to be implemented because it has very large delays when updating information.pythoncoder wrote: ↑Wed Feb 24, 2021 10:03 amDo you actually need to code this in C? There are MicroPython libraries for accessing EEPROM chips and for displaying text on TFT screens which work fast enough for most purposes, except maybe gaming.
For example micropython_eeprom and nano-gui along with other micro GUIs for touch displays. And those are just my efforts - there are others if you look e.g. in the wiki.