First of all you need the _declspec(dllexport) because we want to create a shared library. It is also required to have this specific signature int luaopen[MODULE](lua_State*) so Lua can find the ...
The basic question here is how to pass a MicroPython object to a C function in a custom C module. In this case a PWM object. There are probably many ways to do this. Here is my way of doing it. It may ...