Separate serial functions from system.c to serial.c