If I have a hierarchy device.CAN1.receive(), I know that in the definition of receive(), I will get a pointer - self - to CAN1 which I've defined as
Code: Select all
typedef struct _atiupy_canch_obj_t {
mp_obj_base_t base;
void* ptr_can_channel;
qstr name;
} atiupy_canch_obj_t;
I know that in the definition of atiupy_canch_obj_t I could put in a pointer mp_obj_t the_parent which points to device i.e. put a pointer to the mp_obj_t that is one level up.
PITFALL:
Someone may be saying "just set base.type->parent equal to device" but that parent entry is meant for inheritance which is not what I'm doing here.
Aside from adding mp_obj_t the_parent to atiupy_canch_obj_t, how can I find the mp_obj_t one level up the hierarchy?