Get Menu Items in Custom Module
Have you tried using Menu Block? 


  provides configurable blocks of menu trees starting with any level of any menu.


It does exactly what you're looking for. If you still want to write a custom module I reckon looking through the code for that module would be the best place to start.