How to configure pin behavior inside a custom C module?
Posted: Wed Feb 24, 2021 8:18 pm
Hi,
I'm trying to create a custom C module for Micropython, for my custom board. This custom board works with a STM32F407VGT6; and has 4 push buttons on it, attached to specific pins of the MCU.
Right now I have a Python file, which contains a class that allows me to work with the buttons of my board. In this micropython file, I write at the top "from machine import Pin", and then at the bottom there is a class that, depending on the button that the user pressed, a specific function is called and returns the value of the button pressed (High or Low). This allows certain user to import this class in his micropython code, and use the buttons of the boad in an easy way. Actually, I have treated this file as a frozen module, and I have builded my custom firmware for my custom board with that frozen module inside.
The thing is that I want to turn this Python frozen module file into a C module for Micropython.
I've already read some documentation about this, but I can't figure out how to manipulate the pins of the MCU (in order to configure the Pin.IN and PULL_UP stuff for the buttons of my board) inside the "STATIC mp_obj_t example_function_buttons(....){}" function, inside the C module file.
How can I configure certain pins inside the C module file, in order for me to configure their behaviors in order to manipulate the buttons, and then return the value of the button pressed?
Any help would be really appreciated!
I'm trying to create a custom C module for Micropython, for my custom board. This custom board works with a STM32F407VGT6; and has 4 push buttons on it, attached to specific pins of the MCU.
Right now I have a Python file, which contains a class that allows me to work with the buttons of my board. In this micropython file, I write at the top "from machine import Pin", and then at the bottom there is a class that, depending on the button that the user pressed, a specific function is called and returns the value of the button pressed (High or Low). This allows certain user to import this class in his micropython code, and use the buttons of the boad in an easy way. Actually, I have treated this file as a frozen module, and I have builded my custom firmware for my custom board with that frozen module inside.
The thing is that I want to turn this Python frozen module file into a C module for Micropython.
I've already read some documentation about this, but I can't figure out how to manipulate the pins of the MCU (in order to configure the Pin.IN and PULL_UP stuff for the buttons of my board) inside the "STATIC mp_obj_t example_function_buttons(....){}" function, inside the C module file.
How can I configure certain pins inside the C module file, in order for me to configure their behaviors in order to manipulate the buttons, and then return the value of the button pressed?
Any help would be really appreciated!