Maybe the application note AN4680(PMSM Electrical Parameters
Measurement) is useful.
And I came across this implementation based on the paper(Experimental Evaluation of PI tuning techniques for field oriented contol of permanent magnet synchronous motors), it should help derive the PID parameters for current and speed control from the measured motor parameters.