Driver writing is a complex task but the O'Reilly book "Linux Device Drivers" is brilliant. In short a module is normally written in C. You define the functions int init_module(void) and void cleanup_module(void) to handle loading and unloading the module. Other functions can be used to create entries into /dev or /proc, write to I/O ports / memory, etc. Note that debugging kernel code is a fair bit harder than debugging a normal program as incorrect code can potentially hang the kernel and you have no access to the standard C libraries (i.e. many useful functions disappear). The O'Reilly book I mentioned is available to read on the web at http://www.xml.com/ldd/chapter/book/index.html
and contains a lot more information than I can post.