drivers/motor_driver: make motor configuration non-global #21798
      
        
          +195
        
        
          −154
        
        
          
        
      
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Contribution description
The Pull Request #10290 introduced the
drivers/motor_driver, which added a global motor configuration toboards/common/nucleo64andboards/common/native. The latter even included aqdecsimulation (although very specialized for the motor driver case).IMO this really shouldn't be global because not all Nucleo Boards would ever be used with the motor driver and
I had to change the driver API because the driver itself relied on the
motor_driver_configbeing global, it was not a parameter for the motor functions. While changing that, I noticed that themotor_driverparameter of all the motor functions was redundant.The only place that "bit" me was in the QDEC simulation on Native, but I added a check to regain the index.
To be honest I'm not super sure how or if the indexing worked previously though...
Testing procedure
It builds?
Even on
masterthe motor driver test currently does not work and the output is unchanged for this PR.This PR:
Issues/PRs references
Rabbithole I fell into when looking into the static errors of #21337... (see #21337 (comment) ).