Hi,
I would like to understand how the following maps to C drivers.
As an example: i2c.scan()
I understand the driver level code and found the I2C driver including the scan commands in the drivers. What I don't understand is how calling the python code maps to the C code. Followed this http://wiki.micropython.org/Creating-Pyb-Modules but not sure if it is outdated as the qstrdefsport.h file doesn't match up to what the autor was saying.
I guess what I am asking is how would I implement i2c.xyz() assuming that the low level drivers exist.
Thanks. Graeme
Mapping between Micropython and C
Re: Mapping between Micropython and C
You probably want to read this thread:
viewtopic.php?f=16&t=2861&p=19206
You can find the mapping here:
https://github.com/micropython/micropyt ... 2c.c#L1018
The scan is an entry in the locals dict, which is included in the pyb_i2c_type, which is in turn referenced from either the pyb module:
https://github.com/micropython/micropyt ... pyb.c#L188
(there is also machine.i2c and you didn't specify which one you were using).
To add an xyz function, you'd add an entry to the same table that has the scan function in it, and then implement the function.
viewtopic.php?f=16&t=2861&p=19206
You can find the mapping here:
https://github.com/micropython/micropyt ... 2c.c#L1018
The scan is an entry in the locals dict, which is included in the pyb_i2c_type, which is in turn referenced from either the pyb module:
https://github.com/micropython/micropyt ... pyb.c#L188
(there is also machine.i2c and you didn't specify which one you were using).
To add an xyz function, you'd add an entry to the same table that has the scan function in it, and then implement the function.