restructure gpio and i2c code