mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Merge pull request #11897 from SteveCEvans/spi2_gyro_flash
Fix chaining of FLASH SPI transactions
This commit is contained in:
commit
c5468981e6
4 changed files with 14 additions and 4 deletions
|
@ -415,6 +415,7 @@ static void spiIrqHandler(const extDevice_t *dev)
|
||||||
// The end of the segment list has been reached
|
// The end of the segment list has been reached
|
||||||
bus->curSegment = nextSegments;
|
bus->curSegment = nextSegments;
|
||||||
nextSegment->u.link.dev = NULL;
|
nextSegment->u.link.dev = NULL;
|
||||||
|
nextSegment->u.link.segments = NULL;
|
||||||
spiSequenceStart(nextDev);
|
spiSequenceStart(nextDev);
|
||||||
} else {
|
} else {
|
||||||
// The end of the segment list has been reached, so mark transactions as complete
|
// The end of the segment list has been reached, so mark transactions as complete
|
||||||
|
|
|
@ -696,11 +696,12 @@ void spiSequenceStart(const extDevice_t *dev)
|
||||||
|
|
||||||
// If a following transaction has been linked, start it
|
// If a following transaction has been linked, start it
|
||||||
if (bus->curSegment->u.link.dev) {
|
if (bus->curSegment->u.link.dev) {
|
||||||
const extDevice_t *nextDev = bus->curSegment->u.link.dev;
|
|
||||||
busSegment_t *nextSegments = (busSegment_t *)bus->curSegment->u.link.segments;
|
|
||||||
busSegment_t *endSegment = (busSegment_t *)bus->curSegment;
|
busSegment_t *endSegment = (busSegment_t *)bus->curSegment;
|
||||||
|
const extDevice_t *nextDev = endSegment->u.link.dev;
|
||||||
|
busSegment_t *nextSegments = (busSegment_t *)endSegment->u.link.segments;
|
||||||
bus->curSegment = nextSegments;
|
bus->curSegment = nextSegments;
|
||||||
endSegment->u.link.dev = NULL;
|
endSegment->u.link.dev = NULL;
|
||||||
|
endSegment->u.link.segments = NULL;
|
||||||
spiSequenceStart(nextDev);
|
spiSequenceStart(nextDev);
|
||||||
} else {
|
} else {
|
||||||
// The end of the segment list has been reached, so mark transactions as complete
|
// The end of the segment list has been reached, so mark transactions as complete
|
||||||
|
|
|
@ -423,11 +423,12 @@ void spiSequenceStart(const extDevice_t *dev)
|
||||||
|
|
||||||
// If a following transaction has been linked, start it
|
// If a following transaction has been linked, start it
|
||||||
if (bus->curSegment->u.link.dev) {
|
if (bus->curSegment->u.link.dev) {
|
||||||
const extDevice_t *nextDev = bus->curSegment->u.link.dev;
|
|
||||||
busSegment_t *nextSegments = (busSegment_t *)bus->curSegment->u.link.segments;
|
|
||||||
busSegment_t *endSegment = (busSegment_t *)bus->curSegment;
|
busSegment_t *endSegment = (busSegment_t *)bus->curSegment;
|
||||||
|
const extDevice_t *nextDev = endSegment->u.link.dev;
|
||||||
|
busSegment_t *nextSegments = (busSegment_t *)endSegment->u.link.segments;
|
||||||
bus->curSegment = nextSegments;
|
bus->curSegment = nextSegments;
|
||||||
endSegment->u.link.dev = NULL;
|
endSegment->u.link.dev = NULL;
|
||||||
|
endSegment->u.link.segments = NULL;
|
||||||
spiSequenceStart(nextDev);
|
spiSequenceStart(nextDev);
|
||||||
} else {
|
} else {
|
||||||
// The end of the segment list has been reached, so mark transactions as complete
|
// The end of the segment list has been reached, so mark transactions as complete
|
||||||
|
|
|
@ -356,6 +356,13 @@ static uint32_t m25p16_pageProgramContinue(flashDevice_t *fdevice, uint8_t const
|
||||||
segments[DATA1].len = bufferSizes[0];
|
segments[DATA1].len = bufferSizes[0];
|
||||||
fdevice->callbackArg = bufferSizes[0];
|
fdevice->callbackArg = bufferSizes[0];
|
||||||
|
|
||||||
|
/* As the DATA2 segment may be used as the terminating segment, the rxData and txData may be overwritten
|
||||||
|
* with a link to the following transaction (u.link.dev and u.link.segments respectively) so ensure that
|
||||||
|
* rxData is reinitialised otherwise it will remain pointing at a chained u.link.segments structure which
|
||||||
|
* would result in it being corrupted.
|
||||||
|
*/
|
||||||
|
segments[DATA2].u.buffers.rxData = (uint8_t *)NULL;
|
||||||
|
|
||||||
if (bufferCount == 1) {
|
if (bufferCount == 1) {
|
||||||
segments[DATA1].negateCS = true;
|
segments[DATA1].negateCS = true;
|
||||||
segments[DATA1].callback = m25p16_callbackWriteComplete;
|
segments[DATA1].callback = m25p16_callbackWriteComplete;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue