modified the config_gpio function to be more generic. passing 'mode' as a compulsory argument would make things inflexible
added mode tracking and checking code for the GPIO mapping functions. Also added some more useful comments