/// write telemetry sample to Flash memory void telemFlashSample(telemU* data) { dfmemSave((unsigned char *)data, sizeof(telemStruct_t)); if(samplesToSave == 0) //Done sampling, commit last buffer { dfmemSync(); } }
void telemSaveData(telemStruct_t * telemPkt) { //Write the packet header info to the DFMEM dfmemSave((unsigned char*) telemPkt, sizeof(telemStruct_t)); samplesToSave--; //This is done here instead of the ISR because telemSaveData() will only be //executed if samplesToSave > 0 upon entry. if (samplesToSave == 0) { //Done sampling, commit last buffer dfmemSync(); } }
void dfmemSave(unsigned char* data, unsigned int length) { //If this write will not fit into the buffer, then if (currentBufferOffset + length > dfmem_geo.buffer_size) { dfmemSync(); // i) write current buffer to memory, and ii) switch to new buffer } /* dfmemWriteBuffer2MemoryNoErase(nextPage, currentBuffer); currentBuffer = (currentBuffer) ? 0 : 1; // toggle buffer currentBufferOffset = 0; // reset to beginning nextPage++; */ // write data into buffer dfmemWriteBuffer(data, length, currentBufferOffset, currentBuffer); currentBufferOffset += length; }