static void cmdEraseMemSector(unsigned char status, unsigned char length, unsigned char *frame) { unsigned int page; page = frame[0] + (frame[1] << 8); LED_RED = 1; dfmemEraseSector(0x0100); // erase Sector 1 (page 256 - 511) LED_RED = 0; }
static void cmdTxSavedImuData(unsigned char status, unsigned char length, unsigned char *frame) { unsigned int page, byte; unsigned int i, j; Payload pld; //senGetMemLocIndex(&page, &byte); page = 0x0200; byte = 0; LED_RED = 1; dfmemEraseSector(0x0100); // erase Sector 1 (page 256 - 511) for (i = 0x0100; i < 0x0200; ++i) { j = 0; while (j < 512) { pld = payCreateEmpty(18); // data length = 16 dfmemRead(i, j, 16, pld->pld_data); paySetStatus(pld, status); paySetType(pld, CMD_GET_IMU_DATA); while (!radioReceivePayload()); j += 16; } delay_ms(200); } LED_RED = 0; }
void telemErase(unsigned long numSamples) { //dfmemEraseSectorsForSamples(numSamples, sizeof (telemU)); // TODO (apullin) : Add an explicit check to see if the number of saved // samples will fit into memory! LED_2 = 1; unsigned int firstPageOfSector, i; //avoid trivial case if (numSamples == 0) { return; } //Saves to dfmem will NOT overlap page boundaries, so we need to do this level by level: unsigned int samplesPerPage = mem_geo.bytes_per_page / telemPacketSize; //round DOWN int division unsigned int numPages = (numSamples + samplesPerPage - 1) / samplesPerPage; //round UP int division unsigned int numSectors = (numPages + mem_geo.pages_per_sector - 1) / mem_geo.pages_per_sector; //At this point, it is impossible for numSectors == 0 //Sector 0a and 0b will be erased together always, for simplicity //Note that numSectors will be the actual number of sectors to erase, // even though the sectors themselves are numbered starting at '0' DisableIntT1; dfmemEraseSector(0); //Erase Sector 0a dfmemEraseSector(8); //Erase Sector 0b //Start erasing the rest from Sector 1: for (i = 1; i <= numSectors; i++) { firstPageOfSector = mem_geo.pages_per_sector * i; //hold off until dfmem is ready for secort erase command //while (!dfmemIsReady()); //LED should blink indicating progress LED_2 = ~LED_2; //Send actual erase command dfmemEraseSector(firstPageOfSector); } EnableIntT1; //Leadout flash, should blink faster than above, indicating the last sector //while (!dfmemIsReady()) { // LED_2 = ~LED_2; // delay_ms(75); //} LED_2 = 0; //Green LED off //Since we've erased, reset our place keeper vars dfmemZeroIndex(); }
void telemErase(unsigned long numSamples) { //dfmemEraseSectorsForSamples(numSamples, sizeof (telemU)); // TODO (apullin) : Add an explicit check to see if the number of saved // samples will fit into memory! //Green LED will be used as progress indicator LED_GREEN = 1; unsigned int firstPageOfSector, i; //avoid trivial case if (numSamples == 0) { return; } //Saves to dfmem will NOT overlap page boundaries, so we need to do this level by level: unsigned int samplesPerPage = mem_geo.bytes_per_page / telemPacketSize; //round DOWN int division unsigned int numPages = (numSamples + samplesPerPage - 1) / samplesPerPage; //round UP int division unsigned int numSectors = (numPages + mem_geo.pages_per_sector - 1) / mem_geo.pages_per_sector; //This is a terrible hack to avoid bus conflicts. //TODO: find source of bus problems and fix DisableIntT1; DisableIntT5; //At this point, it is impossible for numSectors == 0 //Sector 0a and 0b will be erased together always, for simplicity //Note that numSectors will be the actual number of sectors to erase, // even though the sectors themselves are numbered starting at '0' dfmemEraseSector(0); //Erase Sector 0a LED_GREEN = ~LED_GREEN; dfmemEraseSector(8); //Erase Sector 0b LED_GREEN = ~LED_GREEN; //Start erasing the rest from Sector 1, // The (numsectors-1) here is because sectors are numbered from 0, whereas // numSectors is the actual count of sectors to erase; fencepost error. for (i = 1; i <= (numSectors-1); i++) { firstPageOfSector = mem_geo.pages_per_sector * i; //hold off until dfmem is ready for sector erase command //LED should blink indicating progress //Send actual erase command dfmemEraseSector(firstPageOfSector); LED_GREEN = ~LED_GREEN; } //Leadout flash, should blink faster than above, indicating the last sector while (!dfmemIsReady()) { LED_GREEN = ~LED_GREEN; delay_ms(50); } LED_GREEN = 0; //Green LED off //This is a terrible hack to avoid bus conflicts. //TODO: find source of bus problems and fix EnableIntT1; EnableIntT5; //Since we've erased, reset our place keeper vars dfmemZeroIndex(); }