If you really want to start writing a device driver, it's probably best to study an existing driver for a similar piece of hardware. If you say what kind of hardware you're interested in, then we could give you more specific advice. A driver for a USB network dongle is quite different from a driver for a PCI audio chip, for example.