Hi crpixa,
I suggest trying your code in stages / steps:
Does Example16 work correctly unmodified?
Does Example16 work if you add a single VCNL4040 - without the mux?
Does Example16 work if you add a single VCNL4040 using the mux?
I can not see your code for enableMuxPort, but I assume you are calling the Qwiic Mux library function enablePort ? Likewise, I assume you are calling disablePort inside disableMuxPort ? I suggest calling setPortState(0) first to ensure all eight ports are disabled. I think that all ports are enabled by default. The hard fault may be caused because you then have multiple sensors connected simultaneously?
I hope this helps,
Paul (PaulZC)