title: C: How to transfer bytes bit-by-bit recursively?
body: <p>I am trying to write a function that sends a 16-bit word and stores it in a another variable. What I want to do is to take the word, and transfer (write) the data to the new variable one bit at a time.</p>
  
  <p>It would also be great if this could be done recursively. So for instance I have the function SendCommand(uint32_t addr, uint16_t data), and after one bit has been transferred, the byte could be shifted and the function could be called again with the new data.</p>
  
  <p>My questions are:</p>
  
  <ul>
  <li>How do I extract and write to the new variable one bit at a time?</li>
  <li>What is a possible way to determine the end of the word, and stop calling the function?</li>
  </ul>
  
  <p><strong>Note: MSB first</strong></p>
  
  <p>EDIT:</p>
  
  <p>The reason I am doing it this way is because I am writing pseudo code for a device that will accept this data. Now in my code, I am simulating a clock, and the format specified for this device writes a bit to the register every falling edge of the clock.</p>