I guess what I really wrote was a library; one could write a program that used my code to do reads and writes from/to the cassette deck without having to know how the deck worked.
No, the question makes sense, maybe even more than one sense. Let me see...
I guess we can think of an OS as an abstraction of the hardware on which it runs.
You apply power to the machine, and (these days) you get a screen background and some icons and you can move the mouse cursor with the mouse and type on the keyboard to enter text, etc.
At some place in the OS, there is the concept of "the user's mouse".
But it might be USB, or BlueTooth, or some other interface; you still want the user's mouse to do the same things and cause the same OS actions.
So a driver, on one side, interacts with the hardware signals -- knows when it's moving, when it is clicked, etc.
On the other side, it is communicating with the OS, saying "current position is X,Y" "left mouse button pressed", "left mouse button released", etc.
The OS defines how the driver communicates to the OS about the actions the OS supports for the user's mouse.
So if someone comes up with a new interface for the mouse, they can write a new driver, and no one has to mess with the code the OS has for interacting with it otherwise.
So is that on top of the OS? I'm not sure...
In one way it is, in another it's sort of under the OS
Oh, no! I've put her to sleep! 8>)