title: Change peripheral timer in embedded software easy
body: <p>I'm working on a an embedded software project for a microchip pic16f. This pic has only three timers. </p>
  
  <p>Now i have a driver (let's call it driver A) that uses timer0 and timer1. Now i want to add functionality (driver b) to my program, but that requieres the use of timer1. But timer1 is already in use for driver A. </p>
  
  <p>I can rewrite driver A so that it makes use of timer0 and timer2, so that driver b can use timer1.</p>
  
  <p>But maybe in an upcoming project , i want to use my driver A, but with timer 1 and 2  so timer0 can be used for another driver c and having to rewrite my driver again.
  With three timers, there aren't many possible combinations, but even with this basic cpu I'll have many different versions  of a working driver A making it impractical to manage them and fixing bugs in my code. (Imagine this driver for an mcu with more timers and even more possible ways to write Driver A)</p>
  
  <p>How do you solve this problem? How can you write a driver without a hardcoded timer in it, and assign a suitable timer on initialisation? I think in c++ every timer would be an object that inherits from a timer superclass that you can pass as on object to the constructor of driverA, but i'm working in c, and therefore i can't  use objects.</p>