I just checked my sent mail and it seems I never responded to this question.
The firmware can also take advantage of the first benefit of TDD, it helps get the code right in the first place. In the book there is the FlashDriver example that uses the seam right above the device IORead() and IOWrite().
In the FlashDriver example, we test drive right from the data sheet, using MockIO. In the book I use a hand-crafted mock, though now I use CppUMock.
If your drivers evolve, or there is shared code between drives under the seam, they can enjoy the regression test benefit TDD creates.
Since the book I have seen a fair amount of legacy microcontroller and DSP code. I've written several articles that show some of the things I've run into in legacy firmware.
Search for the articles on my blog about
- embedded
- non-standard keywords
- include test double
- embedded asm
These articles show how to get arounds 'special extensions' to C and other non-portable code. Ideally if you are test driving from the start, you limit when you use the non-portable constructs to a small area of your code.
In the end, its all just C. If you know how to fake an application interface, you should be able to fake access to IO operations.
You can also write some tests that interact with your real hardware. But this kind of depends on your hardware. For example, you can write tests that use your FlashDriver in the HW. You could write tests for a UART that you add a loopback connector to. You could consider doing a partially automated tests that runs the LEDs through a cycle for a few seconds that you can recognize.
I have been getting some reports for people that I have trained, and that made TDD work for them, that they are finding their code works in the hardware the first time or with very few changes. One person reported a new first, getting done early because of only a few integration problems. The problems were quickly discovered and repaired because they knew (through TDD) what their code was doing and they had the TDD safety net.
Thanks for the kudos on the book. Sorry I did not notice the original question.
James
Sent from my iPad