PMSM Vector Control using Hall sensors in TORQUE CONTROL

Dear Community,

In Reference to the RA6T2, we would like to develop a e-bike PMSM motor controller using RA6T2 platform and i found example code for Hall sensor based FOC which is good for my application. But the entire control loop is designed for speed control loop. My application need a Torque control loop and speed varies with torque in e-bike's. Can you help with what modifications has to be done to this example code to modify it to Torque control loop ?

https://www.renesas.com/us/en/document/apn/120-degree-conducting-control-permanent-magnet-synchronous-motor-hall-sensors-mckmcb-ra-family?r=1542426

Thanks,

Naga Penmetsa