Yes I saw that branch and it is nice but cannot be code-generated and used for embedded applications. I created a CMEX version myself using OSQP codegen which can be used but it is limited and does not have all the design capabilities and formulations of MathWorks MPC tools.
Yes all needed is a
function [x,status] = mpcCustomSolverCodeGen(H,f,A,b,x0) script which calls OSQP MEX file at each sample time. However, the main challenge is the setup->update->solve structure of the solver and I am not really sure how we can trick this without touching MPC tools.
Sure, I will create a feature request in github. That would be really nice if you can implement an interface to use OSQP as a custom solver for MPC tools.
On a separate note: with OSQP codegen feature you cannot solve a problem in which there are sparsity changes, right? because you create the workspace only once and then update the matrices/vectors as needed (assuming sparsity does not change) afterwards but you cannot set up the problem again during simulations.