Have you tried to look at some implementations?
- eCos has a HAL that has documentation to accept this.
- eLua also has a HAL that has grown around it to support the platforms on which it runs (ARM, AVR32, etc.)., check the architecture information and the "Platform Interface" and "Common Modules" menus. If you cross out Lua, eLua is essentially a HAL.
There are other examples, but I would recommend looking at examples of examples of cross-platform and cross-platform hardware APIs. In addition, if / when you go and start building interfaces, be sure to study the individual implementations of the platform peripherals before sticking the API. You will find that some interaction models are usually supported on many platforms, while others are very platform specific. If your API assumes that the functionality will always be available, it will be difficult to port to platforms that either do not have or do not support the necessary functionality at all. Sometimes you can get around this in the software with simple solutions, otherwise you may find that it is either impossible or it is terribly difficult to make the behavior consistent across platforms.
source share