Hi,
as the title says, I was wondering if there is a reason behind the existence of the init_helper functions of the modules?
It seems very redundant to call the init function, that itself only calls the init_helper function.
Could I just put the initialization directly inside the make_new function? (theoretically speaking, I know that the function will become bloated)
Thanks
-ExXec
Any reason behind make_new -> init -> init_helper ?
Re: Any reason behind make_new -> init -> init_helper ?
The reason is, that there are two paths to initialize a module, first in make_new, which is called when you create the instance of the object (e.g. uart = machine.UART(0)), second in the init call (e.g. uart.init()).
And the sequence you mention is not always (if ever) used. machine_uart.c for instance does not call machine_uart_init() within machine_uart_make_new(). And that is more the scheme i recall.
And the sequence you mention is not always (if ever) used. machine_uart.c for instance does not call machine_uart_init() within machine_uart_make_new(). And that is more the scheme i recall.
Re: Any reason behind make_new -> init -> init_helper ?
Ok that makes more sense I guess.
You mentioned "machine_uart_make_new", in the 1.9.4 version(the one I'm working on) this is still called "pyb_uart_make_new".
Is this just a naming difference?
You mentioned "machine_uart_make_new", in the 1.9.4 version(the one I'm working on) this is still called "pyb_uart_make_new".
Is this just a naming difference?
My fork/port: https://github.com/rk-exxec/micropython ... ts/tm4c123
Re: Any reason behind make_new -> init -> init_helper ?
Your're right. For the stm32 ports, even when the file is called machine_uart.c, the functions is called pyb_uart_make_new(). I had looked into the esp32 port.