1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Correctly terminate segments list with u.link

This commit is contained in:
Steve Evans 2022-09-10 20:57:51 +01:00
parent aa185860e8
commit 3e842b67d4

View file

@ -169,7 +169,8 @@ static bool sdcard_waitForIdle(int maxBytesToWait)
// Note that this does not release the CS at the end of the transaction
busSegment_t segments[] = {
{.u.buffers = {NULL, &idleByte}, sizeof(idleByte), false, sdcard_callbackIdle},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
sdcard.idleCount = maxBytesToWait;
@ -194,7 +195,8 @@ static uint8_t sdcard_waitForNonIdleByte(int maxDelay)
// Note that this does not release the CS at the end of the transaction
busSegment_t segments[] = {
{.u.buffers = {NULL, &idleByte}, sizeof(idleByte), false, sdcard_callbackNotIdle},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
sdcard.idleCount = maxDelay;
@ -234,7 +236,8 @@ static uint8_t sdcard_sendCommand(uint8_t commandCode, uint32_t commandArgument)
busSegment_t segments[] = {
{.u.buffers = {command, NULL}, sizeof(command), false, NULL},
{.u.buffers = {NULL, &idleByte}, sizeof(idleByte), false, sdcard_callbackNotIdle},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
if (!sdcard_waitForIdle(SDCARD_MAXIMUM_BYTE_DELAY_FOR_CMD_REPLY) && commandCode != SDCARD_COMMAND_GO_IDLE_STATE)
@ -280,7 +283,8 @@ static bool sdcard_validateInterfaceCondition(void)
// Note that this does not release the CS at the end of the transaction
busSegment_t segments[] = {
{.u.buffers = {NULL, ifCondReply}, sizeof(ifCondReply), false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
spiSequence(&sdcard.dev, &segments[0]);
@ -313,7 +317,8 @@ static bool sdcard_readOCRRegister(uint32_t *result)
// Note that this does not release the CS at the end of the transaction
busSegment_t segments[] = {
{.u.buffers = {NULL, response}, sizeof(response), false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
spiSequence(&sdcard.dev, &segments[0]);
@ -362,7 +367,8 @@ static sdcardReceiveBlockStatus_e sdcard_receiveDataBlock(uint8_t *buffer, int c
{.u.buffers = {NULL, buffer}, count, false, NULL},
// Discard trailing CRC, we don't care
{.u.buffers = {NULL, NULL}, 2, false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
spiSequence(&sdcard.dev, &segments[0]);
@ -381,7 +387,8 @@ static bool sdcard_sendDataBlockFinish(void)
busSegment_t segments[] = {
{.u.buffers = {(uint8_t *)&dummyCRC, NULL}, sizeof(dummyCRC), false, NULL},
{.u.buffers = {NULL, &dataResponseToken}, sizeof(dataResponseToken), false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
spiSequence(&sdcard.dev, &segments[0]);
@ -419,7 +426,8 @@ static void sdcard_sendDataBlockBegin(uint8_t *buffer, bool multiBlockWrite)
{.u.buffers = {NULL, NULL}, 1, false, NULL},
{.u.buffers = {&token, NULL}, sizeof(token), false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
segments[2].u.buffers.txData = buffer;
@ -563,7 +571,7 @@ static void sdcardSpi_init(const sdcardConfig_t *config, const spiPinConfig_t *s
busSegment_t segments[] = {
// Write a single 0xff
{.u.buffers = {NULL, NULL}, SDCARD_INIT_NUM_DUMMY_BYTES, false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
spiSequence(&sdcard.dev, &segments[0]);
@ -615,7 +623,8 @@ static sdcardOperationStatus_e sdcard_endWriteBlocks(void)
// 8 dummy clocks to guarantee N_WR clocks between the last card response and this token
{.u.buffers = {NULL, NULL}, 1, false, NULL},
{.u.buffers = {&token, NULL}, sizeof(token), false, NULL},
{.u.buffers = {NULL, NULL}, 0, false, NULL},
{.u.link = {NULL, NULL}, 0, true, NULL},
};
spiSequence(&sdcard.dev, &segments[0]);