Test Driven Development for Embedded C by James W. Grenning — Erase Suspend Resume Flowchart
2 min readOct 8, 2023
This post describes my solution to the exercise on implementation of Erase Suspend and Resume flowchart of m28w160ect (a flash memory) mentioned in chapter 10 of the book (link). I used the CppUTest harness for the tests. The source files for CppUTest and Unity can be downloaded from here.
Erase Suspend Resume (ERS) Algorithm
The Erase Suspend & Resume flowchart (shown below) is given on pg-44 of the datasheet.
Design Notes
- Following the book, the status register address is set to 0x00
- The device specific register addresses and status flags are defined in m28w160ect.h
- The “any_address” used in write and read operations mentioned in the flowchart is defined by the variable randomAddr = 0x01 in ERSTests.cpp
- Flash_Create() and Flash_Destroy() functions are dummy functions created to maintain consistency
Test List
- Erase resume succeeds immediately — DONE
- Erase suspend succeeds immediately — DONE
- Erase resume/suspend does not succeed immediately — DONE
In summary, the test list and design is very similar to the test list created for write operation explained in chapter 10. I couldn’t think of any additional tests for this exercise.