コード例 #1
0
ファイル: telem.c プロジェクト: camrose/roach
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();
}
コード例 #2
0
ファイル: telem.c プロジェクト: dhaldane/imageproc-lib
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();

}