/******************************************************************** * メモリー書き込み ******************************************************************** */ void cmd_poke(void) { uchar size,area; uchar *p; area = PacketFromPC.size; p = (uchar*)PacketFromPC.adrs; #if 1 /* Add by senshu */ if(area & AREA_EEPROM) { unsigned char ee_adr = (unsigned char)(PacketFromPC.adrs & 0xff); WriteEE(ee_adr, Data0); } else { if( Mask1 ) { //マスク書き込み. *p = (*p & Mask1) | Data0; }else{ //通常書き込み. *p = Data0; } } #else if( Mask1 ) { //マスク書き込み. *p = (*p & Mask1) | Data0; }else{ //通常書き込み. *p = Data0; } #endif }
void WriteParametersEE(int8 s) { int8 *p; uint8 b; uint16 addr; if( s == 1 ) addr = _EESet1; else addr = _EESet2; p = &FirstProgReg; while ( p <= &LastProgReg) WriteEE(addr++, *p++); } // WriteParametersEE
//============================================================================= // Routine to save setup structure into eeprom // //============================================================================= int save_setup( void ) { int size = sizeof(pid); int *sptr = (int *)&pid; int res; int offset = 0; // compute correct checksum for upper part of array // and place it in the checsum variable pid.cksum = -calc_cksum((sizeof(pid)-sizeof(int))/sizeof(int), (int*)&pid); // this routine attempts to write the entire ram setup structure // into the eeprom on board. // write 16 words of structure at a time while (size > 0) { // Erase 16 words (1 row in dsPIC30F DataEEPROM) in Data EEPROM // from calEE structure res = EraseEE(__builtin_tblpage(&pidEE), __builtin_tbloffset(&pidEE)+offset, ROW); if (res) printf("clr of eeprom failed at %d\r\n",offset); res = WriteEE(sptr, __builtin_tblpage(&pidEE), __builtin_tbloffset(&pidEE)+offset, ROW); if (res) printf("write to eeprom failed at offset %d\r\n",offset); offset += ROW*2; // bump offset to destination 32 bytes up sptr += ROW; // bump source ptr up 16 words size -= ROW*2; // 16 words or 32 bytes/write } return res; }
void BootService(void) { BlinkUSBStatus(); if((usb_device_state < CONFIGURED_STATE)||(UCONbits.SUSPND==1)) return; if(trf_state == SENDING_RESP) { if(!mBootTxIsBusy()) { BOOT_BD_OUT.Cnt = sizeof(dataPacket); mUSBBufferReady(BOOT_BD_OUT); trf_state = WAIT_FOR_CMD; }//end if return; }//end if if(!mBootRxIsBusy()) { counter = 0; switch(dataPacket.CMD) { case READ_VERSION: ReadVersion(); counter=0x04; break; case READ_FLASH: case READ_CONFIG: ReadProgMem(); counter+=0x05; break; case WRITE_FLASH: WriteProgMem(); counter=0x01; break; case ERASE_FLASH: EraseProgMem(); counter=0x01; break; case READ_EEDATA: ReadEE(); counter+=0x05; break; case WRITE_EEDATA: WriteEE(); counter=0x01; break; case WRITE_CONFIG: WriteConfig(); counter=0x01; break; case RESET: //When resetting, make sure to drop the device off the bus //for a period of time. Helps when the device is suspended. UCONbits.USBEN = 0; big_counter = 0; while(--big_counter); Reset(); break; case UPDATE_LED: if(dataPacket.led_num == 3) { mLED_3 = dataPacket.led_status; counter = 0x01; }//end if if(dataPacket.led_num == 4) { mLED_4 = dataPacket.led_status; counter = 0x01; }//end if break; default: break; }//end switch() trf_state = SENDING_RESP; if(counter != 0) { BOOT_BD_IN.Cnt = counter; mUSBBufferReady(BOOT_BD_IN); }//end if }//end if }//end BootService
int main(int argc, char* argv[]) { #ifdef MEMDEBUG atexit(&DumpUnfreed); #endif if (argc < 2 || argc > 3) myerror("Usage: corree_multi filename"); dbgout = &std::cout; std::ifstream fin(argv[1]); double vare=0.; std::vector<CellData> celldata; std::vector<std::vector<CellData> > expcelldata; Read(fin,minsep,binsize,celldata,expcelldata,vare); dbg<<"ngal = "<<celldata.size()<<std::endl; dbg<<"nexp = "<<expcelldata.size()<<std::endl; dbg<<"vare = "<<vare<<": sig_sn (per component) = "<<sqrt(vare)<<std::endl; dbg<<"nbins = "<<nbins<<": min,maxsep = "<<minsep<<','<<maxsep<<std::endl; Cell wholefield(celldata); std::vector<Cell*> exposures; double maxexpsize = 0.; for(int i=0;i<int(expcelldata.size());++i) if(expcelldata[i].size()>0) { exposures.push_back(new Cell(expcelldata[i])); double size = exposures.back()->getSize(); dbg<<"size("<<i<<") = "<<size<<" "<<maxexpsize<<std::endl; if (size > maxexpsize) maxexpsize = size; } // *2 to get diameter, rather than radius dbg<<"max size = "<<2*maxexpsize<<std::endl; // round up to the next bin size const int k1 = int(floor((log(2*maxexpsize) - logminsep)/binsize))+1; maxexpsize = exp(k1*binsize+logminsep); dbg<<"max size = "<<maxexpsize<<std::endl; double maxexpsizesq = maxexpsize*maxexpsize; std::vector<BinData2<3,3> > data(nbins); for(int i=0;i<int(exposures.size());++i) for(int j=0;j<int(exposures.size());++j) if (i!=j) { dbg<<"i,j = "<<i<<','<<j<<std::endl; Process11(data,minsep,maxexpsize,minsepsq,maxexpsizesq, *exposures[i],*exposures[j]); } Process2(data,maxexpsize,maxsep,maxexpsizesq,maxsepsq,wholefield); // Process2(data,minsep,maxsep,minsepsq,maxsepsq,wholefield); FinalizeProcess(data,vare); dbg<<"done processing\n"; std::ofstream e2out("e2.out"); std::ofstream m2out("m2.out"); WriteEE(e2out,minsep,binsize,smoothscale,data); WriteM2(m2out,minsep,binsize,data); for(int i=0;i<int(exposures.size());++i) delete exposures[i]; if (dbgout && dbgout != &std::cout) { delete dbgout; dbgout=0; } return 0; }