// ---------------------------------------------------- // TEST application for // Cruise Control application for Panther Electro-Steer // // -- TEST9/10 -- Display/Load EEPROM // // Copyright 2005,2006, Mike Noel, All Rights Reserved // ---------------------------------------------------- #include #include #include #include // Moto 1.0 EEPROM File Slots and Process Slots // // A BrainStem module stores TEA files in an EEPROM. The Moto 1.0 module // contains 12 file slots numbered 0-11. Files slots 0-10 are 1K in size. // File slot 11 is 16K in size. // // Programs can run in any of 3 "virtual machine" (VM) process slots // numbered 0-2. Each process has a private stack space of 112 bytes. // These processes can run concurrently. A 32 byte scratchpad RAM buffer // may be used for sharing data between processes. // // There is additional space on the EEPROM dedicated to storing reflexes. // The Moto 1.0 stores 128 reflex vectors and 128 reflex commands. For // simple tasks, it may be possible to use a reflex instead of a TEA program // and conserve process slots and/or file slots. // // Starting from TEA slot 0, the program slots are on 1K boundaries starting // at address 5K (0x1400). So the high byte of the start address for each TEA // file slot is: 14, 18, 1C, 20, 24, 28, 2C, 30, 34, 38, 3C, 40" // 0 1 2 3 4 5 6 7 8 9 10 11 // // PowerTrool eeprom locations for various parameters - put them at the top // of file slot 2 (just under start of slot 3) #define pt_eep_file_slot 0x2000 // general parameters #define pt_eep_SerialNum pt_eep_file_slot-0x02 #define pt_eep_buildnum pt_eep_file_slot-0x04 #define pt_eep_SwitchBits pt_eep_file_slot-0x06 // rudder parameters #define pt_eep_RudderMax pt_eep_file_slot-0x08 #define pt_eep_CumRudNumSet pt_eep_file_slot-0x0A // autosteer parameters #define pt_eep_PID_P pt_eep_file_slot-0x0C #define pt_eep_PID_I pt_eep_file_slot-0x0E #define pt_eep_PID_D pt_eep_file_slot-0x10 #define pt_eep_Swing_OK_First pt_eep_file_slot-0x12 #define pt_eep_Swing_OK_Second pt_eep_file_slot-0x14 #define pt_eep_Min_Rudder_Change pt_eep_file_slot-0x16 // compass parameters #define pt_eep_compass_offset pt_eep_file_slot-0x18 #define pt_eep_compass_threshold pt_eep_file_slot-0x1A // compass calibration parameters #define pt_eep_compass_xmax pt_eep_file_slot-0x1C #define pt_eep_compass_xmin pt_eep_file_slot-0x1E #define pt_eep_compass_ymax pt_eep_file_slot-0x20 #define pt_eep_compass_ymin pt_eep_file_slot-0x22 // next parameter... #define pt_eep_NEXT pt_eep_file_slot-0x24 int local_eep_read_int(int address) { // int val=0; asm { pushss 6 /* address */ popsm aPortEEPROMRead /* read byte */ popbs 2 /* hi byte of result */ pushss 6 incs 2 /* address + 1 */ popsm aPortEEPROMRead /* read byte */ popbs 1 /* lo byte of result */ } return val; } void local_eep_write_int(int address, int towrite) // { asm { pushmb aPortAddress /* address of self */ pushlb 5 /* length of rest of command */ pushlb cmdMEM_WR /* write from eeprom */ pushss 9 /* address */ pushss 9 /* int to store */ pushlb 7 /* packet length */ popcmd } } // ********************* Test Routine ******************** void main () { // print pgm header msg aPrint_String("Test 9/10 - Display/Load EEPROM...\n"); aCore_Sleep(1000); #ifdef LOADIT // set eeprom defaults local_eep_write_int(pt_eep_SerialNum, 101); // <====== change this... local_eep_write_int(pt_eep_buildnum, 256); local_eep_write_int(pt_eep_SwitchBits, 256+512+1024); local_eep_write_int(pt_eep_RudderMax, 40); local_eep_write_int(pt_eep_CumRudNumSet, 30); local_eep_write_int(pt_eep_PID_P, 20); local_eep_write_int(pt_eep_PID_I, 100); local_eep_write_int(pt_eep_PID_D, 5); local_eep_write_int(pt_eep_Swing_OK_First, 0); local_eep_write_int(pt_eep_Swing_OK_Second, 0); local_eep_write_int(pt_eep_Min_Rudder_Change, 2); local_eep_write_int(pt_eep_compass_offset, 0); local_eep_write_int(pt_eep_compass_threshold, 0); //local_eep_write_int(pt_eep_compass_xmax, -8000); //local_eep_write_int(pt_eep_compass_xmin, +8000); //local_eep_write_int(pt_eep_compass_ymax, -8000); //local_eep_write_int(pt_eep_compass_ymin, +8000); #endif #ifndef LOADIT // print eeprom info aPrint_String("\nSerial # "); aPrint_IntDec(local_eep_read_int(pt_eep_SerialNum)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("Build # "); aPrint_IntDec(local_eep_read_int(pt_eep_buildnum)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("SwitchBits "); aPrint_IntDec(local_eep_read_int(pt_eep_SwitchBits)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("RudderMax "); aPrint_IntDec(local_eep_read_int(pt_eep_RudderMax)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("CumRudNumSet "); aPrint_IntDec(local_eep_read_int(pt_eep_CumRudNumSet)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("PID_P "); aPrint_IntDec(local_eep_read_int(pt_eep_PID_P)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("PID_I "); aPrint_IntDec(local_eep_read_int(pt_eep_PID_I)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("PID_D "); aPrint_IntDec(local_eep_read_int(pt_eep_PID_D)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("Swing OK 1st "); aPrint_IntDec(local_eep_read_int(pt_eep_Swing_OK_First)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("Swing OK 2nd "); aPrint_IntDec(local_eep_read_int(pt_eep_Swing_OK_Second)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("Min Rudder Change "); aPrint_IntDec(local_eep_read_int(pt_eep_Min_Rudder_Change)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("compass offset "); aPrint_IntDec(local_eep_read_int(pt_eep_compass_offset)); aPrint_Char('\n'); aCore_Sleep(1000); aPrint_String("compass threshold "); aPrint_IntDec(local_eep_read_int(pt_eep_compass_threshold)); aPrint_Char('\n'); aPrint_Char('\n'); aCore_Sleep(1000); #endif // Print sign off message aPrint_String("Test 9/10 finished\n"); aCore_Sleep(1000); }