void INIT_SPI() /* This MUST be run every time the Handyboard is turned off.*/ { poke(0x1009, 0x38); poke(0x1028, 0x54); } /* Register functions */ int writeReg(int address, int byte) { if(address >= 0x1000) ICBwriteXReg(256*(address - 0x1000) + byte); else ICBwrite0Reg(256*address + byte); } /* These allow clean dis/connects from the IC computer. */ void disable_pcode_serial() { poke(0x3c, 1); } void reenable_pcode_serial() { poke(0x3c, 0); } /* These are routines that get used alot. */ int mainDisconnect() { INIT_SPI(); disable_pcode_serial(); printf("Disconnect and press start...\n"); start_press(); } void mainDone() { chooseSonars(0); motForward(0); reenable_pcode_serial(); }