This is a very basic memory management unit for flash memories around a MB used mostly in embedded systems.
This MMU was written to save a specific kind of data -- objects > 256B, < 63KB made up of a user-identified header and uniform data. It is heavily tied to the design of flash memory and the API exposed by flash manufacturers.
And example would be a series of measurements. In this case header holds a timestamp, a type of measurement and some kind of ID and data is saved as a byte-array.
┌──────────┐ ┌──────────┐ │ │ │ │ --->uMMU_Save()│ │---------->Memory_Save()│ │ │ uMMU │<----------Memory_Load()│ Memory │ <---uMMU_Load()│ │-->Memory_Sector_Erase()│ │ │ │ │ │ └──────────┘ └──────────┘
Type - BT_Header: Initiates a new object.
Type - BT_Data: Appends data to an existing object.
Type - BT_Header: Shifts pointer to the next object, returns it's data chunk. Erases previous object.
Type - BT_Data: Returns current object's data chunk.
An example of use:
┌─Object 1────┐ │┌──────┐ ┌┐ │ ││Header│->││ │ │└──────┘ └┘ │ └─────────────┘ ┌─Object 2───────────────────┐ │┌──────┐ ┌──────────┬─────┐│ ─────>││Header│->│Data ┆ ││ ┆ │└──────┘ └──────────┴──^──┘│ ┆ └────────────────────────┆───┘ -----uMMU_Save(BT_Data, …)-----┘ ┆ <-uMMU_Load(BT_Header, …) ┆ ┆ ┌─Object 3───────────────────┐ v │┌──────┐ ┌──────────┬─────┐│ ─────>││Header│->│Data ┆ ││ │└──────┘ └──────────┴──^──┘│ └────────────────────────┆───┘ --uMMU_Save(BT_Data, …)--------┘
To use this library you will need to:
- Supply your own low-level functions for your memory IC:
- Memory_Save
- Memory_Load
- Memory_Sector_Erase
- Specify parameters of your memory in the header.
Or use the ones I wrote for M25P80.