how to convert twi library from interrupt to polling based