[ion] ExamMode: add comment

This commit is contained in:
Émilie Feral
2019-12-19 15:35:57 +01:00
committed by LeaNumworks
parent 3454265d7e
commit 0254266803

View File

@@ -107,8 +107,11 @@ void IncrementExamMode(uint8_t delta) {
}
// Write the value in flash
/* Avoid writing out of sector */
/* As the number of changed bits is capped by 2, if *writingAddress has more
* than one remaining 1 bit, we know we toggle bits only in the first byte of
* newValue. We can settle for writing one byte instead of two. */
size_t writtenFlash = *writingAddress == 1 ? sizeof(uint16_t) : sizeof(uint8_t);
/* Avoid writing out of sector */
assert(writingAddress < (uint8_t *)&_exam_mode_buffer_end - 1 || (writingAddress == (uint8_t *)&_exam_mode_buffer_end - 1 && writtenFlash == 1));
Ion::Device::Flash::WriteMemory(writingAddress, newValue, writtenFlash);
}