Stuck with program flow and freezing programm

byte getSensorValue(int sensorReading, int switchValue, 
                    int switchLimit, byte switchStatus){
  byte onStatus = 0;
  
  if(switchStatus == 0){
  [...]
    if(sensorReading <= switchValue){
  [...]
  else if(switchStatus = 1){
  [...]

Might want to fix that else if.

Regards,

Brad
KF7FER